Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!ames!ucbcad!ucbvax!decvax!linus!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.unix.questions Subject: Re: finding NFS dirs in csh? Message-ID: <565@mcgill-vision.UUCP> Date: Tue, 9-Dec-86 04:15:56 EST Article-I.D.: mcgill-v.565 Posted: Tue Dec 9 04:15:56 1986 Date-Received: Sun, 14-Dec-86 08:51:12 EST References: <772@gcc-milo.ARPA> Organization: McGill University, Montreal Lines: 49 In article <772@gcc-milo.ARPA>, brad@gcc-milo.ARPA (Brad Parker) writes: > Does anyone know how to tell if a file is "remote" in a csh (or sh) script? > I need to tell if a directory is a remote mount point or below a remote > mount point. I want to exclude remote directories in a script which > spans the file systems from root (/) - you know... "find / ..." > Any ideas? > (Like wow - these transparent file systems are *really* transparent!) Not transparent enough :-(. Some versions of find have an option for this: find / -fstype nfs -prune .... Without this, I know of no easy way to tell whether a *file* is remote or not. From a shell script, that is. From a C program, just call stat() (or lstat()); a remote file will show a major device number of 255 (true of MtXinu 4.3+NFS and SunOS 3.0, presumably of SunOS other numbers as well). For a *directory*, things are easier. NFS breaks the directory-as-a-file paradigm (one of the reasons I hate NFS), so an attempt to open() and read() a directory will produce errors. Since standard I/O insulates programs from these errors, a remote directory will look like an empty file to many programs. For example, you can use (Bourne shell) if cmp -s suspect-directory /dev/null; then echo suspect-directory is remote else echo suspect-directory is local fi (C shell) if { cmp -s suspect-directory /dev/null } then echo suspect-directory is remote else echo suspect-directory is local endif der Mouse USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse think!mosart!mcgill-vision!mouse Europe: mcvax!decvax!utcsri!mcgill-vision!mouse ARPAnet: think!mosart!mcgill-vision!mouse@harvard.harvard.edu [USA NSA food: terrorist, cryptography, DES, drugs, CIA, secret, decode]