#Nyaux

1 messages Β· Page 64 of 1

molten grotto
#

they share the same FileDescriptorHandle

#

so yeah the refcnt too

surreal path
#

okay

molten grotto
#

either you add a refcount field to the FileDescriptorHandle that you update (and finally free + destroy after it reaches zero) or you make some kind of generic refcounted object thing that you can use with other things too

surreal path
molten grotto
#
typedef struct {
    size_t count;
    void (*destructor)(void *me);
} refobj_hdr;

void *refobj_create(size_t size, void (*destructor)(void *me)) {
    refobj_hdr *hdr = kmalloc(size + sizeof(refobj_hdr));
    if (!hdr) return NULL;
    hdr->count = 1;
    hdr->destructor = destructor;
    return hdr + 1;
}

void refobj_ref(void *obj) {
    refobj_hdr *hdr = (refobj_hdr *)obj - 1;
    __atomic_fetch_add(&hdr->count, 1, __ATOMIC_RELAXED);
}

void refobj_unref(void *obj) {
    refobj_hdr *hdr = (refobj_hdr *)obj - 1;
    if (__atomic_sub_fetch(&hdr->count, 1, __ATOMIC_ACQ_REL) == 0) {
        hdr->destructor(obj);
        kfree(hdr);
    }
}
surreal path
#

we bal;ll

daring juniper
#

let's go! letsgo

surreal path
#

posnyatral standard @elder shoal since we both use keyboard device files as our inputs

kind root
#

nice

elder shoal
#

Real

surreal path
#

real

surreal path
#

what should parameters to say a readdir vfs op, im not having the seeking being handled in the readdir op itself (hope thats okay) as my fd system does that fine, should it be (vnode, hnd, buffer, buffersize, offset)? and like hnd->position is ur pos???

#

idk

#

im so confused rn

median goblet
#

offset being read write

#

and possibly a version field as well so that you can deal with race conditions when someone else modifies the directory by adding/removing a file

broken depot
# surreal path what should parameters to say a readdir vfs op, im not having the seeking being ...

I have these two:

    /// Find a directory entry.
    fn find_dirent(&self, name: &[u8]) -> EResult<Dirent>;
    /// Get all directory entries.
    fn get_dirents(&self) -> EResult<Vec<Dirent>>;

This is on my VNodeOps trait so &self implicitly includes the FS-specific data needed to do these calls.
The contract, then, is that the things like this:

    /// Create a new file in this directory.
    fn make_file(&mut self, name: &[u8], spec: MakeFileSpec) -> EResult<Box<dyn VNodeOps>>;

Take a multable reference, i.e. the generic VFS code ensures that make_file is not concurrently called when e.g. find_dirent is.

#

Having the two separate functions for finding a dirent and getting all of them has worked nicely so far for me.
To answer your question: A reference to the VNode should be all you need (and add filename for find_dirent ofc)

molten grotto
#

or what is it used for

broken depot
#

For example, RAMFS uses a BTreeMap where FAT will use a linear read of the directory's contents.

molten grotto
#

what I meant by generic vfs lookup op was fn lookup(&mut self, name: &str) -> Result<VNode>; that's implemented by the fs (not so generic ig, idk why I said generic lol)

broken depot
#

Well, the FS makes the Box<dyn VNodeOps>

#

VFS only stores that box

molten grotto
#

yeah but you get the idea

#

ig your find_dirent is basically the same thing then?

#

just with a different name

broken depot
#

All three functions you see above are functions of the trait VNodeOps

broken depot
#

Well except for the part where looking up a dirent need not actually open the VNode

#

That is handled by this function in VfsOps:

    /// Open a file or directory.
    /// The caller must guarantee `dirent` is up-to-date.
    fn open(&self, dirent: &Dirent) -> EResult<Box<dyn VNodeOps>>;

The Dirent type contains some more info than an actual struct dirent in userspace would, so that all information needed to actually open the file can be stored in it.

molten grotto
#

ah, interesting

broken depot
#

This lets you open a file directly from a dirent cache entry

surreal path
surreal path
broken depot
# surreal path What about position and offset

POSIX semantics require loading all dirents at once when you start reading the first dirent in a directory through the read system call, so you'd simply call get_dirents at that point and store it in the file descriptor (in my case VfsFile, which implements the File trait).

#

With more dirent cache awareness, I could even optimize this to not duplicate memory in the future.

surreal path
broken depot
#

Yes, but remember to clear that out when the position is set to 0 again as IIRC, these same semantics require you to load it again when you re-start reading from the beginning.

surreal path
#

I’m confused

broken depot
#

Position (file descriptor offset, etc.)

#

Because if you don't clear that (which is effectively a cache), then you could only get the dirents once every time you open a file descriptor on a directory.

surreal path
#

uh huh

broken depot
#

So the logic becomes:
On read, cache the dirents in the FD if offset is 0.
On seek, clear that cache if the offset becomes 0.

median goblet
surreal path
median goblet
surreal path
#

Oki

broken depot
#

Note: POSIX allows you to use any number as the offset for directories, and says that applications must only use offsets obtained from tell for this reason.

#

If any other number is used, the result is undefined.

brisk zenith
broken depot
# brisk zenith why would POSIX semantics require this

It's been a bit since I researched this, but doing a read (not getdents!) on a FD that refers to a directory should be consistent; if the directory is modified halfway through a loop reading it, undefined results could occur if you don't enforce these semantics.

brisk zenith
#

pretty sure POSIX doesn't require readdir consistency when concurrent modification is involved

