From 8d335f7d879166af8cbbf69bff3b077ccef414db Mon Sep 17 00:00:00 2001 From: Bill Joy Date: Thu, 16 Oct 1980 07:35:38 -0800 Subject: [PATCH] put back in df dir SCCS-vsn: bin/df/df.c 4.3 --- usr/src/bin/df/df.c | 49 +++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/usr/src/bin/df/df.c b/usr/src/bin/df/df.c index e0172b3b43..8459ca941e 100644 --- a/usr/src/bin/df/df.c +++ b/usr/src/bin/df/df.c @@ -1,13 +1,16 @@ -static char *sccsid = "@(#)df.c 4.2 (Berkeley) %G%"; +static char *sccsid = "@(#)df.c 4.3 (Berkeley) %G%"; #include #include #include #include #include +#include +/* + * df + */ #define NFS 20 /* Max number of filesystems */ - struct { char path[32]; char spec[32]; @@ -30,9 +33,7 @@ main(argc, argv) char **argv; { int i; - FILE *f = fopen(FSTAB, "r"); char buf[128]; - struct fstab fs; while (argc >= 1 && argv[1][0]=='-') { switch(argv[1][1]) { @@ -64,23 +65,21 @@ char **argv; printf("\tiused\tifree\t%%iused"); putchar('\n'); if(argc <= 1) { - if (f == NULL) + struct fstab *fsp; + if (setfsent() == 0) perror(FSTAB), exit(1); - while (!feof(f)){ - fscanf(f, FSTABFMT, FSTABARG(&fs)); - if (strcmp(fs.fs_type, "rw") && strcmp(fs.fs_type, "ro")) + while( (fsp = getfsent()) != 0){ + if ( (strcmp(fsp->fs_type, FSTAB_RW) != 0) + &&(strcmp(fsp->fs_type, FSTAB_RO) != 0) ) continue; if (root[0] == 0) - strcpy(root, fs.fs_spec); - dfree(fs.fs_spec); + strcpy(root, fsp->fs_spec); + dfree(fsp->fs_spec); } + endfsent(); exit(0); } - if (f){ - fscanf(f, FSTABFMT, FSTABARG(&fs)); - strcpy(root, fs.fs_spec); - } for(i=1; i