SUMMARY: Is find broken on 2.5.1?

From: Edward Finch (efinch@eos.hitc.com)
Date: Tue Feb 04 1997 - 09:28:47 CST


Sorry for the delay in posting my summary!

My original question:

The following commands:

     find / -local -print

and

     find / -fstype nfs -prune -o -print

both recurse into NFS-mounted directories.

What am I doing wrong? How can I look for files only
on the local system? This is for a script that will
run on multiple platforms, so I don't want to parse
/etc/mnttab, etc.

---------------------

I would like to thank the following people for their replies:

Rick Schieche <scud@lewis-deh2.army.mil>
Trevor Paquette <tpaquett@aec.ca>
Michael Sullivan <mike@trdlnk.com>
Kris Briscoe <hxktb0@svho1nfs_1.supervalu.com>
Jim Harmon <jim@telecnnct.com>
Chris Marble <cmarble@orion.ac.hmc.edu>
AO <cherub@lava.net>
Casper Dik <casper@holland.Sun.COM>
Lawson A S <tony@csmail.essex.ac.uk>
Ross Stocks <ROSS.STOCKS.PSD36651@nt.com>
James K Brigman <brigjk@aur.alcatel.com>
Russ Poffenberger <poffen@San-Jose.ate.slb.com>
Tom Powers <tomp@cwix.net>
Gerhard den Hollander <gerhard@jason.nl>
Ing. Francisco J. Donderis L. <fadal@sonitel.com>

-----------------------

The answers have been grouped into the following categories:

1) Use the -mount or -xdev option of the find command. This doesn't work for
   me because some of our machines have /, /usr, etc on different filesystems.

2) Use find / -fstype nfs -prune -o -print. This doesn't work on the 2.5.1
   machines we have. I verified that /etc/dfs/fstypes contains
   "nfs NFS Utilities"

3) find / -local -print -o -prune. See #2.

4) find / -fstype ufs -print. The original post stated that the script needs
   to run on multiple architectures.

5) find / -fstype 4.2 -prune -o -print. See #4.

6) Casper Dik wrote:

It's a problem with what NFS v3 mounts return as "fstype" and the types
find considers local.

You could try "-fstype nfs3" or add "nfs3" to /etc/dfs/fstypes
(though that may have other side effects)

I didn't want to fiddle with /etc/dfs/fstypes, so I didn't try this.

7) Use the -local option of the find command. Several people pointed out that
   this _will_ descend into NFS mounts, it just doesn't print anything. Some
   of our NFS-mounted filesystems are huge, so this didn't work either.

8) Use find / -print -o -fstype nfs -prune. Another good suggestion, but it
   behaves the same as mine.

9) Look into GNU tar. We have lots of architectures (18) to be exact, and I
   didn't want to setup that many versions.

10) Use /bin/find. Perhaps it was aliased on my machine? (Nope.)

11) Use find / -fstype ufs -prune -o -print. See #2, #8 and #4.

------------------------

My solution was to parse all the fstabs :(

I learned a lot, and it does come in handy. The /bin/sh scriptette:

case `uname -sr` in

   "AIX 2")
      FILE_SYSTEMS=`cat /etc/filesystems | sed -e 's/\:$//g' | awk '{ if
(index($1,"/") == 1 ) { part=$1 } if (NF == 3 ) { if ($1=="mount" && $3 !=
"false") { print part } } }'`;;

   "HP-UX A.09.05")
      FILE_SYSTEMS=`grep '^/dev/' /etc/checklist | grep -v ' swapfs ' | awk
'{if (index($2,"/") == 1 ) print $2}'`;;

   "HP-UX B.10.01")
      FILE_SYSTEMS=`grep '^/dev/' /etc/checklist | grep -v ' swapfs ' | awk
'{if (index($2,"/") == 1 ) print $2}'`;;

   "IRIX 5.3")
      FILE_SYSTEMS=`grep '^/dev/' /etc/fstab | awk '{if (index($2,"/") == 1 )
print $2}'`;;

   "IRIX 6.2")
      FILE_SYSTEMS=`grep '^/dev/' /etc/fstab | awk '{if (index($2,"/") == 1 )
print $2}'`;;

   "IRIX64 6.2")
      FILE_SYSTEMS=`grep '^/dev/' /etc/fstab | awk '{if (index($2,"/") == 1 )
print $2}'`;;

   "OSF1 V3.0")
      FILE_SYSTEMS=`cat /etc/fstab | awk '{if (index($2,"/") == 1 ) print
$2}'`;;

   "OSF1 V3.2")
      FILE_SYSTEMS=`cat /etc/fstab | awk '{if (index($2,"/") == 1 ) print
$2}'`;;

   "OSF1 V4.0")
      FILE_SYSTEMS=`cat /etc/fstab | awk '{if (index($2,"/") == 1 ) print
$2}'`;;

   "SunOS 4.1.1")
      FILE_SYSTEMS=`grep '^/dev/' /etc/fstab | awk '{if (index($2,"/") == 1 )
print $2}'`;;

   "SunOS 4.1.3")
      FILE_SYSTEMS=`grep '^/dev/' /etc/fstab | awk '{if (index($2,"/") == 1 )
print $2}'`;;

   "SunOS 4.1.3_U1")
      FILE_SYSTEMS=`grep '^/dev/' /etc/fstab | awk '{if (index($2,"/") == 1 )
print $2}'`;;

   "SunOS 4.1.4")
      FILE_SYSTEMS=`grep '^/dev/' /etc/fstab | awk '{if (index($2,"/") == 1 )
print $2}'`;;

   "SunOS 5.2")
      FILE_SYSTEMS=`grep '^/dev/' /etc/vfstab | awk '{if (index($3,"/") == 1 )
print $3}'`;;

   "SunOS 5.3")
      FILE_SYSTEMS=`grep '^/dev/' /etc/vfstab | awk '{if (index($3,"/") == 1 )
print $3}'`;;

   "SunOS 5.4")
      FILE_SYSTEMS=`grep '^/dev/' /etc/vfstab | awk '{if (index($3,"/") == 1 )
print $3}'`;;

   "SunOS 5.5")
      FILE_SYSTEMS=`grep '^/dev/' /etc/vfstab | awk '{if (index($3,"/") == 1 )
print $3}'`;;

   "SunOS 5.5.1")
      FILE_SYSTEMS=`grep '^/dev/' /etc/vfstab | awk '{if (index($3,"/") == 1 )
print $3}'`;;

   *)
      echo "Unsupported system type: $sys_type"
      exit 1;;

esac

export FILE_SYSTEMS

I realize that a lot of lines are duplicated; I was cutting-and-pasting, and
it seemed easier to leave them as they are. If you find any bugs, or make any
additions, please forward them to me. Perhaps this can be archived or posted
periodically.

Thanks again for all of your responses,
Ed

-- 
Ed Finch
System & ClearCase Administrator
NASA's Earth Observation System, "Mission To Planet Earth"

---

"When you say 'I wrote a program that crashed Windows', people just stare at you blankly and say 'Hey, I got those with the system, *for free*"

- Linus Torvalds



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:44 CDT