---
cat/ls.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/cat/ls.c b/cat/ls.c
index 9161fb6..b7a99b2 100644
--- a/cat/ls.c
+++ b/cat/ls.c
@@ -37,6 +37,7 @@
#include "options.h"
#include "visit.h"
+#include "windows.h"
/* Currently open libguestfs handle. */
guestfs_h *g;
@@ -76,6 +77,8 @@ static void output_int64_uid (int64_t);
static void output_string (const char *);
static void output_string_link (const char *);
+static const char *get_windows_root ();
+
static void __attribute__((noreturn))
usage (int status)
{
@@ -176,6 +179,7 @@ main (int argc, char *argv[])
#define MODE_LS_R 2
#define MODE_LS_LR (MODE_LS_L|MODE_LS_R)
int mode = 0;
+ CLEANUP_FREE const char * win_root;
g = guestfs_create ();
if (g == NULL) {
@@ -371,10 +375,18 @@ main (int argc, char *argv[])
free_drives (drvs);
free_mps (mps);
+ win_root = get_windows_root ();
+
unsigned errors = 0;
while (optind < argc) {
- const char *dir = argv[optind];
+ CLEANUP_FREE const char *dir;
+
+ if (win_root != NULL) {
+ dir = windows_path (g, win_root, argv[optind], 1 /* readonly */ );
+ } else {
+ dir = safe_strdup (g, argv[optind]);
+ }
switch (mode) {
case 0: /* no -l or -R option */
@@ -409,6 +421,24 @@ main (int argc, char *argv[])
exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
+static const char *
+get_windows_root (void)
+{
+ CLEANUP_FREE_STRING_LIST char **roots = NULL;
+ const char *root;
+
+ roots = guestfs_inspect_get_roots (g);
+ assert (roots);
+ assert (roots[0] != NULL);
+ assert (roots[1] == NULL);
+ root = safe_strdup(g, roots[0]);
+
+ if (is_windows (g, root))
+ return root;
+ else
+ return NULL;
+}
+
static int
do_ls (const char *dir)
{
--
1.9.3