From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96076330121421.tru64-unix-managers.marc@archive.invalid> From: bouchard_l () decus ! fr (Louis Bouchard - Decylog) Date: Tue, 19 Mar 1996 08:40:56 +0000 To: tru64-unix-managers Subject: Orphan Summary : fuser.c X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96076330121421 Hello, A while ago I saw a summary containing the source of a fuser command. Since it looked quite like the one I was using, I didn't bother to keep it. But since then, my needs have changed a bit and the limitation to F_FILE_ONLY has been anoying me. I ended up rewriting my own fuser.c to allow the user to specify a mount point, allowing the F_CONTAINED argument to be used. I just saw a question about a "Device Busy" on /mnt which reminded me that I ment to send that source for a while. So here it is. Might be some bugs in it. Might not be the prettiest looking "C" programming you've seen. I don't claim to be a "C" developper. This little piece of code has been doing its job for a while now and that's all I ask. I taught that someone might need this. ...Louis ---------------------------------------------------------------------------- | Louis Bouchard J'aimes que ca cesse quand c'est fini. Quand | Ingenieur Systeme ca recommence, ca me scie. | bouchard_l@decusf.fr R. Ducharme | Bouygues Telecom | 39-26-66-73 ---------------------------------------------------------------------------- ----------------------------------------------------------------- /************************************************************************* ** Title : fuser ** ** Format : fuser [-f | -c] ** ** file : fuser.c ** ** Function: Give the file name/mount poind, PID and user ** ** name of the process which has the file opened ** ************************************************************************** */ #include #include #include #include #define File_Owner_Limit 10000 #define Args "fc" f_user_t File_Owner[File_Owner_Limit]; struct passwd *Owner_Name; main(int argc, char *argv[]) { int i,x=0; int c,errflg=0; long Fuser_Type=F_FILE_ONLY; optarg=NULL; while ( !errflg && ( c = getopt(argc,argv,Args)) != -1 ) switch (c) { case 'c' : Fuser_Type=F_CONTAINED; break; case 'f' : Fuser_Type=F_FILE_ONLY; break; case '?' : exit(1); default : errflg++; } if ( (x=fuser(argv[optind],Fuser_Type,File_Owner,(long) sizeof (File_Owner))) > 0 ) { for (i=0;ipw_name); } } }