From: Claudio Fontana Date: Fri, 6 May 2022 13:10:50 +0000 (+0200) Subject: virfile: add comment about the use of SEEK_END in virFileDiskCopy X-Git-Tag: v8.4.0-rc1~250 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f79de95b16c5dadf845e53be9070aea0f61450b2;p=thirdparty%2Flibvirt.git virfile: add comment about the use of SEEK_END in virFileDiskCopy Signed-off-by: Claudio Fontana Reviewed-by: Daniel P. Berrangé --- diff --git a/src/util/virfile.c b/src/util/virfile.c index df16ea5d1e..e4522b5f67 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4741,6 +4741,10 @@ virFileDiskCopy(int disk_fd, const char *disk_path, int remote_fd, const char *r if (!p.isBlockDev && p.isDirect) { off_t off; if (p.isWrite) { + /* + * note: for write we do not only check that disk_fd is seekable, + * we also want to know that the file is empty, so we need SEEK_END. + */ if ((off = lseek(disk_fd, 0, SEEK_END)) != 0) { virReportSystemError(off < 0 ? errno : EINVAL, "%s", _("O_DIRECT write needs empty seekable file"));