Check for 0 ino_t in readdir(3)

mdf at FreeBSD.org mdf at FreeBSD.org
Tue Jun 7 17:32:08 UTC 2011


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?

If 0 cannot be a valid inode number, my GSoC mentee Gleb suggested
d_fileno == 0 be skipped in dirent_exists() as used by
vop_stdvptocnp(9), and also skipped by unionfs.

Thanks,
matthew


More information about the freebsd-hackers mailing list