Finding links

The Wheel in the Sky swc at griffin.uvm.edu
Sun Oct 22 14:22:54 AEST 1989


in article  <598 at cogent.UUCP> (Doug Perlich) writes:
>I might be located in directory xyz and I think "Hmm, I want to know what
>the name of the link to the file foobar is".

Given one path name of a file, find all other directories entries
pointing to the same file.  This means all directory entries with the
same inumber on the same file system as the given file name.

ncheck reports all the directory entries along with the inode they
point to.  You can also select just a certain inode to list pathnames
for.  Use ls -i to get the inumber for the file you want to
cross-reference.

A much slower method but one that doesn't require read access to the
special file uses find.  This also decends the fs tree to other
filesystems and across nfs mounts, but this can be prevented by cd'ing
to the mount point of the filesystem containing the file and by -xdev
option [-prune is documented but not yet implemented for SunOS4.0.3].

swc at kira>mkdir xyz abc
swc at kira>touch xyz/foobar
swc at kira>ln xyz/foobar abc/foobee
swc at kira>ls -i xyz/foobar
 15106 xyz/foobar
swc at kira>find . -inum 15106 -xdev -ls
15106    0 -rw-r--r--  2 root     daemon    0 Oct 21 23:54 ./xyz/foobar
15106    0 -rw-r--r--  2 root     daemon    0 Oct 21 23:54 ./abc/foobee
swc at kira>df xyz/foobar
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/xd0h             494269  406091   38751    91%    /home
swc at kira>ncheck -a -i 15106 /dev/xd0h
/dev/xd0h:
15106   /tmp/xyz/foobar
15106   /tmp/abc/foobee

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Steve Chappelow         System TroubleShooter          EMBA Computer Facility  
(swc at uvm.edu || uunet!uvm-gen!swc)	               (802)656-2926



More information about the Comp.unix.questions mailing list