romfs main structure

146 views
Skip to first unread message

proclus_arabus

unread,
Dec 12, 2010, 10:09:53 PM12/12/10
to romfs discussion
I am trying to read and understand the romfs source code. I must say
that it is very badly explained and commented. for example, I got
stuck at understanding what the function romfs_readdir does. it
apparently reads a directory entry, but beyond that no clue. also,
what is the purpose of the operation

offset = i->i_ino & ROMFH_MASK;

it apparently shaves the low 4 bits of inode no, but why?

there are many more questions to be asked, but this two are the most
immediate.



chexum

unread,
Dec 13, 2010, 3:31:43 AM12/13/10
to romfs discussion
You need to read the source together with the fs format documentation
(found on the sourceforge page, or the kernel source). Sadly, a large
part of any filesystem code is interfacing other parts of the kernel,
and it would be awkward to document the rest of the kernel from within
a different component.

A readdir() function (referenced from romfs_dir_operations) is the
workhorse to do what you expect from the ls command. It can be called
on a directory, and the fs is requried to return the list of files in
that directory. How it's returned was streamlined in the past few
years, so it's not very straightforward, but it has to cope with much
more complex filesystems as well.

In romfs the inode of a file is actually the location of the file
metadata on disk, but it has to be on a 16-byte boundary.
Technically, it should come from the kernel itself, so it should
already be safe, but it made sense at the time.

Janos

proclus_arabus

unread,
Dec 14, 2010, 3:00:10 AM12/14/10
to romfs discussion
thanks a lot for the info. I have of course read the fs format
documentation before writing to this post, but it was of no great
help, because how VFS uses the romfs metadata is not there. For
example, file offset is employed as inode no, but this is not written
down in that document.

I think your sentence

>A readdir() function (referenced from romfs_dir_operations) is the
> workhorse to do what you expect from the ls command. It can be called
> on a directory, and the fs is requried to return the list of files in
> that directory.

should be embedded as a comment in the source code.

After I have received your letter, I generated an example file
structure by using genromfs and a lot of things came to light. The
only thing that is still dark is the meaning of the spec.info field in
the file header. Again, I can guess it's meaning, but I never trust at
my guesses! :-)

Thanks again,
-mehmet

chexum

unread,
Dec 14, 2010, 2:37:13 PM12/14/10
to romfs discussion
As I mentioned, I'm not sure how much of the rest of the kernel should
be documented from inside romfs. All the filesystems are working the
same way. Although I tend to believe romfs is one of the simpler
ones, but the drawback is that it might be too simple as it doesn't
support many features all of the normal filesystems do.

spec.info by the way is again documented in the layout format, it's
the type specific information needed for hard links, directories and
device nodes.

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/filesystems/romfs.txt#l118
Reply all
Reply to author
Forward
0 new messages