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 <yamato@redhat.com>
#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"));
}
}