lkml.org 
[lkml]   [1997]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: VFS
> Yes, I do [and I suppose this is true for all file systems].
>
> NFS must go though the local file system on one end. It uses
> file handles too, not inode numbers.

Come on, what exactly is a file handle in the Linux kernel?
Please consider the user space nfsd. For each file that is opened,
it creates an NFS filehandle and passes it to the client. This handle
encodes the inode number and some other magic.

Now suppose the server reboots, i.e. all transient state on the server
side is lost - only the persistent state (on disk) remains. If the
client now comes with the NFS filehandle, unfsd searches the entire
volume (i.e. all names) for the file with that very inode number. This
is how it works.

> For reference, could you name a few other programs that want
> to use inode numbers? [AFAIK, there are no system calls that
> take inode numbers as args.] Thanks.

I grepped the source of fileutils 3.15 for st_ino, and this is what I
found. Please note that you could have done that easily yourself:
- lib/rename.c uses st_ino to avoid renaming a file to itself. To do so,
it tests whether device and inode number are the same.
- In cp, cp-aux.c:is_ancestor performs the same test. The function is
given a list of ancestors, and decides whether a specific struct stat
is part of that list.
- cp.c:copy does this test to a) remember what files it already copied
and b) avoid copying a file onto itself.
- df:find_mount_point repeatedly changes to ".." until it a) either
hits a file that is on a different device or b) hits the same inode
number twice (which must be the root directory)
- install:copy_file wants to avoid copying files onto themselves.
- ln:same_name not only tests for the same file, but also for same
file name.
- ls:print_long_format prints the inode number (this is the one you
already mentioned)
- mv does the test for moving a file onto itself
- mvdir checks whether a directory is going to be moved into one of
its subdirectories, using devices and inode numbers.

So if you implement funny inode number semantics, you are going to
break half of /bin.

Regards,
Martin

\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.109 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site