Page 2 of 3
Posted: Fri Mar 28, 2008 10:22 am
by z180
i try giving the vectors of my vfs out of the head back
my vfs is a bit incomplete but is based on various
documentation ,sourcecode of different systems
and my own input (it could be that i forgot some functions)
the vector struct vfsops in struct vfs (and struct vfsinfo) contains
sbread (for mount)
sbwrite
alloc_inode
free_inode
vfsctl (commands like ioctl)
mountroot
struct inode contains struct inodeops
lookup
create ( (can create fifos )unix had only creat)
open
close
rdwr (read and write have same vector)
ioctl
select (for pipes/FIFOs and IFCHR devices,I have no sockets)
rename
unlink
readlink
symlink
link
pagein(like VOP_GETPAGES)
pageout
strategy(for block device inodes)
sync
free
stat
Posted: Sun Mar 30, 2008 8:18 am
by Jeko
Sorry... I didn't explain very well...
If for example I have a ext3 filesystem mounted on '/', how can I mount devfs on '/dev' ?
I must write functions to handle mountpoints in the ext3 filesystem driver?
Posted: Sun Mar 30, 2008 8:30 am
by JamesM
Hi MarkOS,
All of this is painstakingly explained in the tutorial page I linked you to.
You impement a VFS - a virtual file system. This is a graph of nodes. Each node can represent a file, directory, pipe, socket, symbolic link, character device or block device. Each node has within it function pointers for open()/close()/read/write/ioctl. These function pointers point to the appropriate functions in the driver for the filesystem type that the inode is part of. Mounting a new filesystem is as simple as taking an existing directory node, adding children (your (devfs in your example) driver would do this) and setting those children's function pointers to point to your devfs functions, instead of your ext3 functions.
Cheers,
James
Posted: Sun Mar 30, 2008 8:37 am
by Jeko
JamesM wrote:Hi MarkOS,
All of this is painstakingly explained in the tutorial page I linked you to.
You impement a VFS - a virtual file system. This is a graph of nodes. Each node can represent a file, directory, pipe, socket, symbolic link, character device or block device. Each node has within it function pointers for open()/close()/read/write/ioctl. These function pointers point to the appropriate functions in the driver for the filesystem type that the inode is part of. Mounting a new filesystem is as simple as taking an existing directory node, adding children (your (devfs in your example) driver would do this) and setting those children's function pointers to point to your devfs functions, instead of your ext3 functions.
Cheers,
James
I understand this...
But how can I mount '/dev' on '/' ?
I don't know which filesystem is in '/', there can be ext3, reiserfs, ext2, or another.
How can I create mountpoints not statically but dinamically? The filesystem driver must have a function pointer for a function mount?
What if I want to mount '/media/hda0' on '/dev/hda0'?
Posted: Sun Mar 30, 2008 8:44 am
by JamesM
The entire point of a VFS is that it abstracts away the need to know what driver is used to access any particular file.
To mount /dev on /, you first take "/", which will be a VFS node, and find the "dev" directory child node. You then pass that VFS node into your devfs driver's "mount" function. The devfs driver will use that as its root.
Posted: Sun Mar 30, 2008 8:51 am
by Jeko
JamesM wrote:The entire point of a VFS is that it abstracts away the need to know what driver is used to access any particular file.
To mount /dev on /, you first take "/", which will be a VFS node, and find the "dev" directory child node. You then pass that VFS node into your devfs driver's "mount" function. The devfs driver will use that as its root.
Ok... This is the answer to my questions!
So I need to add the mount function's pointer in the fs node structure.
Posted: Sun Mar 30, 2008 9:21 am
by Dex
If you want a good well commented example, written in fasm, see "titan operating system", the OS written by Tomasz Grysztar (coder of fasm ), if you can not finded it let me know, i have a copy on disk some where.
Posted: Sun Mar 30, 2008 9:34 am
by Jeko
Dex wrote:If you want a good well commented example, written in fasm, see "titan operating system", the OS written by Tomasz Grysztar (coder of fasm ), if you can not finded it let me know, i have a copy on disk some where.
I can't find it.. Could you send me it by email? (or post it here if you can)
Posted: Sun Mar 30, 2008 10:28 am
by Dex
Here is a link
http://board.flatassembler.net/topic.php?t=153
But you need to be a member to down load it.
Posted: Sun Apr 06, 2008 12:17 pm
by Jeko
JamesM wrote:The entire point of a VFS is that it abstracts away the need to know what driver is used to access any particular file.
To mount /dev on /, you first take "/", which will be a VFS node, and find the "dev" directory child node. You then pass that VFS node into your devfs driver's "mount" function. The devfs driver will use that as its root.
but when I read the dir /dev, how can the filesystem mounted on '/' know that /dev is a mountpoint?
Posted: Sun Apr 06, 2008 12:54 pm
by JamesM
Do you even read what I write?
Posted: Sun Apr 06, 2008 2:46 pm
by Brynet-Inc
MarkOS wrote:but when I read the dir /dev, how can the filesystem mounted on '/' know that /dev is a mountpoint?
Why would it need to? All the root file system would need is an empty directory where DevFS will be mounted (/dev for example..).
The DevFS would essentially claim that point of the hierarchy and populate it with device nodes, none of which would physically read or write to the file system mounted at /.
I think you're having a hard time grasping some of the basic concepts here... not sure how you want us to help you with that.
Posted: Sun Apr 06, 2008 4:02 pm
by Jeko
I can't explain myself well because I don't know english very well...
I make an example.
I have ext3 mounted on '/'.
There is a directory in the ext3 filesystem 'dev'.
The DevFS is mounted on '/dev/'.
If I open '/' and I read subdirs, I have:
'.'
SOMEDIRS
'dev'
If I open '/dev' how can I know it's a mountpoint? I must have a list of mountpoints? Or the ext3 filesystem must say it's a mountpoint?
Posted: Mon Apr 07, 2008 12:45 am
by JoeKayzA
MarkOS wrote:If I open '/dev' how can I know it's a mountpoint? I must have a list of mountpoints? Or the ext3 filesystem must say it's a mountpoint?
To my knowledge, most *nix-like os maintain a list of mountpoints and check the absolute path against this list to determine which filesystem driver to pass the request to, or they use a seperate tree of inodes above the actual filesystem layer (at vfs level) where you could put this information. In my opinion, the filesystem driver itself shouldn't deal with mountpoints at all, at least not in the traditional unix way of doing things.
Posted: Mon Apr 07, 2008 1:13 am
by JamesM
Exactly - it's dealt with via the function pointers I explained above again and again...
At the VFS level there is no such thing as a mountpoint - just the inodes in / and the inodes in /dev would have their read()/write()/etc function pointers pointing at different places, the former to the ext3 read/write/etc functions, the latter to the devfs read/write/etc functions.