mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-09 12:38:27 -05:00
Fix mingw32 portability
This commit is contained in:
+10
-1
@@ -136,7 +136,7 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
|
||||
/* memset wants the mmap'ed file to be present on disk so create a
|
||||
* sparse file
|
||||
*/
|
||||
r = ftruncate(fd, len);
|
||||
r = ftruncate(fd, offset + len);
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
@@ -158,6 +158,9 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
|
||||
char *buf;
|
||||
unsigned long long remain, bytes;
|
||||
|
||||
if (lseek(fd, offset, SEEK_SET) < 0)
|
||||
return errno;
|
||||
|
||||
/* Split up the write in small chunks so as not to allocate lots of RAM */
|
||||
remain = len;
|
||||
bytes = 1024 * 1024;
|
||||
@@ -949,6 +952,7 @@ int virFileLinkPointsTo(const char *checkLink,
|
||||
int virFileResolveLink(const char *linkpath,
|
||||
char **resultpath)
|
||||
{
|
||||
#ifdef HAVE_READLINK
|
||||
struct stat st;
|
||||
char *buf;
|
||||
int n;
|
||||
@@ -981,6 +985,11 @@ int virFileResolveLink(const char *linkpath,
|
||||
|
||||
*resultpath = buf;
|
||||
return 0;
|
||||
#else
|
||||
if (!(*resultpath = strdup(linkpath)))
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user