#Nyaux

1 messages · Page 63 of 1

surreal path
#

NOT AGAIN

#

THIRD TIME THIS SUMMER

#

I FELL ASLEEP IN VR I ONLY HAD MY WINDOW OPEN?

#

howd i get sick

#

insane

maiden ridge
#

What's up with nyaux rn

surreal path
maiden ridge
#

What's the bug

surreal path
#

okay so basically after forking a program and pressing a ps2 key it fucking dies (jumps to some bullshit RIP for some odd ass reason)

#

i had a few theories as to why its happening but like

#

they were all proven wrong lol

#

^ @maiden ridge more info

maiden ridge
#

That's incredible

#

😭

surreal path
#

yea very fun bug

#

VERY fun

maiden ridge
#

I remember this happening in Polaris a few months back

surreal path
#

what was ur issue

maiden ridge
#

I don't remember clearly but it was stack corruption

#

Because the stacks did not get switched properly

#

It overwrote each other's data

surreal path
#

weird

maiden ridge
#

So when it returned

#

It jumped to some weird address

surreal path
#

thing is

#

it seem'd the task switching was fine

maiden ridge
#

Considering you're processing a ps2 interrupt here

#

And a syscall is happening here

#

Because read

#

I guess you could have that issue?

surreal path
#

interrupts are disabled on syscalls

#

as to mitigate this

maiden ridge
#

Wait so how do you read from ps2?

surreal path
#

ps2 interrupts happen when not in a syscall?

#

like when doing anything that doesnt hold a lock

#

or not a syscall

maiden ridge
#

Ok fair

surreal path
#

mhm

brisk zenith
surreal path
#

then press a ps2 key

brisk zenith
#

oh wait yeah with doom it works

surreal path
#

yea\

brisk zenith
#

or well, reproduces

#

quite the opposite

surreal path
#

yep

ebon needle
elder shoal
#

running without interrupts enabled in syscalls just feels wrong to me

brisk zenith
#

okay so the issue is that while the bash read call is waiting for input a different thread (the forked bash? i'm not sure but it doesn't matter) also does a read call and when the bash read call is unblocked it returns with the wrong rsp

#

now i just need to figure out why it's using the wrong rsp

#

@surreal path why do you do this syscall_user_sp stuff manually in the syscall functions, instead of in schedd? seems a lot more prone to error this way

#

anyway @surreal path this patch fixes the issue, and prevents this class of issue from occurring in other syscalls in the future https://hst.sh/azareyicif.php

kind root
#

Damn

surreal path
brisk zenith
#

Yeah

surreal path
#

was that the fucking issue that weve been stuck on for fucking weeks

#

what in the actual fuck

#

vro

brisk zenith
#

Read was blocking and some other process was performing syscalls in the meantime so when read unblocked it returned with the wrong rsp

elder shoal
#

trolled

brisk zenith
#

The fix I used was to just move the syscall_stack_ptr_tmp save/restore to the scheduler

#

So nothing has to do it manually anymore

surreal path
#

im gonna test this now

#

if this works vro im gonna go and shoot some intel employees

#

(in deltarune)\

ebon needle
#

bro was working on this month and fix was just move line

surreal path
#

alr here we go

ebon needle
#

osdev hard reality

surreal path
#

it fucking solves it

#

now yea it still does the oom

surreal path
brisk zenith
#

OOM is a bit harder to debug since it's most likely a memory leak but I'll try, how do you reproduce it?

surreal path
surreal path
#

like a few times

#

dont provide a wad file ofc

brisk zenith
#

i have discovered at least one memory leak: this code sequence allocates more pages than it frees

surreal path
#

do u think its the cause

brisk zenith
#

it's definitely contributory

#

don't know if it's the only memory leak

#

but it is a pretty big one

surreal path
#

i see

#

weird

brisk zenith
#

like that code sequence has almost 1.4k unaccounted pages

surreal path
#

wtf???

tawdry mirage
#

inb4 free_pagemap doesn't recurse into all the pt levels

brisk zenith
#

no that's the first thing i checked, it does

tawdry mirage
#

ah

brisk zenith
#

actually false alarm, that was only because it was the first duplicate_pagemap operation on oldprocess->cur_map

#

if i do it twice there are no unaccounted pages on the 2nd one

#

so back to square one ig

surreal path
#

fair

brisk zenith
#

ok apparently there's one process made on every invocation that just doesn't get reaped (or maybe it doesn't exit in the first place? i'm not sure yet)

#

that would explain ever increasing memory usage

surreal path
#

???

#

thats so weird

brisk zenith
#

i'm trying to figure out what this process is first

#

like it only gets created for doomgeneric

#

other programs work as expected

surreal path
#

dumb idea but maybe add a field to the process thats js some string that you can store the executing program name for

#

on execve

#

i do believe doomgeneric uses system()

brisk zenith
#

apparently it's calling system("/usr/bin/zenity --help >/dev/null 2>&1")

surreal path
#

yea

brisk zenith
#

ah i see

#

system is calling waitpid(pid_of_spawned_process, ...)

#

that hits this path

#

so the process is never waited for and thus never reaped

surreal path
#

oh i see

#

so its something i dont have implemented

brisk zenith
#

yea

surreal path
#

makes sense

brisk zenith
surreal path
#

yea that makes sense

kind root
#

nyuax trolling trl

surreal path
#

real

surreal path
hollow goblet
#

wow smart people

ebon needle
surreal path
#

sorry chat no nyaux today some shit happened and i dont feel too good

frigid cliff
surreal path
#

