On Windows, for a filename such as ..\conf.db, the name of the lockfile
constructed by lockfile_name() turns out to be ...\conf.db.~lock~. This is
not a valid path. The extra '.' added to make the file hidden does not work
as expected if backslash ('\') is used for directory separation.
A simple fix is to not use '.' on Windows to hide the file.
Signed-off-by: Nithin Raju <[email protected]>
---
lib/lockfile.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/lockfile.c b/lib/lockfile.c
index 1ef6251..6862509 100644
--- a/lib/lockfile.c
+++ b/lib/lockfile.c
@@ -74,6 +74,11 @@ lockfile_name(const char *filename_)
char *filename;
const char *slash;
char *lockname;
+#ifndef _WIN32
+ char hidden_prefix[] = ".";
+#else
+ char hidden_prefix[] = "";
+#endif
/* If 'filename_' is a symlink, base the name of the lockfile on the
* symlink's target rather than the name of the symlink. That way, if a
@@ -83,9 +88,10 @@ lockfile_name(const char *filename_)
filename = follow_symlinks(filename_);
slash = strrchr(filename, '/');
lockname = (slash
- ? xasprintf("%.*s/.%s.~lock~",
- (int) (slash - filename), filename, slash + 1)
- : xasprintf(".%s.~lock~", filename));
+ ? xasprintf("%.*s/%s%s.~lock~",
+ (int) (slash - filename), filename, hidden_prefix,
+ slash + 1)
+ : xasprintf("%s%s.~lock~", hidden_prefix, filename));
free(filename);
return lockname;
--
1.9.1
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev