[Libguestfs] [PATCH 1/7] mount: Add mount_vfs_nochroot

Richard W.M. Jones rjones at redhat.com
Tue Feb 12 12:06:47 UTC 2013


On Tue, Feb 12, 2013 at 11:04:20AM +0000, Matthew Booth wrote:
> This internal function allows mounting a mountable outside /sysroot.
> ---
>  daemon/daemon.h |  6 ++++++
>  daemon/mount.c  | 14 +++++++++++---
>  2 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/daemon/daemon.h b/daemon/daemon.h
> index 67adec0..d343dfd 100644
> --- a/daemon/daemon.h
> +++ b/daemon/daemon.h
> @@ -65,6 +65,12 @@ extern int xread (int sock, void *buf, size_t len)
>  
>  extern char *mountable_to_string (const mountable_t *mountable);
>  
> +/*-- in mount.c --*/
> +
> +extern int mount_vfs_nochroot (const char *options, const char *vfstype,
> +                               const mountable_t *mountable,
> +                               const char *mp, const char *user_mp);
> +
>  /* Growable strings buffer. */
>  struct stringsbuf {
>    char **argv;
> diff --git a/daemon/mount.c b/daemon/mount.c
> index 7e1199f..452b938 100644
> --- a/daemon/mount.c
> +++ b/daemon/mount.c
> @@ -126,9 +126,7 @@ int
>  do_mount_vfs (const char *options, const char *vfstype,
>                const mountable_t *mountable, const char *mountpoint)
>  {
> -  int r;
>    CLEANUP_FREE char *mp = NULL;
> -  CLEANUP_FREE char *error = NULL;
>    struct stat statbuf;
>  
>    ABS_PATH (mountpoint, , return -1);
> @@ -149,6 +147,14 @@ do_mount_vfs (const char *options, const char *vfstype,
>      return -1;
>    }
>  
> +  return mount_vfs_nochroot (options, vfstype, mountable, mp, mountpoint);
> +}
> +
> +int
> +mount_vfs_nochroot (const char *options, const char *vfstype,
> +                    const mountable_t *mountable,
> +                    const char *mp, const char *user_mp)
> +{
>    CLEANUP_FREE char *options_plus = NULL;
>    const char *device = mountable->device;
>    if (mountable->type == MOUNTABLE_BTRFSVOL) {
> @@ -169,6 +175,8 @@ do_mount_vfs (const char *options, const char *vfstype,
>      }
>    }
>  
> +  CLEANUP_FREE char *error = NULL;
> +  int r;
>    if (vfstype)
>      r = command (NULL, &error,
>                   str_mount, "-o", options_plus ? options_plus : options,
> @@ -179,7 +187,7 @@ do_mount_vfs (const char *options, const char *vfstype,
>                   device, mp, NULL);
>    if (r == -1) {
>      reply_with_error ("%s on %s (options: '%s'): %s",
> -                      device, mountpoint, options, error);
> +                      device, user_mp, options, error);
>      return -1;
>    }

Much more comprehensible, ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list