#Nyaux

1 messages Β· Page 10 of 1

surreal path
#

my os wont support swap

#

cause funny

#

for tmpfs, is there a calculation for making sure the offset isnt out of bounds of the file size?

#

or smthin?

#

?

#

πŸ˜”

tawdry mirage
#

? offset + read size <= file size?

surreal path
#

when memcpying the data onto the file

#

memcpy(file.data + offset, buffer, size)

#

wait

#

i can do just

#

file size - offset

#

okay

#

something like this

kind root
surreal path
kind root
#

Instantly seeing an overflow here

tawdry mirage
#

well yeah __builtin_add_overflow(offset, read size) meme

kind root
#

Lmao

surreal path
#

and for writing to a file

#

if the file doesnt exist

#

ill allocate it ig?

#

that makes sense?

#

i suppose

surreal path
#

is this the correct approach to this?

#

or no?

#

im guessing no?

#

??

cinder plinth
#

it is

surreal path
#

alr

#

i think this is correct

#

anyways thats rdwr done!

#

very cool 😎

#

lets test it!!!

surreal path
#

meow.txth?

#

why is it meow.txth???

#

umm

#

wtf

#

uh oh

#

me putting memsets everywhere

#

yea that fixed it

#

memsets!

#

always memset ur memory kids

#

CHAT

#

WE HAVE A RAM FS!!!!

#

!!!!!!!!

#

πŸ₯³

#

okay so

#

is that everything

#

can i implment tar parsing and make a initramfs trl

#

Nyaux progress.

#

im gonna make a tar parser

cinder plinth
#

the device thing you can do after

surreal path
#

pass in a tar file

surreal path
cinder plinth
#

depends

#

the devfs

surreal path
#

what is devfs

cinder plinth
#

/dev

surreal path
#

for interacting with devices?

cinder plinth
#

yea

surreal path
#

idk what ioctl() is lmao

#

also wdym by i can do it after

#

??

cinder plinth
#

you can load executables in userspace

#

before

#

doing that

#

you can just simulate fd 0 1 2

tawdry mirage
surreal path
#

wha

cinder plinth
#

you just dont expose them by name

surreal path
#

is a initramfs

#

so heres what im gonna do

#

pass in a tar file from limine modules, parse that and use it to create a root fs

#

easy

#

😎

#

i just gotta figure out how to decode tar

#

lmao

cinder plinth
#

pretty simple

#

apart from the octal shit

surreal path
#

octal?

#

tf is an octal

cinder plinth
#

base-8 number

surreal path
#

does tar use octal???

#

ah hell naw

cinder plinth
#

yes

surreal path
#

that sounds like pain

cinder plinth
#

not really

#

"The only trick is, that file size is not stored in binary, rather in an ASCII octal string. For example 1025 is stored as '000000002001'."

#

no idea why they did that

surreal path
#

who in their right mind

#

thought that was a good fucking idea

#

"yea lets store the size in ascii octal"!!!!

#

πŸ’€

plush hearth
#

its really weird and painful to deal with

thorn bramble
#

fun, i never noticed

#

probably because in zig i can just std.fmt.parseUnsigned(usize, self.file_size[0..11], 8); :^)

#

but yeah that looks less than optimal lol

leaden hinge
kind root
#

Yeah but still why did they do that

#

Why not store it as a textual representation

#

β€œone thousand five hundred and twelve”

haughty kite
#

remember to put "bytes" right after that for security like on cheques

unkempt relic
#

octal was the fashion of the time

haughty kite
#

i think at the time bytes weren't 8 bit were they

surreal path
#

Okay TODAYS THE DAY

#

WE WORK ON DECODING A TAR FILE AND POPULATING MY TMPFS WITH FILES!!!

#

!!!!

#

im gonna make a random folder called "root"

#

or smthin

#

fill it with directories and files and stuff

#

then im gonna zip that up into a tar file

#

and give that as a module to limine

#

😎

#

what should i store in this initramfs trl

kind root
#

β€œDecoding”

#

Its not even encoded

surreal path
#

not rlly, just reading the header ik lmao

#

as in parsing the tar file

#

yk

kind root
#

Yeah

surreal path
#

will i compress the directory into .tar ig?

#

ig

#

lets put this into limine trl

#

okay got the module

#

gonna have a function that takes a limine module as input and populates the tmpfs ig

#

what is name of linked file?

#

we got our tar header trl

elder shoal
#

Par tarsing

surreal path
#

tar parsing vs par tarsing

surreal path
#

this should work

#

why tf is it not getting the actual address

edgy pilot
surreal path
#

of the next header

surreal path
surreal path
leaden hinge
surreal path
#

i think i need to align up the new header address ig?

#

or something

#

didnt matter

edgy pilot
#

hdr_ptr + 512 + align_up(filesize, 512)

surreal path
#

oh right

#

j

#

J

barren agate
#

j

surreal path
#

fucking j

#

so wtf is going on

#

none of the directories are named j

edgy pilot
#

can you send the whole code?

surreal path
#

okay

surreal path
# edgy pilot can you send the whole code?
// stolen from osdev wiki :trl:
unsigned int getsize(const char *in)
{
 
    unsigned int size = 0;
    unsigned int j;
    unsigned int count = 1;
 
    for (j = 11; j > 0; j--, count *= 8)
        size += ((in[j - 1] - '0') * count);
 
    return size;
 
}
void parse_tar_and_populate_tmpfs(struct limine_file *archive)
{
    struct tar_header *hdr_ptr = archive->address;
    kprintf("first tar header is at address: %p\n", hdr_ptr);
    kprintf("Name: %s\n", hdr_ptr->name);
    if (strncmp(hdr_ptr->name, "root/", strlen(hdr_ptr->name)) != 0)
    {
        kprintf("ramfs: invalid initramfs!\n");
        kpanic("Fuck you\n", NULL);
    }
    else
    {
        kprintf("ramfs: Found Valid initramfs, populating tmpfs...\n");
        struct vnode *roo = kmalloc(sizeof(struct vnode));
        memset(roo, 0, sizeof(struct vnode));
        if (strncmp(hdr_ptr->type, "5", strlen(hdr_ptr->type)) != 0)
        {
            kprintf("ramfs: this shouldnt be possible but the root directory isnt a directory?\n");
            kpanic("tf?\n", NULL);
        }
        else
        {
            struct vfs *tmpfs_vfs = kmalloc(sizeof(struct vfs));
            memset(tmpfs_vfs, 0, sizeof(struct vfs));
            root = tmpfs_vfs;
            root->list = roo;
            roo->ops = &tmpfsops;
            struct tmpfs_dir *root_dir = kmalloc(sizeof(struct tmpfs_dir));
            memset(root_dir, 0, sizeof(struct tmpfs_dir));
            roo->type = NYAVNODE_DIR;
            roo->data = root_dir;
            roo->filesystem = &root;
            kprintf("Creating Root VNODE, populating...\n");
            kprintf("Size of root dir: %d\n", getsize(hdr_ptr->filesize_octal));
            hdr_ptr = hdr_ptr + 512 + align_up(getsize(hdr_ptr->filesize_octal), 512);
            kprintf("addr of new header: %p\n", hdr_ptr);
            kprintf("name of new thing %s\n", hdr_ptr->name);
        }
    }
}
#

tar header

struct tar_header
{
    char name[100];
    char mode[8];
    char uid[8];
    char gid[8];
    char filesize_octal[12];
    char unix_time_format[12];
    char chksum[8];
    char type[1];
    char name_linked_file[100];
    char ustar[6];
    char ver_ustar[2];
    char owner_name[32];
    char group_name[32];
    char device_major[8];
    char device_minor[8];
    char filenameprefix[155];
};
#

fuck u u stupid tar header

edgy pilot
#

cast hdr_ptr to uint8_t* or void* before adding

surreal path
#

k

#

it fixed it

#

bruh

#

why tf did that fix it i dont know !

#

oh wait i know

#

right

surreal path
#

question, with the tar file

#

the order of tar headers will always be the same as the directory layout

#

right?

#

like

#

first tar header might be a directory called root

#

second will be a directory in root called kitty

#

then third header will be a file in kitty called meow.txt

#

wait

#

im confused now

#

ok im fixing this

surreal path
#

i think it worked?

#

im GUESSING its in order

#

most likely

#

i hope

#

🀞

#

otherwise my code will break lol

#

fuck

#

so heres the thing

#

how i've implmenteed my segment thing

#

sucks ass

#

im so fucked

#

can i ask how some of yall implement the parsing of paths so i can steal take inspiration yes

#

fuckin hell

surreal path
#

ah i see, so you take your absolute path and replace every '/' with \0

#

a null terminator

#

then easily you just loop over the total path length, get the vnode, then add the length of the cur string to i in this loop

#

ah i get u

edgy pilot
surreal path
#

thank you mathew!

elder shoal
#

Np :3

surreal path
# elder shoal Np :3

im gonna make two helper functions that can create a directory or file from an absolute path

#

good idea?

elder shoal
#

I use one function for that

#

vfs_create

#

which calls VOP_CREATE

#

vfs_create takes a path relative to a vnode and VOP_CREATE takes a vnode and a name

surreal path
#

i have a vop_create actually

#

as per spec of the sun vfs

elder shoal
#

I have a single function for creating directores and files and everything else

#

except symlinks

#

because they can be special

