summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorpirzyk <pirzyk@FreeBSD.org>2001-06-04 23:07:15 +0000
committerpirzyk <pirzyk@FreeBSD.org>2001-06-04 23:07:15 +0000
commit7e25cedba658e2e86f2d376fe365e7a54cbc2e18 (patch)
tree2cc4eb6240d4fb6d224d9ac79266ee167ce2cc9a /bin
parent7d96c52053877a70db05c280899fc20637777e34 (diff)
downloadFreeBSD-src-7e25cedba658e2e86f2d376fe365e7a54cbc2e18.zip
FreeBSD-src-7e25cedba658e2e86f2d376fe365e7a54cbc2e18.tar.gz
Added the -l option to df, so to be compatable with other unicies.
PR: bin/27240 Reviewed by: GAWollman MFC after: 2 weeks
Diffstat (limited to 'bin')
-rw-r--r--bin/df/df.16
-rw-r--r--bin/df/df.c57
2 files changed, 59 insertions, 4 deletions
diff --git a/bin/df/df.1 b/bin/df/df.1
index 9a4b797..ab426c6 100644
--- a/bin/df/df.1
+++ b/bin/df/df.1
@@ -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 @@ Use 1024-byte (1-Kbyte) blocks rather than the default. Note that
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 @@ When this option is specified,
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.
diff --git a/bin/df/df.c b/bin/df/df.c
index 0def97c..3abeb95 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -54,6 +54,7 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mount.h>
+#include <sys/sysctl.h>
#include <ufs/ufs/ufsmount.h>
#include <err.h>
@@ -99,6 +100,7 @@ int bread __P((off_t, void *, int));
int checkvfsname __P((const char *, char **));
char *getmntpt __P((char *));
int main __P((int, char *[]));
+char *makenetvfslist __P((void));
char **makevfslist __P((char *));
void prthuman __P((struct statfs *, long));
void prthumanval __P((double));
@@ -126,7 +128,7 @@ main(argc, argv)
fstype = "ufs";
vfslist = NULL;
- while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1)
+ while ((ch = getopt(argc, argv, "abgHhiklmnPt:")) != -1)
switch (ch) {
case 'a':
aflag = 1;
@@ -156,6 +158,11 @@ main(argc, argv)
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;
@@ -507,6 +514,52 @@ usage()
{
(void)fprintf(stderr,
- "usage: df [-b | -H | -h | -k | -m | -P] [-ain] [-t type] [file | filesystem ...]\n");
+ "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);
+}
OpenPOWER on IntegriCloud