>From 81e3376e67fce51bb7162ad14b3ce6e40754898c Mon Sep 17 00:00:00 2001 From: Richard W.M. Jones Date: Mon, 28 Mar 2011 13:35:53 +0100 Subject: [PATCH] fish: fuse: Add -m dev:mnt:opts to allow mount options to be specified. This lets you turn on ACLs and xattrs by doing: -m /dev/sda1:/:acl,user_xattr The extra parameter is passed through to mount_options: libguestfs: trace: mount_options "acl,user_xattr" "/dev/sda1" "/" --- fish/fish.c | 2 +- fish/guestfish.pod | 17 +++++++++++++---- fish/options.c | 11 +++++++++-- fish/options.h | 15 ++++++++++++--- fuse/Makefile.am | 2 +- fuse/guestmount.c | 2 +- fuse/guestmount.pod | 14 +++++++++++++- 7 files changed, 50 insertions(+), 13 deletions(-) diff --git a/fish/fish.c b/fish/fish.c index 22f3359..65a0c1d 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -117,7 +117,7 @@ usage (int status) " --keys-from-stdin Read passphrases from stdin\n" " --listen Listen for remote commands\n" " --live Connect to a live virtual machine\n" - " -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n" + " -m|--mount dev[:mnt[:opts]] Mount dev on mnt (if omitted, /)\n" " -n|--no-sync Don't autosync\n" " -N|--new type Create prepared disk (test1.img, ...)\n" " --progress-bars Enable progress bars even when not interactive\n" diff --git a/fish/guestfish.pod b/fish/guestfish.pod index abf6d7a..98286d1 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -299,9 +299,9 @@ L below. Connect to a live virtual machine. (Experimental, see L). -=item B<-m dev[:mountpoint]> +=item B<-m dev[:mountpoint[:options]]> -=item B<--mount dev[:mountpoint]> +=item B<--mount dev[:mountpoint[:options]]> Mount the named partition or logical volume on the given mountpoint. @@ -318,8 +318,17 @@ filesystems and LVs available (see L, L and L commands), or you can use the L program. -Using this flag is mostly equivalent to using the C -command or the C command if the I<--ro> flag was given. +The third (and rarely used) part of the mount parameter is the list of +mount options used to mount the underlying filesystem. If this is not +given, then the mount options are either the empty string or C +(the latter if the I<--ro> flag is used). By specifying the mount +options, you override this default choice. Probably the only time you +would use this is to enable ACLs and/or extended attributes if the +filesystem can support them: + + -m /dev/sda1:/:acl,user_xattr + +Using this flag is equivalent to using the C command. =item B<-n> diff --git a/fish/options.c b/fish/options.c index 436e10d..43a15e4 100644 --- a/fish/options.c +++ b/fish/options.c @@ -1,5 +1,5 @@ /* libguestfs - guestfish and guestmount shared option parsing - * Copyright (C) 2010 Red Hat Inc. + * Copyright (C) 2010-2011 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -106,11 +106,18 @@ mount_mps (struct mp *mp) if (mp) { mount_mps (mp->next); + const char *options; + if (mp->options) + options = mp->options; + else if (read_only) + options = "ro"; + else + options = ""; + /* Don't use guestfs_mount here because that will default to mount * options -o sync,noatime. For more information, see guestfs(3) * section "LIBGUESTFS GOTCHAS". */ - const char *options = read_only ? "ro" : ""; r = guestfs_mount_options (g, options, mp->device, mp->mountpoint); if (r == -1) { /* Display possible mountpoints before exiting. */ diff --git a/fish/options.h b/fish/options.h index b755d90..9507671 100644 --- a/fish/options.h +++ b/fish/options.h @@ -109,6 +109,7 @@ struct mp { struct mp *next; char *device; char *mountpoint; + char *options; }; /* in inspect.c */ @@ -173,12 +174,20 @@ extern int add_libvirt_drives (const char *guest); perror ("malloc"); \ exit (EXIT_FAILURE); \ } \ + mp->options = NULL; \ + mp->mountpoint = bad_cast ("/"); \ p = strchr (optarg, ':'); \ if (p) { \ *p = '\0'; \ - mp->mountpoint = p+1; \ - } else \ - mp->mountpoint = bad_cast ("/"); \ + p++; \ + mp->mountpoint = p; \ + p = strchr (p, ':'); \ + if (p) { \ + *p = '\0'; \ + p++; \ + mp->options = p; \ + } \ + } \ mp->device = optarg; \ mp->next = mps; \ mps = mp diff --git a/fuse/Makefile.am b/fuse/Makefile.am index 7d3b463..1cdb993 100644 --- a/fuse/Makefile.am +++ b/fuse/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2009 Red Hat Inc. +# Copyright (C) 2009-2011 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/fuse/guestmount.c b/fuse/guestmount.c index 6adf140..c4c6524 100644 --- a/fuse/guestmount.c +++ b/fuse/guestmount.c @@ -881,7 +881,7 @@ usage (int status) " --help Display help message and exit\n" " --keys-from-stdin Read passphrases from stdin\n" " --live Connect to a live virtual machine\n" - " -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n" + " -m|--mount dev[:mnt[:opts]] Mount dev on mnt (if omitted, /)\n" " -n|--no-sync Don't autosync\n" " -o|--option opt Pass extra option to FUSE\n" " -r|--ro Mount read-only\n" diff --git a/fuse/guestmount.pod b/fuse/guestmount.pod index 338af97..ea0cb63 100644 --- a/fuse/guestmount.pod +++ b/fuse/guestmount.pod @@ -148,7 +148,9 @@ to try to read passphrases from the user by opening C. Connect to a live virtual machine. (Experimental, see L). -=item B<-m dev[:mnt]> | B<--mount dev[:mnt]> +=item B<-m dev[:mountpoint[:options]]> + +=item B<--mount dev[:mountpoint[:options]]> Mount the named partition or logical volume on the given mountpoint B (this has nothing to do with mountpoints in the host). @@ -156,6 +158,16 @@ B (this has nothing to do with mountpoints in the host). If the mountpoint is omitted, it defaults to C. You have to mount something on C. +The third (and rarely used) part of the mount parameter is the list of +mount options used to mount the underlying filesystem. If this is not +given, then the mount options are either the empty string or C +(the latter if the I<--ro> flag is used). By specifying the mount +options, you override this default choice. Probably the only time you +would use this is to enable ACLs and/or extended attributes if the +filesystem can support them: + + -m /dev/sda1:/:acl,user_xattr + =item B<-n> | B<--no-sync> By default, we attempt to sync the guest disk when the FUSE mountpoint -- 1.7.4.1