17aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley/* df.c - report free disk space.
24f344e356d2c36c4b1df46917eaef25f82ca79a9landley *
32896480c4918f2accccb8301bec457a7bff7377eRob Landley * Copyright 2006 Rob Landley <rob@landley.net>
42c226859cfc911c4a1eea009897050a16714aeecRob Landley *
5f91b7c89bc852868692b9518185421ebb52d67b3Rob Landley * See http://opengroup.org/onlinepubs/9699919799/utilities/df.html
62896480c4918f2accccb8301bec457a7bff7377eRob Landley
7c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott HughesUSE_DF(NEWTOY(df, "HPkht*a[-HPkh]", TOYFLAG_SBIN))
855928b1e0a08d84a5cbc50020f0a8c1024f5b6ceRob Landley
92896480c4918f2accccb8301bec457a7bff7377eRob Landleyconfig DF
109b504b4afe16636b31b0e52dea69e7478d6fb780Rob Landley  bool "df"
117aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  default y
127aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  help
13c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott Hughes    usage: df [-HPkh] [-t type] [FILESYSTEM ...]
142896480c4918f2accccb8301bec457a7bff7377eRob Landley
159b504b4afe16636b31b0e52dea69e7478d6fb780Rob Landley    The "disk free" command shows total/used/available disk space for
167aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    each filesystem listed on the command line, or all currently mounted
177aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    filesystems.
182896480c4918f2accccb8301bec457a7bff7377eRob Landley
196132e360e11a0dfc6edf27f8634d44f4eb8e526fRob Landley    -a	Show all (including /proc and friends)
207aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    -P	The SUSv3 "Pedantic" option
217aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    -k	Sets units back to 1024 bytes (the default without -P)
22c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott Hughes    -h	Human readable output (K=1024)
23c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott Hughes    -H	Human readable output (k=1000)
24f232c37cf2c3b5578c9d19e7e16e77b4a9b00450Rob Landley    -t type	Display only filesystems of this type.
255486075caee329fcc5ab7766a8a571fd3a45d363Rob Landley
265486075caee329fcc5ab7766a8a571fd3a45d363Rob Landley    Pedantic provides a slightly less useful output format dictated by Posix,
275486075caee329fcc5ab7766a8a571fd3a45d363Rob Landley    and sets the units to 512 bytes instead of the default 1024 bytes.
282896480c4918f2accccb8301bec457a7bff7377eRob Landley*/
294f344e356d2c36c4b1df46917eaef25f82ca79a9landley
30c0e56edaf256adb6c60c5a052525a1ffbb927901Rob Landley#define FOR_df
31c56215062c961402515daeef8330ed75cd94af29landley#include "toys.h"
32c56215062c961402515daeef8330ed75cd94af29landley
33c0e56edaf256adb6c60c5a052525a1ffbb927901Rob LandleyGLOBALS(
347aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  struct arg_list *fstype;
35b1aaba1fc8176ac0b7c202a664d2554aa0967116Rob Landley
367aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  long units;
37c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  int column_widths[5];
38c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  int header_shown;
39b1aaba1fc8176ac0b7c202a664d2554aa0967116Rob Landley)
40b1aaba1fc8176ac0b7c202a664d2554aa0967116Rob Landley
41c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughesstatic void measure_column(int col, const char *s)
42c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes{
43c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  size_t len = strlen(s);
44c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
45c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  if (TT.column_widths[col] < len) TT.column_widths[col] = len;
46c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes}
47c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
48c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughesstatic void measure_numeric_column(int col, long long n)
49c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes{
50c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  snprintf(toybuf, sizeof(toybuf), "%lld", n);
51c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  return measure_column(col, toybuf);
52c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes}
53c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
54c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughesstatic void show_header()
55c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes{
56c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  TT.header_shown = 1;
57c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
58c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  // The filesystem column is always at least this wide.
59c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  if (TT.column_widths[0] < 14) TT.column_widths[0] = 14;
60c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
61c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  if (toys.optflags & (FLAG_H|FLAG_h)) {
62c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    xprintf("%-*s Size  Used Avail Use%% Mounted on\n",
63c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes            TT.column_widths[0], "Filesystem");
64c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  } else {
65c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    const char *blocks_label = TT.units == 512 ? "512-blocks" : "1K-blocks";
66c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    const char *use_label = toys.optflags & FLAG_P ? "Capacity" : "Use%";
67c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
68c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    measure_column(1, blocks_label);
69c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    measure_column(2, "Used");
70c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    measure_column(3, "Available");
71c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    measure_column(4, use_label);
72c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    xprintf("%-*s %*s %*s %*s %*s Mounted on\n",
73c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes            TT.column_widths[0], "Filesystem",
74c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes            TT.column_widths[1], blocks_label,
75c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes            TT.column_widths[2], "Used",
76c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes            TT.column_widths[3], "Available",
77c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes            TT.column_widths[4], use_label);
78c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
79c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    // For the "Use%" column, the trailing % should be inside the column.
80c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    TT.column_widths[4]--;
81c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  }
82c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes}
83c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
84c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughesstatic void show_mt(struct mtab_list *mt, int measuring)
8509ea7ac1a269db3c9a3b76840b37a7cb1eccbc24landley{
867aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  long long size, used, avail, percent, block;
877aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  char *device;
887aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
897aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  // Return if it wasn't found (should never happen, but with /etc/mtab...)
907aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  if (!mt) return;
917aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
927aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  // If we have -t, skip other filesystem types
937aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  if (TT.fstype) {
947aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    struct arg_list *al;
957aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
967aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    for (al = TT.fstype; al; al = al->next)
977aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley      if (!strcmp(mt->type, al->arg)) break;
987aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
997aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    if (!al) return;
1007aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  }
1017aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
1027aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  // If we don't have -a, skip synthetic filesystems
1037aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  if (!(toys.optflags & FLAG_a) && !mt->statvfs.f_blocks) return;
1047aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
1057aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  // Figure out how much total/used/free space this filesystem has,
1067aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  // forcing 64-bit math because filesystems are big now.
1077aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  block = mt->statvfs.f_bsize ? mt->statvfs.f_bsize : 1;
1087aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  size = (block * mt->statvfs.f_blocks) / TT.units;
1097aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  used = (block * (mt->statvfs.f_blocks-mt->statvfs.f_bfree)) / TT.units;
110f232c37cf2c3b5578c9d19e7e16e77b4a9b00450Rob Landley  avail = (block*(getuid()?mt->statvfs.f_bavail:mt->statvfs.f_bfree))/TT.units;
1117aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  if (!(used+avail)) percent = 0;
1127aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  else {
1137aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    percent = (used*100)/(used+avail);
1147aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    if (used*100 != percent*(used+avail)) percent++;
1157aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  }
1167aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
1177aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  device = *mt->device == '/' ? realpath(mt->device, NULL) : NULL;
1187aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  if (!device) device = mt->device;
1197aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
120c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  if (measuring) {
121c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    measure_column(0, device);
122c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    measure_numeric_column(1, size);
123c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    measure_numeric_column(2, used);
124c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    measure_numeric_column(3, avail);
125c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  } else {
126c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    if (!TT.header_shown) show_header();
127c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
128c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    if (toys.optflags & (FLAG_H|FLAG_h)) {
129c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      char *size_str = toybuf, *used_str = toybuf+64, *avail_str = toybuf+128;
130c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      int hr_flags = (toys.optflags & FLAG_H) ? HR_1000 : 0;
131c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
132c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      human_readable(size_str, size, hr_flags);
133c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      human_readable(used_str, used, hr_flags);
134c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      human_readable(avail_str, avail, hr_flags);
135c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      xprintf("%-*s %4s  %4s  %4s % 3lld%% %s\n",
136c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        TT.column_widths[0], device,
137c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        size_str, used_str, avail_str, percent, mt->dir);
138c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    } else xprintf("%-*s %*lld %*lld %*lld %*lld%% %s\n",
139c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        TT.column_widths[0], device,
140c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        TT.column_widths[1], size,
141c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        TT.column_widths[2], used,
142c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        TT.column_widths[3], avail,
143c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        TT.column_widths[4], percent,
144c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        mt->dir);
145c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  }
1467aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
1477aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  if (device != mt->device) free(device);
14809ea7ac1a269db3c9a3b76840b37a7cb1eccbc24landley}
14909ea7ac1a269db3c9a3b76840b37a7cb1eccbc24landley
150efda21ca931766eed6cfc49d1b2122c53827d9fcRob Landleyvoid df_main(void)
151c56215062c961402515daeef8330ed75cd94af29landley{
152dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley  struct mtab_list *mt, *mtstart, *mtend;
153c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes  int measuring;
1547aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
155c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott Hughes  if (toys.optflags & (FLAG_H|FLAG_h)) {
156c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott Hughes    TT.units = 1;
157c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott Hughes  } else {
158c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott Hughes    // Units are 512 bytes if you select "pedantic" without "kilobytes".
159c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    TT.units = toys.optflags & FLAG_P ? 512 : 1024;
160c82343fe0bb293d3ed60b9122426f0bbcb0e58b0Elliott Hughes  }
1617aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
162dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley  if (!(mtstart = xgetmountlist(0))) return;
163dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley  mtend = dlist_terminate(mtstart);
1647aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
1657aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  // If we have a list of filesystems on the command line, loop through them.
1667aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  if (*toys.optargs) {
167c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    // Measure the names then output the table.
168c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    for (measuring = 1; measuring >= 0; --measuring) {
169c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      char **next;
1707aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
171c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      for (next = toys.optargs; *next; next++) {
172c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        struct stat st;
1737aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
174c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        // Stat it (complain if we can't).
175c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        if (stat(*next, &st)) {
176c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes          perror_msg("'%s'", *next);
177c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes          continue;
178c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        }
1797aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
180c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        // Find and display this filesystem.  Use _last_ hit in case of
181c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        // overmounts (which is first hit in the reversed list).
182c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        for (mt = mtend; mt; mt = mt->prev) {
183c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes          if (st.st_dev == mt->stat.st_dev
184c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes              || (st.st_rdev && (st.st_rdev == mt->stat.st_dev)))
185c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes          {
186c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes            show_mt(mt, measuring);
187c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes            break;
188c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes          }
1897aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley        }
1907aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley      }
1917aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    }
1927aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  } else {
193dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley    // Loop through mount list to filter out overmounts.
194dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley    for (mt = mtend; mt; mt = mt->prev) {
1957aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley      struct mtab_list *mt2, *mt3;
1967aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
197dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley      // 0:0 is LANANA null device
1987aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley      if (!mt->stat.st_dev) continue;
1997aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
2007aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley      // Filter out overmounts.
2017aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley      mt3 = mt;
202dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley      for (mt2 = mt->prev; mt2; mt2 = mt2->prev) {
2037aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley        if (mt->stat.st_dev == mt2->stat.st_dev) {
204f232c37cf2c3b5578c9d19e7e16e77b4a9b00450Rob Landley          // For --bind mounts, show earliest mount
205dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley          if (!strcmp(mt->device, mt2->device)) {
2060685ab75525609cddfeadc6ad8da6f2ff18be7acElliott Hughes            if (!(toys.optflags & FLAG_a)) mt3->stat.st_dev = 0;
207dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley            mt3 = mt2;
208dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley          } else mt2->stat.st_dev = 0;
2097aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley        }
2107aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley      }
2117aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley    }
212c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes
213c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    // Measure the names then output the table.
214c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    for (measuring = 1; measuring >= 0; --measuring) {
215c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      // Cosmetic: show filesystems in creation order.
216c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      for (mt = mtstart; mt; mt = mt->next) {
217c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes        if (mt->stat.st_dev) show_mt(mt, measuring);
218c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes      }
219c10638d3b16d065c1efd97ae17c1a8bf417be706Elliott Hughes    }
2207aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley  }
2217aa651a6a4496d848f86de9b1e6b3a003256a01fRob Landley
222dc640259adff6007d195fd4cc78dcf9829e5e6eeRob Landley  if (CFG_TOYBOX_FREE) llist_traverse(mtstart, free);
223c56215062c961402515daeef8330ed75cd94af29landley}
224