From: Daan De Meyer Date: Fri, 28 Jan 2022 16:18:49 +0000 (+0000) Subject: shared: Handle filesystems that don't support hole punching in COPY_HOLES X-Git-Tag: v251-rc1~419 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b2d0f9efd2634a07522ce0383d3a44d417f8f1e;p=thirdparty%2Fsystemd.git shared: Handle filesystems that don't support hole punching in COPY_HOLES --- diff --git a/src/shared/copy.c b/src/shared/copy.c index a92cfc0f615..09417063562 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -119,9 +119,11 @@ static int create_hole(int fd, off_t size) { if (end < 0) return -errno; - /* If we're not at the end of the target file, punch a hole in the existing space using fallocate(). */ + /* If we're not at the end of the target file, try to punch a hole in the existing space using fallocate(). */ - if (offset < end && fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, MIN(size, end - offset)) < 0) + if (offset < end && + fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, MIN(size, end - offset)) < 0 && + !ERRNO_IS_NOT_SUPPORTED(errno)) return -errno; if (end - offset >= size) {