Subject: Re: bin/560: ls -i returns incorrect inodes on symlinks and root dirs
To: Charles M. Hannum <>
From: I can teach you how to fish... <>
List: netbsd-bugs
Date: 11/08/1994 12:46:56
#define AUTHOR " ("Charles M. Hannum")"

 * I just consulted the POSIX.1 and POSIX.2 specifications on this, and
 * it is my interpretation that if we were to change ls(1) to print the
 * inode number of the mounted-on directory, we would also have to change
 * stat(2) to return the st_ino and st_dev for the mounted-on directory.

Why is this?  ls(1) uses the directory structure to get inums, stat(2)
goes out and actually LOOKS at the inode, completely ignoring the inode
number in the directory.  They're doing two different things.

 * I believe this would be a lose.

As you describe it, yes.

 * However, it seems like a performance win to optimize away the stat(2)s
 * for non-directories, and I will do this.

Actually, I believe that's probably why inos for mounted-on directories
would show up, instead of the ino for the root of the filesystem associated
thereto:  performance.

If you *really* interpret POSIX in the way you do, then OK and I suppose
nothing will change your mind.

I must say, though, it seems kind of silly to me to make an exemption
for non-directories in this fashion.  Seeing as you're already reading
the directory and sorting the structures by name, there's nothing
preventing you from using the d_fileno.  Doing this straight instead
of exempting directories will also avoid unnecessary coding.

Just my { char	x:2;}, YMMV.


#undef AUTHOR	/* " ("Charles M. Hannum")" */

 _______Wizardry is dead._____ _____WHO: Greywolf (my nameplate even says so)
/ ___\ _ \ __\ V / \  / /__ \| | __/WHAT: UNIX System, Admin
\ \| |   < _| ` ' \ '` / \/ /|_| _/ WHERE: Autodesk, Inc.  3 Harbor Dr.
 \___|_|\_\__\|_|  \/\/ \__/___/_|  Sausalito, CA 94965 (415) 332-2344 x4219
	see also: