help-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-HURD] libdiskfs


From: marco
Subject: Re: [Help-HURD] libdiskfs
Date: Sun, 18 May 2003 22:47:09 +0200 (CEST)

> I am trying to understand hurd programming interface for filesystem
> drivers. I am currently reading fatfs, since it should be quite simple
> compared to  other fs, but it is not very easy :-(
> Where can get info about how do diskfs/pager/store work?
> Should i try to understand a linux fs driver before?
> Anyway it seems simpler, since linux fs drivers do register functions
> like open/write/read/readlink/..., and there is no implicit pager
> library.

It is very hard to understand libdiskfs because it uses many libraries.
Not even fatfs is easy to understand (and not even working perfectly!). In
fact fatfs is the worse example there is because fat doesn't use inodes,
this makes the code really complex because inode numbers are generated,
etc.

The most simple (IMO) libdiskfs translator is tmpfs. tmpfs does not use a
real stored filesystem, instead of that it uses memory to store files in.
In fatfs, ext2fs, etc there is much code to access the fat partition, etc.

The calls you talk about are implemented using callback funtions in the
translator:

open is handled by both dir.c (diskfs_lookup_hard). This routine mainly
translates filenames to inode numbers by looking them up in the dirent. It
is also used for finding free slots for new dirents. Please ignore this
function and everything it calls because it is one of the hardest
functions to understand.

The second callback used for open is diskfs_cached_lookup, it reads the
inode of disk(into a struct stat) if it isn't in the cache by calling
read_node(read_node is not a must to implements, but it is done this way
in most translators) so libdiskfs can check permissions, etc.

write and read are implemented in pager.c by implementing pager_read_page
and page_write page. Every open file has its own pager. The actual reads
and writes are performed by libdiskfs and these pager callbacks read and
write a part of the file when it is not in memory.

To handle creation of links, directories, etc. there are some callback
funtions in dir.c

Ofcourse all mentions filenames don't (have to) exist for all libdiskfs
translators, but most (if not all) use these names.

I cannot answer your question about how difficult this is to learn
compared to the linux filesystem interfaces, but I know this is the
hardest library to learn about in the Hurd. You can better start with
libtrivfs and libnetfs.

I hope this mail answered all of your questions, if it did not free free
to ask more questions.

Thanks,
Marco







reply via email to

[Prev in Thread] Current Thread [Next in Thread]