There is no ftruncate() in visual studio. There is a _chsize_s()
which has a similar functionality.

Signed-off-by: Gurucharan Shetty <gshe...@nicira.com>
---
 include/windows/windefs.h |    1 +
 lib/util.c                |   12 ++++++++++++
 lib/util.h                |    1 +
 3 files changed, 14 insertions(+)

diff --git a/include/windows/windefs.h b/include/windows/windefs.h
index dcfa20b..6d36adc 100644
--- a/include/windows/windefs.h
+++ b/include/windows/windefs.h
@@ -22,6 +22,7 @@
 #include <WS2tcpip.h>
 #include <windows.h>
 #include <BaseTsd.h>
+#include <io.h>
 
 #define inline __inline
 #define __func__ __FUNCTION__
diff --git a/lib/util.c b/lib/util.c
index 68a1ce6..6353e9c 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -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
diff --git a/lib/util.h b/lib/util.h
index 9afe10e..53039da 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -493,6 +493,7 @@ uint64_t bitwise_get(const void *src, unsigned int src_len,
 
 char *ovs_format_message(int error);
 char *ovs_lasterror_to_string(void);
+int ftruncate(int fd, off_t length);
 #endif
 
 #ifdef  __cplusplus
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to