# HG changeset patch # User Rob Landley # Date 1377902064 18000 # Node ID 11cf9b97fae746f54def1e74c38eebd72b3e2f9c # Parent 40d0c96a8e8924527b837a520fe23243ecbab88b Allow getmountlist to read fstab too. diff -r 40d0c96a8e89 -r 11cf9b97fae7 lib/getmountlist.c --- a/lib/getmountlist.c Fri Aug 30 01:53:31 2013 -0500 +++ b/lib/getmountlist.c Fri Aug 30 17:34:24 2013 -0500 @@ -10,13 +10,14 @@ // Get list of mounted filesystems, including stat and statvfs info. // Returns a reversed list, which is good for finding overmounts and such. -struct mtab_list *xgetmountlist(void) +struct mtab_list *xgetmountlist(char *path) { struct mtab_list *mtlist, *mt; struct mntent *me; FILE *fp; - if (!(fp = setmntent("/proc/mounts", "r"))) perror_exit("bad /proc/mounts"); + if (!path) path = "/proc/mounts"; + if (!(fp = setmntent(path, "r"))) perror_exit("bad %s", path); // The "test" part of the loop is done before the first time through and // again after each "increment", so putting the actual load there avoids diff -r 40d0c96a8e89 -r 11cf9b97fae7 lib/lib.h --- a/lib/lib.h Fri Aug 30 01:53:31 2013 -0500 +++ b/lib/lib.h Fri Aug 30 17:34:24 2013 -0500 @@ -162,7 +162,6 @@ void terminal_size(unsigned *x, unsigned *y); int yesno(char *prompt, int def); void for_each_pid_with_name_in(char **names, int (*callback)(pid_t pid, char *name)); -unsigned long xstrtoul(const char *nptr, char **endptr, int base); // net.c int xsocket(int domain, int type, int protocol); @@ -177,7 +176,7 @@ char type[0]; }; -struct mtab_list *xgetmountlist(void); +struct mtab_list *xgetmountlist(char *path); void bunzipStream(int src_fd, int dst_fd); diff -r 40d0c96a8e89 -r 11cf9b97fae7 toys/posix/df.c --- a/toys/posix/df.c Fri Aug 30 01:53:31 2013 -0500 +++ b/toys/posix/df.c Fri Aug 30 17:34:24 2013 -0500 @@ -108,7 +108,7 @@ TT.units); } else puts("Filesystem\t1K-blocks\tUsed Available Use% Mounted on"); - mtlist = xgetmountlist(); + mtlist = xgetmountlist(0); // If we have a list of filesystems on the command line, loop through them. if (*toys.optargs) {