Implement the -m/--mount as available in guestfish to override the
automatic introspection and specify which partitions to mount instead.
---
cat/ls.c | 25 +++++++++++++++++++------
cat/virt-ls.pod | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/cat/ls.c b/cat/ls.c
index 97022c5..38acc4d 100644
--- a/cat/ls.c
+++ b/cat/ls.c
@@ -102,6 +102,8 @@ usage (int status)
" -h|--human-readable Human-readable sizes in output\n"
" --keys-from-stdin Read passphrases from stdin\n"
" -l|--long Long listing\n"
+ " -m|--mount dev[:mnt[:opts[:fstype]]]\n"
+ " Mount dev on mnt (if omitted, /)\n"
" -R|--recursive Recursive listing\n"
" --times Display file times\n"
" --time-days Display file times as days before now\n"
@@ -130,7 +132,7 @@ main (int argc, char *argv[])
enum { HELP_OPTION = CHAR_MAX + 1 };
- static const char *options = "a:c:d:hlRvVx";
+ static const char *options = "a:c:d:hlm:RvVx";
static const struct option long_options[] = {
{ "add", 1, 0, 'a' },
{ "checksum", 2, 0, 0 },
@@ -147,6 +149,7 @@ main (int argc, char *argv[])
{ "keys-from-stdin", 0, 0, 0 },
{ "long", 0, 0, 'l' },
{ "long-options", 0, 0, 0 },
+ { "mount", 1, 0, 'm' },
{ "recursive", 0, 0, 'R' },
{ "time", 0, 0, 0 },
{ "times", 0, 0, 0 },
@@ -161,6 +164,9 @@ main (int argc, char *argv[])
};
struct drv *drvs = NULL;
struct drv *drv;
+ struct mp *mps = NULL;
+ struct mp *mp;
+ char *p;
const char *format = NULL;
int c;
int option_index;
@@ -247,6 +253,11 @@ main (int argc, char *argv[])
mode |= MODE_LS_L;
break;
+ case 'm':
+ OPTION_m;
+ inspector = 0;
+ break;
+
case 'R':
mode |= MODE_LS_R;
break;
@@ -313,7 +324,7 @@ main (int argc, char *argv[])
* values.
*/
assert (read_only == 1);
- assert (inspector == 1);
+ assert (inspector == 1 || mps != NULL);
assert (live == 0);
/* Many flags only apply to -lR mode. */
@@ -342,18 +353,20 @@ main (int argc, char *argv[])
if (drvs == NULL)
usage (EXIT_FAILURE);
- /* Add drives, inspect and mount. Note that inspector is always true,
- * and there is no -m option.
- */
+ /* Add drives, inspect and mount. */
add_drives (drvs, 'a');
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
- inspect_mount ();
+ if (mps != NULL)
+ mount_mps (mps);
+ else
+ inspect_mount ();
/* Free up data structures, no longer needed after this point. */
free_drives (drvs);
+ free_mps (mps);
unsigned errors = 0;
diff --git a/cat/virt-ls.pod b/cat/virt-ls.pod
index be955d3..b7b676e 100644
--- a/cat/virt-ls.pod
+++ b/cat/virt-ls.pod
@@ -357,6 +357,42 @@ L</RECURSIVE LONG LISTING> above.
Read key or passphrase parameters from stdin. The default is
to try to read passphrases from the user by opening C</dev/tty>.
+=item B<-m dev[:mountpoint[:options[:fstype]]]>
+
+=item B<--mount dev[:mountpoint[:options[:fstype]]]>
+
+Mount the named partition or logical volume on the given mountpoint.
+
+If the mountpoint is omitted, it defaults to C</>.
+
+Specifying any mountpoint disables the inspection of the guest and
+the mount of its root and all of its mountpoints, so make sure
+to mount all the mountpoints needed to work with the filenames
+gives as arguments.
+
+If you don't know what filesystems a disk image contains, you can
+either run guestfish without this option, then list the partitions,
+filesystems and LVs available (see L</list-partitions>,
+L</list-filesystems> and L</lvs> commands), or you can use the
+L<virt-filesystems(1)> program.
+
+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<ro>
+(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<mount-options> command.
+
+The fourth part of the parameter is the filesystem driver to use, such
+as C<ext3> or C<ntfs>. This is rarely needed, but can be useful if
+multiple drivers are valid for a filesystem (eg: C<ext2> and C<ext3>),
+or if libguestfs misidentifies a filesystem.
+
=item B<-l>
=item B<--long>
--
1.9.3