#Nyaux
1 messages ยท Page 9 of 1
...
yea works now
nice
the io port is fixed io im guessing?
can be both?
either
i hope you are one of the first people to use gcc 14 once it's actually out
gcc 14
whats the changes in gcc 14
as per the c99 standard, a bunch of what are currently warnings become hard errors
oh no
including -Wincompatible-pointer-types
scary
its not
dont think so
why not use a struct that you will pass to callback
and store resources there and whether a keyboard was found
it wont get called?
oh ok i can do a bool then
well u need to store resource somewhere as well
why, i dont rlly need to
i already store the port number and int number
if i do find them
oh ok
whats causing the ๐คฏ ?
yea uhhh
if an inode
represents a directory or file
how does the vfs know if its a directory or file
and like
what are v nodes
the inode stores it's type
inodes are not vfs things
oh
inodes are on disk fs
theres usually a dedicated function for that, like readdir
you have vnodes typically
okay and what do vnodes represent
so your vfs would be a tree of vnodes, which represent files/directories/links/whatever that come from a filesystem. Then the interfaces the kernel provides usually deal with vnodes, and a filesystem driver takes care of mapping vnodes to on-disk things.
assuming you're doing single-root (unix-style) vfs, but if you want to have multiple roots you just have multiple trees (think windows with C:/D:/E: drivers)
how does the vfs typically work in unix like oses, how does one implment them, yes i get a vnode is an entry in the vfs but what do vnodes contain????? what do i need to do as a kernel developer right now. i have a lot of questions
sorry idk why that message was taking so long to send ๐ญ internet issues
so your vnode would contain everything the kernel needs to provide the vfs interface. So that'd be something like:
- linkage within the tree (parent, children, maybe siblings).
- a lock to protect the vnode itself
- a type field
- an opaque pointer for the filesystem driver, this is where it can store any filesystem-specific data.
- a pointer or handle to access the file contents.
- maybe a reference count, depends on your design
you may want to include permissions here too
I personally just copied netbsd's api
and your workflow for doing something in the vfs would look like:
- traverse the tree, find your vnode.
- check if the operation makes sense
- ask the filesystem driver associated with the vnode to perform the operation.
So you'd need a way to know which filesystem a vnode represents.
okay ill start by making a vnode struct
Should honestly go into resource links
that represents a particular filesystem
oh
so which filesystem the vnode comes from
Im actually not sure what the per-node flags are used for here
Add on per need basis
i probs need a type field to describe if the vnode represents a file, directory or whatever
correct?
yeah
ok so something like
Why is it all caps lol
funny
and? 
and this will be the vfs node
yeah have fun typing those enum values everytime lol

anyways should a vnode store its name or no
What if its a 32k char name
usually the name is only fetched from the driver when its needed
for the above reason ๐
so how will say someone find a file from a path? do they loop through every vfs node, traverse the tree. call the get name driver thing from the stored function pointers in the vfs node, check if the name matches, if not keep traversing? sorry bit confused
thats the right direction. So first of all you'd want a function for querying if a node has a child with a specific name, and you'd also want to provide a general 'lookup' function. There's two ways of providing that:
- You could break the path down into segments (the things between the separators) and call the "do you have this child" function for each segment until you error out or find what you're looking for.
- You could also pass the path to the node's driver and ask it to resolve as much of it as it can for you, until it fails or maybe reaches a mountpoint of another filesystem. In that case you call that driver with the remaining path.
okay im really confused but maybe if i write this down ill understand better, is this what a vfs is:
each vnode represents a file or directory, stated by its type field, each vnode contains a bunch of function pointers which points to its driver equivalent functions it may need to use
each vfs represents a mounted file system, each vfs holds a pointer to the first vnode in the tree it represents
say we want to resolve path '/hello/world.txt', we break the path up into things like '/', 'hello', 'world.txt' we lookup for the root vfs, and start traversing the tree. we select a vnode. use its driver interface to check if the filename matches any part of the path. if it does thats our vnode else we keep traversing. if we dont find it we select the next vfs and start traversing its tree essentially
am i understanding this correctly?
yeah that sounds right
yes
thats how i do it
your vfs only really needs to support absolute paths, so you can always start at the root node
I split up the path then call lookup() until it's reached the file you wanna do the OP on
okay interesting
so in your example it would be: check if root node has hello/, check if hello/ has world.txt. No need to special case the start of the path (by treating / as a node name).
I find that simpler imo
I included the trailing slash to indicate its a dir, but dont be confused by that (its not part of the name)
yeah you need a proper path parser
yeah for sure
and then if the root vfs doesnt have hello/, goes to the next vfs and checks if the vfs name is hello. if so traverse the tree to find world.txt
correct?
no
oh
if it doesnt have it ENOENT
ENOENT?
the root node is the top of the tree, if it doesnt have the first part of the path (hello/), it doesnt exist within that vfs.
"No such file or directory"
okay wait
i think im understanding
my brain is cooking
wait

