summaryrefslogtreecommitdiffstats
path: root/daemon/mount.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-07-15 22:25:51 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-07-15 22:25:51 +0100
commit7fc3faabc71621a9d8b429d15327955f20757080 (patch)
treecca1624403bd4e48bb4a1f7c23bd3f0d4cedc034 /daemon/mount.c
parentdbbbc753043aca5a32a96fa391851cc394e2ceea (diff)
downloadlibguestfs-7fc3faabc71621a9d8b429d15327955f20757080.tar.gz
libguestfs-7fc3faabc71621a9d8b429d15327955f20757080.tar.xz
libguestfs-7fc3faabc71621a9d8b429d15327955f20757080.zip
New command: 'mountpoints' which returns a hash of device -> mountpoint.
Diffstat (limited to 'daemon/mount.c')
-rw-r--r--daemon/mount.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/daemon/mount.c b/daemon/mount.c
index 1820f8a8..5bbbc67a 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -142,14 +142,15 @@ do_umount (char *pathordevice)
return 0;
}
-char **
-do_mounts (void)
+static char **
+mounts_or_mountpoints (int mp)
{
char *out, *err;
int r;
char **ret = NULL;
int size = 0, alloc = 0;
char *p, *pend, *p2;
+ int len;
r = command (&out, &err, "mount", NULL);
if (r == -1) {
@@ -179,6 +180,20 @@ do_mounts (void)
free (out);
return NULL;
}
+ if (mp) {
+ p2 += 12; /* 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;
+ }
+ }
}
p = pend;
@@ -192,6 +207,18 @@ do_mounts (void)
return ret;
}
+char **
+do_mounts (void)
+{
+ return mounts_or_mountpoints (0);
+}
+
+char **
+do_mountpoints (void)
+{
+ return mounts_or_mountpoints (1);
+}
+
/* Unmount everything mounted under /sysroot.
*
* We have to unmount in the correct order, so we sort the paths by