SUMMARY: inode2filename

From: Miller Alan <Alan.Miller_at_is-energy.de>
Date: Fri Sep 26 2003 - 14:40:30 EDT
The winner is:

	Michael.J.Watson@wellsfargo.com

		who sent me a nifty little script that parses the pfile output,
		to determine the inode, major, and minor numbers  and then run
		an appropriate ff command (similar to ncheck, see below)
		unfortunately it didn't exactly work for me (think cause of veritas)
		also relies on a find command (but is limited to /dev tree)

		the script is attached

the runner-up was:

	Martin Schmitt [mas@scsy.de]

		Who told me about the ncheck command.

		ncheck -i <inode>
			[root@server] ncheck -i 986876
			/dev/vx/dsk/rootvol:
			986876  /devices/pseudo/random@0:urandom

		Caveaut:
		ncheck still scans the file systems but the scan can be limited
		to a specific FS
			[root@server] ncheck -i 986876 /dev/vx/dsk/usr_local_vol
		or to specific FS-Types (all ufs FSs in vfstab)
			[root@server] ncheck -i 986876 -F ufs
		you still need to know which FS the inode is on

basically, everybody else told me to run: "find /mount -inum <xxx> -print"
I prefer the pfiles/ff method since running find or ncheck on all my file
systems
which are fairly large, takes too long.

	Bertrand_Hutin@fr.ftsi.fujitsu.com
	Glass, David [david.glass@bg-group.com]
	Bennett, Steve [s.bennett@lancaster.ac.uk]
	Hendrik Visage [hvisage@is.co.za]
	Tony_Schloss@ao.uscourts.gov
	Dominic Clarke [dominicc@foe.co.uk]
	Urie, Todd [TUrie@trueposition.com]
	Brett Lymn [blymn@baesystems.com.au]
	Lieven Marchand [lieven.marchand@just.fgov.be]
	Bob Rahe bob@dtcc.edu
	George Schlossnagle [george@omniti.com]
	Jeff Horwitz [jhorwitz75@yahoo.com]
	Kevin Buterbaugh [Kevin.Buterbaugh@lifeway.com]
	adh@an.bradford.ma.us
	Darren Dunham [ddunham@taos.com]
	Jay Lessert [jayl@accelerant.net]
	Victor Belei [vbelei@counterpane.com]

Again thanks to everybody for their quick responses.

BTW: The following people are not in their offices:

	Brown, Rob [Rob@bskyb.com]
	Manohar Nayak [Manohar@Yodlee.com]
	RHEAULT, ROBERT R [ROBERT_R_RHEAULT@fleet.com]
	Granzow, Doug (NIH/NCI) [granzowd@mail.nih.gov]
	Vmer Cankardes [omeca@kocbank.com.tr]
	Karien Depijper [karien.depijper@telindus.com]


--
Alan Miller
is:energy  GmbH
Unit Operations, Operating Systems - OPOO
Tresckowstrasse 3
30457 Hannover
Telefon: (0511) 439-4292		Telefax: (0511) 439-4226
Email: alan.miller@is-energy.de	I-Net: <www.is-energy.de>
# #!/bin/ksh
#
apNF() { nawk ' {print $NF} '; }
ap2()  { nawk ' {print $2} '; }

if [  "`/usr/xpg4/bin/id -u`" !=  "0" ] ; then
   echo
   echo "This script doesn't run correctly unless run as root."
   echo "...Exiting..."
   echo
   return 1
fi

rm /tmp/pfcn* 2>/dev/null

if [ -n  "$1" ]
then
  pfiles $1  > /tmp/pfcnv
else
  echo
  echo  "Usage:  >$0  <pid>"
  echo
  echo  "   Exiting."
  echo
  exit 1
fi
if [ $? -ne 0 ]
then
  exit 2
fi

echo
echo "Starting pfile conversion script."
export PID=$1
echo "PID is $PID:"
# echo "`ps -ef | egrep $1 | awk '$2 == $PID {print $0}'`"
# For some reason, the above command should work but doesn't...?
echo
echo "Output format is:"
echo "Inode	Filename Filesize Owner"
echo

egrep S_IF /tmp/pfcnv | cut -d: -f2- | sort -u | \
      while read FT MODE DEV INO UID GID RDEV
do
  MAJ=`echo $DEV | cut -d: -f2 | cut -d, -f1`
  MIN=`echo $DEV | cut -d: -f2 | cut -d, -f2`
  INO=`echo $INO | cut -d: -f2`
  echo "$MAJ:$MIN\t\t$INO" >> /tmp/pfcnv2
done

for i in `cut -d"	" -f1 /tmp/pfcnv2 | sort | uniq`;do
   export INOLST=""
   for k in `egrep $i /tmp/pfcnv2 | cut -c8- | sort -nu`;do
      if [ -n "$k" ]; then
         if [ -z "$INOLST" ]; then
           INOLST=$k
         else
           INOLST="$INOLST,$k"
         fi
      fi
   done
   echo "$i\t\t$INOLST" >> /tmp/pfcnv3
done

cat /tmp/pfcnv3 | while read MM INOLST2 
do
   echo $MM | tr ":" " " | read MJ MN
   if [ $MN -lt 10 ]; then
      MN="   $MN"
   elif [ $MN -lt 100 ]; then
      MN="  $MN"
   elif [ $MN -lt 1000 ]; then
      MN=" $MN"
   fi
   CURRDEV=`find /devices -ls | egrep "$MJ,$MN" | egrep -v raw | nawk '{print $12}'`
   if [ -n "$CURRDEV" ]; then
      /usr/sbin/ff -uls -i $INOLST2 `find /dev -ls | egrep $CURRDEV | egrep -v rdsk | nawk '{print $11}'`
   else
      echo "Filesystem with numbers $MJ,$MN and inode(s) $INOLST were not found."
      echo
   fi
done
rm /tmp/pfcn*
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Fri Sep 26 14:40:25 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:20 EST