Re: glibc is the culprit - Re: vfs.txt and i_ino

From: Guest section DW (dwguest@win.tue.nl)
Date: Sun Feb 10 2002 - 08:23:00 EST


On Sun, Feb 10, 2002 at 11:58:48AM +0000, Anton Altaparmakov wrote:

> So glibc is for some reason hiding inode zero from us...

Well, we can read the source..
For example, sysdeps/unix/readdir.c:

/* Read a directory entry from DIRP. */
DIRENT_TYPE *
__READDIR (DIR *dirp) {
        do {
                ...
                /* Skip deleted files. */
        } while(dp->d_ino == 0);

        return dp;
}

Or, for example, sysdeps/generic/glob.c:

# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)

The glibc code assumes that a zero ino
means a file that is to be skipped.

Many filesystem types use a zero d_ino to denote a deleted file.
Of course user space should not worry about such things -
the readdir system call should only return non-deleted items -
but some systems leave this visible.
(Also in the Linux kernel source one finds places where either
ino is returned, or 0, in case no ino was found.)

It is probably best to avoid giving real files ino 0.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Feb 15 2002 - 21:00:32 EST