From 05bbdd83d65782a9872b579505e1299587cd2009 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 11 Nov 2015 19:43:17 -0600 Subject: [PATCH 1/1] write.c: let compaction work on untruncatable files --- src/write.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/write.c b/src/write.c index f3308a24..7f13630c 100644 --- a/src/write.c +++ b/src/write.c @@ -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. */ - 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; } -- 2.43.0