Messages in this thread | | | Date | Fri, 25 Jul 1997 09:35:46 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: VFAT 2.1.47 |
| |
On Fri, 25 Jul 1997, Andreas Schwab wrote: > > Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> writes: > > |> Below is my attempt of a vfat fix for Linux 2.1.47. > |> Please review. > > There is likely to be one problem that i also tripped along while porting > msdos: you must not return ENOENT from lookup, instead only the fact that > dentry->d_inode is NULL tells the VFS that the file does not exist. Thus > you should change all `return -ENOENT' in vfat_lookup to `return 0'. This > also includes the implicit ENOENT that you may get from vfat_find.
Right. The reason you have to do this is because the VFS layer actually uses the negative dentry for a few things:
- it's a negative cache, so that the VFS layer doesn't need to call down to the filesystem the next time around if somebody keep trying to look up nonexistent files (which happens a lot with path lookup, for example).
- a negative dentry is also a placeholder for _becoming_ a real dentry. When you create a new file, you will do a lookup of the file which will start out as a negative dentry, and then the create function will turn that negative dentry into a real dentry.
The second use for negative dentries allows us to do various things a lot more cleanly than the old code did - creating a new file by following a symlink is just one of these. The old code had to do this in two stages: first look up all but the last part of the filename, and then handle the last part specially. The new dentry code avoids all special cases, to a large degree thanks to using negative dentries.
Linus
| |