tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY FOLLOWUP - forced umount
@ 1999-09-16  8:44 managers account
  0 siblings, 0 replies; only message in thread
From: managers account @ 1999-09-16  8:44 UTC (permalink / raw)
  To: tru64-unix-managers


So many requests have been received for the fuser program to use on 4.0b
an the script that I am following up by posting them here for the archive.
stuart mckenzie

From kazuro.furukawa@kek.jp Thu Sep 16 09:22:53 1999

On 4.0B fuser(2) was available.  I attached a message which have 
simple program to list PID's using fuser(2).  You may modify this 
to kill them. 




/*
 * fuser - Reports PIDs and UIDs for files, file systems and/or the devices
attached to them.
 *           This is so simple it makes you wonder why DEC didn't bother to
do it themselves.
 *
 *  Produced at Pacific Star Communicatons
 *
 * History :
 * 	31/12/95	J.Rouse		Initial version
 *	31/12/95	D.Bock		Added in flags for process type.
 */

#include <stdio.h>
#include <sys/sysinfo.h>
#include <sys/signal.h>
#include <sys/fuser.h>


main(argc,argv)
int argc;
char **argv;
{
  char *file;
  f_user_t fuser_array[10000];          /* Arbitrary array size */
  int i,fuser_count=0;

  if ( argc != 2 ) {
    printf("Usage: fuser FILE\n");
    exit(1);
  }

  file = argv[1];

  /* No buffering */
  setbuf(stdout,NULL);

  fuser_count=fuser(file, 0l, fuser_array, (long) sizeof (fuser_array)); 
  if ( fuser_count <0 ){
    exit (1);
  } else {
    printf("%s:\n",file); 
    if (fuser_count > 0 ){
      for ( i=0; i < fuser_count; i++){
        printf("%d", fuser_array[i].fu_pid);
        if (fuser_array[i].fu_flags & (F_CDIR|F_RDIR))
          printf("c");
        else if (fuser_array[i].fu_flags & (F_PDIR))
          printf("p");
        else if (fuser_array[i].fu_flags & (F_TTY))
          printf("t");
        else if (fuser_array[i].fu_flags & (F_TRACE))
          printf("tr");
        printf(" ");
      };
    };
    printf("\n");
  } 

  exit(0);
}



And the script approach:

From Davis@Tessco.Com Thu Sep 16 09:23:11 1999
 


Here is a sample of script that does something
similar to what you want. You probably can't use
this as-is, you'll need to re-write it or adapt
it for your needs.



kill_proc_on () {
  # stop processes with open files.
  ${BINDIR}/bin/fuser -ck $*
}

nfs_wait_loop () {
# function, to wait for a clean umount of mount points
# parameters proc_string, interval 

  proc_string=$1; interval=$2; is_running=0 
  while [ $is_running -eq 0 ]
  do
    mount | grep -w "$proc_string" | grep -v grep 
    is_running=$?
    if [ $is_running -eq 1 ]
    then
      break
    else
      /sbin/umount -f $proc_string
      kill_proc_on  $proc_string
      sleep $interval
      is_running=0
    fi
  done
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-09-16  8:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-09-16  8:44 SUMMARY FOLLOWUP - forced umount managers account

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox