Implementing a make command

Simon Fowler simon at himi.org
Sun Feb 17 15:02:41 EST 2002


On Sun, Feb 17, 2002 at 02:20:42PM +1100, Michael Still wrote:
> 
> Heidi ho,
> 
> I would like to play with my own filesystem type, which means I need to
> implement a mikalmount command. I have the code to smbmount, but it isn't
> very heavily commented.
> 
> Is anyone aware of any good introductions on the requirements of these
> mount commands? Also, once you have created the mount point, how does the
> operating system actually access files on that filesystem?
> 
Are you looking at putting the filesystem code in the kernel? If so,
you most likely /won't/ need your own mount program - mount(8)
passes all the information you'll need. You only need an extra mount
program to handle really odd stuff like extra authentication and so
forth. 

On Linux, filesystem drivers hook into the VFS by providing a
collection of methods (see fs.h - struct inode_operations, struct
file_operations, struct super_operations, and struct
address_space_operations for advanced stuff). You register a
filesystem using DECLARE_FSTYPE() and register_filesystem(), which
only cares about your super_operations. Each object (struct inode,
struct super_block, struct file) has a pointer to the appropriate
array of methods, and you have to set this up at the point you
initialise each object - after that, the VFS simply access your
methods via the pointer. 

There's some documentation under Documentation/filesystems, but it's
generally out of date - there's some new stuff in 2.5.5-pre*, I
believe, but I haven't checked it out. The best approach is to grep
through fs/*/ and try and work things out yourself . . . 

I have some code I wrote for an assignment that implements a fairly
simple ramfs which would show the basic ideas if you want - it's not
very good, but it does work, for certain values of 'work'.

Another thing: use UML! It makes kernel development so much simpler
to be able to killall -9 linux when things go wrong, and you don't
have to worry about screwing up your /real/ box's filesystem. You
can also run gdb on it, which is /fun/ ;-) ("Let's all single step
through the page fault path! Wheee!" ;-)

Good luck . . .

Simon

-- 
PGP public key Id 0x144A991C, or ftp://bg77.anu.edu.au/pub/himi/himi.asc
(crappy) Homepage: http://bg77.anu.edu.au
doe #237 (see http://www.lemuria.org/DeCSS) 
My DeCSS mirror: ftp://bg77.anu.edu.au/pub/mirrors/css/ 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.samba.org/archive/linux/attachments/20020217/79c7819e/attachment.bin


More information about the linux mailing list