IMFS: yet another trouble.

Sergei Organov osv at javad.ru
Wed Nov 29 08:48:53 UTC 2000


jennifer averett <jennifer.averett at oarcorp.com> writes:
[...]
> > Oh, yes. As always I've already found it myself yesterday. Now everything
> >works just great! I'd like to mention in addition that 'st_dev' and 'st_ino'
> >fields of 'struct stat' should be set in the file-system 'fstat' routine to
> >some unique values, otherwise 'getcwd()' doesn't work. It'd be fine to
> >mention this fact in the documentation if it's not already there (at least I
> >didn't find it).
> >
> >
> 
> This points to a problem in the IMFS, st_dev is only set if the node is a
> device node.  Looking at getcwd I have a question: This code is identifying
> the root node by the combination of st_ino and st_dev.  This implies that on
> a given device no two nodes can have the same identity.  We have no
> guarantee of this.  Currently each file system assigns its own node id, (in
> the IMFS this id is based upon instance of the file system - therefore if
> the file system were mounted twice there would be two nodes with the same
> id).

As far as I understand, the idea behind st_ino and st_dev pair is that in pair 
they identify a node uniquely. Usually st_ino is block number on some device
(unique within device) and st_dev is device id (globally unique number). For
in memory file system, the st_dev could be some arbitrary unique number that
is the same for all instances of IMFS (in fact it tells that device is RAM),
and st_ino could be just unique pointer, e.g. pointing to the beginning of
particular file. The st_dev should change if IMFS instance is working on top
of some device other than RAM, e.g., NVRAM or something that doesn't share
address space with RAM and thus st_ino values on that device may match those
in RAM by collision.

In fact, AFAIK, in most Unixes st_dev is also subdivided to major and minor
device number. The major number then  specifies a class of devices, and minor
number -- particular device of the class. To mimic this it's possible to
assign arbitrary unique major number to RAM, and use minor number 0 for
current instances of IMFS because all of them operate on the same device, --
RAM.

Best Regards,
Sergei Organov.




More information about the users mailing list