On Windows, backslash('\') is a valid directory separator. In
lockfile_name(), we treat only forward-slash ('/') as a directory
separator. This results in a lockfile name such as
...\conf.db.~lock~ for a input file such as ..\conf.db.

We fix the issue in this patch. This was per Ben's suggestion.
This fix is specific to Windows, since '/' is a valid character
in a file or directory name in Linux.

Signed-off-by: Nithin Raju <nit...@vmware.com>
---
 lib/lockfile.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/lockfile.c b/lib/lockfile.c
index 1ef6251..15a7e4d 100644
--- a/lib/lockfile.c
+++ b/lib/lockfile.c
@@ -82,6 +82,12 @@ lockfile_name(const char *filename_)
      * symlink, not one for each. */
     filename = follow_symlinks(filename_);
     slash = strrchr(filename, '/');
+#ifdef _WIN32
+    if (!slash) {
+        /* On Windows, '\' is a valid directory separator. */
+        slash = strrchr(filename, '\\');
+    }
+#endif
     lockname = (slash
                 ? xasprintf("%.*s/.%s.~lock~",
                             (int) (slash - filename), filename, slash + 1)
-- 
1.9.1

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

Reply via email to