surreal path
#

(cause i dont have things like working directories setup cause im not in userspace rn)

#

actually wait

#

let me modify my vfs_lookup

elder shoal
#

just have it take a vnode and do the lookup relative to it

#

if you need to do absolute just pass vfsroot

#

will save you work later

surreal path
#

i can see in ur function ur not breaking down the path into components

#

oh wait thats for ur thing

#

right

#

ummm

#

okay so how i've currently implmented my vfs_lookup is

#

it assumes the path is absolute

#

which shouldnt be right

#

okay time to make some changes

#

@elder shoal im a little confused by this statement in ur code

#

what is this doing exactly

#

my brain went πŸ’₯

elder shoal
#

so it handles trailing /

#

/root/

#

/usr/bin/

surreal path
#

oh right

surreal path
#

but what about if /home doenst exist

#

what do we do

#

???

elder shoal
#

vfs_lookup returns enoent

#

error

surreal path
#

oh error out, okay

surreal path
elder shoal
#

yeah

surreal path
#

alr

#

thanks mathew for ur help, i hope this works

#

🀞

#

if this works then its FUCKING NYAUX USERLAND TIME 😱

surreal path
#

how do i know when i should stop parsing the tar

#

cause currently

#

this while loop still goes on and starts reading some headers that dont make sense

#

how to know when i've parsed every header?

#

is there a way to checK?

tawdry mirage
#

the tar file ends?

#

cpio has a !!!TRAILER!!! entry at the end but iirc tar doesn't have any special terminator

surreal path
#

but its still reading some weird ass null tar entry

#

searching for path \0

#

okay found a way to stop it by having a check in my vfs create function

tawdry mirage
#

The end of an archive is marked by at least two consecutive zero-filled records.
according to wikipedia

surreal path
#

so i need to do hdr_ptr < (archive->address + archive->size) - 1024

#

yea fixed

#

I POPULATED MY FUCKING TMPFS

#

OMG

#

I HAVE AN INITRAMFS!!!!

#

WOWIE!!!

#

lets read the contents of some of the text files

#

some weird stuff going on

#

but it still finds the directory so

#

idc!

#

oh yea i just needed to um

#

memset some structures

#

easy

#

😎

#

lemme try reading da file

#

it worked but um

#

what is that

#

tf

#

what im doing

#

is this something to do with the end of file thing ?

#

oh wait i think its because i have a newline in the file

#

yea

elder shoal
#

no null terminator?

#

:megamind:

surreal path
#

no? there should be

#

its a txt file

#

i just wrote some text in a text editor

#

and saved it

#

what is that

#

seriously

#

tf

elder shoal
#

hexdump the file

surreal path
#

kk

#

000a?

#

decimal

#

why is there no null terminator????

elder shoal
#

-C

surreal path
#

no null terminator?

#

huh??

#

wheres the null terminator tf

shut laurel
#

there is no null terminator at the end of file

surreal path
#

why???

shut laurel
#

why do you need it

surreal path
#

idk

shut laurel
#

add it at the end of buffer

surreal path
#

nah its okay, im happy that it printed and my initramfs system works

#

that means....

#

userland?

#

RIGHT FUCKING NOW???

#

OK CHAT LETS GO?

#

guys is it time for me to go to userspace..

#

the promised land

#

mints tutorial says i have mostly everything i need

#

i think its time. to go to userland 😱

haughty kite
#

you can usespace without a lot of that shit tbh

#

and some would disagree with mint's approach

surreal path
#

okay but anyways we have pretty much everything we need in place, so

#

sooooo

#

yea 😎

#

time to learn how to get to userland and stuff

#

and load elfs and yeayea!

#

and mlibc idk how to set that up

#

but yea yea

#

and sys calls

#

yea

#

lemme just configure my make file to turn this folder called sys root into a initramfs for booting

#

OKAY DONE

#

SET THAT UP

#

😎

#

pushed changes onto gituhb

wicked loom
haughty kite
#

but yeah fair

wicked loom
#

it was not originally written by me

#

so it's hardly my approach

#

i just modified it a bit in places that i thought were bad

surreal path
#

ummm what is this

#

i dont have mlibc

#

what do i do

#

???

#

me so confusion lol

#

and what is mtools in the limine host recipes

#

@wicked loom ?

#

somethings happening

#

ok needed to modify my kernel recipe

#

now its um compiling gcc

#

i have auto reconf installed????

#

on my system

#

wtf

#

jinx is failing here

#

i have autoreconf tho???

#

does anyone know whats going on

haughty kite
#

container meme i would guess

surreal path
#

im not using a container does jinx use a container

haughty kite
#

yes

surreal path
#

how do i fix this shit

haughty kite
#

no idea

surreal path
#

