aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-02-16 09:25:33 -0600
committerRob Landley <rob@landley.net>2021-02-16 09:26:03 -0600
commit4d3bf8b61e2158856572ca927cd831b9461a03a4 (patch)
tree4cf3d419f27f5ac91bdb17519a223a4ec550daed /toys
parent086356b88e237941eecc78b33b84af969bec0fbe (diff)
downloadtoybox-4d3bf8b61e2158856572ca927cd831b9461a03a4.tar.gz
Let df -a show overmounted filesystems.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/df.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/toys/posix/df.c b/toys/posix/df.c
index d8ba2986..7f43a109 100644
--- a/toys/posix/df.c
+++ b/toys/posix/df.c
@@ -80,8 +80,8 @@ static void show_mt(struct mtab_list *mt, int measuring)
char *dsuapm[6]; // device, size, used, avail, percent, mount
int i;
- // Return if it wasn't found (should never happen, but with /etc/mtab...)
- if (!mt) return;
+ // If we don't have -a, skip overmounted and synthetic filesystems.
+ if (!mt || (!FLAG(a) && (!mt->stat.st_dev || !mt->statvfs.f_blocks))) return;
// If we have -t, skip other filesystem types
if (TT.t) {
@@ -92,9 +92,6 @@ static void show_mt(struct mtab_list *mt, int measuring)
if (!al) return;
}
- // If we don't have -a, skip synthetic filesystems
- if (!FLAG(a) && !mt->statvfs.f_blocks) return;
-
// Prepare filesystem display fields
*dsuapm = *mt->device == '/' ? xabspath(mt->device, 0) : 0;
if (!*dsuapm) *dsuapm = mt->device;
@@ -179,7 +176,7 @@ void df_main(void)
if (mt->stat.st_dev == mt2->stat.st_dev) {
// For --bind mounts, show earliest mount
if (!strcmp(mt->device, mt2->device)) {
- if (!FLAG(a)) mt3->stat.st_dev = 0;
+ mt3->stat.st_dev = 0;
mt3 = mt2;
} else mt2->stat.st_dev = 0;
}
@@ -188,8 +185,7 @@ void df_main(void)
// Measure the names then output the table (in filesystem creation order).
for (measuring = 1;;) {
- for (mt = mtstart; mt; mt = mt->next)
- if (mt->stat.st_dev) show_mt(mt, measuring);
+ for (mt = mtstart; mt; mt = mt->next) show_mt(mt, measuring);
if (!measuring--) break;
print_header();
}