dpif-netlink: add GENEVE creation support
[cascardo/ovs.git] / ovsdb / log.c
index ea3c3f3..8004d3d 100644 (file)
@@ -32,9 +32,6 @@
 #include "socket-util.h"
 #include "transaction.h"
 #include "util.h"
-#include "vlog.h"
-
-VLOG_DEFINE_THIS_MODULE(ovsdb_log);
 
 enum ovsdb_log_mode {
     OVSDB_LOG_READ,
@@ -94,6 +91,7 @@ ovsdb_log_open(const char *name, enum ovsdb_log_open_mode open_mode,
     } else if (open_mode == OVSDB_LOG_READ_WRITE) {
         flags = O_RDWR;
     } else if (open_mode == OVSDB_LOG_CREATE) {
+#ifndef _WIN32
         if (stat(name, &s) == -1 && errno == ENOENT
             && lstat(name, &s) == 0 && S_ISLNK(s.st_mode)) {
             /* 'name' is a dangling symlink.  We want to create the file that
@@ -104,13 +102,19 @@ ovsdb_log_open(const char *name, enum ovsdb_log_open_mode open_mode,
         } else {
             flags = O_RDWR | O_CREAT | O_EXCL;
         }
+#else
+        flags = O_RDWR | O_CREAT | O_EXCL;
+#endif
     } else {
-        NOT_REACHED();
+        OVS_NOT_REACHED();
     }
+#ifdef _WIN32
+    flags = flags | O_BINARY;
+#endif
     fd = open(name, flags, 0666);
     if (fd < 0) {
         const char *op = open_mode == OVSDB_LOG_CREATE ? "create" : "open";
-        error = ovsdb_io_error(errno, "%s: %s failed", op, name);
+        error = ovsdb_io_error(errno, "%s: %s failed", name, op);
         goto error_unlock;
     }
 
@@ -192,13 +196,6 @@ parse_header(char *header, unsigned long int *length,
     return true;
 }
 
-struct ovsdb_log_read_cbdata {
-    char input[4096];
-    struct ovsdb_log *file;
-    int error;
-    unsigned long length;
-};
-
 static struct ovsdb_error *
 parse_body(struct ovsdb_log *file, off_t offset, unsigned long int length,
            uint8_t sha1[SHA1_DIGEST_SIZE], struct json **jsonp)
@@ -359,7 +356,7 @@ ovsdb_log_write(struct ovsdb_log *file, struct json *json)
 
     /* Compose header. */
     sha1_bytes(json_string, length, sha1);
-    snprintf(header, sizeof header, "%s%zu "SHA1_FMT"\n",
+    snprintf(header, sizeof header, "%s%"PRIuSIZE" "SHA1_FMT"\n",
              magic, length, SHA1_ARGS(sha1));
 
     /* Write. */