#

and read on a directory is not defined by POSIX

broken depot
#

Oh

#

Then these are Linux semantics

broken depot
unkempt relic
#

in dealing with readdir offsets, one of the useful properties of traditional filesystems like ufs, ext2, etc is that you can do something like this when asked to readdir starting at some offset x: let y be x rounded down to the nearest multiple-of-block-size. then follow the dirent chain starting from the dirent at y. when you find the first dirent >= x, then return that

#

that's the simplest way to implement readdir statelessly

surreal path
#

im gonna impl it robots way

#

easiest from my point of view

#

we ball later today

#

also holy shit its been nearly 2 years since i started nyaux

#

i should make a late nyaux anniversary thing

surreal path
#

okay we ball now

surreal path
#

i think this is right

#

am i wrong here?

surreal path
pearl zephyr
#

since when the fuck are there 62900 messages

#

holy hell

pearl zephyr
surreal path
#

weve had even doom

pearl zephyr
#

awseome

#

nevermind

surreal path
#

awesome

broken depot
surreal path
broken depot
#

Maybe another day, I'm kinda nonverbal rn

surreal path
#

but no pressure

#

u dont have to lol ill totally understand if ya so no

#

im taking that slience as no, totally understand! sorry ur not feeling well :c

broken depot
#

That just kinda happens sometimes

surreal path
#

i understand

#

okay me impling that op is as much as im gonna do today, im losing my shit with how id get this working without somehow fucking it up lol

#

its hot

surreal path
#

okay i dont know how much nyaux work i can get done today

#

today im going to contribute to gloire for the EC

#

we will see if i can get some nyaux work done too

surreal path
broken depot
#

Yes.

surreal path
broken depot
#

goot

surreal path
#

epic!!

#

im gonna go eep now so i wont be responding for 1-2 hours lol

broken depot
#

Im painting me spaceship

surreal path
#

epicc

broken depot
#

Hoping to do a crystal fragments thing

kind root
median goblet
#

gloire is iirc related to streaks' ironclad os

#

but EC?

kind root
#

EC is embedded controller

edgy pilot
surreal path
#

doing gloire work rn

surreal path
#

im js doing ironclad work

#

im js using it interchangbly

kind root
#

cool

surreal path
elder shoal
surreal path
#

im working on shit at nearly 5am vro

elder shoal
#

Go to sleep

surreal path
#

help me oh lord

#

no

#

well actually yea

#

i will

#

gn

elder shoal
#

Gn

surreal path
#

holy shit i can barely sleep

daring juniper
#

Get a Yo-Kai Watch and summon Baku, boom, problem solved trl

surreal path
#

progress ig tho

daring juniper
#

ayyy! Someone remembers yokai watch! πŸ˜„

surreal path
surreal path
#

im actually gonna go to sleep but before i do

#

why is the name in mlibc's define of name 1024

#

instead of a char ptr

#

why is that allowed

#

what abt names > 1024

ebon needle
steady flume
#

iirc, if you compile your code with -g or -ggdb, you can add the --tui flag to gdb when you run it, eg. cc -g -o my_prog src.c && gdb --tui ./my_prog

surreal path
edgy pilot
#

just don't have paths that are longer meme

surreal path
#

?????

edgy pilot
#

what

surreal path
#

how is that allowed

edgy pilot
#

have you ever seen a path that long?

surreal path
#

there are def names bigger then 1024

edgy pilot
#

nope

surreal path
#

ill make one rn

#

THATS FUCKING RETARDED

#

FILE NAME TOO LONG

#

HOW IS THIS EVEN ALLOWED VRO

#

😭 πŸ™

edgy pilot
#

because paths that long don't exist in the wild

surreal path
#

crazy shit

brisk zenith
#

the entire path has a different limit

#

which on linux I believe is 4096?

#

also the component name length limit is filesystem dependent

#

on ext4 it's 255 bytes iirc

surreal path
#

if the dir entries are 1024 limited

#

it cant be fs dependent

#

cause at the end of the day its gonna be 1024

brisk zenith
#

1024 is the absolute max yeah (on mlibc at least) but the real max (which can be lower) is fs dependent

surreal path
#

fair

brisk zenith
#

looks nice

surreal path
#

yes

brisk zenith
#

love the free floating pc speaker

surreal path
#

llove that pc speaker

#

its very nice

median goblet
surreal path
#

it very much is

molten grotto
surreal path
#

corsair 4000d airflow

#

its not lianli im afraid

molten grotto
#

ah it looked similar to the lianli that I have from the side KEKW

surreal path
#

fair KEKW

molten grotto
kind root
#

should put a fan on the back for that extra airflow

#

they're dirt cheap for the most part

ebon needle
surreal path
orchid dawn
surreal path
# molten grotto

yo is this okay?? ls is trying to access '', what am i supposed to say, if i give it back the cwd it js fstats it until the end of time it doesnt rlly do much other then repeatably call fstat, if i return enoent it says this

#

what do i do

#

it js does this forever

#

like what do u want ls

surreal path
#

anyone know?

elder shoal
#

are you compiling with linux sysdeps? it could be passing and empty path and AT_EMPTY_PATH to the fstatat call if you use that

#
              If pathname is an empty string (or NULL, since Linux 6.11)
              operate on the file referred to by dirfd (which may have
              been obtained using the open(2) O_PATH flag).  In this
              case, dirfd can refer to any type of file, not just a
              directory, and the behavior of fstatat() is similar to that
              of fstat().  If dirfd is AT_FDCWD, the call operates on the
              current working directory.  This flag is Linux-specific;
              define _GNU_SOURCE to obtain its definition
