The Mingw platform lacks readlink(), so we stub out this method on that platform. The plain write() implementation of safezero() was not actually doing anything with the 'offset' arg. This makes it seek to the offset location before writing data. The mmap implementation of safezero() was also not quite right, truncating to len, so if offset was non-zero, it would not be large enough. Daniel Index: configure.in =================================================================== RCS file: /data/cvs/libvirt/configure.in,v retrieving revision 1.211 diff -u -p -r1.211 configure.in --- configure.in 1 Apr 2009 10:40:38 -0000 1.211 +++ configure.in 1 Apr 2009 15:53:35 -0000 @@ -72,7 +72,7 @@ dnl Use --disable-largefile if you don't AC_SYS_LARGEFILE dnl Availability of various common functions (non-fatal if missing). -AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity getuid getgid posix_fallocate mmap]) +AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity getuid getgid posix_fallocate mmap readlink]) dnl Availability of various not common threadsafe functions AC_CHECK_FUNCS([strerror_r strtok_r getmntent_r getgrnam_r getpwuid_r]) Index: src/util.c =================================================================== RCS file: /data/cvs/libvirt/src/util.c,v retrieving revision 1.98 diff -u -p -r1.98 util.c --- src/util.c 1 Apr 2009 10:26:22 -0000 1.98 +++ src/util.c 1 Apr 2009 15:53:35 -0000 @@ -136,7 +136,7 @@ int safezero(int fd, int flags ATTRIBUTE /* 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 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 *chec 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 *linkp *resultpath = buf; return 0; +#else + if (!(*resultpath = strdup(linkpath))) + return -ENOMEM; + return 0; +#endif } -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list