we ball later today

#

i need to investigate an issue with doom not getting ps2 packets properly

surreal path
#

alright chat we bzll

#

lets go debug this shit

#

kaBOOM

#

there goes your tower fell the power

#

sorry chat stuck in my head

#

also btw heres todo list for nyaux:

  • fix doom key issues
  • port openrc
  • implement more file related syscalls & sysdeps
  • try to get gcc to compile something
  • support #!/abc/123
  • implement even MORE syscalls and attempt to port more programs
  • implement sockets then get X ported
  • implement signals
  • idk whats next
#

okay im seeing subscriber fd 5 only SOMETIMES gets packets on keypress

#

its how i link subscribers it seems

#

to explain

say we have subscriber 1

we add subscriber 2

so now head points at subscriber 2 -> subscriber 1

now the ps2 driver has a subscriber object itself, so it calls its own handle right to put shit in. its subscriber points to nothing so doom gets JACK shit, thats what it seems?

#

and considering the ps2 driver opens /dev/keyboard on every interrupt (which is stupid) shit gets weird

#

im gonna add it so ps2 driver keeps track of its owns handle and keeps its open

#

hmm

#

still doing that shit?

surreal path
#

i think this whole subscriber system is kinda overly complicated a little

#

rather then every subscriber having its own ringbuf

#

wait nvm

#

okay so like

#

i need to figure this out

#

fuck

#

kinda complicated aint it

#

@elder shoal how do you deal with this, reading your code you use some kind of hash table?? im a little confused

elder shoal
#

it just maps an id into a keyboard_t

#

its probably not the best way of doing it

#

but it just works and idc

surreal path
#

cause u cant exactly "iterate" over a hashmap?

#

wait no u can

#

nvm

elder shoal
#

get keyboard pointer from hashmap -> put packets in keyboard ringbuffer

surreal path
#

wait do u put the packets on write?

#

and iterate over the hashmap and put the packet to each keyboard_t's ringbuffer?

surreal path
elder shoal
#

keyboard irq -> driver calls into generic code with packet formed and keyboard pointer already known -> that does a bit more profcessing on it for things like shift keys and then puts it on the ring buffer for the keyboard -> the process reads /dev/keyboardXYZ -> it gets the keyboard pointer from the hashtable using the minor device number -> that reads from the ringbuffer or blocks/returns EAGAIN -> process returns read call results

elder shoal
surreal path
#

and push the packet to each keyboard_t

#

that should work

surreal path
surreal path
#

anyways we ball later, probs 8

ebon needle
surreal path
#

no

ebon needle
#

😡

surreal path
#

i fixed the ps2 kbd issue

#

doom works perfectly fine

#

all pushed onto github

#

reasons i didnt say much is i feel absolutely ass

#

im gonna go figure out why openrc wont build

#

then cry in a corner til i sleep or sm shit

maiden ridge
#

openrc?

surreal path
#

yea

#

like

#

it will build but

#

it would get added into the sysroot

#

hold on ill show

#

@maiden ridge this issue

#

idk why its doing this shit

#

i make my base files the exact same as menix

#

i changed it to be like menix

#

and im using menix patches for openrc

#

so why wont it add itself

#

????

#
#! /bin/sh

name=base-files
version=0.0
revision=1
source_dir="base-files"
skip_pkg_check=yes
package() {
 
mkdir -pv "${dest_dir}/dev"
    mkdir -pv "${dest_dir}/etc"
    mkdir -pv "${dest_dir}/home/menix"
    mkdir -pv "${dest_dir}/proc"
    mkdir -pv "${dest_dir}/run"
    mkdir -pv "${dest_dir}/root"
    mkdir -pv "${dest_dir}/sys"
    mkdir -pv "${dest_dir}/tmp"
    mkdir -pv "${dest_dir}/usr"
    mkdir -pv "${dest_dir}/usr/bin"
    mkdir -pv "${dest_dir}/usr/lib"
    mkdir -pv "${dest_dir}/usr/sbin"
    mkdir -pv "${dest_dir}/usr/share"
    mkdir -pv "${dest_dir}/var"

    ln -svf usr/bin "${dest_dir}/bin"
    ln -svf usr/lib "${dest_dir}/lib"
    ln -svf usr/sbin "${dest_dir}/sbin"
    ln -svf ../run "${dest_dir}/var/run"

    cp -rpv ${source_dir}/. "${dest_dir}"/

}

base files recipe

ebon needle
#

/home/menix

surreal path
#

dw abt it

#

like thats not the issue

maiden ridge
#

/dev ??

#

What

surreal path
#

yea i shouldnt

#

ill remove /dev

maiden ridge
#

Most of these directories are usually present

#

Just keep the symlink part

surreal path
#

okay

maiden ridge
#
ln -s usr/bin "${dest_dir}"/bin
    ln -s usr/bin "${dest_dir}"/sbin
    ln -s usr/lib "${dest_dir}"/lib
    ln -s usr/lib "${dest_dir}"/lib64
    ln -s bin "${dest_dir}"/usr/sbin
    ln -s lib "${dest_dir}"/usr/lib64
surreal path
#

you forgot -svf?

maiden ridge
#

It's from my recipes

#

Means the same thing

surreal path
#

okay

maiden ridge
#

v just means verbose and f forces

surreal path
#

still same error

#

base files is just this

maiden ridge
#

Run the copy first

#

Then do the links

surreal path
#

k

maiden ridge
#

Second thing

#

Weird

#

Let me see the openrc recipe

surreal path
#

