Different inodes

Kirk McKusick mckusick at mckusick.com
Tue Nov 11 13:13:56 PST 2008


To: Peter Jeremy <peterjeremy at optushome.com.au>
Cc: freebsd-fs at freebsd.org
Subject: Re: Different inodes

> On 2008-Nov-10 16:36:56 +0100, Attila Nagy <bra at fsn.hu> wrote:

> It seems that symlinks are inconsistent then listing them with "ls -i" 
> directly, but with "ls -Ri" shows no errors. Also, I didn't faced any 
> problems so far when switching NFS servers.

When you do an `ls -i' of a directory, the `ls' command does a stat()
of the name, discovers that it is a directory, does a readdir of the
directory, and prints out the inode numbers listed for each entry in
the directory. For entries that are symbolic links, the inode number
in the directory is the inode number of the symbolic link.

When you do an `ls -i' of a name which is a symbolic link, `ls' does
a stat() of the name. When you do a stat() of a symbolic link, you
follow the link, so the stat infor that comes back is for the thing
to which the symbolic link points. Thus when it prints the inode
number, you get the inode number of the file to which the symbolic
link points. To get the inode number of the symbolic link, `ls'
would have to do an lstat() instead of a stat(). That would be a
rather drastic change of historic behavior.

	Kirk McKusick


More information about the freebsd-fs mailing list