Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to keep the find comand from traversing NFS mounts?

336 views
Skip to first unread message

Randall P. Johnson

unread,
Nov 10, 1998, 3:00:00 AM11/10/98
to
Hi,
I'd like to stop the find command from traversing NFS mounted filesystems
on solaris 2.5, 2.5.1, and 2.6 hosts. The "-local" switch doesn't seem to do
the trick. Does anyone know how?

Thanks!
--
Randall P. Johnson
Randy....@mci.com
work (916) 649-6174
fax (916) 649-6062

and...@cucumber.demon.co.uk

unread,
Nov 11, 1998, 3:00:00 AM11/11/98
to
In article <3648D08...@mci.com>,

"Randall P. Johnson" <randy....@mci.com> writes:
>Hi,
>I'd like to stop the find command from traversing NFS mounted filesystems
>on solaris 2.5, 2.5.1, and 2.6 hosts. The "-local" switch doesn't seem to do
>the trick. Does anyone know how?

I think the nearest you can do is specify -mount and list
all the local filesystems.

-local merely stops matches in remote filesystems from
being further processed, but they are still traced as
it might be that a local filesystem is mounted somewhere
inside a remote one and/or some earlier command line
switches might still be applicable to remote files.

Try some refinement based on...

find `awk '$3=="ufs" {print $2}' /etc/mnttab` -mount .....

--
Andrew Gabriel
Consultant Software Engineer


Sheldon T. Hall

unread,
Nov 11, 1998, 3:00:00 AM11/11/98
to
On Tue, 10 Nov 1998 15:47:16 -0800, "Randall P. Johnson"
<randy....@mci.com> wrote:

>Hi,
>I'd like to stop the find command from traversing NFS mounted filesystems
>on solaris 2.5, 2.5.1, and 2.6 hosts. The "-local" switch doesn't seem to do
>the trick. Does anyone know how?

I don't have any NFS file systems, so I can't test this, but O'Reilly's
"Unix Power Tools" suggests the "-o -fstype nfs -prune" clause. The "-o"
may be unnecessary, the example isn't very clear.

-Shel

--
Sheldon T. Hall
sh...@cis.compuserve.com
This message sold by weight, not by volume;
Content may settle during shipment.

Katherine Hosch

unread,
Nov 11, 1998, 3:00:00 AM11/11/98
to
"Randall P. Johnson" wrote:

> Hi,
> I'd like to stop the find command from traversing NFS mounted filesystems
> on solaris 2.5, 2.5.1, and 2.6 hosts. The "-local" switch doesn't seem to do
> the trick. Does anyone know how?

Can't you just do a "find -fstype ufs ...." ?

-- katherine


Katherine Hosch, System Administrator k...@cs.uno.edu
Department of Computer Science 504-280-7190
University of New Orleans 504-280-7228 (fax)
New Orleans, LA 70148 504-723-6953 (pcs)

-- "I read, much of the night, and go south in winter."

James Dennis

unread,
Nov 12, 1998, 3:00:00 AM11/12/98
to
When I have wanted to do this in the past, I've used something like

find / -name junk.out ! -fstype nfs -print

the ! means don't go there.

Jamie

Katherine Hosch wrote in message <3649C0CA...@cs.uno.edu>...

m...@udel.edu

unread,
Nov 12, 1998, 3:00:00 AM11/12/98
to
In article <3649b88a...@storm.columbus.rr.com>,

7670...@compuserve.com wrote:
> On Tue, 10 Nov 1998 15:47:16 -0800, "Randall P. Johnson"
> <randy....@mci.com> wrote:
>
> >Hi,
> >I'd like to stop the find command from traversing NFS mounted filesystems
> >on solaris 2.5, 2.5.1, and 2.6 hosts. The "-local" switch doesn't seem to do
> >the trick. Does anyone know how?
>
> I don't have any NFS file systems, so I can't test this, but O'Reilly's
> "Unix Power Tools" suggests the "-o -fstype nfs -prune" clause. The "-o"
> may be unnecessary, the example isn't very clear.
>
> -Shel
>
> --
> Sheldon T. Hall
> sh...@cis.compuserve.com
> This message sold by weight, not by volume;
> Content may settle during shipment.
>

Actually, you should use

find <path> -fstype ufs <other expressions>

if you want "to stop the find command from traversing NFS mounted
filesystems" rather than -fstype nfs You need -prune if you don't want to
search directories below the first pattern matched.

--
Mikhail Gloukhovtsev m...@udel.edu

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

John Kotches

unread,
Nov 12, 1998, 3:00:00 AM11/12/98
to
James Dennis wrote:
>
> When I have wanted to do this in the past, I've used something like
>
> find / -name junk.out ! -fstype nfs -print
>
> the ! means don't go there.
>
> Jamie

Isn't -local also an appropriate (and much shorter)solution?


Let's see what "man find" says

-local True if the file system type is not a remote
file system type as defined in the
/etc/dfs/fstypes file. nfs is used as the
default remote filesystem type if the
/etc/dfs/fstypes file is not present.

Many times a simple way is provided :-)

Cheers everyone.


> Katherine Hosch wrote in message <3649C0CA...@cs.uno.edu>...

> >"Randall P. Johnson" wrote:
> >
> >> Hi,
> >> I'd like to stop the find command from traversing NFS mounted filesystems
> >> on solaris 2.5, 2.5.1, and 2.6 hosts. The "-local" switch doesn't seem to
> do
> >> the trick. Does anyone know how?
> >

> >Can't you just do a "find -fstype ufs ...." ?
> >
> >-- katherine

