From owner-freebsd-fs Thu Jan 28 15:47:00 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA09578 for freebsd-fs-outgoing; Thu, 28 Jan 1999 15:47:00 -0800 (PST) (envelope-from owner-freebsd-fs@FreeBSD.ORG) Received: from cs.columbia.edu (cs.columbia.edu [128.59.16.20]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA09562 for ; Thu, 28 Jan 1999 15:46:50 -0800 (PST) (envelope-from ezk@shekel.mcl.cs.columbia.edu) Received: from shekel.mcl.cs.columbia.edu (shekel.mcl.cs.columbia.edu [128.59.18.15]) by cs.columbia.edu (8.9.1/8.9.1) with ESMTP id SAA27072 for ; Thu, 28 Jan 1999 18:46:46 -0500 (EST) Received: (from ezk@localhost) by shekel.mcl.cs.columbia.edu (8.9.1/8.9.1) id SAA09690; Thu, 28 Jan 1999 18:46:44 -0500 (EST) Date: Thu, 28 Jan 1999 18:46:44 -0500 (EST) Message-Id: <199901282346.SAA09690@shekel.mcl.cs.columbia.edu> X-Authentication-Warning: shekel.mcl.cs.columbia.edu: ezk set sender to ezk@shekel.mcl.cs.columbia.edu using -f From: Erez Zadok To: freebsd-fs@FreeBSD.ORG Subject: patches to support "ignore" mount flag Sender: owner-freebsd-fs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org [This was send-pr'ed as well.] 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 than 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. Erez. ############################################################################## 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. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message