From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,69d213cdeb1df8c0 X-Google-Attributes: gidfee84,public From: Alex Nord Subject: Re: equivalent of Solaris `fuser' command under DU ? Date: 1997/02/14 Message-ID: <330494BE.43C@jabil.com>#1/1 X-Deja-AN: 218837716 References: To: Hugues Talbot Content-Type: text/plain; charset=us-ascii Organization: Jabil Circuit, Inc. Mime-Version: 1.0 Reply-To: alex_nord@jabil.com Newsgroups: comp.unix.osf.osf1 X-Mailer: Mozilla 3.0Gold (WinNT; I) Hugues Talbot wrote: > > Hello all Dec Unix Guru, > > I'm running DU 3.2c on an AlphaStation 200-4/233. > I'm looking for the equivalent of the Solaris command `fuser' > under Dec Unix. > I noticed that DU does have the fuser system call. Did > someone out there go to the trouble of making an application out of > it? > > Thanks for any help/pointer. Here's some quick C code I threw together. Every now and then, it gives me some 'unpredictable' output (read "None at all!"), but I think I at least have all the core dumps worked out of it. :) #include #include #include #include #include #include int main(argc, argv) int argc; char *argv[]; { int x,y; struct f_user * wowie; struct f_user crap[1]; struct passwd person; if (getuid() != 0) { fprintf (stderr,"You must be root to use %s!\n",argv[0]); exit (-1); } if (argc != 2) { fprintf (stderr,"Usage : fuser \n"); exit (-1); } x=fuser(argv[1], 0L, crap, sizeof(struct f_user)); if (errno == 2) { fprintf (stderr,"'%s' - Not Found\n",argv[1]); exit (-1); } if (x==0) { fprintf(stdout,"No processes are currently accessing %s\n",argv[1]); exit (x); } wowie=(struct f_user *) malloc(x*(sizeof(struct f_user))); x=fuser(argv[1], 0L, wowie, (long) (x * (sizeof (struct f_user)))); for (y=0;y