Implemented the -k flag more properly...don't destroy the user's setting

of the BLOCKSIZE environment variable.
This commit is contained in:
David Greenman 1994-08-12 07:26:52 +00:00
parent 7952584606
commit ebf93438bf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=2039
2 changed files with 21 additions and 5 deletions

View File

@ -107,7 +107,7 @@ void prtstat __P((struct statfs *, int));
void ufs_df __P((char *, int));
void usage __P((void));
int iflag, nflag, tflag;
int iflag, nflag, tflag, kflag;
struct ufs_args mdev;
int
@ -121,13 +121,15 @@ main(argc, argv)
int ch, err, i, maxwidth, width;
char *mntpt;
iflag = nflag = tflag = kflag = 0;
while ((ch = getopt(argc, argv, "iknt:")) != EOF)
switch (ch) {
case 'i':
iflag = 1;
break;
case 'k':
putenv("BLOCKSIZE=1024");
kflag = 1;
break;
case 'n':
nflag = 1;
@ -305,11 +307,18 @@ prtstat(sfsp, maxwidth)
static int headerlen, timesthrough;
static char *header;
long used, availblks, inodes;
char *oldbsize = NULL;
if (maxwidth < 11)
maxwidth = 11;
if (++timesthrough == 1) {
if (kflag) {
oldbsize = getenv("BLOCKSIZE");
putenv("BLOCKSIZE=1k");
}
header = getbsize(&headerlen, &blocksize);
if (oldbsize)
putenv(oldbsize);
(void)printf("%-*.*s %s Used Avail Capacity",
maxwidth, maxwidth, "Filesystem", header);
if (iflag)

View File

@ -66,12 +66,13 @@ main(argc, argv)
FTS *fts;
FTSENT *p;
long blocksize;
char *oldbsize = NULL;
int ftsoptions, listdirs, listfiles;
int Hflag, Lflag, Pflag, aflag, ch, notused, rval, sflag;
int Hflag, Lflag, Pflag, aflag, ch, notused, rval, sflag, kflag;
char **save;
save = argv;
Hflag = Lflag = Pflag = aflag = sflag = 0;
Hflag = Lflag = Pflag = aflag = sflag = kflag = 0;
ftsoptions = FTS_PHYSICAL;
while ((ch = getopt(argc, argv, "HLPaksx")) != EOF)
switch (ch) {
@ -91,7 +92,7 @@ main(argc, argv)
aflag = 1;
break;
case 'k':
putenv("BLOCKSIZE=1024");
kflag = 1;
break;
case 's':
sflag = 1;
@ -142,7 +143,13 @@ main(argc, argv)
argv[1] = NULL;
}
if (kflag) {
oldbsize = getenv("BLOCKSIZE");
putenv("BLOCKSIZE=1k");
}
(void)getbsize(&notused, &blocksize);
if (oldbsize)
putenv(oldbsize);
blocksize /= 512;
if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)