Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jan 1999 17:34:10 -0500 (EST)
From:      Erez Zadok <ezk@ape.mcl.cs.columbia.edu>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Cc:        ezk@ape.mcl.cs.columbia.edu
Subject:   kern/9764: patches to support "ignore" mount flag
Message-ID:  <199901282234.RAA01770@ape.mcl.cs.columbia.edu>

next in thread | raw e-mail | index | archive | help

>Number:         9764
>Category:       kern
>Synopsis:       allow /bin/df not to list certain entries (made by automounter)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 28 14:40:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Erez Zadok
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
Columbia University Department of Computer Science.
>Environment:

	Vanilla 3.0-RELEASE system, with elf kernel and boot blocks off of
	-current, and running amd from the am-utils-6.0 distribution or
	a later distribution (which I maintain.)

>Description:

	Most modern OSs have the ability to flag certain mounts as ones to
	be ignored by default by the df(1) program.  This is used mostly to
	avoid stat()-ing entries that do not represent "real" disk mount
	points (such as those made by an automounter such as amd.)  It is
	also useful not to have to stat() these entries because it takes
	longer to report them that for other file systems, being that these
	mount points are served by a user-level file server and resulting in
	several context switches.  Worse, if the automounter is down
	unexpectedly, a causal df(1) will hang in an interruptible way.
	Finally, amd normally has nothing to report for its own mount point,
	so seeing output like:

	Filesystem		1K-blocks     Used    Avail Capacity  Mounted on
	pid204@ape:/proj	        0        0        0   100%    /proj

	only clutters the rest of the listing.  The patch below adds a new
	flag MNT_IGNORE to the system, and tells the kernel to report it
	back to a statfs() call.  Then /bin/df is modified so that by
	default it does not list any entries with the MNT_IGNORE flag on,
	unless df -a is used.  This is comparable behavior to the df program
	elsewhere: Solaris/SunOS, linux, GNU df, and more.

	With this patch in place, am-utils is able to automatically detect
	the existence of the MNT_IGNORE flag during the configure run, and
	use it at run-time as it does with other OSs.

>How-To-Repeat:

	Since this is not a bug, there isn't much to repeat.  It is clear
	when using amd that all of the automounter mount points themselves
	are stat()-ed and listed by df(1).

>Fix:
	
	Apply the following patch.  It creates a new mount flag MNT_IGNORE,
	makes sure that the kernel reports it back via statfs, and makes
	/bin/df ignore entries with the MNT_IGNORE flag set unless a -a
	(new) flag is set.  I've tested this for over a week now without a
	single adverse effect.

Index: src/bin/df/df.1
===================================================================
RCS file: /proj/bank/fist/freebsd/cvsroot/src/bin/df/df.1,v
retrieving revision 1.13
diff -c -r1.13 df.1
*** df.1	1998/05/13 07:56:58	1.13
--- df.1	1999/01/27 19:46:46
***************
*** 40,46 ****
  .Nd display free disk space
  .Sh SYNOPSIS
  .Nm df
! .Op Fl ikn
  .Op Fl t Ar type
  .Op Ar file | Ar filesystem ...
  .Sh DESCRIPTION
--- 40,46 ----
  .Nd display free disk space
  .Sh SYNOPSIS
  .Nm df
! .Op Fl aikn
  .Op Fl t Ar type
  .Op Ar file | Ar filesystem ...
  .Sh DESCRIPTION
***************
*** 59,64 ****
--- 59,67 ----
  .Pp
  The following options are available:
  .Bl -tag -width Ds
+ .It Fl a
+ Show all mount points, including those that were mounted with the MNT_IGNORE
+ flag.
  .It Fl i
  Include statistics on the number of free inodes.
  .It Fl k
Index: src/bin/df/df.c
===================================================================
RCS file: /proj/bank/fist/freebsd/cvsroot/src/bin/df/df.c,v
retrieving revision 1.20
diff -c -r1.20 df.c
*** df.c	1998/12/16 05:29:09	1.20
--- df.c	1999/01/27 19:46:37
***************
*** 73,79 ****
  int	  ufs_df __P((char *, int));
  void	  usage __P((void));
  
! int	iflag, nflag;
  struct	ufs_args mdev;
  
  int
--- 73,79 ----
  int	  ufs_df __P((char *, int));
  void	  usage __P((void));
  
! int	aflag = 0, iflag, nflag;
  struct	ufs_args mdev;
  
  int
***************
*** 88,95 ****
  	char *mntpt, *mntpath, **vfslist;
  
  	vfslist = NULL;
! 	while ((ch = getopt(argc, argv, "iknt:")) != -1)
  		switch (ch) {
  		case 'i':
  			iflag = 1;
  			break;
--- 88,98 ----
  	char *mntpt, *mntpath, **vfslist;
  
  	vfslist = NULL;
! 	while ((ch = getopt(argc, argv, "aiknt:")) != -1)
  		switch (ch) {
+ 		case 'a':
+ 			aflag = 1;
+ 			break;
  		case 'i':
  			iflag = 1;
  			break;
***************
*** 129,137 ****
  				if (width > maxwidth)
  					maxwidth = width;
  			}
  		}