cooking is better than cooked
IGNORE THE POORLY DRAWN DIAGRAM
maybe its worth saying too, in case its causing confusion, the struct vfs in the paper I linked (and the struct you showed earlier) is what I've been refering to as a filesystem driver. One of these would be your root driver which has the root vnode.
yes i understand that
ok cool
so im gonna need this
okay and
im gonna make a function pointers thingy rn
okay
get_filename()
returns nothing
const char* would be preferable imo
or you could have it return the name length, and take in a caller-supplied buffer (that way management of the name's memory is the caller's problem)
anyway, implementation details
should vnode have a entry that points to a uint64_t address that could be the inode of whatever file system?
@desert haven ?
a private pointer for the driver can contain that info
so stick a void* that the filesystem driver can access when dealing with that vnode
and the driver can store what it needs there, like the on-disk address of the file
yeah something like that
okay
so now i kinda defined the structs
do i need to make a function that can parse a path or what should i do first
yeah you could start with that
and then after that you'd be looking at writing your vfs and a tempfs driver, which is just a filesystem that stores everything in ram. It can super simple, but it allows you to test your vfs.
is it called tempfs or ramfs

tar is a good way to populate an initial tempfs though ๐
by passing it as a bootloader module
tar is not a filesystem
its very easy
its quite simple
lol was waiting for this
oh right
im trying to
Getting sued speedrun
okay i got a path parser done
stole some strtok thing and then used that to do a funny like this
bit cursed but eh
fun fact sizeof char is always 1
like guaranteed by the c standard
so * sizeof char is just useless
okay made a function that parsers a path, guessing i need to make a function that resolves the vfs node from the path?
ok removed it lol
also that logic looks wrong
wdym
assume parse_path("/a/b/c"):
strlen(path) = 6 => buf points to a 6 byte buffer
buf[0] = p; accesses bytes [0, 8) in the buffer, so accessing 2 bytes past the end
my brain ๐ฅ
why accessing bytes 0, 8
??
what is sizeof(char *)?
8
oh
right
what should i change in this case
should i make the buffer bigger or just completely change the logic
buf needs to dynamically grow as you find entries (or you can scan the string twice, once to collect the number of entries, then again to collect the entries themselves)
oh that's another thing, strtok writes into the input
oh
so this is just gonna page fault on a write to a read only page
ugh then i guess ill just straight up remove strtok
this is pain
i hate working with strings

