Calling fallocate on the new (smaller) capacity ensures
that the whole file is allocated, but it does not reduce
the file size.
Also call ftruncate after fallocate.
https://bugzilla.redhat.com/show_bug.cgi?id=
1366446
}
goto cleanup;
}
- } else {
- if (ftruncate(fd, capacity) < 0) {
- virReportSystemError(errno,
- _("Failed to truncate file '%s'"), path);
- goto cleanup;
- }
+ }
+
+ if (ftruncate(fd, capacity) < 0) {
+ virReportSystemError(errno,
+ _("Failed to truncate file '%s'"), path);
+ goto cleanup;
}
if (VIR_CLOSE(fd) < 0) {