yea look in the git repo its there

#

recipes/openrc

#

still same error

maiden ridge
#

Ah wait

#

Pass sbindir in the openrc recipe

#

Maybe that should work

surreal path
#

wdym?

maiden ridge
#
arch-meson                       \
        --libexecdir=/usr/libexec/rc \
        --sbindir=/usr/bin           \
surreal path
#

add sed?

#

oh wait

#

yea

#

ill do that

maiden ridge
#

Whenever I have doubts I just check the Arch Linux pkgbuilds lol

#

Or LFS

surreal path
#

still??

maiden ridge
surreal path
#

okay

surreal path
maiden ridge
#

What does the pkgbuild do lol

#

Yes

surreal path
#

yea

#

lets check

#

will it build

maiden ridge
#

Wait a minute

surreal path
#

hm/

maiden ridge
#

This pkgbuild format

#

Is similar

#

Ok wow

#

Why did I realise this much later lmao

surreal path
#

lol

#

still same error

maiden ridge
#

Ugh you can't do things like ls pkgs/package with this new Jinx as well

surreal path
#

yea

surreal path
#

its telling me this

maiden ridge
surreal path
maiden ridge
#

forgot what it was called builddir or something

#

Oh nvm

#

We literally just copy the source dir to the working dir

surreal path
#

?/

maiden ridge
#

Wait

surreal path
#

?

#

ok

#

same

maiden ridge
#

Ok yeah prepare is never called that's why

#

Bruh

#

What is this weird thing

#

Fuck it

#

code sources/openrc

#

Find the file

#

And manually do the edit

#

Then ./jinx rebuild openrc

#

👍

mossy belfry
#

is the New York AUX allocator lockless btw

#

nyaux

thorn bramble
#

simple fix, make it not do that

#

make it install things under $prefix/bin instead

tawdry mirage
#

ah wait i misunderstood what you said lol

#

yeah you need prefix=/usr

magic kernel
#

yeah

tawdry mirage
magic kernel
#

and keep in mind that xbps will not package empty directories, so add .keep to your empty stuff in base-files meme

thorn bramble
#

base files is correct

#

it comes from vinix

tawdry mirage
#

yeah

#

not saying it isnt

thorn bramble
#

or one of the many jinx distros maintained by mint

#

i'm just noting that for dennis

#

not really relevant but yeah

magic kernel
#

Cuz those base-files are probably derived from core-files in Managarm, which I wrote meme

surreal path
maiden ridge
supple robin
#

cooked

crystal scarab
#

i hate it when that happens

surreal path
#

hold on killing some openrc devs

supple robin
#

mfw echo foo | xdd

surreal path
magic kernel
surreal path
#

im taking a break from everything for at least a week, i am sorry.

crystal scarab
broken depot
surreal path
magic kernel
surreal path
magic kernel
#

Bro I know you can do it

#

Ur way smarter than me and I got it too (ok only cuz people with braincells wrote the underlying stuff for me meme)

surreal path
#

id disagree with that statement but thanks dennis

magic kernel
#

Ok exhibit A why ur smarter than me: wrote an OS

#

Couldn’t be me

#

I never wrote an OS (unironically I never did)

elder shoal
#

this reminds me I need to port openrc to astral, I've been meaning to do that since forever

crystal scarab
#

What do you guys use currently? A custom init, no init at all or what?

elder shoal
#

I use a simple init I wrote

crystal scarab
#

I see, me too

surreal path
#

okay so the issue is

#

for some odd reason process pid 3 has a pointer held to a process that JUST had its structure dealloced

#

so like

#

wtf?

#

i LOVE shit related to race conditions!!!

#

@kind root dont you love that

kind root
#

Those are the best bugs

surreal path
#

WAIT just a fucking minute

#

why am i deallocting the process structure in the first place

#

i have a question

#

with orphan'd process's should you deallocate its kernel stack? as well as its pagemap, fd shit, etc etc

#

wait i forgor my kernel stacks are per thread

#

okay not kernel stacks

#

but the fd shit and the page map

#

should THOSE get dealloc'd when a process gets orphan'd

#

anyone know?

surreal path
coral dove
#

After the process fully exits

surreal path
#

kk

coral dove
#

You can then free

surreal path
#

then reaper doesnt have to do much really

coral dove
#

Yeah not at all

surreal path
#

at least for now ™ ill need some mechanism for deallocating processes later ™ when openrc works for that and shit

coral dove
#

You should reap first then deallocate

surreal path
#

yea

#

ALSO

coral dove
#

Yes

surreal path
#

im still able to dealloc the threads

#

right

#

in reaper

coral dove
#

Yes you can

surreal path
#

epikc

#

so i still get rid of kstack since its per thread

coral dove
#

Yes, but only after the process exists

surreal path
#

wha

coral dove
#

Wait

#

Oh nvm

#

Yes you are

#

You get rid of k stack because it’s per thread

#

Correct

surreal path
#

epic

coral dove
#

Just make sure you do sanity checks because shit goes wrong when doing that for some reason

#

Spam asserts for the time being

coral dove
#

Did you figure out the orphan process stuff?

surreal path
#

it works

#

mhm

coral dove
#

Perfect

#

Are you doing

Orphan -> reap -> dealloc ?

surreal path
#

its the job of init to reap if im correct so

#

i cant reap without a proper init

thorny glen
#

im doing orphan

surreal path
#

im doing orphan

coral dove
#

💀

molten grotto
#

how's nyaux going btw, I haven't really followed in the past weeks

surreal path
#

we got openrc to semi-run dies cause no pipes

#

bug with the fuckin scheduler was fixed

#

bug with the keyboard is fixed

#

we have proper ps2 now

#

doom runs perfectly

molten grotto
surreal path
#

indeed

coral dove
#

Bro

#

I looked up how many times

#

It says fuck in the Nyaux repo

#

😭😭

surreal path
#

😭

mossy belfry
#

healthy and happy codebase

surreal path
#

hi chat

daring juniper
#

hallo :3

surreal path
#

im burned out a little so im actually taking a break at least for 1-3 days

kind root
coral dove
tender gorge
#

Even if a lot of this project is distraction, you're still doing it for fun

crystal scarab
#

nvm i figured it out

surreal path
#

anyways tmrw we balling

crystal scarab
#

oh i see

#

i don't have relocation yet

kind root
#

i made an idt

#

are u proud of me

elder shoal
#

did you add an idt init.... ok print

kind root
#

i dont even have a gdt print atm

#

i wil add those after i make a proper reentrant logger trl

coral dove
elder shoal
#

only the most advanced kernels have one

coral dove
#

Yessir

kind root
#

NOT meme, if u dont have it = your kernel is mid

coral dove
#

Don’t worry, it’s like the first thing that prints in mine lol

crystal scarab
#

3rd thing in mine

#

Also mine has 3 GDTs

#

I tried to remove one by moving its entries to another one but I couldn't get it working for some reason

daring juniper
crystal scarab
#

True

#

But having a GDT with 7 entries is more fun for me :^)

daring juniper
#

fair lol

crystal scarab
#

Extra points if there're 32-bit or 16-bit entries

crystal scarab
mossy belfry
#

linux is terrible since they don't GDT init OK

#

I also know my kernel will never be as good as your kernels so i also don't GDT init OK

#

maybe linux is being humble

daring juniper
#

Also third thing in mine, after ASCII logo and kernel version

mossy belfry
#

no need to flex on us like that jeez

crystal scarab
#

True

surreal path
#

little hot still so we wait a lil

kind root
#

fair fair

surreal path
#

its so hot still??????

#

its fucking 9:14pm

#

my fans at full speed vro

mossy belfry
#

do you live near the equator

surreal path
#

its STILL hot even with the fan

#

no

nova fox
#

do u live in ca

#

or in the US

surreal path
#

no i live in ireland

nova fox
#

danmn

mossy belfry
#

how are the potatoes

surreal path
#

ok vro

nova fox
#

kris approved

elder shoal
#

meanwhile I live in a country that the equator goes through and it was 10c this morning troll

surreal path
#

real

nova fox
#

i live in the CA

ionic musk
coral dove
#

It’s fucking 39C where I am right now

orchid dawn
#

39C isn't that bad

coral dove
#

Weather is bipolar

orchid dawn
#

I live in Phoenix AZ 💔

coral dove
#

Oh that’s fucked

#

I went there

#

Last year

#

I never experienced such torture

#

I actually threw up when I went into my rental car

orchid dawn
#

I've been here my whole life 🥹

coral dove
#

After it sat in the sun

surreal path
#

i am working on nyaux js letting yall know, i forgot to say this i kinda js opened vscode and started cooking

#

i am learning more about opendir() and readdir() in hopes to implement it for ls

#

basically im writing a userspace test program to see how linux behaves

cinder plinth
#

Dry it's fine

surreal path
#

mb chat had a doctor appointment yesterday

#

im still trying to figure out how should i implement directory streams

#

i still do not understand what d_off is, manpage makes it kinda vague lol

tawdry mirage
#

d_off where?

brisk zenith
#

Assuming the directory wasn't modified in the meantime

#

Historically it was the byte offset of the directory data on disk but nowadays it's just an opaque value

surreal path
#

also my bad chat js depression is why i havent been active

surreal path
brisk zenith
#

dw

#

but yeah basically it's just if you seek(SEEK_SET) with this value you get the entry it's from unless the directory has been modified in the meantime and it does not necessarily have any further meaning

surreal path
#

thats so stupid

#

also for impl of directory streams ill js implement it where fd->privatedata will store the directory stream shi and like the fd wont have an underlying vnode and uhhhh yea well i need to also figure out how to store the directory entries in the privatedata field to be fair

brisk zenith
#

oh and it should match the return value of lseek(fd, 0, SEEK_CUR) before the readdir call

brisk zenith
surreal path
#

i mean directory stream not directories they have vnodes lol

brisk zenith
#

yeah and directory streams are just fds from the kernel's perspective, why would you make those fds have no underlying vnode instead of pointing to the directory's vnode

surreal path
#

oh then if they point to the directories vnode where do i store the dictory entry stream struct thingys

brisk zenith
# surreal path ? im confused

