[Pkg-libvirt-commits] [libguestfs] 207/266: fish, edit: specifies whether mount Windows as readonly

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:42:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit de6258352997e4e7990862a9809d4fbbc875b978
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Wed Aug 27 16:41:35 2014 +0200

    fish, edit: specifies whether mount Windows as readonly
---
 edit/edit.c    |  3 ++-
 fish/windows.c | 11 ++++++-----
 fish/windows.h |  4 +++-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/edit/edit.c b/edit/edit.c
index d4ce747..cd91b5f 100644
--- a/edit/edit.c
+++ b/edit/edit.c
@@ -336,7 +336,8 @@ edit (const char *filename, const char *root)
 
   /* Windows?  Special handling is required. */
   if (root != NULL && is_windows (g, root))
-    filename = filename_to_free = windows_path (g, root, filename);
+    filename = filename_to_free = windows_path (g, root, filename,
+                                                0 /* not read only */);
 
   /* Download the file to a temporary. */
   fd = mkstemp (tmpfile);
diff --git a/fish/windows.c b/fish/windows.c
index ddf2af1..06dcab3 100644
--- a/fish/windows.c
+++ b/fish/windows.c
@@ -33,7 +33,7 @@
 #include "c-ctype.h"
 
 static void mount_drive_letter (guestfs_h *g, char drive_letter,
-                                const char *root);
+                                const char *root, int readonly);
 
 int
 is_windows (guestfs_h *g, const char *root)
@@ -48,7 +48,7 @@ is_windows (guestfs_h *g, const char *root)
 }
 
 char *
-windows_path (guestfs_h *g, const char *root, const char *path)
+windows_path (guestfs_h *g, const char *root, const char *path, int readonly)
 {
   char *ret;
   size_t i;
@@ -57,7 +57,7 @@ windows_path (guestfs_h *g, const char *root, const char *path)
   if (c_isalpha (path[0]) && path[1] == ':') {
     char drive_letter = c_tolower (path[0]);
     /* This returns the newly allocated string. */
-    mount_drive_letter (g, drive_letter, root);
+    mount_drive_letter (g, drive_letter, root, readonly);
     ret = strdup (path + 2);
     if (ret == NULL) {
       perror ("strdup");
@@ -94,7 +94,8 @@ windows_path (guestfs_h *g, const char *root, const char *path)
 }
 
 static void
-mount_drive_letter (guestfs_h *g, char drive_letter, const char *root)
+mount_drive_letter (guestfs_h *g, char drive_letter, const char *root,
+                    int readonly)
 {
   char *device;
   size_t i;
@@ -126,7 +127,7 @@ mount_drive_letter (guestfs_h *g, char drive_letter, const char *root)
   if (guestfs_umount_all (g) == -1)
     exit (EXIT_FAILURE);
 
-  if (guestfs_mount (g, device, "/") == -1)
+  if ((readonly ? guestfs_mount_ro : guestfs_mount) (g, device, "/") == -1)
     exit (EXIT_FAILURE);
 
   /* Don't need to free (device) because that string was in the
diff --git a/fish/windows.h b/fish/windows.h
index bb68634..5543182 100644
--- a/fish/windows.h
+++ b/fish/windows.h
@@ -36,9 +36,11 @@ extern int is_windows (guestfs_h *g, const char *root);
  *  - 'root' must be a Windows installation
  *  - 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
  */
-extern char *windows_path (guestfs_h *g, const char *root, const char *path);
+extern char *windows_path (guestfs_h *g, const char *root, const char *path,
+                           int readonly);
 
 #endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list