[Libguestfs] [PATCH 03/13] fish, edit: move the exit-on-case-sensitive-error behaviour to virt-edit

Pino Toscano ptoscano at redhat.com
Thu Aug 28 13:21:06 UTC 2014


Do not unconditionally exit if guestfs_case_sensitive_path, but let
windows_path still return null. Make virt-edit then check for that, and
eventually exit on its own.
---
 edit/edit.c    | 5 ++++-
 fish/windows.c | 3 +--
 fish/windows.h | 3 +--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/edit/edit.c b/edit/edit.c
index cd91b5f..1f5ec7b 100644
--- a/edit/edit.c
+++ b/edit/edit.c
@@ -335,9 +335,12 @@ edit (const char *filename, const char *root)
   CLEANUP_FREE char *backupname = NULL;
 
   /* Windows?  Special handling is required. */
-  if (root != NULL && is_windows (g, root))
+  if (root != NULL && is_windows (g, root)) {
     filename = filename_to_free = windows_path (g, root, filename,
                                                 0 /* not read only */);
+    if (filename == NULL)
+      exit (EXIT_FAILURE);
+  }
 
   /* Download the file to a temporary. */
   fd = mkstemp (tmpfile);
diff --git a/fish/windows.c b/fish/windows.c
index 06dcab3..04ead2f 100644
--- a/fish/windows.c
+++ b/fish/windows.c
@@ -84,11 +84,10 @@ windows_path (guestfs_h *g, const char *root, const char *path, int readonly)
     if (ret[i] == '\\')
       ret[i] = '/';
 
+  /* If this fails, we want to return NULL. */
   char *t = guestfs_case_sensitive_path (g, ret);
   free (ret);
   ret = t;
-  if (ret == NULL)
-    exit (EXIT_FAILURE);
 
   return ret;
 }
diff --git a/fish/windows.h b/fish/windows.h
index 5543182..c543604 100644
--- a/fish/windows.h
+++ b/fish/windows.h
@@ -37,8 +37,7 @@ extern int is_windows (guestfs_h *g, const char *root);
  *  - relies on an already being done introspection
  *  - will unmount all the existing mount points and mount the Windows root
  *    (according to 'readonly')
- *  - will exit() on memory allocation failures, and if it is not possible
- *    to get the true path on case-insensitive filesystems
+ *  - will exit() on memory allocation failures
  */
 extern char *windows_path (guestfs_h *g, const char *root, const char *path,
                            int readonly);
-- 
1.9.3




More information about the Libguestfs mailing list