#

-100 is the AT_FDCWD magic number iirc

surreal path
#

i didnt get anything tho?

#

did i?

#

i forgor

surreal path
#

i am provided with flag AT_SYMLINK_NOFOLLOW

#

@elder shoal

elder shoal
#

hm

coral dove
surreal path
#

i dont know whats going on

#

i guess ill wait for the really smart ppl to come online to maybe help

#

by help i mean, point out what i did wrong

ebon needle
#

like what program

#

a

#

ls

surreal path
#

ls

surreal path
#

i am going to personally shoot every coreutil developer in the head

#

someehow adding printfs to ls is causing weird ass behavior where sometimes it reaches a print sometimes it doenst

#

the only thing i can rlly do is atttach gdb and find out where ls is loaded so i can add the symbol file and bt and hope and pray

molten grotto
#

did you fix the AT_FDCWD thing

surreal path
#

yea

#

fstat is handling AT_CWD

#

and i do check for AT_EMPTY_PATH

#

to which im not provided

#

i still give it the cwd vnode stat

#

even then

#

giving ENOENT js makes things not work and ls spam trying to access directory ''

surreal path
molten grotto
surreal path
#

trying to access directory '' or smt

#

idfk

#

thats all i know whats going on

#

-100 is AT_FWCWD which i do handle

#

@molten grotto some of my fstat code

#

my bad i had to use waypipe to get the screenshit

#

im too lazy to get on my chair

molten grotto
#

what does the mlibc side look like

#

or did you change it from when you last pushed

edgy pilot
surreal path
surreal path
edgy pilot
#

what does fstat return there

daring palm
surreal path
surreal path
daring palm
edgy pilot
edgy pilot
#

I gathered as much bro

#

what does it do

#

and what's the error

surreal path
#

i genuinely do not know what ls is trying to do cause adding printfs to the source js makes shit inconsisent

surreal path
edgy pilot
#

bro what error does it return when you give it stat

surreal path
#

😭

edgy pilot
surreal path
#

mhm

edgy pilot
#

what error does ls return when you give it the cwd stat

#

for the 3rd time

surreal path
#

it js repeats the fstat

surreal path
#

on the same node

#

same flags

#

same shit

edgy pilot
#

What's in that stat

surreal path
#

wdym

edgy pilot
#

what's in the stat that you return

#

the values

#

the data

#

the contents

elder shoal
#

Maybe the issue is actually in readdir?

surreal path
#

pretty much 0 expect mode

#

i think

surreal path
#

i dont think so? i mean fastfetch would have shit itself if it was? considering it did do a readdir

#

tho it could be possible

surreal path
elder shoal
#

You could be returning an empty file name in readdir and its trying to open that

#

Check what it returns in userspace

surreal path
#

i checked with gdb, it seems to be returning shit correctly, and uh yeh sure ill do that

#

whats the name of the dirent structure for mlibc in the sysdeps

#

i found it

#

@elder shoal

surreal path
#

i found it lol

surreal path
#

pain :c

elder shoal
#

Can you print all the dent entries?

#

Like all fields

surreal path
#

every field?

#

every dent entry

#

okay

#

well i will do it when i get on my pc

#

im not doing it via waypipe

surreal path
#

@elder shoal mb

#

here ya go

elder shoal
#

There is something wrong with that last one

surreal path
#

i fixed

#

ls now exits

#

lovely

#

okay for any other offset, do i give it like one entry or still give it the entire list from beginning + offset to end?

#

anyone know? i really dont know what mlibc expects lmao

surreal path
#

id assume the latter?

#

yea no i have no idea what im doing here

#

uhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

may js look at astral code or smt

#

or rather badgeros

#

since its similar to nyaux in the way readdir is impl'd

#

cause @broken depot gave the idea

broken depot
surreal path
#

okii

ebon needle
surreal path
broken depot
#

Oh yes lemme grab that link for you

surreal path
#

epic

ebon needle
surreal path
#

yes

broken depot
#

Ok so turns out

#

I removed this at some point and don't remember why

surreal path
ebon needle
broken depot
#

My current approach seems to be to just have a function that lets you get all dirents

#

Which is to be expected

surreal path
#

which i do in offset 0

broken depot
#

But I, for some reason, didn't make a readdir function for the file descriptors???

surreal path
#

but i dont know what to do when offset is not 0

broken depot
ebon needle
#

you already gave all files with sys_read_entries

surreal path
#

explain

broken depot
#

Do you just have a single big array with all the dirents in it in the linux_dirent format?

surreal path
#

yuh

broken depot
#

ok

surreal path
#

readdir is impl'd per fs

#

tmpfs does it in a big array

#

and that is the format vnodes expect

#

they have this thing called a dirstream

#
struct dirstream {

size_t position; // currently useless
struct linux_dirent64 *nodes;
size_t cnt
}

@broken depot how it looks

broken depot
#

ok cool

#

So since the position is something you get to define yourself, I'd just use it as an array index

surreal path
#

right

#

okay but still what do i do when offset is not 0 on the fd

broken depot
#

Well if the offset isn't 0 then you do a bounds check, and then copy the node at that index to the read buffer provided by the caller of readdir

surreal path
#

right

#

index is calculated by the offset yea?

#

like

broken depot
#

Like I said, you get to define what offset means for readdir, so I'd just define it to be the array index into nodes

surreal path
#
struct __syscall_ret syscall_readdir(int fd, void *buf) {
  sprintf("syscall_readdir(): fd %d, buf usr addr %p\r\n", fd, buf); 
  struct FileDescriptorHandle *hnd = get_fd(fd);
 if (hnd == NULL) {

    return (struct __syscall_ret){.ret = -1, .errno = EBADF};
  }
  if (hnd->node == NULL) {

    return (struct __syscall_ret){.ret = -1, .errno = EIO};
  }
  if (hnd->offset == 0) {
    // cache em
    int res = 0;
    struct dirstream *star = hnd->node->ops->getdirents(hnd->node, &res);
    hnd->privatedata = star;
    if (res != 0) {
      return (struct __syscall_ret){.ret = -1, .errno = res};
    }
    // this is okay to do as no 1 FUCK YOU IM MEMCPYING TO USR SPACE
    // 2 entries are at least ensured
    memcpy(buf, star->list, (star->cnt) * sizeof(struct linux_dirent64));
    star->position += (star->cnt) * sizeof(struct linux_dirent64);
    hnd->offset += (star->cnt) * sizeof(struct linux_dirent64);
    sprintf("done readdir\r\n");
    return (struct __syscall_ret){.ret = (star->cnt) * sizeof(struct linux_dirent64), .errno = 0};
  }
  sprintf("READDIR OTHER SHIT IS UNIMPL'D\r\n");
 UNIMPL 
}

what my readdir looks like atm, also yea i do need to add the buf size as a parameter which ill do

broken depot
#

yes

surreal path
#

oki makes sense

broken depot
#

Also, make sure you have something (for example a spinlock or mutex) in place to prevent that stuff from getting free'd mid-syscall by another thread seeking to position 0 on the same FD.

#

I personally would advocate for simply putting a mutex around both seek and readdir on directory FDs.

surreal path
broken depot
#

perfect

#

Also, I'd recommend letting userspace specify how many entries it wants to fetch

surreal path
#

yea with the size parameter

broken depot
#

yep

#

This also looks like you do no checking of the address KEKW

surreal path
#

nyaux very secure

broken depot
#

clearly

surreal path
#
struct linux_dirent64 {
    uint64_t d_ino;
    int64_t d_off;
    unsigned short    d_reclen;
    unsigned char    d_type;
    char        d_name[1024]; // mlibc does this so like, we cant escape it...
  // we cant be the epic kernel 
};
kind root
#

file { contents[9999999999] } trl

surreal path
broken depot
surreal path
#

nlibc has it 1024

crystal scarab
#

nlibc

surreal path
#

mlibc*

#

not n

broken depot
#

That seems wrong, as Linux has it as an unsized array at the end of the struct:

       The linux_dirent structure is declared as follows:

           struct linux_dirent {
               unsigned long  d_ino;     /* Inode number */
               unsigned long  d_off;     /* Not an offset; see below */
               unsigned short d_reclen;  /* Length of this linux_dirent */
               char           d_name[];  /* Filename (null-terminated) */
                                 /* length is actually (d_reclen - 2 -
                                    offsetof(struct linux_dirent, d_name)) */
               /*
               char           pad;       // Zero padding byte
               char           d_type;    // File type (only since Linux
                                         // 2.6.4); offset is (d_reclen - 1)
               */
           }
surreal path
#

well look

#

1024 is js

#

yummy

#

i love eating 1024 characters

broken depot
#

Imagine storing 4x NAME_MAX in a temporary value because fuck you that's why KEKW

surreal path
#

is funny

molten grotto
# surreal path nlibc has it 1024

you don't have to copy that much tho, you can just copy offsetof(dirent, d_name) + len_of_name_including_null bytes and put that as the reclen

surreal path
#

well what are you gonna do abt it trl

#

mlibc wont cut off my balls if i dont do it like yall

#

yes its an optizmiation i guess

#

but has nyaux ever cared abt smt like that

#

i mean

#

a lot of shit in nyaux is still missing locks

#

idk what will happen if i ran some other threads on the other cores

#

nor is my scheduler advanced enough to load balance atm

#

actually

#

after sockets i may js stop any userspace shit js to work on load balancing and stuff

#

then get back to work and probs try to get xorg or impl signals idfk

supple robin
#

where pipes

surreal path
#

oh yeah PIPES

#

after ls

surreal path
#

😭 πŸ™

supple robin
surreal path
elder shoal
#

where firefox

surreal path
#

mathew: where men
marvin: where opensuse plushies
me: where bitches nooo

#

wait no actually

#

marvin: where rewrite number #SIZE_T_MAX

surreal path
#

crawl ur way back into ur astral thread /joking

#

waitwiaiwaiat @elder shoal you play factorio right

#

do u have space age

supple robin
elder shoal
#

i do

elder shoal
supple robin
surreal path
elder shoal
#

sorry I dont have time for another factory game in my life I'm still in EV in gregtech 😭

surreal path
#

insane shit 😭

elder shoal
#

especially now with uni back

surreal path
#

i was js gonna give u a tour of my factory lol

elder shoal
#

ohhh

#

I can do that later tonight

surreal path
#

ah okii

broken depot
surreal path
ebon needle
#

(with c++)

surreal path
#

chat we ball after i get up

surreal path
#

im up

#

but first

#

i must give @elder shoal a tour in factorio

#

and @broken depot

#

yall ready?

elder shoal
#

I am not

surreal path
#

dies

elder shoal
#

give me a few hours and I can

surreal path
#

oki

crystal scarab
surreal path
#

honestly ill js get back to work on readdir

