]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix mingw32 portability
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 2 Apr 2009 18:42:33 +0000 (18:42 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 2 Apr 2009 18:42:33 +0000 (18:42 +0000)
ChangeLog
configure.in
src/util.c

index 3e8434413113c109400efc1dc3fa72ddd139bb18..4bcaf13eb109ab3b445e0c23cc32de2ffeb68e1e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Apr  2 19:41:00 BST 2009 Daniel P. Berrange <berrange@redhat.com>
+
+       Mingw portability fixes
+       * src/util.c: Fix virFileResolveLink for Win32 platform.
+       Fix offset usage in safezero for mmap() and write() impls
+       * configure.in: Add check for readlink()
+
 Thu Apr  2 15:18:00 CEST 2009 Daniel Veillard <veillard@redhat.com>
 
        * docs/schemas/domain.rng: some missing disk bus values and cleanups
index 392f2b9f054fab049e1c15aad27d27052b0026c7..70a6b1ac77b6da17eca7bb94b4111a018ce22b36 100644 (file)
@@ -72,7 +72,7 @@ dnl Use --disable-largefile if you don't want this.
 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])
@@ -937,8 +937,8 @@ if test "$with_storage_scsi" = "check"; then
 
    AC_DEFINE_UNQUOTED([WITH_STORAGE_SCSI], 1,
      [whether SCSI backend for storage driver is enabled])
-   AM_CONDITIONAL([WITH_STORAGE_SCSI], [test "$with_storage_scsi" = "yes"])
 fi
+AM_CONDITIONAL([WITH_STORAGE_SCSI], [test "$with_storage_scsi" = "yes"])
 
 
 LIBPARTED_CFLAGS=
index 65088b04c57c625a6f09f5c1675cc76e831b5da1..5abdbbcec431222815079c568b4edaf9827dcfaf 100644 (file)
@@ -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
 }