[Libguestfs] [PACTH v2] customize: fix --upload to FAT partition (RHBZ#1196101)

Maros Zatko mzatko at redhat.com
Wed Mar 25 17:07:29 UTC 2015


FAT doesn't support file ownership, so show info instead
of error.
---
 customize/customize_run.ml | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index dbb77df..40d19ac 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -289,8 +289,20 @@ exec >>%s 2>&1
       let statbuf = stat path in
       let perms = statbuf.st_perm land 0o7777 (* sticky & set*id *) in
       g#chmod perms dest;
-      let uid, gid = statbuf.st_uid, statbuf.st_gid in
-      g#chown uid gid dest
+
+      (* Check if target resides on FAT filesystem and then don't change
+       * ownership
+       *)
+      let mps = List.map (fun (dev, mp) -> mp, g#vfs_type dev) (g#mountpoints ()) in
+      let is_vfat = List.exists (fun (mp, fs) ->
+        mp = (String.sub dest 0
+          (min (String.length mp) (String.length dest))) && fs = "vfat") mps in
+
+      if not is_vfat then
+        let uid, gid = statbuf.st_uid, statbuf.st_gid in
+        g#chown uid gid dest
+      else
+        info (f_"Uploading to vfat, skipping chown")
 
     | `Write (path, content) ->
       msg (f_"Writing: %s") path;
-- 
1.9.3




More information about the Libguestfs mailing list