From owner-freebsd-bugs Thu May 10 8:39:46 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from ringworld.nanolink.com (ringworld.nanolink.com [195.24.48.13]) by hub.freebsd.org (Postfix) with SMTP id 5A56137B42C for ; Thu, 10 May 2001 08:39:22 -0700 (PDT) (envelope-from roam@orbitel.bg) Received: (qmail 58183 invoked by uid 1000); 10 May 2001 15:38:48 -0000 Date: Thu, 10 May 2001 18:38:48 +0300 From: Peter Pentchev To: Garrett Wollman Cc: freebsd-bugs@FreeBSD.org Subject: Re: bin/27240: df does not support '-l' option Message-ID: <20010510183848.C56859@ringworld.oblivion.bg> Mail-Followup-To: Garrett Wollman , freebsd-bugs@FreeBSD.org References: <200105101500.f4AF05207651@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200105101500.f4AF05207651@freefall.freebsd.org>; from wollman@khavrinen.lcs.mit.edu on Thu, May 10, 2001 at 08:00:05AM -0700 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Thu, May 10, 2001 at 08:00:05AM -0700, Garrett Wollman wrote: > The following reply was made to PR bin/27240; it has been noted by GNATS. > > From: Garrett Wollman > To: Jim.Pirzyk@disney.com > Cc: FreeBSD-gnats-submit@FreeBSD.ORG > Subject: bin/27240: df does not support '-l' option > Date: Thu, 10 May 2001 10:50:16 -0400 (EDT) > > < > > + case 'l': > > + if (vfslist != NULL) > > + errx(1, "-l and -t are mutally exclusive."); > > + vfslist = makevfslist("nonfs"); > > + break; > > Actually, that's not the right way to implement this function. The > correct way would be to scan the list of available filesystem types > and look for ones without the VFCF_NETWORK flag. OK, how about the following patch - it just gets all filesystems, and then processes only those for which statfs(2) has set the MNT_LOCAL flag. G'luck, Peter -- No language can express every thought unambiguously, least of all this one. Index: src/bin/df/df.1 =================================================================== RCS file: /home/ncvs/src/bin/df/df.1,v retrieving revision 1.22 diff -u -r1.22 df.1 --- src/bin/df/df.1 2001/02/01 16:24:49 1.22 +++ src/bin/df/df.1 2001/05/10 15:37:55 @@ -44,7 +44,7 @@ .Fl b | h | H | k | .Fl m | P .Oc -.Op Fl ain +.Op Fl ailn .Op Fl t Ar type .Op Ar file | filesystem ... .Sh DESCRIPTION @@ -91,6 +91,8 @@ this overrides the .Ev BLOCKSIZE specification from the environment. +.It Fl l +Only display information about locally-mounted filesystems. .It Fl m Use 1048576-byte (1-Mbyte) blocks rather than the default. Note that this overrides the @@ -106,7 +108,7 @@ will not request new statistics from the filesystems, but will respond with the possibly stale statistics that were previously obtained. .It Fl P -Use POSIX compliant output of 512-byte blocks rather than the default. +Use POSIX compliant output of 512-byte blocks rather than the default. Note that this overrides the .Ev BLOCKSIZE specification from the environment. Index: src/bin/df/df.c =================================================================== RCS file: /home/ncvs/src/bin/df/df.c,v retrieving revision 1.26 diff -u -r1.26 df.c --- src/bin/df/df.c 2001/05/09 08:44:15 1.26 +++ src/bin/df/df.c 2001/05/10 15:37:56 @@ -107,7 +107,7 @@ unit_t unit_adjust __P((double *)); void usage __P((void)); -int aflag = 0, hflag, iflag, nflag; +int aflag, hflag, iflag, lflag, nflag; struct ufs_args mdev; int @@ -124,7 +124,7 @@ fstype = "ufs"; vfslist = NULL; - while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1) + while ((ch = getopt(argc, argv, "abgHhiklmnPt:")) != -1) switch (ch) { case 'a': aflag = 1; @@ -154,6 +154,9 @@ putenv("BLOCKSIZE=1k"); hflag = 0; break; + case 'l': + lflag = 1; + break; case 'm': putenv("BLOCKSIZE=1m"); hflag = 0; @@ -188,12 +191,16 @@ if (vfslist != NULL) { maxwidth = 0; for (i = 0; i < mntsize; i++) { + if (lflag && !(mntbuf[i].f_flags & MNT_LOCAL)) + continue; width = strlen(mntbuf[i].f_mntfromname); if (width > maxwidth) maxwidth = width; } } for (i = 0; i < mntsize; i++) { + if (lflag && !(mntbuf[i].f_flags & MNT_LOCAL)) + continue; if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) prtstat(&mntbuf[i], maxwidth); } @@ -203,7 +210,7 @@ for (; *argv; argv++) { if (stat(*argv, &stbuf) < 0) { err = errno; - if ((mntpt = getmntpt(*argv)) == 0) { + if ((mntpt = getmntpt(*argv)) == NULL) { warn("%s", *argv); rv = 1; continue; @@ -232,7 +239,9 @@ continue; } else if (statfs(mntpt, &statfsbuf) == 0) { statfsbuf.f_mntonname[0] = '\0'; - prtstat(&statfsbuf, maxwidth); + if (!lflag || + (statfsbuf.f_flags & MNT_LOCAL)) + prtstat(&statfsbuf, maxwidth); } else { warn("%s", *argv); rv = 1; @@ -255,7 +264,8 @@ } if (argc == 1) maxwidth = strlen(statfsbuf.f_mntfromname) + 1; - prtstat(&statfsbuf, maxwidth); + if (!lflag || (statfsbuf.f_flags & MNT_LOCAL)) + prtstat(&statfsbuf, maxwidth); } return (rv); } @@ -289,12 +299,15 @@ int i, j; struct statfs *mntbuf; - if (vfslist == NULL) + if (!lflag && (vfslist == NULL)) return (nflag ? mntsize : getmntinfo(mntbufp, MNT_WAIT)); mntbuf = *mntbufp; for (j = 0, i = 0; i < mntsize; i++) { - if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) + if (lflag && !(mntbuf[i].f_flags & MNT_LOCAL)) + continue; + if ((vfslist != NULL) && + checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; if (!nflag) (void)statfs(mntbuf[i].f_mntonname,&mntbuf[j]); @@ -462,7 +475,7 @@ sfsp = &statfsbuf; sfsp->f_type = 1; strcpy(sfsp->f_fstypename, "ufs"); - sfsp->f_flags = 0; + sfsp->f_flags = MNT_LOCAL; sfsp->f_bsize = sblock.fs_fsize; sfsp->f_iosize = sblock.fs_bsize; sfsp->f_blocks = sblock.fs_dsize; @@ -506,6 +519,6 @@ { (void)fprintf(stderr, - "usage: df [-b | -H | -h | -k | -m | -P] [-ain] [-t type] [file | filesystem ...]\n"); + "usage: df [-b | -H | -h | -k | -l | -m | -P] [-ain] [-t type] [file | filesystem ...]\n"); exit(EX_USAGE); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message