#

and write some more uacpi bindings later

#

ive already written a bunch

#

to my sadness

crystal scarab
#

you workin' on ironclad too?

surreal path
#

contributing for the ec driver

crystal scarab
#

i see

surreal path
#

nyaux is no 1 priority tho

#

still

broken depot
surreal path
#

i js like helping :)

surreal path
#

mathew isnt even getting on factorio for a bit anyway

broken depot
#

Tomorrow same time would work though

surreal path
#

alr epicc

#

me when i have to scroll up the nyaux thread to find important pieces of info

crystal scarab
#

lol

#

the important pieces of bentobox info are in my head

surreal path
#

lol

crystal scarab
#

i installed qemu to my mind

#

i can run bentobox in my sleep

surreal path
#

would i round down bufsize to the nearest linux_dirent

broken depot
#

Yep

surreal path
#

alr epic

surreal path
#

i js realized my round down and up functions are align up and down

#

which makes sense

#

@broken depot quick question cause my math skills arent the best today

#
struct __syscall_ret syscall_readdir(int fd, void *buf, size_t size) {
  sprintf("syscall_readdir(): fd %d, buf usr addr %p\r\n", fd, buf); 
  size = align_down(size, sizeof(struct linux_dirent64));
  struct FileDescriptorHandle *hnd = get_fd(fd);
 if (hnd == NULL) {

    return (struct __syscall_ret){.ret = -1, .errno = EBADF};
  }
  if (hnd->node == NULL) {

    return (struct __syscall_ret){.ret = -1, .errno = EIO};
  }
  // if (hnd->offset == 0) {
    // cache em
    int res = 0;
    struct dirstream *star = hnd->node->ops->getdirents(hnd->node, &res);
    hnd->privatedata = star;
    if (res != 0) {
      return (struct __syscall_ret){.ret = -1, .errno = res};
    }
    // this is okay to do as no 1 FUCK YOU IM MEMCPYING TO USR SPACE
    // 2 entries are at least ensured
    memcpy(buf, star->list, (star->cnt) * sizeof(struct linux_dirent64));
    size_t new_idx = size / sizeof(struct linux_dirent64);
    if (star->position + new_idx > star->cnt) {
      new_idx = star->cnt;
      size = star->cnt * sizeof(struct linux_dirent64);
    }
    star->position += new_idx;
    hnd->offset += size;
    sprintf("done readdir\r\n");
    return (struct __syscall_ret){.ret = size, .errno = 0};
  // }
  //sprintf("READDIR OTHER SHIT IS UNIMPL'D\r\n");
 // UNIMPL 
}
#

is the math correct for this?

#

ill triple check

#

sorry i said something stupid eariler so i deleted it lol

#

thats not how that works

#

dw abt it

surreal path
surreal path
#

wtf happened

crystal scarab
#

static_cast<struct dirent*>(sex)

surreal path
#

@elder shoal factorio?

elder shoal
#

sure like 10 min so I can heat up dinner

surreal path
#

oki

crystal scarab
surreal path
kind root
surreal path
#

it must have not copied correctly

edgy pilot
elder shoal
surreal path
#

oki whats ur steam

elder shoal
# kind root whats up with greg?

havent played it much lately, in super early ev, got a titanium line and ae2 set up and slowly building towards the stuff needed for nitrobenzene production

surreal path
#

added

elder shoal
#

accepted

#

syn synack ack

edgy pilot
#

is it a good idea to send it in a public discord

surreal path
#

booting up factorio

elder shoal
#

doesnt matter that much but true I dont want random friend requests

crystal scarab
#

I saw it for a split second :^)

#

Didn't have time to process what it was tho

elder shoal
#

just steam friend code

edgy pilot
surreal path
#

join @elder shoal

elder shoal
crystal scarab
elder shoal
#

my computer takes a bit to load space age

crystal scarab
#

That is clearly a skill issue for not using an nvme raid 0 as your boot drive :^)

#

/s

#

Sorry I had the urge to flex on that

elder shoal
#

I do have a ssd on my boot drive but factorio is installed on a hard disk

crystal scarab
#

Ah

edgy pilot
#

space age takes a while to load from an ssd as well

crystal scarab
elder shoal
#

idk its still loading

crystal scarab
#

Ah

#

I'll stop flexing

elder shoal
#

start flexing by paypalling me money

#

we both get something out of it then

crystal scarab
#

Tbf the only reason I have a raid 0 is because I used to have one 500gb nvme and it was too little

elder shoal
#

6 minutes to load

crystal scarab
#

So I got another 500gb nvme and made a raid 0

crystal scarab
#

I should get Factorio and see the loading times on my machine lol

#

In all seriousness tho, is Factorio really worth it

#

It's unlike most of the stuff I've played

surreal path
#

my align down is not working as intended?

#

so mlibc passed in 2048

#

i aligned down

#

i got back 2048

#

size of struct linux_dirent64 is 1048

#

so using astrals round down fixed it

#

crazy

kind root
elder shoal
#

my case is mostly uni started again and my work break ended so time is kinda super sparse now

surreal path
#

ls is able to read things all js fine

#

but it isnt displaying anything

#

oh and ls -la causes a deadlock

#

in fstat

#

yea i have no idea

surreal path
elder shoal
#

. . . . . . . . . . . . . . . .

surreal path
#

lol

daring juniper
#

hmmm, something ain't right here (β‰–_β‰– )

surreal path
#

readdir impld

daring juniper
#

ayy, letsgo! πŸŽ‰

