mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
147
|
||||
149
|
||||
|
||||
@@ -2937,6 +2937,42 @@ 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.");
|
||||
|
||||
("mkmountpoint", (RErr, [String "path"]), 148, [],
|
||||
[],
|
||||
"create a mountpoint",
|
||||
"\
|
||||
C<guestfs_mkmountpoint> and C<guestfs_rmmountpoint> are
|
||||
specialized calls that can be used to create extra mountpoints
|
||||
before mounting the first filesystem.
|
||||
|
||||
These calls are I<only> necessary in some very limited circumstances,
|
||||
mainly the case where you want to mount a mix of unrelated and/or
|
||||
read-only filesystems together.
|
||||
|
||||
For example, live CDs often contain a \"Russian doll\" nest of
|
||||
filesystems, an ISO outer layer, with a squashfs image inside, with
|
||||
an ext2/3 image inside that. You can unpack this as follows
|
||||
in guestfish:
|
||||
|
||||
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.");
|
||||
|
||||
("rmmountpoint", (RErr, [String "path"]), 149, [],
|
||||
[],
|
||||
"remove a mountpoint",
|
||||
"\
|
||||
This calls removes a mountpoint that was previously created
|
||||
with C<guestfs_mkmountpoint>. See C<guestfs_mkmountpoint>
|
||||
for full details.");
|
||||
|
||||
]
|
||||
|
||||
let all_functions = non_daemon_functions @ daemon_functions
|
||||
|
||||
Reference in New Issue
Block a user