mdf wrote:
> There is a check in the function implementing readdir(3) for a zero
> inode number:
> 
> struct dirent *
> _readdir_unlocked(dirp, skip)
> DIR *dirp;
> int skip;
> {
> /* ... */
> if (dp->d_ino == 0 && skip)
> continue;
> /* ... */
> }
> 
> "skip" is 1 except for when coming from _seekdir(3).
> 
> I don't recall any requirement that a filesystem not use an inode
> numbered 0, though for obvious reasons it's a poor choice for a file's
> inode. So... is this code in libc incorrect? Or is there
> documentation that 0 cannot be a valid inode number for a filesystem?
> 
Well, my recollection (if I'm incorrect, please correct me:-) is that, for
real BSD directories (the ones generated by UFS/FFS, which everything else
is expected to emulate), the d_ino field is set to 0 when the first entry
in a directory block is unlink'd. This is because directory entries are not
permitted to straddle blocks, so the first entry can not be subsumed by the
last dirent in the previous block.

In other words, when d_ino == 0, the dirent is free.

rick
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to