changeset 1508:b0ade326c855 draft

mount: terminate list so unknown user mount attempts don't endlessly loop, add better error reporting.
author Rob Landley <rob@landley.net>
date Sun, 28 Sep 2014 13:15:41 -0500
parents 321e9d5032c1
children 22691dfb17b9
files toys/lsb/mount.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/toys/lsb/mount.c	Sun Sep 28 13:11:20 2014 -0500
+++ b/toys/lsb/mount.c	Sun Sep 28 13:15:41 2014 -0500
@@ -71,6 +71,7 @@
 // TODO work out how that differs from "mount -ar"
 // TODO what if you --bind mount a block device somewhere (file, dir, dev)
 // TODO "touch servername; mount -t cifs servername path"
+// TODO mount -o remount a user mount
 
 // Strip flags out of comma separated list of options, return flags,.
 static long flag_opts(char *new, long flags, char **more)
@@ -82,7 +83,6 @@
     // NOPs (we autodetect --loop and --bind)
     {"loop", 0}, {"bind", 0}, {"defaults", 0}, {"quiet", 0},
     {"user", 0}, {"nouser", 0}, // checked in fstab, ignored in -o
-//    {"noauto", 0}, {"swap", 0},
     {"ro", MS_RDONLY}, {"rw", ~MS_RDONLY},
     {"nosuid", MS_NOSUID}, {"suid", ~MS_NOSUID},
     {"nodev", MS_NODEV}, {"dev", ~MS_NODEV},
@@ -275,7 +275,7 @@
   // Do we need to do an /etc/fstab trawl?
   // This covers -a, -o remount, one argument, all user mounts
   if ((toys.optflags & FLAG_a) || (dev && (!dir || getuid() || remount))) {
-    if (!remount) mtl = xgetmountlist("/etc/fstab");
+    if (!remount) dlist_terminate(mtl = xgetmountlist("/etc/fstab"));
 
     for (mm = remount ? remount : mtl; mm; mm = (remount ? mm->prev : mm->next))
     {
@@ -311,6 +311,9 @@
       if (!(toys.optflags & FLAG_a)) break;
     }
     if (CFG_TOYBOX_FREE) llist_traverse(mtl, free);
+    if (!mm && !(toys.optflags & FLAG_a))
+      error_exit("'%s' not in %s", dir ? dir : dev,
+                 remount ? "/proc/mounts" : "fstab");
 
   // show mounts from /proc/mounts
   } else if (!dev) {