]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Ignore a request of HFS+ Compression if the filesystem a file
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 31 Oct 2012 02:01:09 +0000 (11:01 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 31 Oct 2012 02:01:09 +0000 (11:01 +0900)
is restoring on does not support.

libarchive/archive_write_disk_posix.c

index 81458b39885fb796c015bd52e139d5cad9e8f0da..870c984dc3aa134d4ec4154d3b1d7b326528600f 100644 (file)
@@ -569,6 +569,26 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry)
 
        ret = restore_entry(a);
 
+#if defined(UF_COMPRESSED) && defined(HAVE_STRUCT_STAT_ST_FLAGS) && \
+      defined(HAVE_FCHFLAGS)
+       /*
+        * Check if the filesystem the file is restoring on supports
+        * HFS+ Compression. If not, cancel HFS+ Compression.
+        */
+       if (a->todo | TODO_HFS_COMPRESSION) {
+               /*
+                * NOTE: UF_COMPRESSED is ignored even if the filesystem
+                * supports HFS+ Compression because the file should
+                * have at least an extended attriute "com.apple.decmpfs"
+                * before the flag is set to indicate that the file have
+                * been compressed. If hte filesystem does not support
+                * HFS+ Compression the system call will fail.
+                */
+               if (a->fd < 0 || fchflags(a->fd, UF_COMPRESSED) != 0)
+                       a->todo &= ~TODO_HFS_COMPRESSION;
+       }
+#endif
+
        /*
         * TODO: There are rumours that some extended attributes must
         * be restored before file data is written.  If this is true,