surreal path
#

something i have forgotten to do is wire up nyauxes ps2 driver correctly to the tty

#

its not wired up correctly so u cant use shift or anythin

daring juniper
#

ah, that might be helpful lol

sharp dagger
sharp dagger
sharp dagger
surreal path
#

im back

#

we ball with nyaux in a bit

#

what we gonna do today is basically wire up ps2 properly to the tty

#

if we get that done by today then um

#

pipes

#

which will be scary because i have ZERO idea on how they work

#

lol

broken depot
#

Good news: I have a tested-ish pipe implementation you can steal re-write in C because it's Rust

surreal path
#

id rather not lol

#

part of the fun of osdev is learning how shit works

#

so ima learn how pipes work and impl them myself

broken depot
#

I use a ringbuffer for them

surreal path
#

i see

broken depot
#

Then I use some fancy atomic operations to make multi-read, multi-write possible without mutexes

surreal path
#

insane shit

mossy belfry
#

how do you pronounce cmpxchg

broken depot
#

ye os

mossy belfry
#

I like to say "cumpks chug"

broken depot
#

(the U is silent)

coral dove
broken depot
#

Imagine saying all those words

mossy belfry
coral dove
#

Isn’t that invlpg

mossy belfry
broken depot
#

No, that's sfence.vma trl

#

(I have terminal RISC-V disease)

coral dove
broken depot
#

RISC-V equiv to invlpg

#

Except it also lets you clear the whole TLB if you want to

broken depot
#

BTW Nyaux what are you planning to port for your userspace?

surreal path
#

we wanna get to wayland weston soon

#

so like

#

a whole bunch of shit

broken depot
#

oh nice

brisk zenith
surreal path
#

first is X tho

#

we def wanna have X first

#

id probs do it before signals

#

to get X running

broken depot
#

You'll really start wanting signals soon though

surreal path
#

yea def

broken depot
#

Do you not have them at all yet?

surreal path
#

no not at all

elder shoal
#

signals are great

#

especially for job control

#

so you dont end up locking up the system with cat

surreal path
#

signals are scary

#

ive heard horror stories impling them

elder shoal
#

and also you need signals for any terminal to be remotely usable in x

surreal path
#

ik

broken depot
#

I implemented my signals with a queue with the stipulation that synchronous signals like SIGSEGV or something with raise skips the queue.

surreal path
#

no idea what ur saying but oki

broken depot
#

Then when a user thread is scheduled, or returns from a syscall, I check for pending signals. I don't allow for recursively catching them, so it just kills the process in that case.

surreal path
#

uh huh

coral dove
#

sfence.vma …..

#

Weird name

elder shoal
broken depot
#

idk I don't actually have raise

broken depot
#

But I do have synchronous signals (SIGSEGV)

surreal path
elder shoal
#

raise is just a kill() to self in my implementation iirc

broken depot
#

I think this is the time to look up what the semantics for raise are supposed to be

brisk zenith
#

raise is just kill(getpid(), sig)

#

has the exact same semantics

broken depot
#

Ok well that's nice and simple then

#

But uhh yeah signals really aren't that bad. But they are another thing where you need some specific manipulating of the thread context, just like scheduling is.

#

Maybe tomorrow I could help you with pipes and/or signals

mossy belfry
#

or ASTs or whatever you call em

#

it seems like ASTs can be used for signals since they execute when returning to userspace

broken depot
sharp dagger
# surreal path very epic

signals arent really that bad, you just have to redirect the address when entering the thread. for me:

  • i copy in a tiny trampoline into userspace and push the signal handler, signum (and optionally siginfo)
  • the interrupt frame of the thread is set to have its RIP point to this trampoline, and so the interrupt handler brings us there
  • save current context in that trampoline
  • jump to handler and let it do its thing
  • restore context in that trampoline
surreal path
#

okay guys

surreal path
#

we are wokring on shit and like im trying to figure out how to give ctrl+c and ctrl+x and friends to the tty ringbuf?

#

like how would i do that?

edgy pilot
surreal path
#

i already did that

#

im js asking

sharp dagger
#

you send ctrl characters

#

these values

surreal path
#

how does userspace expect them

edgy pilot
surreal path
#

what about ctlr x

#

ctrl*

edgy pilot
#

what's ctrl x

sharp dagger
surreal path
#

ctrl + x

surreal path
edgy pilot
sharp dagger
#

if you're holding ctrl then the ASCII code of the character sent to the PTY should change

surreal path
#

exits*

sharp dagger
thorny glen
surreal path
#

diabolical

sharp dagger
thorny glen
#

ctrl-x corresponds to a particular byte

sharp dagger
#

there exists a control character for Ctrl + X

thorny glen
#

it reads this byte

sharp dagger
#

^X kekw

thorny glen
#

and goes

#

ope

#

i should exit

surreal path
#

what is this byte?

sharp dagger
#

shit i forgot

thorny glen
#

iirc ctrl-A is 1, ctrl-B is 2, and so on

edgy pilot
thorny glen
#

ctrl-@ is 0

sharp dagger
#

yeah that's it

surreal path
#

okay makes sense

sharp dagger
surreal path
#

thanks will and sasdallas and ilo

surreal path
#

those are not part of the funny V family of macros

sharp dagger
surreal path
sharp dagger
#

if the ISIG lflag is set

surreal path
#

i dont have signals yet

#

so this is unrelated lol

surreal path
#

you mean

#

what the Vfamily of shit do

#

its used for isig

#

okay makes sense

#

alright thank you lmao

