Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!its63b!simon From: simon@its63b.ed.ac.uk (ECSC68 S Brown CS) Newsgroups: comp.unix.questions Subject: Re: finding NFS dirs in csh? Message-ID: <160@its63b.ed.ac.uk> Date: Thu, 4-Dec-86 10:19:31 EST Article-I.D.: its63b.160 Posted: Thu Dec 4 10:19:31 1986 Date-Received: Fri, 5-Dec-86 05:43:55 EST References: <772@gcc-milo.ARPA> Reply-To: simon@its63b.ed.ac.uk (ECSC68 S Brown CS) Organization: I.T. School, Univ. of Edinburgh, U.K. Lines: 50 Keywords: NFS, getdirentries, sh 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 / ..." > > >(Like wow - these transparent file systems are *really* transparent!) Well, I havn't found this to be the case at all! (At least using NFS between SUNs and a Pyramid). It seems that if you open(2) a remote directory for reading, any read(2) will return 0 bytes - it looks like a totally empty directory! - there isn't even "." or ".." entries. You have to use the getdirentries(2) call to actually read remote directories. So, you could check if a file is remote by: 1. If its a directory (stat => st_mode&S_IFDIR), then try to read something from it. If it looks empty then it's remote. 2. If its a non-directory, just apply step 1 to its parent. Of course, it might be a bit more tricky to do things like this in a shell script... Perhaps something like: # # shell function to see if a file is remote # isremote(){ if [ -d $1 ] then if [ `cat $1 | wc -c` == 0 ] # it looks empty then return 0 # true else return 1 # false fi elif isremote $1/.. # is parent remote? then return 0 else return 1 fi } Of course, this might just only work 'cos NFS is set up wrong here. :-) -- Simon Brown Department of Computer Science, University of Edinburgh, Scotland. ...!{decvax,ihnp4,seismo}!mcvax!ukc!cstvax(!its63b)!simon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Life is full of woe, don't you know..." [Anon.] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~