X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fmount.c;h=6c30304e537669bba7df9a54b5c12803608967a9;hb=4a5e13f15734aa7363e605f716ad6e29c67475c5;hp=e7265fe2aea33921095651d36003b629a5c5cd45;hpb=78029b529ad98769685d607230b70f71832d5906;p=libguestfs.git diff --git a/daemon/mount.c b/daemon/mount.c index e7265fe..6c30304 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -42,13 +42,13 @@ 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); + RESOLVE_DEVICE (device, return -1); is_root = strcmp (mountpoint, "/") == 0; @@ -65,10 +65,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 +96,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 +113,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 +176,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 +277,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; } }