diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-07-15 23:12:02 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-07-15 23:12:02 +0100 |
commit | 7428b0a70caed014d0cb4126fe8a77432d8957c6 (patch) | |
tree | ac205ce3daeddff9129e4d7bc7c01eb62eaa1fdc /daemon | |
parent | 7fc3faabc71621a9d8b429d15327955f20757080 (diff) | |
download | libguestfs-7428b0a70caed014d0cb4126fe8a77432d8957c6.tar.gz libguestfs-7428b0a70caed014d0cb4126fe8a77432d8957c6.tar.xz libguestfs-7428b0a70caed014d0cb4126fe8a77432d8957c6.zip |
New commands: 'mkmountpoint' and 'rmmountpoint'
These specialized commands are used to create additional mountpoints
before mounting filesystems. They are only used where you want to
mount several unrelated or read-only filesystems together, and need
additional care to use correctly.
Here is how to use these calls to unpack the "Russian doll" nest
of a Fedora 11 live CD:
add-ro Fedora-11-i686-Live.iso
run
mkmountpoint /cd
mkmountpoint /squash
mkmountpoint /ext3
mount /dev/sda /cd
mount-loop /cd/LiveOS/squashfs.img /squash
mount-loop /squash/LiveOS/ext3fs.img /ext3
The inner filesystem is now unpacked under the /ext3 mountpoint.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/mount.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/daemon/mount.c b/daemon/mount.c index 5bbbc67a..20811f15 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -22,6 +22,8 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/stat.h> +#include <sys/types.h> #include "daemon.h" #include "actions.h" @@ -349,3 +351,52 @@ do_mount_loop (char *file, char *mountpoint) return 0; } + +/* Specialized calls mkmountpoint and rmmountpoint are really + * variations on mkdir and rmdir which do no checking and (in the + * mkmountpoint case) set the root_mounted flag. + */ +int +do_mkmountpoint (char *path) +{ + int r; + + /* NEED_ROOT (-1); - we don't want this test for this call. */ + ABS_PATH (path, -1); + + CHROOT_IN; + r = mkdir (path, 0777); + CHROOT_OUT; + + if (r == -1) { + reply_with_perror ("mkmountpoint: %s", path); + return -1; + } + + /* Set the flag so that filesystems can be mounted here, + * not just on /sysroot. + */ + root_mounted = 1; + + return 0; +} + +int +do_rmmountpoint (char *path) +{ + int r; + + NEED_ROOT (-1); + ABS_PATH (path, -1); + + CHROOT_IN; + r = rmdir (path); + CHROOT_OUT; + + if (r == -1) { + reply_with_perror ("rmmountpoint: %s", path); + return -1; + } + + return 0; +} |