From: Masatake YAMATO Date: Fri, 19 Jan 2024 14:47:30 +0000 (+0900) Subject: fallocate: fix the way to evaluate values returned from posix_fallocate X-Git-Tag: v2.40-rc1~37^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fa738e31cdc8b678c20c0c42d7432927db2640c2;p=thirdparty%2Futil-linux.git fallocate: fix the way to evaluate values returned from posix_fallocate Unlike Linux native system calls, posix_fallocate doesn't return -1 whe an error occurs; it returns a errno value directly. The bug of the original code was reported by @Yugend on #2714. Signed-off-by: Masatake YAMATO --- diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 19fb87ff79..ac7c687f22 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -144,8 +144,8 @@ static void xfallocate(int fd, int mode, off_t offset, off_t length) #ifdef HAVE_POSIX_FALLOCATE static void xposix_fallocate(int fd, off_t offset, off_t length) { - int error = posix_fallocate(fd, offset, length); - if (error < 0) { + errno = posix_fallocate(fd, offset, length); + if (errno != 0) { err(EXIT_FAILURE, _("fallocate failed")); } }