From: Gurucharan Shetty Date: Mon, 10 Mar 2014 15:37:21 +0000 (-0700) Subject: ovsdb-server: Truncate file for Windows. X-Git-Tag: sliver-openvswitch-2.2.90-1~6^2~139 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=daa04db864882c1b0a479a4b292134ad3286b965;p=sliver-openvswitch.git ovsdb-server: Truncate file for Windows. There is no ftruncate() in visual studio. There is a _chsize_s() which has a similar functionality. Signed-off-by: Gurucharan Shetty Acked-by: Ben Pfaff --- diff --git a/include/windows/windefs.h b/include/windows/windefs.h index dcfa20bf0..6d36adc0c 100644 --- a/include/windows/windefs.h +++ b/include/windows/windefs.h @@ -22,6 +22,7 @@ #include #include #include +#include #define inline __inline #define __func__ __FUNCTION__ diff --git a/lib/util.c b/lib/util.c index 68a1ce6ea..6353e9c9e 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 9afe10e61..53039da41 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