* src/generator.ml: Change all `String "device"' to `Device "device"'.
[libguestfs.git] / daemon / mount.c
index e7265fe..14e683a 100644 (file)
@@ -42,14 +42,12 @@ int root_mounted = 0;
 
 int
 do_mount_vfs (char *options, char *vfstype,
-             char *device, char *mountpoint)
+              char *device, char *mountpoint)
 {
   int r, is_root;
   char *mp;
   char *error;
 
-  IS_DEVICE (device, -1);
-
   is_root = strcmp (mountpoint, "/") == 0;
 
   if (!root_mounted && !is_root) {
@@ -65,10 +63,10 @@ do_mount_vfs (char *options, char *vfstype,
 
   if (vfstype)
     r = command (NULL, &error,
-                "mount", "-o", options, "-t", vfstype, device, mp, NULL);
+                 "mount", "-o", options, "-t", vfstype, device, mp, NULL);
   else
     r = command (NULL, &error,
-                "mount", "-o", options, device, mp, NULL);
+                 "mount", "-o", options, device, mp, NULL);
   free (mp);
   if (r == -1) {
     reply_with_error ("mount: %s on %s: %s", device, mountpoint, error);
@@ -96,7 +94,7 @@ do_mount_ro (char *device, char *mountpoint)
 
 int
 do_mount_options (char *options, char *device,
-                 char *mountpoint)
+                  char *mountpoint)
 {
   return do_mount_vfs (options, NULL, device, mountpoint);
 }
@@ -113,7 +111,7 @@ do_umount (char *pathordevice)
 
   if (strncmp (pathordevice, "/dev/", 5) == 0) {
     buf = pathordevice;
-    IS_DEVICE (buf, -1);
+    RESOLVE_DEVICE (buf, return -1);
   } else {
     buf = sysroot_path (pathordevice);
     if (buf == NULL) {
@@ -176,22 +174,22 @@ mounts_or_mountpoints (int mp)
     if (p2 != NULL) {
       *p2 = '\0';
       if (add_string (&ret, &size, &alloc, p) == -1) {
-       free (out);
-       return NULL;
+        free (out);
+        return NULL;
       }
       if (mp) {
-       p2 += 4 + sysroot_len;  /* skip " on /sysroot" */
-       len = strcspn (p2, " ");
-
-       if (len == 0)           /* .. just /sysroot, so we turn it into "/" */
-         p2 = (char *) "/";
-       else
-         p2[len] = '\0';
-
-       if (add_string (&ret, &size, &alloc, p2) == -1) {
-         free (out);
-         return NULL;
-       }
+        p2 += 4 + sysroot_len; /* skip " on /sysroot" */
+        len = strcspn (p2, " ");
+
+        if (len == 0)          /* .. just /sysroot, so we turn it into "/" */
+          p2 = (char *) "/";
+        else
+          p2[len] = '\0';
+
+        if (add_string (&ret, &size, &alloc, p2) == -1) {
+          free (out);
+          return NULL;
+        }
       }
     }
 
@@ -277,8 +275,8 @@ do_umount_all (void)
       p3 = p2 + strcspn (p2, " ");
       *p3 = '\0';
       if (add_string (&mounts, &size, &alloc, p2) == -1) {
-       free (out);
-       return -1;
+        free (out);
+        return -1;
       }
     }
 
@@ -320,7 +318,7 @@ do_mount_loop (char *file, char *mountpoint)
   char *error;
 
   NEED_ROOT (-1);
-  ABS_PATH (file, -1);
+  ABS_PATH (file, return -1);
 
   /* We have to prefix /sysroot on both the filename and the mountpoint. */
   mp = sysroot_path (mountpoint);
@@ -358,7 +356,7 @@ do_mkmountpoint (char *path)
   int r;
 
   /* NEED_ROOT (-1); - we don't want this test for this call. */
-  ABS_PATH (path, -1);
+  ABS_PATH (path, return -1);
 
   CHROOT_IN;
   r = mkdir (path, 0777);
@@ -383,7 +381,7 @@ do_rmmountpoint (char *path)
   int r;
 
   NEED_ROOT (-1);
-  ABS_PATH (path, -1);
+  ABS_PATH (path, return -1);
 
   CHROOT_IN;
   r = rmdir (path);