unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (OSF1-V5.1-alpha)
Page:
Section:
Apropos / Subsearch:
optional field



fuser(2)							     fuser(2)



NAME

  fuser	- Reports PIDs and UIDs	for files, file	systems	and/or the devices
  attached to them.

SYNOPSIS

  #include <&lt;sys/fuser.h>&gt;


  int fuser(
	  char *file,
	  long flag,
	  struct f_user	fuser_array[],
	  long sizeof_fuser_array );

PARAMETERS

  file
      Specifies	the file name.

  flag
      Specifies	one of the following values.  If none of the following are
      values are specified, the	default	is to match open files.

      F_FILE_ONLY
	  Matches only file ids.

      F_CONTAINED
	  Provides mount point matching.

      F_NOLINK
	  Matches deleted files	on the mount point specified by	file.

  fuser_array
      Specifies	the array.

  sizeof_fuser_array
      Specifies	the number of elements in the fuser array.

DESCRIPTION

  The fuser function reports a list of PIDs and	UIDs that are associated with
  a specified file, file system, and/or	the devices that are attached to
  them.

  The fuser function can report	back additional	information about "matches"
  by ORing one of the following	constants that can be passed back in the
  member fu_flags:

  F_CDIR
      Current directory

  F_RDIR
      Current directory

  F_PDIR
      Parent of	the current directory

  F_OPEN
      At least one file	open, but the number open is not known.

  F_TEXT
      Executable image.

  F_TTY
      Controlling terminal

  F_TRACE
      Trace

  F_MMAP
      At least one file	is mmapped

RETURN VALUES

  On success, the fuser	function returns the number of fuser_array elements
  that were found. The contents	of the structure are as	follows:

       typedef struct  f_user {
	       pid_t   fu_pid;
	       int     fu_flags;
	       uid_t   fu_uid;
       } f_user_t;

  If an	error has occurred, the	fuser function returns -1 and sets errno to
  indicate the error.

ERRORS

  If the fuser function	fails, errno may be set	to one of the following
  values:

  [EINVAL]
      The array	is not large enough to hold the	number of array	elements
      returned or the array structure cannot be	filled

  [ENOENT]
      The file parameter specified does	not exist

EXAMPLES

   1.  Open regular files and special files are	matched	using the flag param-
       eter set	at 0L. Thus, if	process	127 and	3220 open the /home/try	file
       simultaneously and the fuser function is	active,	the PIDs and UIDs
       associated with the home/try file are reported as in the	following
       example:


	    fuser("/home/try", 0L, fuser_array,	\
		 (long)	(sizeof	(fuser_array)/sizeof(fuser_array[0]));

   2.  Similarly, if the special device	file /dev/ttyp2	is open	by process
       32, then	that PID and its associated UID	are reported as	in the fol-
       lowing example:


	    fuser("/dev/ttyp2",	0L, fuser_array, \
		 (long)	(sizeof	(fuser_array)/sizeof(fuser_array[0]));