From daa04db864882c1b0a479a4b292134ad3286b965 Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Mon, 10 Mar 2014 08:37:21 -0700 Subject: [PATCH] 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 --- 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 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 -- 2.43.0