> >
> >Katherine Hosch, System Administrator k...@cs.uno.edu
> >Department of Computer Science 504-280-7190
> >University of New Orleans 504-280-7228 (fax)
> >New Orleans, LA 70148 504-723-6953 (pcs)
> >
> >-- "I read, much of the night, and go south in winter."
> >
> >

--
************************************************************
* A goofy Unix SA working for a large computer equipment *
* manufacturer and services provider. Opinions expressed *
* are mine and not my employers. jkotches@_pobox_.com *
************************************************************

Casper H.S. Dik - Network Security Engineer

unread,
Nov 12, 1998, 3:00:00 AM11/12/98
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

Katherine Hosch <k...@cs.uno.edu> writes:

>"Randall P. Johnson" wrote:

>> Hi,
>> I'd like to stop the find command from traversing NFS mounted filesystems
>> on solaris 2.5, 2.5.1, and 2.6 hosts. The "-local" switch doesn't seem to do
>> the trick. Does anyone know how?

>Can't you just do a "find -fstype ufs ...." ?


No. That command will examine only files on ufs filesystems, but it
will a lso traverse nfs mounts looking for them. (It's just like -type f;
it looks at all files)

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

Casper H.S. Dik - Network Security Engineer

unread,
Nov 12, 1998, 3:00:00 AM11/12/98
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

"James Dennis" <jde...@netset.com> writes:

>When I have wanted to do this in the past, I've used something like

>find / -name junk.out ! -fstype nfs -print

>the ! means don't go there.


No, it means "ignore the file if it's not an nfs file".

It will still look at all nfs files.

You need to use -xdev, -local or -fstype nfs -prune -o ...

Dean Neumann

unread,
Nov 14, 1998, 3:00:00 AM11/14/98
to
John Kotches wrote:

>
> James Dennis wrote:
> >
> > When I have wanted to do this in the past, I've used something like
> >
> > find / -name junk.out ! -fstype nfs -print
> >
> > the ! means don't go there.
> >
> > Jamie
>
> Isn't -local also an appropriate (and much shorter)solution?
>
> Let's see what "man find" says
>
> -local True if the file system type is not a remote
> file system type as defined in the
> /etc/dfs/fstypes file. nfs is used as the
> default remote filesystem type if the
> /etc/dfs/fstypes file is not present.
>
>
> Many times a simple way is provided :-)
>
> Cheers everyone.
>

I believe -local only solves half the problem: it may prune nfs
filesystems, but find stiff traverses loopback mounts, so you could
potentially get multiple matches reported for the same file.

Something like
find / ! -fstype ufs -prune
should, I believe, prune all non-ufs paths, including lofs mounts.

Casper, is this correct?

--
Dean Neumann (dneu...@neumann-associates.com)
Neumann & Associates Information Systems Inc.

Note: Remember to delete the ".delete-this-part"
portion of the return address before replying.

Richard L. Hamilton

unread,
Nov 15, 1998, 3:00:00 AM11/15/98
to
I just played around with that a bit as follows:
(where /var is a ufs filesystem)
mount -F lofs /var/tmp /mnt

find /mnt -fstype lofs -print (only finds directories)
find /mnt -fstype ufs -print (finds everything other than directories)

System info:
SunOS mindwarp 5.6 Generic_105181-09 sun4m sparc SUNW,SPARCstation-10

This is definitely not what I would have expected! However, the "BUGS"
section of lofs(7fs) somewhat explains what's happening:

>BUGS
> (1) Files can be modified on a read-only loopback mounted
> file system and (2) a loopback mounted file system can be
> unmounted even if there is an open regular file on that file
> system. The loopback file system works by shadowing direc-
> tories of the underlying file system. Because no other file
> types are shadowed, the loopback file system can not enforce
> read-only access to non-directory files located on a read-
> only mounted loopback file system. Thus, write access to
> regular files located on a loopback mounted file system is
> determined by the underlying file system. In addition, the
> loopback file system can not correctly determine whether a
> loopback mounted file system can be unmounted or not. It
> can only detect when a directory is active or not, not when
> a file within a directory is active. Thus, a loopback
> mounted file system may be unmounted if there are no active
> directories on the file system, even if there are open files
> on the file system.


In article <364E0325...@neumann-associates.com>,

--
ftp> get |fortune
377 I/O error: smart remark generator failed

Bogonics: the primary language inside the Beltway

mailto:rlh...@mindwarp.smart.net http://www.smart.net/~rlhamil

and...@cucumber.demon.co.uk

unread,
Nov 15, 1998, 3:00:00 AM11/15/98
to
In article <364E0325...@neumann-associates.com>,
Dean Neumann <dneumann.del...@neumann-associates.com> writes:
>
>I believe -local only solves half the problem: it may prune nfs
>filesystems, but find stiff traverses loopback mounts, so you could
>potentially get multiple matches reported for the same file.
>
>Something like
> find / ! -fstype ufs -prune
>should, I believe, prune all non-ufs paths, including lofs mounts.

It will (I suspect) fail to find a ufs filesystem mounted in
an NFS filesystem, which whilst rare, is certainly not unheard
of. Hence my earlier suggestion...

Casper H.S. Dik - Network Security Engineer

unread,
Nov 15, 1998, 3:00:00 AM11/15/98
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

rlh...@smart.net (Richard L. Hamilton) writes:

>find /mnt -fstype lofs -print (only finds directories)
>find /mnt -fstype ufs -print (finds everything other than directories)

>System info:
>SunOS mindwarp 5.6 Generic_105181-09 sun4m sparc SUNW,SPARCstation-10

>This is definitely not what I would have expected! However, the "BUGS"
>section of lofs(7fs) somewhat explains what's happening:


Yes, only lofs directories have lofs nodes.

0 new messages