diff options
author | Rob Landley <rob@landley.net> | 2014-05-27 07:56:51 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-05-27 07:56:51 -0500 |
commit | 55e9f35223e40f455b80671f25b412072d9af678 (patch) | |
tree | 96fdd4514b2147136a344fd13d83d1b06ada7f4f | |
parent | 369a4e0dd08130d2e22140280932b138ab283106 (diff) | |
download | toybox-55e9f35223e40f455b80671f25b412072d9af678.tar.gz |
Add mount options to data getmountlist collects.
-rw-r--r-- | lib/getmountlist.c | 14 | ||||
-rw-r--r-- | lib/lib.h | 1 |
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/getmountlist.c b/lib/getmountlist.c index c863de5d..d5a392d6 100644 --- a/lib/getmountlist.c +++ b/lib/getmountlist.c @@ -4,7 +4,6 @@ */ #include "toys.h" - #include <mntent.h> // Get list of mounted filesystems, including stat and statvfs info. @@ -25,17 +24,18 @@ struct mtab_list *xgetmountlist(char *path) for (mtlist = 0; (me = getmntent(fp)); mtlist = mt) { mt = xzalloc(sizeof(struct mtab_list) + strlen(me->mnt_fsname) + - strlen(me->mnt_dir) + strlen(me->mnt_type) + 3); + strlen(me->mnt_dir) + strlen(me->mnt_type) + strlen(me->mnt_opts) + 4); mt->next = mtlist; // Collect details about mounted filesystem (don't bother for /etc/fstab). - stat(me->mnt_dir, &(mt->stat)); - statvfs(me->mnt_dir, &(mt->statvfs)); + if (stat(me->mnt_dir, &(mt->stat)) || statvfs(me->mnt_dir, &(mt->statvfs))) + perror_msg("stat '%s'"); // Remember information from /proc/mounts - mt->dir = stpcpy(mt->type, me->mnt_type) + 1; - mt->device = stpcpy(mt->dir, me->mnt_dir) + 1; - strcpy(mt->device, me->mnt_fsname); + mt->dir = stpcpy(mt->type, me->mnt_type)+1; + mt->device = stpcpy(mt->dir, me->mnt_dir)+1; + mt->opts = stpcpy(mt->device, me->mnt_fsname)+1; + strcpy(mt->opts, me->mnt_opts); } endmntent(fp); @@ -167,6 +167,7 @@ struct mtab_list { struct statvfs statvfs; char *dir; char *device; + char *opts; char type[0]; }; |