From owner-freebsd-fs@FreeBSD.ORG Tue Nov 11 21:13:56 2008 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BA3741065679 for ; Tue, 11 Nov 2008 21:13:56 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (chez.mckusick.com [64.81.247.49]) by mx1.freebsd.org (Postfix) with ESMTP id 564638FC2E for ; Tue, 11 Nov 2008 21:13:56 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (localhost [127.0.0.1]) by chez.mckusick.com (8.14.2/8.14.2) with ESMTP id mABKxL3Z068989; Tue, 11 Nov 2008 12:59:22 -0800 (PST) (envelope-from mckusick@chez.mckusick.com) Message-Id: <200811112059.mABKxL3Z068989@chez.mckusick.com> To: Attila Nagy Date: Tue, 11 Nov 2008 12:59:21 -0800 From: Kirk McKusick Cc: freebsd-fs@freebsd.org Subject: Re: Different inodes X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Nov 2008 21:13:56 -0000 To: Peter Jeremy Cc: freebsd-fs@freebsd.org Subject: Re: Different inodes > On 2008-Nov-10 16:36:56 +0100, Attila Nagy 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