]> wimlib.net Git - wimlib/commitdiff
write.c: let compaction work on untruncatable files
authorEric Biggers <ebiggers3@gmail.com>
Thu, 12 Nov 2015 01:43:17 +0000 (19:43 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 12 Nov 2015 02:01:07 +0000 (20:01 -0600)
src/write.c

index f3308a24c14f88ffa47b579680c2e484a040b936..7f13630cceec991aea303afd27b74f0b1b67f888 100644 (file)
@@ -2430,7 +2430,10 @@ finish_write(WIMStruct *wim, int image, int write_flags,
        ret = WIMLIB_ERR_WRITE;
        if (unlikely(write_flags & WIMLIB_WRITE_FLAG_UNSAFE_COMPACT)) {
                /* Truncate any data the compaction freed up.  */
        ret = WIMLIB_ERR_WRITE;
        if (unlikely(write_flags & WIMLIB_WRITE_FLAG_UNSAFE_COMPACT)) {
                /* Truncate any data the compaction freed up.  */
-               if (ftruncate(wim->out_fd.fd, wim->out_fd.offset)) {
+               if (ftruncate(wim->out_fd.fd, wim->out_fd.offset) &&
+                   errno != EINVAL) /* allow compaction on untruncatable files,
+                                       e.g. block devices  */
+               {
                        ERROR_WITH_ERRNO("Failed to truncate the output WIM file");
                        goto out;
                }
                        ERROR_WITH_ERRNO("Failed to truncate the output WIM file");
                        goto out;
                }