ovsdb-server: Truncate file for Windows.
authorGurucharan Shetty <gshetty@nicira.com>
Mon, 10 Mar 2014 15:37:21 +0000 (08:37 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Wed, 12 Mar 2014 16:14:54 +0000 (09:14 -0700)
There is no ftruncate() in visual studio. There is a _chsize_s()
which has a similar functionality.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
include/windows/windefs.h
lib/util.c
lib/util.h

index dcfa20b..6d36adc 100644 (file)
@@ -22,6 +22,7 @@
 #include <WS2tcpip.h>
 #include <windows.h>
 #include <BaseTsd.h>
+#include <io.h>
 
 #define inline __inline
 #define __func__ __FUNCTION__
index 68a1ce6..6353e9c 100644 (file)
@@ -1688,4 +1688,16 @@ ovs_lasterror_to_string(void)
 {
     return ovs_format_message(GetLastError());
 }
+
+int
+ftruncate(int fd, off_t length)
+{
+    int error;
+
+    error = _chsize_s(fd, length);
+    if (error) {
+        return -1;
+    }
+    return 0;
+}
 #endif
index 9afe10e..53039da 100644 (file)
@@ -493,6 +493,7 @@ uint64_t bitwise_get(const void *src, unsigned int src_len,
 \f
 char *ovs_format_message(int error);
 char *ovs_lasterror_to_string(void);
+int ftruncate(int fd, off_t length);
 #endif
 
 #ifdef  __cplusplus