mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
New command: 'mountpoints' which returns a hash of device -> mountpoint.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1 +1 @@
|
||||
146
|
||||
147
|
||||
|
||||
@@ -1371,7 +1371,9 @@ contains the filesystem.");
|
||||
This returns the list of currently mounted filesystems. It returns
|
||||
the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
|
||||
|
||||
Some internal mounts are not shown.");
|
||||
Some internal mounts are not shown.
|
||||
|
||||
See also: C<guestfs_mountpoints>");
|
||||
|
||||
("umount_all", (RErr, []), 47, [FishAlias "unmount-all"],
|
||||
[InitBasicFS, Always, TestOutputList (
|
||||
@@ -2927,6 +2929,14 @@ This is the same as C<guestfs_removexattr>, but if C<path>
|
||||
is a symbolic link, then it removes an extended attribute
|
||||
of the link itself.");
|
||||
|
||||
("mountpoints", (RHashtable "mps", []), 147, [],
|
||||
[],
|
||||
"show mountpoints",
|
||||
"\
|
||||
This call is similar to C<guestfs_mounts>. That call returns
|
||||
a list of devices. This one returns a hash table (map) of
|
||||
device name to directory where the device is mounted.");
|
||||
|
||||
]
|
||||
|
||||
let all_functions = non_daemon_functions @ daemon_functions
|
||||
|
||||
Reference in New Issue
Block a user