Virtual File System Functions
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
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
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
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...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
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'?
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.
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!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.
So I need to add the mount function's pointer in the fs node structure.
I can't find it.. Could you send me it by email? (or post it here if you can)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.
Here is a link http://board.flatassembler.net/topic.php?t=153
But you need to be a member to down load it.
But you need to be a member to down load it.
but when I read the dir /dev, how can the filesystem mounted on '/' know that /dev is a mountpoint?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.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Why would it need to? All the root file system would need is an empty directory where DevFS will be mounted (/dev for example..).MarkOS wrote:but when I read the dir /dev, how can the filesystem mounted on '/' know that /dev is a mountpoint?
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.
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?
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?
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.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?
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.
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.