#

okay i got nano working

#

epic

kind root
#

holy

#

nyaux is now basically astral

surreal path
#

REAL

elder shoal
#

so true

daring juniper
surreal path
#

control characters working with ps2

elder shoal
#

now I need to get back to work so astral will be basically linux by the next 10 to 50 years

kind root
#

lol

surreal path
#

lol

#

okay

#

pipes

kind root
#

chromium speedrun astral vs nyaux

surreal path
#

now

surreal path
#

who wins

molten grotto
#

vs my microkernel

elder shoal
#

I dont think I would have the patience to port chromium

kind root
kind root
surreal path
#

lol very epic

elder shoal
#

idk but it just sounds laborious

molten grotto
kind root
#

lmfao

elder shoal
#

and I wouldnt even know where to begin

#

stares at managarm patches with evil intents

kind root
#

bonkers would tell you

#

i mean it used to work

elder shoal
#

maybe when the kernel is in a better state I can look at it

#

as in fully self hosting, stable, fast, etc

crystal scarab
#

hell yeah

surreal path
#

i shall impl change directory first then pipes

#

at the very least

crystal scarab
#

cd is very simple

elder shoal
#

pipes too if you dont think too hard about some bullshit rules

#

PIPE_BUF my behated

hexed sluice
surreal path
hexed sluice
#

Nyaux vs Astral is like the story of the bunny vs the turtle

surreal path
#

real!!!!

hexed sluice
#

Rayan is the turtle, and Mathew the bunny

surreal path
#

yessss :3

hexed sluice
#

:3

surreal path
#

i really need to update nyaux's recipes to jinx 0.6 ngl

molten grotto
# kind root lmfao

tbh maybe it would be slightly more likely if I'd actually work on the userspace side too instead of just spending days after days writing more and more kernel functions lol

elder shoal
#

rushing userspace is a bad thing

#

having a robust kernel would make it easier for userspace later on

kind root
#

it's probably a scary number of nt/win32 api functions needed

molten grotto
#

maybe

hexed sluice
#

you need userland to know what syscalls you need and to test them, though

#

you cannot really only work on the kernel in isolation

mossy belfry
kind root
#

including the deps of all external dlls

surreal path
#

interesting

crystal scarab
surreal path
#

is it normal for 2 chdir calls to be made?

thorn bramble
thorn bramble
#

maybe

crystal scarab
#

This

thorn bramble
#

make it not fail it should become a single one

mossy belfry
surreal path
cinder plinth
surreal path
cinder plinth
#

also you should include nano syntax highlighting files

cinder plinth
#

It's so portable

surreal path
#

really?

#

damn

#

anyone got recipes i can steal for lua trl

kind root
#

lua is known for its portability

molten grotto
surreal path
#

huh?

cinder plinth
#

Yea

cinder plinth
#

Lua is like 2 files

surreal path
#

so i dont compile it?

#

lol im so confused

#

oh wait

#

oh okay

molten grotto
#

ig for the normal build you do have the makefile + multiple files

crystal scarab
#

Yoinked the idea

sharp dagger
sharp dagger
#

iirc its just make CC=<your GCC>

sharp dagger
cinder plinth
#

Pretty sure there's a one file variant

#

iirc

sharp dagger
surreal path
sharp dagger
#

nice

surreal path
#

so baller

sharp dagger
#

mlibc right?

surreal path
#

yuh

sharp dagger
#

i might have to consider porting that

#

or Newlib to test against my libc

surreal path
#

ill go get lua now

sharp dagger
surreal path
#

YOOOO @kind root @elder shoal @supple robin

kind root
#

Nice

elder shoal
#

yippee

daring juniper
#

awesome sauce poggers

surreal path
#

i may be losing it

#

im doing ANYTHING but learning how pipes work πŸ’€

daring juniper
sharp dagger
#

thing goes in one end and thing come out other end

#

long answer: you have a read end and a write end, read end can read from a circular buffer, write end writes to the circular buffer

#

if the read pipe gets closed and the writer tries to write send SIGPIPE

#

that's it

edgy pilot
#

like pipes

molten grotto
#

probably never unless roblox starts supporting linux first (either native or in wine)

edgy pilot
molten grotto
#

ah interesting, I guess it changed since I last looked

edgy pilot
#

the question is, when factorio on nyaux

#

hmmm how would you even run factorio on mlibc

molten grotto
#

you remove version info from the binary and use a preloaded compatibility library that overrides stuff like pthread functions where the structure size mlibc uses/some macro initialized fields differ from the ones used in glibc

molten grotto
#

its the one that I made for that yeah

edgy pilot
#

would it still work with newer versions of mlibc and glibc?

#

I don't see why not

molten grotto
#

well the addition of symbol versioning support to mlibc made it not work hence the need to strip the versioning info from the binary you want to run using a script, and the previous glibc detection inside the lib relied on the fact that glibc binaries/libraries contain symbols with glibc in their versions

#

I have changes for that locally, the new way is kinda weird because it changes the os abi in the binary to solaris and uses that to detect it lol

edgy pilot
#

ah

ebon needle
surreal path
edgy pilot
#

I know, crazy

molten grotto
surreal path
molten grotto
#

though I wonder if it is obfuscated, it looks very gibberish even for c++ code

hexed sluice
#

proud of you, potato boy

surreal path
#

BUT NO WAY U JS CALLED ME POTATO BOY

#

😭 πŸ₯€

#

NAHHHHH THATS INSANEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEe

hexed sluice
#

:3

surreal path
#