that call returns the current position in the directory fd; this code should always succeed (barring concurrent use of the fd or modification of the dir) ```c
struct dentry entry;
off_t pos = lseek(fd, 0, SEEK_CUR);
readdir_fd(fd, &entry);
assert(entry.d_pos == pos);

brisk zenith
surreal path
#

well posix expects directories streams to be like in a certain structure

#

right

brisk zenith
#

do you mean the DIR type?

surreal path
#

yea

brisk zenith
#

that's a libc internal thing that's implemented on top of fds

#

similar to FILE vs fds

surreal path
#

right

brisk zenith
#

as far as the syscall layer is concerned it's just an fd

surreal path
#

what does mlibc expect

brisk zenith
#

iirc all mlibc wants for directories specifically is sys_getdents

#

and it should return the same structure as linux's getdents64

surreal path
#

ya mean this

brisk zenith
#

ah yeah that

surreal path
#

so like u have to store those d entries somewhere right

#

thats ze thing

brisk zenith
#

it also might expect sys_seek to work properly on directories as i described earlier, but that's only if mlibc is fully feature complete wrt the dir stream functions

brisk zenith
surreal path
#

so that means the dir stream vnode ptr should not point to the directory vnode

tawdry mirage
#
void seekdir(DIR *, long) {
    __ensure(!"Not implemented");
    __builtin_unreachable();
}
long telldir(DIR *) {
    __ensure(!"Not implemented");
    __builtin_unreachable();
}
#

nop

#

and apparently no one in the whole world needs this :^)

brisk zenith
# brisk zenith they're stored in the vnode

just like you (probably) have a vnode function for looking up the child of a directory vnode, you should have a readdir function that reads as many entries from a specific position

surreal path
#

oh i see

#

what would that readdir function op look like

brisk zenith
#

pretty much exactly the same as the normal read function

surreal path
#

yea but what would it read into the buf

#

a posix dir entry thingy?

brisk zenith
#

you might even make them the same function although then you have to be extra careful to return EISDIR/ENOTDIR when appropriate

surreal path
#

and wdym by as many entries as possible from a position

#

my brain is exploding

#

😭

brisk zenith
brisk zenith
surreal path
#

right

brisk zenith
#

so like if you have a size_t readdir(vnode *self, void *buffer, size_t size, uint64_t *position) it'll read entries starting at position (note this is an opaque filesystem-internal value; the only value that's guaranteed to mean anything is 0 which reads from the start of the dir) until EOF or size - bytes_read < size_of_next_entry, at which point it updates position and returns bytes_read

surreal path
#

right

#

is there an impl i can take a look at as reference?

brisk zenith
surreal path
#

right

#

i see u implement seek on the fs level itself

brisk zenith
#

readdir figures out which dentry to start with (potentially a fake one for the two dot entries) and starts writing into the buffer until you can't anymore

surreal path
#

nyaux does not do this, it does it on the fd level

brisk zenith
#

in this case position is just an index into the list of children (offset by 2 to account for the fake . and .. entries)

surreal path
#

right

brisk zenith
#

the seek function on the fs level takes an anchor and an offset and returns either an error or an absolute position

#

it doesn't actually update the fd

#

you have to have some kind of fs-level seek function because different file types/devices interpret anchors and positions in different ways

#

for example some fs might only support seek_{set,cur,end} while another also supports seek_hole

#

one device might support seek_{set,cur} but not seek_end

brisk zenith
#

also fs-level is kind of a misnomer here, these functions are per-file-description

#

different file descriptions from the same fs are allowed to have different readdir impls for example

surreal path
#

even fucking worse nooo

#

what do i do in that case nooo nooo

#

like what do u think nyaux should do that would be easiest cause this sounds complicateed as fuck

brisk zenith
#

this is also necessary for proper chardev/blkdev support, where they can exist on almost any fs but their ops are independent of the fs

surreal path
#

also wtf is happening here

surreal path
brisk zenith
surreal path
#

oh yea

surreal path
#

like

#

i dont even know where to begin impling that

#

im so fucking cookef

#

like how does that even fucking work

#

who changes the ops

brisk zenith
#

might be best to conceptually imagine it in a language that has OOP support like C++

surreal path
#

why is it required for proper chardev/blkdev support

surreal path
#

everything vfs is C

#

im afraid

brisk zenith
#

conceptually imagine is different from implement

#

you can conceptually imagine something in C++ and implement it in C

surreal path
#

right but like i dont get any of this in general

#

thats the thing

brisk zenith
#

right now you have something like this ```c++
class FileDescription {
off_t position;
Vnode *vnode;

public:
off_t seek(...) {
...
this->position = new_position;
return new_position;
}

ssize_t read(...) {
    ...
    int error = this->vnode->read(buffer, num_readable, this->position);
    ...
    this->position += num_readable;
    ...
}

};

class Vnode {
public:
virtual int read(...) {
return ENOTSUP;
}
};

surreal path
#

mhm

brisk zenith
#

