Date: Fri, 11 May 2001 08:30:03 -0700 (PDT) From: Jim Pirzyk <Jim.Pirzyk@disney.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/27240: df does not support '-l' option Message-ID: <200105111530.f4BFU3l07328@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/27240; it has been noted by GNATS.
From: Jim Pirzyk <Jim.Pirzyk@disney.com>
To: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/27240: df does not support '-l' option
Date: Fri, 11 May 2001 08:18:39 -0700
So here is the complete patch using VFCF_NETWORK flag to generate the list
of networked filesystems.
On Thursday 10 May 2001 07:50 am, Garrett Wollman wrote:
> <<On Wed, 9 May 2001 22:06:47 -0700 (PDT), Jim.Pirzyk@disney.com said:
> > + 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.
>
> -GAWollman
*** ./bin/df/df.1.orig Mon Mar 5 01:55:59 2001
--- ./bin/df/df.1 Thu May 10 12:01:01 2001
***************
*** 44,50 ****
.Fl b | h | H | k |
.Fl m | P
.Oc
! .Op Fl ain
.Op Fl t Ar type
.Op Ar file | filesystem ...
.Sh DESCRIPTION
--- 44,50 ----
.Fl b | h | H | k |
.Fl m | P
.Oc
! .Op Fl ailn
.Op Fl t Ar type
.Op Ar file | filesystem ...
.Sh DESCRIPTION
***************
*** 91,96 ****
--- 91,98 ----
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,112 ****
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.
Note that this overrides the
.Ev BLOCKSIZE
specification from the environment.
--- 108,114 ----
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.
Note that this overrides the
.Ev BLOCKSIZE
specification from the environment.
*** ./bin/df/df.c.orig Mon Jun 12 20:19:40 2000
--- ./bin/df/df.c Fri May 11 08:15:02 2001
***************
*** 54,59 ****
--- 54,60 ----
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mount.h>
+ #include <sys/sysctl.h>
#include <ufs/ufs/ufsmount.h>
#include <err.h>
***************
*** 96,101 ****
--- 97,103 ----
int unitp [] = { NONE, KILO, MEGA, GIGA, TERA, PETA };
int checkvfsname __P((const char *, char **));
+ char *makenetvfslist __P((void));
char **makevfslist __P((char *));
long regetmntinfo __P((struct statfs **, long, char **));
int bread __P((off_t, void *, int));
***************
*** 122,128 ****
char *mntpt, *mntpath, **vfslist;
vfslist = NULL;
! while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1)
switch (ch) {
case 'a':
aflag = 1;
--- 124,130 ----
char *mntpt, *mntpath, **vfslist;
vfslist = NULL;
! while ((ch = getopt(argc, argv, "abgHhiklmnPt:")) != -1)
switch (ch) {
case 'a':
aflag = 1;
***************
*** 152,157 ****
--- 154,164 ----
putenv("BLOCKSIZE=1k");
hflag = 0;
break;
+ case 'l':
+ if (vfslist != NULL)
+ errx(1, "-l and -t are mutually exclusive.");
+ vfslist = makevfslist(makenetvfslist());
+ break;
case 'm':
putenv("BLOCKSIZE=1m");
hflag = 0;
***************
*** 506,511 ****
{
(void)fprintf(stderr,
! "usage: df [-b | -H | -h | -k | -m | -P] [-ain] [-t type] [file |
filesystem ...]\n");
exit(EX_USAGE);
}
--- 513,564 ----
{
(void)fprintf(stderr,
! "usage: df [-b | -H | -h | -k | -m | -P] [-ailn] [-t type] [file |
filesystem ...]\n");
exit(EX_USAGE);
+ }
+
+ char *makenetvfslist()
+ {
+ char *str, *strptr, **listptr;
+ int mib[3], maxvfsconf, miblen, cnt=0, i;
+ struct ovfsconf *ptr;
+
+ mib[0] = CTL_VFS; mib[1] = VFS_GENERIC; mib[2] = VFS_MAXTYPENUM;
+ miblen=sizeof(maxvfsconf);
+ if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &maxvfsconf, &miblen, NULL,
0)) {
+ warnx("sysctl failed");
+ return (NULL);
+ }
+
+ if ((listptr=malloc(sizeof(char*) * maxvfsconf)) == NULL) {
+ warnx("malloc failed");
+ return (NULL);
+ }
+
+ for (ptr=getvfsent();ptr;ptr=getvfsent())
+ if (ptr->vfc_flags & VFCF_NETWORK) {
+ listptr[cnt++] = strdup (ptr->vfc_name);
+ if (! listptr[cnt-1]) {
+ warnx("malloc failed");
+ return (NULL);
+ }
+ }
+
+ if ((str = malloc(sizeof(char)*(32*cnt+cnt+2))) == NULL) {
+ warnx("malloc failed");
+ free(listptr);
+ return (NULL);
+ }
+
+ *str = 'n'; *(str+1) = 'o';
+ for (i = 0,strptr=str+2; i < cnt; i++,strptr++) {
+ strncpy (strptr, listptr[i], 32);
+ strptr+=strlen(listptr[i]);
+ *strptr=',';
+ free(listptr[i]);
+ }
+ *(--strptr) = NULL;
+
+ free(listptr);
+ return (str);
}
--
--- @(#) $Id: dot.signature,v 1.9 2000/07/10 16:43:05 pirzyk Exp $
__o Jim.Pirzyk@disney.com -------------------------------------
_'\<,_ Senior Systems Engineer, Walt Disney Feature Animation
(*)/ (*)
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?200105111530.f4BFU3l07328>
