From e58883c1836ec526fde198e6b42e45d18704f7d4 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 26 Apr 2018 09:55:31 +0200 Subject: [PATCH] Hide return code check fot fallocate (that can silenty fail in this context). --- lib/luks2/luks2_luks1_convert.c | 3 ++- src/cryptsetup_reencrypt.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/luks2/luks2_luks1_convert.c b/lib/luks2/luks2_luks1_convert.c index ac8be931..8907e121 100644 --- a/lib/luks2/luks2_luks1_convert.c +++ b/lib/luks2/luks2_luks1_convert.c @@ -440,7 +440,8 @@ static int move_keyslot_areas(struct crypt_device *cd, off_t offset_from, } /* This can safely fail (for block devices). It only allocates space if it is possible. */ - posix_fallocate(devfd, offset_to, buf_size); + if (posix_fallocate(devfd, offset_to, buf_size)) + log_dbg("Preallocation (fallocate) of new keyslot area not available."); /* Try to read *new* area to check that area is there (trimmed backup). */ if (read_lseek_blockwise(devfd, device_block_size(device), diff --git a/src/cryptsetup_reencrypt.c b/src/cryptsetup_reencrypt.c index 870eb66e..44f26ac8 100644 --- a/src/cryptsetup_reencrypt.c +++ b/src/cryptsetup_reencrypt.c @@ -900,7 +900,7 @@ static int restore_luks_header(struct reenc_ctx *rc) stat(rc->header_file_new, &st) != -1) { fd = open(rc->device_header, O_WRONLY); if (fd != -1) { - posix_fallocate(fd, 0, st.st_size); + if (posix_fallocate(fd, 0, st.st_size)) {}; close(fd); } }