hydrogen has something like this (with different names and stuff ofc) ```c++
class Vnode {
...
public:
virtual FileDescription *open(...) {
return EXDEV;
}
...
};

class RegularFileVnode : public Vnode {
...
public:
virtual int read(...) {
...
}

virtual FileDescription *open(...) {
    return new RegularFileDescription(...);
}
...

};

class DirectoryVnode : public Vnode {
...
public:
virtual FileDescription *open(...) = 0; // overridden by fs
...
};

class DeviceVnode : public Vnode {
...
public:
virtual FileDescription *open(...) {
...
return getDevice(id)->open(...);
}
...
};

class FileDescription {
protected:
off_t position;
Vnode *vnode;

virtual off_t make_absolute_position(off_t offset, int anchor) {
    return -ESPIPE;
}

virtual ssize_t do_read(void *buffer, size_t size, off_t position) {
    return -ENOTSUP;
}

public:
off_t seek(...) {
...
off_t new_position = this->make_absolute_position(offset, anchor);
...
this->position = new_position;
return new_position;
}

ssize_t read(...) {
    ...
    ssize_t ret = do_read(buffer, size, this->position);
    ...
    this->position += ret;
    return ret;
}

ssize_t pread(...) {
    ...
    ssize_t ret = do_read(buffer, size, position);
    ...
    return ret;
}

virtual ssize_t readdir(...) {
    return ENOTDIR;
}

};

class RegularFileDescription : public FileDescription {
protected:
virtual off_t make_absolute_position(off_t offset, int anchor) {
...
}

virtual ssize_t do_read(...) override {
    ...
    int error = static_cast<RegularFileVnode *>(this->vnode)->read(buffer, num_readable, position);
    ...
    return num_readable;
}

};

#

you will notice that vnodes are responsible for creating the file description

#

some vnodes (regular files, chardevs, blockdevs) have a common fs-independent open implementation (and thus file description implementation)

#

others (directories) do not

#

the fs-independent file description implementation for regular files make it so filesystems only have to provide a single function (in this example, reading from an absolute position without taking into account EOF; in actual hydrogen, it's everything necessary for mmap to work properly)

#
#

you'll notice that in mapping this to C some stuff that is conceptually virtual no longer is for efficiency reasons

#

some stuff that was separated is put together for cleanliness

#

etc

#

it just makes sure the args are sane, that the file in question can both seek and read, and delegates to the file description function

#

for regular files that goes into the fs-generic regular_file_read which interacts with the page cache

#

but this op doesn't have to be fs-generic

#

or it the generic version can be built on top of a different mechanism like the page cache

brisk zenith
#

similar story with FIFOs (aka named pipes, which is a bit of a misnomer imo since the more convenient way to implement it is pipes being unnamed fifos)

surreal path
#

like i have so many questions (wtf is a EXDEV) what the fuck is a getDevice(id)???? whats id>??? for some reason all of this is making me overwhelmed? i feel like i have to rewrite my entire vfs to make this work to be fair nooo but like i can think of one way of making this work with my cur vfs impl, js forcefully add some switch statement when mlibc calls open and make it init a dif struct instead of a reg fd, then have that be used for open instead. is this a simple and easy way to get this working without TOO much work? or is this retarded

brisk zenith
#

well getDevice(id) takes a major,minor combo and returns the actual device

surreal path
#

why do u do that

brisk zenith
#

it's just conceptual; in hydrogen I don't have major,minor numbers and just store a pointer to the device in the vnode struct

surreal path
#

why do u lookup via major minor??

#

i dont have major minor numbers so i dont care tbf

brisk zenith
#

because that's the Unixlike Way of Doing Things

surreal path
#

i dont like that way so im js not gonna do that

surreal path
brisk zenith
#

oh I just noticed I used the wrong error code there, EXDEV should be ENOTSUP

#

let me think abt that solution though

surreal path
#

kk

brisk zenith
#

this is within the generic open implementation

surreal path
#

well nop

#

i meant this

#

struct regfdhnd {
...
struct devfshndops *possibledevfdops;
};

struct syscall_ret syscall_open(...) {
...
  if (hnd->node->v_type == BLKDEV || hnd->node->v_type == CHVDEV) {
  hnd->devfshndops = ?; // i dont know what to set that to but default impl i guess?
hnd->devfshndops->open(...); // after doing shit will call node open
}
...
};
#

@brisk zenith

brisk zenith
#

that looks right yeah, linux does something similar

surreal path
#

okay so that means i DONT have to rewrite my entire vfs lol

#

holy shit lets fucking go

brisk zenith
#

they store file description ops in the inode (their vnode) and/or device and open is within those file description ops

surreal path
#

right

#

welp i dont know what open for a device would really do? other then like idfk? i genuinely have no use for fd indepent device open calls atm to be fair

brisk zenith
#

ttys do special shit on open

surreal path
#

like other then calling open on the device itself

surreal path
brisk zenith
#

setting controlling terminal for example

#

connecting to the modem if relevant and not already done

surreal path
#

shouldnt that be done on the vnode open itself

brisk zenith
#

the vnode open is the device open

surreal path
#

yea

#

so tty should do it on the device open?

brisk zenith
#

yeah

surreal path
#

so again no use for fs indepement open yet lol

#

anyways ill impl that soon like later its so fucking hot

#

then ill have to deal with figuring out the funny, i.e. making readdir work

#

also btw on creation do directories create the posix dentry_ts they store on a fs level?

#

in like a list

#

i see u kinda do that in hydrogen?

brisk zenith
#

hydrogen's a bad example for things like that because the only semi-real filesystem it has is ramfs and for stuff like that you need a real on-disk fs to compare against

surreal path
#

right

brisk zenith
#

in this case dentry_t is an entry in the directory structure cache

surreal path
#

which i 100000% have

brisk zenith
#

for ramfs every entry in said cache that hasn't been removed has an extra reference so it stays in memory

surreal path
brisk zenith
#

I suspect you have something that is effectively the same thing except private to the ramfs implementation

#

because there's not really any other way to implement ramfs

surreal path
#

i dont have a cache

brisk zenith
#

and with ramfs it effectively isn't a cache

#

do you have a list of named vnodes on every directory vnode? or maybe a hashmap?

#

because that's effectively what hydrogen's dentry "cache" is on ramfs

surreal path
#

we have this

brisk zenith
#

yeah that's basically the same thing as my dentry_t when associated with ramfs

#

within the vfs as a whole there's a huge difference

#

but all ramfs knows about it is that it's a way to go from parent + name to child

#

or from parent to children + names

surreal path
#

okay but how does this relate to the funny posix dentry structs

brisk zenith
#

not in the slightest

surreal path
#

yea lol

brisk zenith
#

it's just where I get some of the data from

surreal path
#

makes sense

brisk zenith
#

ramfs gets the parameters to this function from dentry_t, but that's the full extent of the relationship

surreal path
#

OH

#

i was being retarded

#

i thought i had to store those dentry_ts in some kind of list

#

but i dont

#

like i thought i had to allocate them

#

i can js create them on the stack then write that shit to the buffer right

#

shouldnt be bad

brisk zenith
#

yeah all readdir does is call that function until it eofs or errors (probably due to a lack of space)

surreal path
#

yea lol

surreal path
#

welp guess ill do opendir

#

OH

#

i did not read

#

my bad

surreal path
#

@brisk zenith if ur up that is lol

brisk zenith
#

the function pointer here is device-dependent

surreal path
#

okay interesting

#

nyaux has the device as a fs itself called devtmpfs

#

but i can still make this work

surreal path
#

pretty much useless for now

#

😭

#

found a bug

#

another bug

#

why is catting the dev dir calling hardlink

tender gorge
#

love you /p

kind root
#

what is /p?

tender gorge
#

platonic

surreal path
#

platonic

kind root
#

sad

surreal path
#

alex is already dating laura lol

mossy belfry
#

"No hetero"

surreal path
#

i set the breakpoint yet

#

its not letting me get into the function\

#

bro

kind root
#

whats the bug atm

surreal path
#

catting /dev does this weird ah shit

kind root
#

just dont cat it trl

surreal path
#

lol

#

but seriously tho this bug is so fucking weird

kind root
#

i believe u

#

btw do u plan to ever rewrite nyaux

surreal path
#

no

#

thats a waste of time

kind root
#

real

surreal path
#

well i still have this bug but this is better?

#

i mean

#

i get no input if i cat /dev/keyboard but yk

#

WHY IS IT CLOSING FD 1 AND FD 0 😭

crystal scarab
#

it is running the funny

surreal path
#

lol but seriously why is it closing fd 1 and fd 2???

kind root
#

it hates them

surreal path
#

oh wait its doing it for cat

#

thats normal

#

yea i have no idea

surreal path
#

why does nothing make sense here

thorn bramble
#

it's not supposed to

#

🧌

surreal path
#

ok vro

thorn bramble
#

nothing ever makes sense vro

surreal path
#

🥀

ebon needle
surreal path
ebon needle
coral dove
#

Holy shit

surreal path
#

hi chat

#

we debug later

#

i was busy all day

surreal path
#

nvm i kinda slept lmao

#

also pc is bought

broken depot
#

Nyaux Gaming

surreal path
#

coming idk in like 1-2 weeks

#

real

broken depot
#

(Port tetris)

surreal path
#

maybw

broken depot
#

Damn now I want to port Tetris to BadgerOS too

#

Unfortunately that's a bit far away in my current planning for it.

thorn bramble
#

WHAT

surreal path
#

yes

thorn bramble
#

where the hell did u buy it from vro

#

taiwan???

surreal path
daring juniper
#

1-2 weeks ain't that bad

thorn bramble
#

it is pretty bad when 99% of prebuilts ship within a few days max

#

but maybe it's a small irish company that builds them on demand

#

who knows, not me

surreal path
#

its custom parts that get assembled

broken depot
#

Custom assembly 1-2 weeks makes sense for

ebon needle
surreal path
#

my dad wants to fiance from this one company named humm

#

i dont have a choice in the matter im afraid

ebon needle
#

😔

molten grotto
#

though if the tetris is made by someone else then it doesn't matter ig

edgy pilot
#

write your own tetris

molten grotto
#

or you can port a gameboy emulator

#

I did that with my own emulator

ebon needle
broken depot
elder shoal
#

most of the things I order get here in like 1-2 weeks

magic kernel
magic kernel
kind root
edgy pilot
#

iirc

#

ryzen 5 9600
16 gb 5200mhz cl40 ddr5
9060xt
1 tb 990 evo plus

#

or 9700

kind root
#

same ssd as me

edgy pilot
#

I have 970 evo plus

molten grotto
#

I have 1tb 980 pro (and 990 pro 2tb though that's still on my shelf and I haven't yet installed that) + 1tb sata crucial mx500 + 240gb sata kingston a400

orchid dawn
#

damn, wtf

#

yall are past Ryzen 5000 yet?

#

crazy, I could never afford something that new

#

all I have is a Ryzen 3500X, a 5700U, a 5500U, and a 4750U

edgy pilot
#

I have 4650g

supple robin
magic kernel
supple robin
#

i think it was 32gb actually

magic kernel
#

It better be

rare pebble
#

I mean, I'd hope there'd be at least 25 messages in 27 days KEKW

surreal path
#

yes i still work on nyaux regularly but not as much anymore

#

i dont even get on discord as much anymore

#

as im just way too fucking depressed to open the laptop

#

most of the time i just stare at the ceiling

#

its not that i dont like working on it its just shit has gotten WAY worse this past month

#

to the point its difficult to even do much

#

but like cry and shit

surreal path
surreal path
#

but like dont expect wayland in a week

#

or smt

#

im gonna go attempt to try the last time to get my dad to talk to the doctor about meds

#

if he makes another excuse im changing the doctor myself atp

#

if only i wasnt depressed, nyaux would be in fucking Xorg i swear

#

nah fucking systemd vro

#

and like i know yall dont expect me to work on it but i want to thats not what im talking about, im js frustrated atp with how im feeling and shit doesnt change and shit get even worse mood wise SOMEHOW

magic kernel
surreal path
surreal path
magic kernel
surreal path
#

no its 32GB

magic kernel
#

I feel the strain of 16gigs on the laptop

#

Oh it is

#

Baller

surreal path
#

yea

#

im not retarded

magic kernel
#

Then storage probably first

surreal path
#

lol

#

yea pretty much

#

again for nyaux development to say on topic i dont think im gonna write a single line until the PC arrives to be fair

#

itll come soon tho

#

its under testing

#

photos btw its been built (this link doesnt have private info dw)

tender gorge
#

was one of the things i wanted to talk to you about when we meet up lol

magic kernel
#

Yeah. You’re 18, you can choose

#

I’d do that ngl

#

You don’t have to deal with your dad here

cinder plinth
#

here at 14 your parents dont have access to your medical info

coral dove
frigid cliff
#

Depends on the state

#

Especially depending on what the medical info is

#

Like I know that in my state (tbh idk why I know this) if you are positive for HIV your healthcare provider MUST tell your parents

surreal path
#

also something more funny

#

nyaux js randomly page faulted js now when trying to launch init

#

just randomly

#

it happened once

#

not reproducable

#

everything works fine after rebooting that VM

#

and does for like 50 tries

#

ANYWAYS

#

pc is dispatched

#

we so ball when it comes

mossy belfry
median goblet
surreal path
#

ok vro

edgy pilot
surreal path
#

ah yes

edgy pilot
#

(scripts exist)

surreal path
#

im not doing that

edgy pilot
#

make something for testing

surreal path
#

im not running it a thousand times

#

even with a scrip

edgy pilot
#

it should take less than a second to reach init

#

half a second

surreal path
#

no?

#

unpacking tha tar exist

edgy pilot
#

bro just make a disk image

surreal path
#

no

edgy pilot
#

who uses initramfs that's gigabytes in size

#

that's not what initramfs is for

surreal path
#

i dont

#

its 400mb

#

mostly cause gcc is compiled with -g\

edgy pilot
surreal path
#

also making a disk image???

#

wdym

surreal path
edgy pilot
surreal path
#

nyaux gets turned into an iso

edgy pilot
#

a file that imitates a disk and you store other files in

surreal path
#

im not writing a disk driver

edgy pilot
edgy pilot
#

basic nvme is ezpz

surreal path
#

it manages resources like a kernel should

#

its mostly posix complient

edgy pilot
#

no readdir?

surreal path
#

again when i get my pc

edgy pilot
edgy pilot
surreal path
#

no nooo

#

ill work on it with a get my pc

edgy pilot
surreal path
#

so monday to tuesday most likely

#

its been dispatched

#

like today

surreal path
#

it will probs come tomorrow

#

or after tomorrow

kind root
#

Letsgo

surreal path
#

pcs not coming til wednesday todays a bank holiday

glossy walrus
#

how do you not know that

surreal path
surreal path
#

its coming tmrw

glossy walrus
surreal path
#

ill genuinely see if fedora is on the cards

edgy pilot
#

it is always on the cards

still estuary
#

nya :3

broken depot
#

nya/ux (the cat operating system)

surreal path
#

Pc acquired tmrw we fucking ball, I need today to tho to like set everything up and stuff

#

Also wanna play a few games

elder shoal
#

play gregtech new horizons

ebon needle
#

or you can play bendy

magic kernel
#

(Or I guess po3 kappa mode if you want a newer MC version)

surreal path
#

Alright chat we ball tonight

#

sorry I fell asleep and

#

nightmares happened

#

But we still balling tonight dwdw

#

We will implement dir streams

broken depot
#

Do you mean stuff like getdents?

surreal path
#

Yes

broken depot
#

very cool

#

ls support in nyaux lesgo

surreal path
#

compiling nyaux now

#

we are SO back

daring juniper
rich trellis
surreal path
#

alright sorry chat, we are balling now im working on it rn

#

so last time we were at figuring cat /dev/keyboard right

#

okay so new development, ps2keyboard is getting its deconstructor called??

#

yea i e whats going on

#

wtf do i do atp

#

program is calling close on fd3

#

but bash is also using fd 3??

#

does anyone know what should i do in this scenario

edgy pilot
#

debug

surreal path
#

no i mean

#

its perfectly reasonable

#

that bash and the program are gonna use the same fd here

#

but i dont know what to do

#

in this scenario

molten grotto
surreal path
#

no

edgy pilot
surreal path
#

as per fork

#

they shouldnt share teh same table after fork tho

edgy pilot
#

close one, other is still open

surreal path
#

wait

#

i js had a brain blast

#

omg im a retard

edgy pilot
#

real

surreal path
#

oky so basically in the keyboard i have this array that stores ps2keyboard classes

#

index is the fd

#

thats not gonna work with multi processes

molten grotto
# surreal path no

so when you do ```c
int fd = open("/dev/null", O_RDONLY);
int new_fd = dup(fd);
close(fd);
char buf[4];
read(new_fd, buf, 4);

surreal path
#

idk

#

well no u wouldnt

#

duping fd creates a new fd handle

#

if other fd is closed ™ that new fd handle wont close

molten grotto
#

what does it refer to tho

surreal path
edgy pilot
#

what does fd handle refer to

#

underlying file

surreal path
kind root
#

whats a real handle?

surreal path
#

this bullshiut

#

uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh waittt

#

yea ur right

#

that shit would cook nyaux qwinci

#

i forgor how my fds work again

#

lol

molten grotto
#

yeah you should refcount the filedescriptorhandle

surreal path
#

whats the best way to do that tho

molten grotto
#

and in dup you just increment the refcount of that and put a copy of it to the new location

surreal path
surreal path