VOP_LOOKUP of .. in msdosfs

Michiel Pelt pelt22 at gmail.com
Sat Aug 5 15:17:53 UTC 2006


Hi,

I am developing a filesystem which doesn't have a . and .. in the root. So I
emulate them, just like msdosfs does. I looked at the msdosfs code. Correct
me if I am wrong, but I think there is something wrong with it.

The msdosfs_lookup function in msdosfs_lookup.c has code dealing with the
rootdirectory at the label foundroot:. At line 523 (release 6.1 code) of the
release code is this piece of code:

pdp = vdp;
if (flags & ISDOTDOT) {
   VOP_UNLOCK(pdp, 0, td);
   error = deget(pmp, cluster, blkoff, &tdp);
   vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td);
   if (error)
      return (error);
   *vpp = DETOV(tdp);
}

This code has been copied from ffs code, but fails for msdosfs.
For starters the introduction of the 'pdp' pointer has no function
whatsoever.

Consider a lookup for .. in the root. In msdosfs the /. and /.. directories
are represented by one and the same vnode (see deget() in msdosfs_denode.c).
The deget gets and locks the vnode that was unlocked by VOP_UNLOCK. The
vn_lock that follows fails with a panic because the vnode is already locked.


So why does this not happen in practice? Because the ISDOTDOT case is
handled by vfs_lookup and never reaches VOP_LOOKUP.

I did get the error because I forgot to set the VV_ROOT flag in the vnode
returned by VFS_ROOT ;-(.

Best Regards

Michiel


More information about the freebsd-fs mailing list