X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fmount.c;h=4f6068232b093ba6aa438ab1cba81f4520a989fa;hb=6bda071b5cd8393b37653687027c4ae6c6cf3804;hp=e7265fe2aea33921095651d36003b629a5c5cd45;hpb=78029b529ad98769685d607230b70f71832d5906;p=libguestfs.git diff --git a/daemon/mount.c b/daemon/mount.c index e7265fe..4f60682 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -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; } } @@ -319,8 +317,8 @@ do_mount_loop (char *file, char *mountpoint) char *buf, *mp; char *error; - NEED_ROOT (-1); - ABS_PATH (file, -1); + NEED_ROOT (return -1); + ABS_PATH (file, return -1); /* We have to prefix /sysroot on both the filename and the mountpoint. */ mp = sysroot_path (mountpoint); @@ -357,8 +355,8 @@ do_mkmountpoint (char *path) { int r; - /* NEED_ROOT (-1); - we don't want this test for this call. */ - ABS_PATH (path, -1); + /* NEED_ROOT (return -1); - we don't want this test for this call. */ + ABS_PATH (path, return -1); CHROOT_IN; r = mkdir (path, 0777); @@ -382,8 +380,8 @@ do_rmmountpoint (char *path) { int r; - NEED_ROOT (-1); - ABS_PATH (path, -1); + NEED_ROOT (return -1); + ABS_PATH (path, return -1); CHROOT_IN; r = rmdir (path);