- 		for (i = 0; i < mntsize; i++)
- 			prtstat(&mntbuf[i], maxwidth);
  		exit(rv);
  	}
  
--- 132,142 ----
  				if (width > maxwidth)
  					maxwidth = width;
  			}
+ 		}
+ 		for (i = 0; i < mntsize; i++) {
+ 			if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0)
+ 				prtstat(&mntbuf[i], maxwidth);
  		}
  		exit(rv);
  	}
  
***************
*** 377,382 ****
  usage()
  {
  	(void)fprintf(stderr,
! 	    "usage: df [-ikn] [-t type] [file | filesystem ...]\n");
  	exit(1);
  }
--- 382,387 ----
  usage()
  {
  	(void)fprintf(stderr,
! 	    "usage: df [-aikn] [-t type] [file | filesystem ...]\n");
  	exit(1);
  }
Index: src/sys/kern/vfs_syscalls.c
===================================================================
RCS file: /proj/bank/fist/freebsd/cvsroot/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.112
diff -c -r1.112 vfs_syscalls.c
*** vfs_syscalls.c	1999/01/05 18:49:55	1.112
--- vfs_syscalls.c	1999/01/27 23:17:41
***************
*** 293,303 ****
  		mp->mnt_kern_flag |= MNTK_WANTRDWR;
  	mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
  	    MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME |
! 	    MNT_NOSYMFOLLOW |
  	    MNT_NOCLUSTERR | MNT_NOCLUSTERW | MNT_SUIDDIR);
  	mp->mnt_flag |= SCARG(uap, flags) & (MNT_NOSUID | MNT_NOEXEC |
  	    MNT_NODEV | MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_FORCE |
! 	    MNT_NOSYMFOLLOW |
  	    MNT_NOATIME | MNT_NOCLUSTERR | MNT_NOCLUSTERW | MNT_SUIDDIR);
  	/*
  	 * Mount the filesystem.
--- 293,303 ----
  		mp->mnt_kern_flag |= MNTK_WANTRDWR;
  	mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
  	    MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME |
! 	    MNT_NOSYMFOLLOW | MNT_IGNORE |
  	    MNT_NOCLUSTERR | MNT_NOCLUSTERW | MNT_SUIDDIR);
  	mp->mnt_flag |= SCARG(uap, flags) & (MNT_NOSUID | MNT_NOEXEC |
  	    MNT_NODEV | MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_FORCE |
! 	    MNT_NOSYMFOLLOW | MNT_IGNORE |
  	    MNT_NOATIME | MNT_NOCLUSTERR | MNT_NOCLUSTERW | MNT_SUIDDIR);
  	/*
  	 * Mount the filesystem.
Index: src/sys/sys/mount.h
===================================================================
RCS file: /proj/bank/fist/freebsd/cvsroot/src/sys/sys/mount.h,v
retrieving revision 1.73
diff -c -r1.73 mount.h
*** mount.h	1998/11/15 15:12:58	1.73
--- mount.h	1999/01/27 20:17:13
***************
*** 141,146 ****
--- 141,147 ----
  #define	MNT_QUOTA	0x00002000	/* quotas are enabled on filesystem */
  #define	MNT_ROOTFS	0x00004000	/* identifies the root filesystem */
  #define	MNT_USER	0x00008000	/* mounted by a user */
+ #define	MNT_IGNORE	0x00800000	/* do not show entry in df */
  
  /*
   * Mask of flags that are visible to statfs()
***************
*** 154,160 ****
  			MNT_DEFEXPORTED	| MNT_EXPORTANON| MNT_EXKERB	| \
  			MNT_LOCAL	| MNT_USER	| MNT_QUOTA	| \
  			MNT_ROOTFS	| MNT_NOATIME	| MNT_NOCLUSTERR| \
! 			MNT_NOCLUSTERW	| MNT_SUIDDIR	| MNT_SOFTDEP	 \
  			/*	| MNT_EXPUBLIC */)
  /*
   * External filesystem command modifier flags.
--- 155,162 ----
  			MNT_DEFEXPORTED	| MNT_EXPORTANON| MNT_EXKERB	| \
  			MNT_LOCAL	| MNT_USER	| MNT_QUOTA	| \
  			MNT_ROOTFS	| MNT_NOATIME	| MNT_NOCLUSTERR| \
! 			MNT_NOCLUSTERW	| MNT_SUIDDIR	| MNT_SOFTDEP	| \
! 			MNT_IGNORE \
  			/*	| MNT_EXPUBLIC */)
  /*
   * External filesystem command modifier flags.


>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901282234.RAA01770>