IMFS: yet another trouble.

jennifer averett jennifer.averett at oarcorp.com
Tue Nov 28 19:07:52 UTC 2000



Sergei Organov wrote:

> jennifer averett <jennifer.averett at oarcorp.com> writes:
> > Sergei Organov wrote:
> >
> > > Hello,
> > >
> > > Using the latest snapshot and attempting to mount my own file-system, I've
> > > got the following trouble:
> > >
> > > When I 'cd' to the directory my file-system is mounted upon and then do
> > > 'cd ..', the IMFS asks my 'eval_path' routine to evaluate "..". Obviously,
> > > ".."  doesn't belong to my file-system, so I can't return my
> > > handlers. Could anybody please tell what my 'eval_path' is supposed to do
> > > in this case?
> > >
> >
> > Your path evaluaton should be capable of going between your filesystem and
> > the filesystem you are mounted upon.  Below is how the IMFS handles this
> > situation.  Since your filesystem is never the root filesystem it doesn't
> > have to check "Am I at the root of all filesystems?".  The mount entry is
> > given to the mounted filesytem at mount time via the fsmount_me method.
> > That should later be used to get into and out of the mounted filesystem.
> > This information should be kept by the filesytem (I'd suggest in it's root
> > node access information)
> >
> >       case IMFS_UP_DIR:
> >
> >          /*
> >           *  Am I at the root of this mounted filesystem?
> >           */
> >
> >          if (pathloc->node_access ==
> >             pathloc->mt_entry->mt_fs_root.node_access) {
> >
> >            /*
> >             *  Am I at the root of all filesystems?
> >             */
> >
> >            if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
> >              break;       /* Throw out the .. in this case */
> >            } else {
> >              newloc = pathloc->mt_entry->mt_point_node;
> >              *pathloc = newloc;
> >              return (*pathloc->ops->evalpath)(&(pathname[i-len]),flags,pathloc);
> >            }
> >      } else {
>
> 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).

>
> > <SNIP>

Jennifer




More information about the users mailing list