Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!cmcl2!husc6!bu-cs!bzs From: bzs@bu-cs.BU.EDU (Barry Shein) Newsgroups: comp.unix.questions Subject: Re: finding NFS dirs in csh? Message-ID: <2788@bu-cs.BU.EDU> Date: Thu, 4-Dec-86 21:31:37 EST Article-I.D.: bu-cs.2788 Posted: Thu Dec 4 21:31:37 1986 Date-Received: Fri, 5-Dec-86 05:24:05 EST Organization: Boston U. Comp. Sci. Lines: 42 I realize that the original question was how to find out if a file is across an NFS system from the csh. Find does it if that's applicable. Now there's wondering out loud how it is done from a C program. I suppose both questions are answered by a simple C command that can be used in a csh script to test nfsness. -Barry Shein, Boston University #include #include #include /* * given a file name on the command line this program: * * Prints NFS or LOCAL if the file is on an NFS or LOCAL file * system respectively. * Silently exits with a non-zero exit status if the file could * not be accessed. */ /* * This magic cookie is gleaned from nfs_vnodeops.c * (is it likely to change? I dunno.) */ #define NFS_DEV 0xff main(argc,argv) int argc; char **argv; { struct stat sbuf; if(argc != 2) exit(1); if(stat(*++argv,&sbuf) < 0) exit(1); /* Here's what you're looking for */ if(major(sbuf.st_dev) == NFS_DEV) printf("NFS\n",*argv); else printf("LOCAL\n"); exit(0); }