#!/bin/sh # # fhfind: takes the expanded filehandle string from an # NFS write error or stale filehandle message and maps # it to a pathname on the server. # # The device id in the filehandle is used to locate the # filesystem mountpoint. This is then used as the starting # point for a find for the file with the inode number # extracted from the filehandle. # # If the filesystem is big - the find may take a long time. # Since there's no way to terminate the find upon finding # the file, you may need to kill fhfind after it prints # the path. # if [ $# -ne 8 ]; then echo echo "Usage: fhfind e.g." echo echo " fhfind 1540002 2 a0000 4df07 48df4455 a0000 2 25d1121d" exit 1 fi # Filesystem ID FSID1=$1 FSID2=$2 # FID for the file FFID1=$3 FFID2=`echo $4 | tr [a-z] [A-Z]` # uppercase for bc FFID3=$5 # FID for the export point (not used) EFID1=$6 EFID2=$7 EFID3=$8 # Use the device id to find the /etc/mnttab # entry and thus the mountpoint for the filesystem. E=`grep $FSID1 /etc/mnttab` if [ "$E" = "" ] ; then echo echo "Cannot find filesystem for devid $FSID1" exit 0 fi set - $E MNTPNT=$2 INUM=`echo "ibase=16;$FFID2" | bc` # hex to decimal for find echo echo "Now searching $MNTPNT for inode number $INUM" echo find $MNTPNT -mount -inum $INUM -print 2>/dev/null