GC some dead code relating to running df on unmounted block devices,
and remove the setgid operator bit from the installed binary: if you want to view free disk space on an unmounted device, you should have read permissions to access it. Reviewed by: phk
This commit is contained in:
parent
7c549baa56
commit
d3d33000fe
@ -3,8 +3,6 @@
|
||||
|
||||
PROG= df
|
||||
SRCS= df.c vfslist.c
|
||||
BINGRP= operator
|
||||
BINMODE=2555
|
||||
|
||||
MOUNT= ${.CURDIR}/../../sbin/mount
|
||||
CFLAGS+= -I${MOUNT}
|
||||
|
36
bin/df/df.c
36
bin/df/df.c
@ -119,7 +119,7 @@ main(argc, argv)
|
||||
struct statfs statfsbuf, *mntbuf;
|
||||
long mntsize;
|
||||
int ch, err, i, maxwidth, rv, width;
|
||||
char *mntpt, *mntpath, **vfslist;
|
||||
char *mntpt, **vfslist;
|
||||
|
||||
vfslist = NULL;
|
||||
while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1)
|
||||
@ -208,40 +208,6 @@ main(argc, argv)
|
||||
} else if ((stbuf.st_mode & S_IFMT) == S_IFCHR) {
|
||||
rv = ufs_df(*argv, maxwidth) || rv;
|
||||
continue;
|
||||
} else if ((stbuf.st_mode & S_IFMT) == S_IFBLK) {
|
||||
if ((mntpt = getmntpt(*argv)) == 0) {
|
||||
mdev.fspec = *argv;
|
||||
mntpath = strdup("/tmp/df.XXXXXX");
|
||||
if (mntpath == NULL) {
|
||||
warn("strdup failed");
|
||||
rv = 1;
|
||||
continue;
|
||||
}
|
||||
mntpt = mkdtemp(mntpath);
|
||||
if (mntpt == NULL) {
|
||||
warn("mkdtemp(\"%s\") failed", mntpath);
|
||||
rv = 1;
|
||||
free(mntpath);
|
||||
continue;
|
||||
}
|
||||
if (mount("ufs", mntpt, MNT_RDONLY,
|
||||
&mdev) != 0) {
|
||||
rv = ufs_df(*argv, maxwidth) || rv;
|
||||
(void)rmdir(mntpt);
|
||||
free(mntpath);
|
||||
continue;
|
||||
} else if (statfs(mntpt, &statfsbuf) == 0) {
|
||||
statfsbuf.f_mntonname[0] = '\0';
|
||||
prtstat(&statfsbuf, maxwidth);
|
||||
} else {
|
||||
warn("%s", *argv);
|
||||
rv = 1;
|
||||
}
|
||||
(void)unmount(mntpt, 0);
|
||||
(void)rmdir(mntpt);
|
||||
free(mntpath);
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
mntpt = *argv;
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user