fuck me

#

😭

surreal path
#

ITS RIGHT THERE

#

BRO

#

issue is autoconf-archive

#

i thnk

#

will fix and reconfigure everything

wicked loom
#

pro tip

#

diff -ur path/to/vinix nyaux

#

make sure the only differences between the 2 are things that you are doing properly

#

if stuff seems to be borked you can just make distclean and start over, for now

surreal path
surreal path
#

not just the host recpies

wicked loom
#

copy what you need

#

which i assume rn is going to be possibly all that is needed for bash

#

so check what bash depends on and the dependencies of the dependencies and so on

#

and copy that over

#

(and any associated patches)

surreal path
#

im just gonna copy everything

#

so i can get this to work

wicked loom
#

bruh, if you copy everything it's gonna build Xorg and a lot of stuff like GTK

surreal path
#

oh

#

πŸ’€

wicked loom
#

don't do that

#

bash is easy

#

it only depends on like ncurses, readline, mlibc

surreal path
#

i dont even have mlibc rn πŸ’€

#

im just gonna copy base-files and kernel

wicked loom
#

sure

#

you can start like that i guess

#

but you'll have to build the kernel with a host compiler aka add imagedeps="gcc" for example

#

to the kernel recipe

surreal path
#

alr

#

wait

#

is there a better way to do this

surreal path
wicked loom
#

yes aka build the cross compiler (the host-recipes/gcc thing) and use that to build the kernel; but that depends on mlibc

#

you'll want to stub out mlibc sooner or later anyways

#

stub out = add support for your OS and make sysdep stubs until you have proper sysdeps

#

you can do that via patching

#

try to build mlibc, it will fail because no support for your OS (obviously)

#

after that happens, you can edit the mlibc that will exist in sources/mlibc-workdir/... and add support for your OS

#

then you run ./jinx regenerate mlibc and it regenerates the patch and then run ./jinx rebuild mlibc-headers mlibc to rebuild mlibc

#

all clear?

surreal path
#

yep

#

i will just stub out everything since i dont even have the syscall and sysexit instructions setup yet πŸ’€ literally just stub out every function lol

wicked loom
#

yeah that is fine

surreal path
#

alr

wicked loom
#

it's just to have it build, it doesn't care if you stub out everything or not

surreal path
#

alr

wicked loom
#

also you can probably ask @elder shoal @thorn bramble and @green elbow for help with jinx and porting mlibc

#

in case i am not around or not good enough at explaining

surreal path
#

alr

#

okay compiling jinx lets work on stubbing out mlibc!!!!

#

my favourite past time activity

green elbow
#

pong

surreal path
#

ping pong

#

waiting for jinx to compile be like

wicked loom
#

jinx needs to bootstrap an arch linux container and then it builds doxygen because upstream is stupid but pretend it's a black box lol

surreal path
#

it pretty much is to me

#

ok autoreconf is working

#

things are happenin

#

it looking for the source recpie for binutils but vinix didnt have a binutil source recpie?

#

???

wicked loom
#

you need the binutils recipe from recipes/

surreal path
#

wheres the source recipe for binutils in vinix

surreal path
#

right

#

okay

wicked loom
#

it's uh

#

a bit complicated

surreal path
#

ok works now 😎 watching this compile so fun yet so long

wicked loom
#

because it checks for the source in recipes/<whatever> for host-recipes/<whatever>, and if that is missing, it checks source-recipes/<whatever>

surreal path
#

okay our first error

#

!!!

#

is with binutils

#

of courseee

#

wdym conflicts with

#

huh???

#

what does that mean

wicked loom
#

you need the patches

#

you're missing the binutils patches

surreal path
#

right

wicked loom
#

just copy the patches dir for binutils over, then run rm -rf sources/binutils* and ./jinx host-rebuild binutils

surreal path
#

alr

wicked loom
#

and of course change the patch to s/vinix/nyaux

#

before rebuilding

surreal path
#

yep

unkempt relic
#

i can't remember if it was vinix or lyre patches and mlibc sysdep folder i initially stole for keyronex

surreal path
#

okay here we go

#

mblibc trollage time

#

this is with binutils

#

i think something to do with the patch?

#

patch looks fine

#

this isnt with mlibc but with binutils huh?

#

im so confused lol

wicked loom
#

did you copy and adjust the patches for autoconf and everything else that needs patches?

surreal path
#

okay patches folder looks like this now

#

will add gcc-host patch too

#

ill just replace everything vinix with nyaux

#

still complaining

#

same issue

#

ill try rebuilding binutils by deleting the source folder

#

why still the same issue

#

πŸ˜”

#

i have the autoconf patch, binutils patch, gcc-host patch, and the mlibc patch from vinix and replaced all instances of "vinix" with "nyaux"