:3

errant pawn
#

I like potatoes

#

I want french fries right now

elder shoal
#

Potato boy is crazy

surreal path
#

oh yeah i added a option to turn off all nyaux debug prints and nyaux is like CRAZY fast without the debug prints

#

idk if its js me but booting nano somehow feels faster on nyaux then native linux?

#

probs bias lol

broken depot
#

BTW @surreal path I have time now for I think at most another hour or two until dinner. I have more time after that.

surreal path
#

i have to go to an appointment today :c

#

in like 30 minutes

broken depot
#

rip

#

Next time I can def do is sunday

surreal path
#

alr!

surreal path
#

yo chat

broken depot
#

haha yes

surreal path
#

yess

surreal path
daring juniper
#

Uh, is this a good thing or a bad thing, I can't tell πŸ˜…

surreal path
surreal path
#

lovely.

#

more memory bugs

#

when js doing wc

#

doesnt even work

#

insane

surreal path
#

when i run wc

pearl zephyr
#

rip

#

what is being made currently im too lazy to scroll up

surreal path
#

okay we will debug this later today

#

i think its one of the syscalls not bound checking smt

#

i may log everything related to readding and writing

surreal path
#

a kernel santizier will be extremely helpful

#

i saw this repo from #resources

#

sysdeps dont look hard

#

i think it will be extremely helpful to have this

#

oh hi qwinci lol

edgy pilot
#

may the torture begin

molten grotto
#

I just got rid of kasan in my kernel because it's kinda annoying having to allocate shadow pages when allocating anything in the virtual memory KEKW

surreal path
#

but fair

edgy pilot
#

you should read about it before trying to port code you don't understand

surreal path
#

that is fair

#

i js wont port it

edgy pilot
#

and copying this kind of stuff most likely won't work

#

it's not made to be ported

molten grotto
#

the way kasan usually works is that there is a region in memory that contains the poison state of every 8 byte chunk in the higher half

#

and you can't just allocate the physical pages for that region to begin with because its a huge amount of memory so you have to map the pages backing the region on demand when you allocate new virtual memory in the higher half

surreal path
#

right

#

well

#

yea well i mean im not add kasan then as this may js be me trying to avoid actually debugging this, honestly its probs a bounds check issue somewhere thats causing the elf memory to be leaked somehow

#

yea it may be helpful but its js kinda me moving from one thing to the next basically

edgy pilot
#

get a rubber ducky

surreal path
#

what i should do instead is focus on looking at every syscall made, look at each value passed to each syscall and look at the return values for smt sus

surreal path
edgy pilot
surreal path
#

wowie

edgy pilot
surreal path
#

lol fair

coral dove
# surreal path ?

Yap to an inanimate object about your bugs and eventually you will figure it out

surreal path
#

mb chat i slept

#

ill get up soon

mossy belfry
#

what a napper

surreal path
#

alright so

#

interesting shit

#

count is 262144 right

#

it reads only 1

#

now i need to figure out why this no workie

#

or well why wc with pipes not working in general

#

okay so

#

doing wc and typing shit does read it fine (tho pressing enter doesnt make it new line?)

#

but ls | wc does not work

#

tho the fifo does say it got read by 40 bytes and written to by 40 bytes

#

first written then read

surreal path
#

found ze issue

#

nvm

surreal path
#

im trying to read the code for wc

#

but bcs its gnu shits complcated

mossy belfry
#

most sane and rational gnu program:

orchid dawn
#

Look at how BusyBox does it

#

It's impl is probably way smaller

pearl zephyr
surreal path
#

yo

#

okay so i discovered the issue

#

its cause fifo_close isnt impled

#

also im missing some pipe semantics

#

ill impl this later after impling some shit for ironclad β„’

surreal path
#

im doing shit for pipes rn

#

js trying to die fixing them to work

#

pipes make me wanna do not okay things to people

#

like HOW

kind root
#

at least u catch a ub error instead of dying

surreal path
surreal path
#

we are closer

#

but it deadlocks somewhere nooo

#

like with ls | wc it js doesnt even return to bash

#

js does nothing after running it

#

fastfetch gives u that then you cannot give input to bash anymore

#

lmao im stupid

#

nvm

#

it didnt fix it

daring juniper
#

😭

surreal path
mossy belfry
#

code still better than glibc

surreal path
#

i have figured out why

#

but i do not know how to solve this

#

as you see i kfree both node and fifo right, but since this is basically IPC another process isnt gonna see it unmapped on its pagemap

#

bascially causing weird shit like this

#

i have no idea how to solve this to be honest in a reasonable way

#

does anyone know?

edgy pilot
mossy belfry
mossy belfry
#

genuinely baffling

surreal path
#

im somehow corrupting the vnodes

#

idc anymore code is on github

surreal path
#

mb i wasnt in a good mood yesterday

#

i have a feeling its cause of the way my hashmap works

#

i think it copies entries not keeps references to the same fd

#

i saw it memcpy in its hashmap_set function so

#

yea i may be cooked in that regard

#

that makes a lot of sense as to why shit dont work then if thats the case but i cannot really prove it to be fair

#

not unless i add more prints

desert haven
surreal path
#

thanks

ebon needle
#

maybe something is writing to already freed memory

thorn bramble
#

inb4 it runs out of memory

surreal path
#

okay so

#

yea im violating forks semantics

#

makes sense as to why pipe doesnt fucking work KEKW

broken depot
#

would you like help debugging?

surreal path
broken depot
#

Ah yes

#

Emotional support Robot