X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fmount.c;h=4f74c02866fd886f17343c1dfdd9128c66beae86;hb=80c479162db74c461d671128237975aecc982a5e;hp=89bef3463ecb728d30d92ad253304fee46be13b6;hpb=84fc760439e82e6b3616abd0d1f9bd7d7eb01ec0;p=libguestfs.git diff --git a/daemon/mount.c b/daemon/mount.c index 89bef34..4f74c02 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -105,24 +105,20 @@ do_mount_options (const char *options, const char *device, int do_umount (const char *pathordevice) { - int freeit = 0, r; - char *buf; + int r; char *err; - if (strncmp (pathordevice, "/dev/", 5) == 0) { - buf = pathordevice; - RESOLVE_DEVICE (buf, return -1); - } else { - buf = sysroot_path (pathordevice); - if (buf == NULL) { - reply_with_perror ("malloc"); - return -1; - } - freeit = 1; + char *buf = (strncmp (pathordevice, "/dev/", 5) == 0 + ? strdup (pathordevice) + : sysroot_path (pathordevice)); + if (buf == NULL) { + reply_with_perror ("malloc"); + return -1; } r = command (NULL, &err, "umount", buf, NULL); - if (freeit) free (buf); + free (buf); + if (r == -1) { reply_with_error ("umount: %s: %s", pathordevice, err); free (err);