#

i tried removing the sources directory for both autoconf and bintuils

#

still nothing

wicked loom
#

you need to repatch autoconf with rm -rf sources/autoconf* and then ./jinx host-rebuild autoconf

#

after that, rm -rf sources/binutils* and ./jinx host-rebuild binutils

#

what recipes and host-recipes do you have now?

surreal path
#

and still the same issue with binutils

wicked loom
#

define "same issue"?

surreal path
#

Invalid configuration 'x86_64-pc-nyaux-mlibc': Kernel 'nyaux' not known to work with OS 'mlibc'

wicked loom
#

did you s/vinix/nyaux/ in the autoconf patch?

surreal path
wicked loom
#

(for all cases?)

surreal path
#

yep

wicked loom
#

send the autoconf patch

surreal path
#

kk

tawdry mirage
#

lol ```

  • x86_64:[Vv]inix::|i?86:[Vv]inix::)
    +GUESS="$UNAME_MACHINE-pc-nyaux-mlibc"
    +;;
  • :[Vv]inix::*)
    +GUESS="$UNAME_MACHINE-unknown-nyaux-mlibc"
wicked loom
#

yeah

surreal path
#

Vvinix

wicked loom
#

fix that to [Nn]yaux

surreal path
wicked loom
#

for all 3 times

surreal path
#

ok rebuilding autoconf

#

rebuilding binutils now

wicked loom
#

make sure you deleted the source for both of them first

surreal path
#

yep

wicked loom
#

aight

surreal path
#
configure: error: /bin/sh /base_dir/sources/binutils/config.sub x86_64-pc-nyaux-mlibc failed
#

BRO COME ON

#

😠

wicked loom
#

what does your recipes/binutils look like?

surreal path
wicked loom
#

that ain't what i asked for lol

surreal path
#

oh wait

#

lmao

#

πŸ’€

#

my recipe

#

wait

wicked loom
#

waiting

surreal path
wicked loom
#

did you copy and edit the libtool patch? what does your host-recipes/libtool look like?

surreal path
#

forgot to

#

added the libtool pathc

#

recompiling

#

man this is tedious lol

wicked loom
#

welcome to userland porting

surreal path
#

😭

elder shoal
#

when you blink you'll be a thousand lines deep in a makefile wondering what you're doing with your life and why you're trying to port that package

surreal path
tawdry mirage
#

solution: just write your own userland

surreal path
#

😭

wicked loom
surreal path
#

my patches folder has the following patches

autoconf
binutils

#

gcc-host

#

libtool

#

mlibc

surreal path
# wicked loom did you check all the casing? what does your host-recipes/libtool look like?
name=libtool
from_source=libtool
revision=1
hostdeps="autoconf automake"
imagedeps="help2man gcc"

build() {
    cp -rp "${source_dir}"/. ./
    ./configure \
        --prefix="${prefix}"

    make -j${parallelism}
}

package() {
    DESTDIR="${dest_dir}" make install

    cp -pv /usr/local/share/autoconf/build-aux/config.sub "${dest_dir}${prefix}"/share/libtool/build-aux/
    cp -pv /usr/local/share/autoconf/build-aux/config.guess "${dest_dir}${prefix}"/share/libtool/build-aux/

        strip_command=strip \
    post_package_strip
}
wicked loom
#

rome wasn't built in one day

surreal path
#

lol

#

true

wicked loom
wicked loom
#

because binutils pulls the gnuconfig from libtool for some reason

kind root
wicked loom
#

god no

kind root
#

Lmao

surreal path
#

that would be legit hell

#

dont torture me like that please

wicked loom
#

trust me i triedℒ️

surreal path
#

😭

#
checking target system type... Invalid configuration 'x86_64-pc-nyaux-mlibc': Kernel 'nyaux' not known to work with OS 'mlibc'.
configure: error: /bin/sh /base_dir/sources/binutils/config.sub x86_64-pc-nyaux-mlibc failed
#

does binutils hate me or smthin

surreal path
#

πŸ˜ƒ

kind root
#

Are you porting gcc?

surreal path
#

no

#

wha

#

im not porting gcc

#

gcc is in my host recipes sure

#

but

#

im not porting it

#

to the actual os

kind root
#

Cant u just start userland by making some assembly app

surreal path
#

bruh

kind root
#

To make it easier for yourself

#

And port GCC later

surreal path
#

im not trying to port

#

gcc??

kind root
#

Just make it print hello world using your syscall

#

And then exit

surreal path
#

bruh

kind root
#

Im just saying you dont need it right now

#

You can even do it in C

surreal path
#

i need patience as mintsuki said, im sure the problem is somewhere

kind root
#

Just using the standard gcc

#

Statically linked freestanding binary

surreal path
#

im gonna run dist-clean and recompile everything

surreal path
surreal path
#

i just gotta figure this out lol

kind root
#

Sure sure have at it lol

surreal path
#

lmao

#

this is how my makefile looks like @wicked loom

#

same thing from vinix but i removed everything but base-file and kernel when doing distro-base

#

ok running dist-clean solved it

#

now its compiling mlibc

#

scawry

#

😱

#

probs gonna scream at me about no nyaux os support but yk

#

well its compiling the host gcc toolchain first

#

lol

#

this is gonna take a bit

#

what does this mean

#

guess i need a recipe called "core-libs"

#

now it wants something called cshim?

#

ok

#

?

#

bruh

#

wdym git program not found???

#

tf

#

bro

#

so close yet so far

wicked loom
#

you need the proper dependencies for mlibc

#

which you evidently do not have

surreal path
#

i have git

#

tf

wicked loom
#

no

#

first off it's inside the container, not on your host machine

#

but second

#

you need cshim, cxxshim, and frigg

surreal path
wicked loom
#

forget about the git thing, git is unnecessary if you have the dependencies

#

no

#

forget your host machine

surreal path
#

okay

wicked loom
#

your host machine is never touched by jinx

#

look at recipes/{cshim,cxxshim,frigg} in vinix

surreal path
#

i put the recpies cshim, cxxshim and frigg into my recipes folder

#

already tho

#

rm -rf sources/something?

wicked loom
#

no

surreal path
#

oh then what

wicked loom
#

your mlibc failed to build because it did not find the dependencies

#

which means you removed the dependencies from the deps="whatever" line

#

do not do that, ever

#

under any circumstance

#

unless you know what you're doing

#

if you removed the deps, readd them, then rebuild mlibc

#

if you don't have the dependencies listed, mlibc won't magically find them

#

builds are isolated

surreal path
#

they are in

#

my mlibc recipe??

wicked loom
#

then how did it not find them

surreal path
#

idfk 😭

wicked loom
#

ok uh

#

did you port pkg-config?

surreal path
#

that is in my source-recpies yes

wicked loom
#

and host-recipes

surreal path
#

yes

#

its in there

finite summit
#

just like use a shell script or something

wicked loom
#

do you have build-support/cross_file.txt

surreal path
wicked loom
#

did you edit it to contain nyaux ?

surreal path
#

oh shit i did not

wicked loom
#

yeah do that

#

then rebuild mlibc

surreal path
#

ok

#

now THATS THE ERROR WE WANT

#

😎

wicked loom
#

yeah there you go

surreal path
#

now for the very fun part

#

porting mlibc!!!!

#

wowie!!!!!

wicked loom
#

it's not too hard

surreal path
#

ok

wicked loom
surreal path
#

thats a LOT

#

of stuff

#

😭

wicked loom
#

well you don't need most of it

surreal path
#

what do i need?

wicked loom
#

mainly the crt-src/* files, the sysdeps/nyaux/meson.build (of course, adapted to remove the files you don't need), all the symlinks in sysdeps/nyaux/include/abi-bits/*, then sysdeps/nyaux/generic/generic.cpp, stubbing out pretty much every sysdep, sysdeps/nyaux/generic/entry.cpp, you will need to add your OS to /meson.build like vinix, and that's it

surreal path
#

do i worry about what the crt-src files are for or do i just

#

steal them from vinix or smthin

wicked loom
#

you can just copy them

#

they are the same for pretty much any regular OS

surreal path
#

okay

wicked loom
#

there is a bunch of symlinks in sysdeps/vinix/include/abi-bits/

#

you need them too

surreal path
#

well will i just copy them

#

or do i have to do it all manually or somthin

wicked loom
#

yeah for now you can just copy them

surreal path
#

okay

#

what are they for btw?

#

so i understand

wicked loom
#

abi

#

it's kinda clunky, i tried to rework this aspect of mlibc in the past but it got rejected

#

basically some headers have structures that need to match what the kernel expects

#

and they are in /abis/*/

surreal path
#

okay

wicked loom
#

then each port can symlink to whatever abi it needs

surreal path
#

okay well i will make the generic.cpp file

wicked loom
#

alright

cinder plinth
#

you should probs try running a hello world in assembly first

wicked loom
#

i don't necessarily agree lol

cinder plinth
#

well first getting CPL=3 would be a good idea

surreal path
#

so are all the sys functions the ones i need to stub?

wicked loom
#

it doesn't matter, you can port a userland already without a working kernel

cinder plinth
cinder plinth
#

no

#

dynamic linker

wicked loom
#

yes

surreal path
#

wha

wicked loom
#

it's rtld

cinder plinth
#

runtime dynamic linker

wicked loom
#

go check :)

alpine mulch
#

get rekt

wicked loom
surreal path
#

alr

cinder plinth
#

wait

wicked loom
#

just stub the sysdeps

cinder plinth
#

who changed it

#

i swear

wicked loom
#

me

cinder plinth
#

it was rtdl

surreal path
wicked loom
#

i changed it because every other libc calls it rtld and it's generally known as rtld

surreal path
#

how to use this macro

elder shoal
cinder plinth
#

yeah I spent so much time trying to get it working lol

wicked loom
surreal path
#

okay

#

i MIGHT need this

surreal path
#

ummm

wicked loom
elder shoal
#

it will always be rtdl in my heart

wicked loom
#

you'll need it though of course

tawdry mirage
#

and also the libc constants are prefixed with RTLD_

surreal path
#

okay any function that calls a syscall i stub

tawdry mirage
#

some of the functions you can skip and mlibc will just return ENOSYS on it's own

wicked loom
#

yeah but the problem is that i don't remember which you can and cannot

surreal path
#

im skipping the ones that dont directly make a syscall

wicked loom
#

that's fine

tawdry mirage
#

but ig that's still effort

wicked loom
#

i did at some point strip down all the sysdeps that weren't needed for it building, but god knows if i will ever be able to find that list

tawdry mirage
#

the bare minimum is what rtld sysdeps declare i think

surreal path
#

how much fuckin sys functions do i have to stub 😭

tawdry mirage
#

since like all of those are not weak

surreal path
#

oh my gilly gosh

#

okay i stubbed all the functions

#

time to config the meson.build

wicked loom
#

nice

surreal path
#

ok took entry.cpp from vinix ig?

#

its making a bunch of syscalls here

#

what do i do

#

i guess i dont change that @wicked loom

#

i cant rlly stub that out

wicked loom
#

one sec

surreal path
#

alr

wicked loom
#

you can remove everything between lines 35 to 114, and remove the sys_sigentry() call inside __mlibc_entry()

#

keep the rest

surreal path
#

okay

wicked loom
#

oh and also remove the #include "syscall.h" line

surreal path
#

done

#

okay

#

i tried doing ./jinx regenerate mlibc

#

and then tried rebuilding mlibc and stuff

#

but it didnt work

#

still didnt see the sysdeps

wicked loom
#

didn't work how

surreal path
#

wait

#

i know why

wicked loom
#

also remember it's ./jinx rebuild mlibc-headers mlibc

surreal path
#

oh right

wicked loom
#

you can remove that and stub it out

#

alternatively you'll need to copy over the ioctls headers as well

#

aka sysdeps/vinix/include/asm/{ioctl.h,ioctls.h}

surreal path
#

IT COMPILED

#

i removed the include for that

#

which worked

#

do i need to readd the include?

wicked loom
#

you must've also stubbed it out i assume?

surreal path
#

ye

surreal path
wicked loom
#

like what i mean is that you must have stubbed out the functions that were using those macros above?

surreal path
#

yea i did

wicked loom
#

if so, don't bother readding those for now

surreal path
#

okay

wicked loom
#

it's not necessary

surreal path
#

okay what now

#

since mlibc compiled

#

do i just run make

#

?

wicked loom
#

yeah

surreal path
#

more recipe shanngains

#

lets go

wicked loom
#

it's not a big deal

#

libgcc and libstdc++ are small and painless

surreal path
#

ok is compiling

surreal path
#

why cant it use nasm

#

bruh

wicked loom
#
  1. you cannot use the internet from recipes by default, you can enable that by adding allow_network="yes" to the recipe
  2. recipes/* is shit that runs on your OS, not on the host, for things to run on the host there is host-recipes
  3. there is no need to put nasm in host-recipes since you can just use that arch repos one by adding imagedeps="nasm"
surreal path
#

kernel?

wicked loom
#

yes

surreal path
#

kk

wicked loom
#

likewise with allow_network="yes"

surreal path
#

okay

#

now

#

its trying to use my old toolcahin for some reason

#

oh wait

#

my kernel make file

#

right

wicked loom
#

you wanna use the x86_64-pc-nyaux-mlibc-* toolchain

surreal path
wicked loom
#

yeah, either that or you can just set that to cc as default and just pass CC=... LD=... to make in the recipe instead

#

i prefer the latter solution

surreal path
wicked loom
#

make CC=... LD=...

surreal path
#

okay

wicked loom
#

where you call make

surreal path
#

uh huh

#

i never have these flags tho?

#

what

#

likeeee

#

what

#

that isnt in my makefile

#

where is it getting that

wicked loom
#

ok ok,

#

calm down

#

you need to add LDFLAGS="" as well to the make call, i can tell you why but i'd just distract you for now

#

i'll tell you later

surreal path
#

okay

#

no rule to make target install

wicked loom
#

you can copy it from vinix/kernel/GNUmakefile

#

at the bottom

#

everything from .PHONY: install to the end

surreal path
#

guess i must make that folder in sysroot

wicked loom
#

no

surreal path
#

oh

wicked loom
#

it likely means you do not set the variable KERNEL to nyaux in your kernel makefile

#

check what the install recipe does

surreal path
#

okay that solved it

wicked loom
#

πŸ‘

surreal path
#

well that was something

wicked loom
#

great

#

awesome

surreal path
#

!!!

wicked loom
#

don't forget to commit your changes before you accidentally run make distclean or otherwise trash it all

surreal path
#

i cant addr2line the executable fuck me

wicked loom
#

you can

surreal path
wicked loom
#

but you need to use the one in builds/kernel/bin/nyaux, because the other one is stripped

surreal path
wicked loom
#

maybe that address is just invalid?

surreal path
#

nope it does the same with any address

#

i try

#

??:?

wicked loom
#

run file builds/kernel/bin/nyaux

#

i think i know why

surreal path
finite summit
#

isn't it supposed to be a hex address

#

0xffffffff8001a6c6

wicked loom
#

try adding CFLAGS="" alongside LDFLAGS="" in your recipes/kernel, then rebuild the kernel

surreal path
#

okay

#

still the ??:?

wicked loom
#

(basically your kernel makefile doesn't force -g and the default CFLAGS are overridden by the jinx config ones, so you build without -g unless you pass no CFLAGS)

#

ok try unset CFLAGS; unset LDFLAGS; make instead

#

(all on the same line, as written)

surreal path
#

ok

#

still

wicked loom
#

did you do ./jinx rebuild kernel?

surreal path
#

ok

#

wait

wicked loom
#

?

surreal path
#

done

#

😎

wicked loom
#

does it work?

surreal path
#

yea, problem is with how jinx gives me the tar file

#

or well

#

how i parse it

#

to an extent

wicked loom
#

like

#

mentally drop the /build_dir/builds/kernel part lol

#

the rest is just your path inside the kernel dir

surreal path
#

i know

wicked loom
#

there is a way to automatically change that

#

but eh

#

one thing at a time

#

this is probably confusing enough as is

surreal path
#

either way, how does tar create the initramfs file

#

like

#

is the first tar header named sys_root or smthin?

#

cause thats a problem if thats the case

wicked loom
#

no

#

the contents of the tar initramfs are the contents of sysroot/

#

so your bash would be /usr/bin/bash inside the initramfs

#

just like a normal *nix system

surreal path
#

oh wait

#

page fault here

#

meaning

#

i know why

#

lol

#

oh and

#

tar header isnt of expected type

#

uhoh!

#

spaggati ohs

wicked loom
#

mind you there are symlinks and friends

surreal path
#

fuck

#

im so fucked

wicked loom
#

you can skip them

#

for now

#

bash will still work

surreal path
#

is fucking everything a symlink

wicked loom
#

uh

#

just check your sysroot/ dir

surreal path
#

looks like this ig

wicked loom
#

if you have the tree command installed, you can run tree -a sysroot

#

the blue files with an arrow are symlinks

#

or i should say cyan

surreal path
#

i no see

wicked loom
#

what do you see

surreal path
#

all normal files

#

in white

#

and directories

wicked loom
#

can you show

surreal path
#

yea

wicked loom
#

tree -a sysroot | grep '\->'

surreal path
#

okay

wicked loom
#

yeah those are symlinks

surreal path
#

makes sense

#

and seems like tmpfs did create some files and directories

wicked loom
#

yeah

surreal path
#

just gonna trust everything is setup valid

#

lol

wicked loom
#

it should be

surreal path
#

yea hopefully

#

lol my kernel page faults on bios

#

like i care

#

!!!!

#

anyways we now have jinx!!!!

#

and mlibc ig??

wicked loom
#

aweomse

#

yes

surreal path
#

yea technically!!!!

#

all i needa do is setup syscalls now

#

jump to usermode

#

easy

#

😎

#

oh and write an elf parser

#

yea

wicked loom
#

it's not that complicated

#

elf is rather simple

surreal path
#

hopefully

#

i will learn in due time

#

i just know now that i gotta setup some structure called a tss?

#

or smthin

#

just following what the sdm says

wicked loom
#

yeah

surreal path
#

now i must make some kind of kernel stack instead of using limines cause seems like the tss is used for when an interrupt happens and cpl changes what stack to switch to (for long mode)

#

also mint i just wanna say thank you for all the help, helping me setup jinx and mlibc and such !!!

#

im rlly thankful!!

#

@wicked loom thank u so much!

steady flume