the compiler should've warned about casting const away
when passing the argument to parse_path
okay so how should parse_path be implmented
whats the "correct" way of doing this?
?
if i wanna like
make an array of char*
pointing to each token
like
i actually dont know what to do anymore
do you need to know all of the parts of the path at the same time?
I iterate through the path one part at a time
no not rlly
so how about a function that takes the path, and the start of the current segment, and returns the start of the next segment (or null)?
could be done using strchar
strchar?
okay but what about paths that have more then one slash like /home/meow/nyaux/kernel/whatev
this function would return home/meow/nyaux/kernel/whatev but i would need just "home"
ok maybe return the length as well (so the next /)
and you can use the strncmp and friends where you pass in the length as well
no need to rely on the null terminator
what?
so your 'get next part of path' function returns a const char* where the part starts, and a size_t for the length of that part.
you cant return 2 types at the same time, unless its a struct
alr
and where does strncmp come into this
for comparing the path segment with the name of the vnode
oh yeah right
@desert haven something like this?
return strncmp(name, seg.seg, seg.len) == 0 lol
lol
but that looks fine, assuming you dont call this with a segment thats empty
cool!
yeah ๐
alr!
how to traverse the tree, since we have parents and siblings and children
whats the best way to do this?
i cant come up with something that will traverse this tree properly
im confused on whats the best way to do this
alright so you can think of a tree has having levels right?
yea
cool, and your path is a bunch of segments
yea
so you're trying to match a segment per level of the tree
right
so you'd track the 'current' node (starting with the root) and level (starting at 0), and check if the current node has any children that match the segment for this level.
if it does, that child becomes the new current node
increment the level/get the next segment of the path
until you either dont find a matching child (node doesnt exist), or you perfectly match the end of the path (you've found your file)
okay so what if the filesystem looks like this
vnode -> vnode
|
v
vnode -> vnode -> vnode
|
v
what we looking for
im guessing that once we searched through all the children of a level, we go back x levels
no backtracking
oh
if the current node doesnt have a child with the current path segment, you cant continue
lets say you lookup /hello/world.txt, if the root doesnt contain a child with the name hello, then you're done - return an error
same idea with /hello/world/again.txt, if you find hello/ and dont find a child with the name world/, you dont go back up a level, that doesnt make any sense.
that would be something like /hello/../world/again.txt
oh right i think i know what your saying
so we set the cur_vnode to the root vfs, check for the first path seg on each sibling. if found we get the next path seg and set cur_vnode to the child of the first path seg vnode we found
and we keep doing that
i get u
thats makes way more sense
yeah exactly
okay easy
test it and find out
you can manually stick some nodes into a tree though?
ig
just for testing
hahaha cool!
YUH
bro
if (true) return true else return false
return strncmp(node->ops->fs_getfilename(node), seg.seg, seg.len) == 0
Great to say some actually progress on this and not just hopeless debugging
Indeed
I managed to get absolutely random allocator faults out of the blue
But iโm 99,9% convinced my allocator is not the problem
it can't be my allocator
i know it
i've checked the logic 10 times
i've done test runs in userspace with 20 threads each doing thousands of allocations
(and checked for overflows use after frees and stuff during the testing)
nononononononono
it was krealloc
So my kmalloc returns based on allocation size either buddy pages or slab objects
And my krealloc copies the memory from the old allocation to the new
And to figure out how much to copy, it checks the slab i allocated from and then copies MIN(new_size, old_size)
what is that
But I forgot the get old_size from the buddys pages when reallocing a buddy page, and always assumed its a slab page
Allocator bugs
Its broken allocators and UB and weird scheduler behavioir and broken IRQLs
so just bugs
Btw apologies for spamming your thread nyaosmaster
so just bugs
btw, get_filename doesn't make much sense for a vnode
consider a file with 2 hard links to it
what name should be returned for it
hm?
what?
alright
whats ur timezone?
inode level then?
no, inodes don't have names
where should it sit then?
directory entries associate a name with an inode
what
wouldnโt vnode level work though, as every hardlink is represented by a vnode in that case?
whats a hardlink, why cant fs_getfilename be a file system operation???
what the fuck is going on
im completely lost
๐ฅ
why would you give each link it's own vnode though? if you update the mode of one, the change should be reflected in the other clones as well
oh right, thats true
which would mean you need to keep track of extra data for that
i am very confused
so a file on an unix-like filesystem is actually made up of 2 parts
the directory entry, which gives it a name, and the inode, which tracks all the other information
and the directory entries just refer to inodes by number
is the directory entry structure implemented by the x file system?
and a hard link is just such a reference, and you can have multiple hard links to the same inode
x file system?
like
Twitter file system
bruh
๐ญ
i mean as in
should the vnode data be a pointer to this directory entry
which in turn points to the inode
or smthin
what you want is an operation to get a list of the directory entries (so ls can list the entries) and some operation to get a vnode for a child by name
what
so the getfilename isnโt really needed anymore as you do it the other way around basically?
getfilename is fundamentally broken because a vnode may have more than one associated name, or may not have any name associated at all
the latter case happens if you have the file open, but unlink it from the filesystem
right
okay im like extremely confused so i think ill explain how i understand the "unix like" vfs as of now
vfs node represents a mounted file system, can have a enum type that explains what type of file system it is. it points to the first vnode it represents and the next vfs in the linked list
vnodes represent a file or directory, they have a field that points to its sibling, its parent, and child. vnodes have a data field that can point to the data structure of the file system which points to the actual data itself.
vnodes have an operations field that allow u to do operations on said field
how i've currently implmented the vfs is i have a function that looks checks if the vnode has the same fs name as the path segment. if so return the vnode, else return null. then i have a loop that traverses the tree until it resolves the vnode from the path. breaking the path down as it goes down the tree until it finds it
path = home/nyaux/kernel.bin
finds vnode with name "home" using fs_getfilename
path = nyaux/kernel.bin
finds vnode with name "nyaux" using fs_getfilename
path = kernel.bin
finds vnode with name "kernel.bin"
what is a directory entry and how does this differ from how i've implemented my vfs
?
path = /home/nyaux/kernel.bin
path starts with /, start looking from the root vnode
cur_vnode = this_process_root_vnode
cur_vnode = cur_vnode->find_child("home")
assuming this succeeds
cur_vnode = cur_vnode->find_child("nyaux")
assuming this succeeds
cur_vnode = cur_vnode->find_child("kernel.bin")
oh so
vfs (represents info about mounted file system)
|
v
vnode (root vnode, name is / or whatever)
|
v
vnode (name is home) -> vnode (name is etc)
|
v
vnode (kernel.bin)
Vnodes dont have a name
oh
Bruh
from the original vnode paper:
Path name traversal is done by the lookuppn routine (lookup path name), which takes a path name in a path
name buffer and returns a pointer to the vnode which the path represents.
[...]
Lookuppn traverses the path one component at a time using the vn_lookup vnode operation. Vn_lookup takes
a directory vnode and a component as arguments and returns a vnode representing that component.
You have a vnode thats current directory
a vnode does not know it's name, what knows it's name (or rather, it's name for it), is the parent directory
You read that directory to find if it has anything with the name
and the parent directory stores that name -> inode association in a directory entry
so theres a directory entry that represents a directory, and it stores the name of its child and its ptr to its inode?
A directory is an array of entries
Each entry has a name
And an associated inode number
That inode might be another directory
Or maybe a file
inode number?
okay im sorry again im rlly lost. im gonna undo everything i did in my vfs.h and vfs.c and rlly try to understand this
is there a resource that explains how this system works start to finish for someone who knows nothing about vfs's
Article on ext on osdev wiki
Greenwich mean time
Well
British summer time now with dst
BST should be year-round
OOHOHHHH SOOO THE DIRECTORY STORES THE NAMES OF THE FILES IT HAS
Finally
you could have like a structure
struct directoryentry
{
char *name;
int inodenum;
struct directoryentry *next;
}
struct directory
{
struct directoryentry *head;
}
Terrible naming but yes
how should it be named
Thats better
so we have a global table called a inode table
an array of inodes of MAXINODENUM
and the inodenumber in a directory entry is the index into this global table array
Pretty terrible idea
I can make a file with inode number 99999999
so what is inode number then
if theres no global array to index to
how r u supposed to get the inode of a file
?
inode numbers are specific to the underlying file system
if i have 2 ext4 file systems on /foo and /bar, inode 3 on /foo is not gonna be the same file as inode 3 on /bar
inode numbers are only unique with two other ids that fstat gives you I think
again im completely fucking lost 
And on some synthetic fses they don't even have to be
dont worry about inodes if you're not gonna support on disk filesystems for now
no i need to worry about inodes
i think (st_dev, st_ino) is a unique value for every file
Ye, that
i need to understand all of this
why is it so complicated

im trying to
you don't need inodes to leak out of the file system driver
the vnode layer can be mostly unaware of them
(saying mostly because there might be a case i'm not thinking of)

im gonna take a break for today on osdev cause i have a presentation due tomorrow thats worth 20% of my summer grade
that sounds pretty important
yea it is
How you gonna do it from Linux
power point web
The things people do to not use windows
we just use google slides
I will caution you against this approach (have you read some resource about ancient unix?) On my return
i have not read any resource on ancient unix
Global inode table is so ancient unix its practically reanimation the ghost of that guy whose name began with d
Denis ritchie
Anyway I'll discuss when I'm ho.e
alright
Hoe
Lol
this is logically (but not literally; the inode table is usually divided into cylinder groups in filesystems like UFS and the ext series, which is just UFS redone) true of the structure of traditional unix filesystems' on-disk formats
but of the in-memory data structures used by most kernels nowadays, big global arrays with a hard limit are very much out of fashion
and given the very high number of inodes you may be dealing with, impractical....
if you are familiar with the structure of traditional unix filesystems then you can imagine the vnode as a virtualised inode
however when sun designed the vfs (the PDF was linked earlier) they made sure to define it sufficiently abstractly that other filesystems could work with it
there are some cases of impedance mismatch, like FAT and its unity of inode and dirent, but even that's no great problem - you will find most filesystems can easily provide APIs like those the vfs as described in the sun paper offers, excepting obvious things like no symlinks or hardlinks on fat
note the vnode described in the sun paper has no concept of name or parent because of what qookie said
the vnode is a virtualised inode there can be multiple paths to it
hard-links
the vnode generally contains a context pointer to some FS-specific data structure so that the FS driver knows what to do with it when asked to read/write to it, make a directory in it, whatever
it is possible to create an entire unix without adding anything else to the VFS than vnodes, the sun vfs paper shows how mountpoints are done there, but the cost would be that each filesystem would really want to include a cache for directory entries to avoid having to do harder work every time someone looks up a filename, even if it were already looked up
so there is a role for having a general namecache structure for lookups, mapping filenames in a folder to their own namecache structures, with namecache structures including a pointer to the associated vnode, and a pointer to the parent namecache structure
as a general rule i recommend referring to the sun vfs (the original) before the bsd vfs, the bsd vfs was an independent reimplementation but not as thoroughly integrated and full of ugly warts like having a VOP_LOCK op which locks a vnode (originally this was supposed to be for file locking, but it's used in BSD for general synchronisation - ugly!!) , and having specific requirements in vnode ops about having VOP_LOCK() locks held
in particular VOP_RENAME in bsd is bad
in Sun VFS it accepts two directory vnodes + two filenames; in BSD it accepts both directory vnodes + both file vnodes! it would be racy but it has requirements to enter on holding relevant locks. in any case it's ugly
I had just finished my exam
๐ญ
Iโm getting back home from school, when I get back home Iโll get reading the sun VFS paper and get grinding ๐๐ช๐ฅ
how did it go
I think I did okay
I usually donโt have to like study too much to get good marks but it was certainly difficult ig
Just gotta hope I got at least 70% or my dads gonna take my devices away probs cause he upset with me about school
๐ญ
zamn
Zamn indeed
at least you're not wasting time playing garbage games like i did when i was your age lol
how old are u again
17
Ye
how old r u???
25
lol
lmao
I was wasting time playing too much valorant at 16 but now I pretty much stopped playing video games all together cause of osdev
๐๐ช
Iโve been programming since 13
yeah i started super late
lol
lol
u can do that and still get a job??
as a lead dev????
Donโt u need a degree or anything
How
I always hear the people who started late complaining about how little chances they have and that they should have started earlier and whatnot
literally my thoughts
Where u from?
Ireland
which county
cork
are u irish????
i was born in ireland but my parents are arabic
my dad goes to galway to work
๐ญ
i dont live there
oh
just some of my family
ah okay
my dad was born in cork though
no
how
im not irish i was just born here
a lot of irish people dont
no
its not the native language
the government keep trying to push it but everyone just speaks english
lit ^
yea
lol
me too ๐ค
teaching of irish in ireland is notoriously shit
every irish adult beyond the age of 25 i meet here can't say anything those who finished high school more recently usually have a few gaelic phrases and little more
however every single one of them supposedly learnt it at school
i avoided every single irish class 
my brain is just gone
๐ฅ
bro
im lost
read the sun paper still dont get it

i dont know how to implement this
why am i so stupid
ugh
all i understand currently is that the virtual file system abstracts whatever file system and each vnode represents a directory or file and each vfs represents a mounted file system
|vfs| -> |vfs|
V -------------V
vnode (directory) -> vnode (directory, is a different file system)
V V
vnode (file) vnode (file)
i dont know how things like a directory entry relates into all this
should a directory entry be implemented by the file system, yada yada yada
a lot of questions
i wanna make sure I REALLY
understand what im doing
before i start writing any code
i need to make sure this is UNIX like, and this is the correct way to design and imeplment a vfs
fuckin hell

and i rlly dont know how inodes relate to this
i wish i wasnt this stupid
okay im reading this paper about "practical file system design" by the guys who made beos or whatever
has stuff about vfs shit here
Okay so
if the vnode type enum is a directory and we are running the function vn_lookup(), vn_lookup is implemented by the file system and returns the child vnode of whatever it found from the path. FOR THIS CASE with a tmpfs file system, we can assume that the vnode is a directory structure in the data pointer and we can look through each array of dir_entry until we find our guy and the dir_entry could point to its vnode?
something like that?
???
yup
oh easy!
now i understand !!!!
๐
๐
should vfs have a static variable that points to the root mounted VFS ????
yea i get that!
wait a process can have a root vnode???
tf
not gonna worry abt this for now
what if path DOESNT start with /?
use the processes current working directory vnode instead of the root vnode
then thou proceedest from thine current working directory
yes
but how will u get the root vfs? if the path is absolute and has a '/'
how will u get the root file system
you store a "root vnode" pointer in the process' structure
bro never used a relative path in his life
also a global one typically
the global one is assigned to init's root vnode ptr, and all other processes inherit it
oh
ohhhh
okay so one second im gonna go into my scheduler and change a few things
cause this is currently how i represent a process

i dont have a "process" struct
do i need to change how i've implemented this in order to continue?
you can either define a process in distinction from a thread or you can put what would usually go into a process struct into independent structs which threads can share pointers to
yea okay so what im gonna do is have it so a thread points to some common struct with other threads that describe the "root vfs" and anything per process related
but my scheduler will still see threads as "just processes to switch to"
i think this is a nice easy approach
yeah that doesnt make much sense
wdym
this sentence
oh yea fair
sorry lemme reword
my scheduler still sees everything as just a thread, it switches to. thats it. thats all it does, goes to the next thread in the linked list thats all it does. if you want process data to be shared between threads. threads can point to a shared structure describing info per process
thats usually how it works
yea okay
vnode? or vfs node?
vnode, as chroot lets you set root to be a non-mountpoint-root
yeah, something along those lines
alr
and ill make a function from my scheduler that gets the process info of the current executing thread
๐
where page table
page table is stored in cpu_context_t
along with the stack
oh right
i shouldnt be storing the rsp in this struct to be fair
as stackframe has rsp
can threads have separate stacks?
i think they can right?
what
can threads have separate stacks
threads can also have names
fair
nice naming convention
_t 
all over the place
i mean the lack of it being the same
if i have a function create_process, what should i set the cur root dir to?
?
okay for NOW im gonna store a global variable in vfs.c that is just the root vfs and set the process vfs initally to that (FOR NOWWWWW)
the current working directory of the calling process
i dont have that
then yeah just have a default of like / or something
as in i dont have user mode and i dont have any calling processes
okay
just some path that makes sense
Kernel could get system root simply
wha
The root mount fs or whatever u wanna call it
okay heres what im gonna do FOR NOW
gonna make vfs_resolve_path just use the root vfs if the start of path is '/' and return unimplemented otherwise
i just want something WORKING now
you probably dont even need working directories right now
yes
does the vfs structure look like this
vfs (root mount)
V
vnode -> vnode -> vnode
or
vfs (root mount)
V
vnode (root)
V
vnode -> vnode -> vnode
lil confused
?
someone pls tell me

the latter
should vnode root be of type directory?
what are the other options
yea fair
you want res to be a two-star parameter (โญ โญ) and to dereference it when you assign it (โญ res = whatever)
huh?
why???
C doesn't have call by name your assignment is merely changing the local value of the pointer res
oh wait i should return res
wait
wait wait
second
ur right
ok its a **res now
and then *res = whatever; to assign it so that the caller can see it
yep
ok and vnode shouldnt need to contain pointers to its parent or siblings or whatev
cause all we need is to read the directory entry in the vnode-> data
yea that makes sense
pointer to siblings and parent has the problem as having a name
yea pretty much
a vnode still should point to its vfs tho, so we know information about its file system?
ig
yeah because you can't have hard links across file systems
yea alr
well at the file system level hard links are directory entries that refer to the same inode
wha no i thought directory entries were like this
you check the type of the ptr_to_vnode and check if its a file or directory
for tmpfs sure, but on like ext2
the dentry is just a (name, inode number) pair
on disk
can inode represent a file or directory?
Yes
So you would have struct inode that would have a vnode pointer
And inode would be stored in a dir entry
Like you have here
should i make a tmpfs_inode or smthin?
If you want to support links
for tmpfs you can work on vnodes alone ig
um
i dont know what to do
what do u guys think i should do, implment tmpfs_inode or just work on vnodes alone
A hardlink would just increment the refcount for a vnode then?
yeah
I guess
refcount?
why do u need to keep track of that
Because you might have multiple directory entries referring to the same node
And if one is deleted you dont wanna wipe the other
why would deleting a directory entry cause wipe the other directory entry
it doesnt matter if they point to the same node
If you leak the nodes then it wouldn't
if the vnode is unused you want to deallocate it
oh right, if ref count is zero u'd wanna deallocate it
yea fair
so you need to keep count of how many users still exist
Lol
Yeah, as someone who is writing a 100% rust OS, rust is kind of a pain for OS dev

viper when
๐
๐
how do i make it so i dont have to manually create all these dir and dir entries and stuff
this is pain 
You write an FS driver ๐คทโโ๏ธ
i did
well
a basic one
tmpfs
well not rlly
๐
just implemented the lookup function for the tmpfs fs
lol
a function
what function?
im thinking sec
which vnode operation would it be
im reading the sun vfs paper
vn_create and vn_mkdir if you look at the vnode paper
will nm be void *?
const char *? since it's a name
vn_rdwr
also strategy, bread, brelse overlap
but don't worry about those artefacts of old unix design
i was thinking ๐
uiop?
bread?
b read makes a lot more sense
sunos-specific structure?
what is uiop for
it is a paper about sunos after all
I do not own anything.
uiop has the count and buffer ptr ig
guess ill just make my own fields
๐
cause im a rebel! i deviate from STANDARDS 
rebel sounds
i just found out you could click on a youtube video inside of discord and watch it right there instead of opening the browser
it's an old unix structure used for i/o particularly to/from userspace
not gonna worry abt it and add my own fields
this is MY kernel afterall, it is unix like ๐
(so far)
first im gonna do the simple vnode ops
like vop_mkdir
if i implement my vfs and a tmpfs file system by TODAY
will that make me a cool kid?
will that make me not a beginner osdev officialy or will i still be considered some beginner osdev
๐
step 1 of being cool: don't ask if you're cool or not.
there is no such thing
i dunno, but i think it's pretty baller the speed at which ur developing this kernel
its because i have no life
๐
depends on your definition of userland
could probably fairly easily get processes running in userspace tomorrow maybe even with a few basic syscalls
assuming you have various things done already
we are very fucking close to userland
yea i have a lot of stuff already
basic ah scheduler, pmm, vmm, slab allocator, apic driver, acpi, ps2 keyboard
and vfs now
what are the vfs files currently
i saw that
wdym?
the vfs is just an abstraction over several filesystems
so which one do the files you showed above belong to
they dont belong to anything, i lit just made some empty vfs structs
right
and i made a tmpfs lookup operation
and a tmpfs directory and directory entry
but i need to make a few operations
now

mkdir
create
rdwr
i make these three operations for the tmpfs and i will have a basic ah tmpfs 
and then i will try to parse a tar file
and populate the tmpfs
what about lookup
and use it
done already
how about remove
that isnt as important for a while really
yep
with v_mkdir can we expect vnode to be a directory?
and not a file?
?
okay i will asume so
i will also create a new vnode?
and alloc that on the heap
ig
and ig tmpfs_dir_entry on the heap too
something like?
i think
oh and also for v_create
what is E?
what is M?
???
im so confused lmao
read, write, that sort of thing
what?.
files can be opened for reading, writing, both
it's for e.g. permission checking
ok then i wont worry abt it
wait it probs better if i allocate the name
cause name field would be invalid if i just did vn_mkdir(.., "directory1", ..)
yea that would be better, i will memcpy the null terminator as well to the name
of note, sunos did a comprehensive integration of the VFS, while 4.4BSD didn't. all pipes in solaris are vnodes in the fifofs for example, while in BSD derivatives only named pipes are. so the open mode can be important in solaris: https://github.com/illumos/illumos-gate/blob/e2a8479967f5e2ae9ba0aa265cfa175d7874b057/usr/src/uts/common/fs/fifofs/fifovnops.c#L223 take this for example
wha
sorry i dont understand
i dont even know what are pipes
๐
only that its those things echo "blah" | grep "blah"
or smthin
i should clarify, the permission checking might actually be irrelevant because i think the access vop is used instead for this. the importance is around e.g. arranging that if someoen opens a pipe for reading, you wake up the writers who were waiting for something like this to happen
im not gonna worry abt this for the moment
when i need pipes and stuff and when i understand what pipes are and how to implement them ill change my vfs and stuff
fair and valid
you will understand the concerns aronud them in due course
yep
for now suffice it to say that in the BSD copy of the VFS, they didn't integrate it completely as it was in sunos, so not every read() and write() call from userland will go through a vnode. but this detail will be of interest only when you are dealing with pipes, device nodes, sockets, that sort of thing
okay
oh and for vnode_create, is the function expected to actually create the tmpfs node for the file vnode? or no
the create vnode op should create a file, according to whatever that means for a filesystem, and return a pointer to its vnode
so for tmpfs it should create a tmpnode
alr
!
something basic
okay these two functions are done ๐
now to make the actual hard part
vn_rdwr
also what is vn_open and vn_close?
im not gonna worry abt that for now
guessing for vn_rdwr, 0 is read and 1 is write
for the read operation, if the file dont exist i gotta make it i guess?
i suppose
read can only be done on an already open filee
and you can't open a file that doesn't exist
O_CREAT: hold my beer
if you have a vnode then the file already exists
what if the tmpfs_node.size is 0
meaning that the tmpfs_node doesnt have any memory backing it, there is nothing to read from
you read 0 bytes
oh qookie while you're here

do you have a statically linked mlibc linux executable real quick
statically linked no
do u need that for ur os?
i have some test binaries on hand, but they're dynamically linkeed
I'm trying to run static glibc executables atm and I feel like mlibc would be easier first
or wha?
yea
ah okay
running linux binaries

you likely need to do nothing for a regular tmpfs file
if the file is empty read just returns 0
ok
/* ARGSUSED1 */
static int
tmp_open(struct vnode **vpp, int flag, struct cred *cred, caller_context_t *ct)
{
/*
* swapon to a tmpfs file is not supported so access
* is denied on open if VISSWAP is set.
*/
if ((*vpp)->v_flag & VISSWAP)
return (EINVAL);
return (0);
}
solaris' current implementation of the open vop for a tmpfs vnode
the only thing it does is ban swapon of a tmpfs file


