On Mon, Mar 23, 2015 at 05:44:35PM +0100, Maros Zatko wrote:
---
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);
This breaks if inspector == 0 (eg. if the -m option is given). It
will actually assert-fail on the next line.
I strongly suggest you look at cat/cat.c and just copy what that
program does.
Also you need to update the documentation.
Rich.
+ 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
_______________________________________________
Libguestfs mailing list
Libguestfs(a)redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW