if (bytes > remain)
bytes = remain;
- if (safezero(fd, 0, vol->allocation - remain, bytes) != 0) {
+ if (safezero(fd, 0, vol->allocation - remain, bytes) < 0) {
ret = -errno;
virReportSystemError(errno, _("cannot fill file '%s'"),
vol->target.path);
remain -= bytes;
}
} else { /* No progress bars to be shown */
- if (safezero(fd, 0, 0, remain) != 0) {
+ if (safezero(fd, 0, 0, remain) < 0) {
ret = -errno;
virReportSystemError(errno, _("cannot fill file '%s'"),
vol->target.path);
#ifdef HAVE_POSIX_FALLOCATE
int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
{
- return posix_fallocate(fd, offset, len);
+ int ret = posix_fallocate(fd, offset, len);
+ if (ret == 0)
+ return 0;
+ errno = ret;
+ return -1;
}
#else