On Fri, Jul 25, 2014 at 07:27:58PM -0700, Nithin Raju wrote: > 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
I think that this can get the wrong result if a filename has a mix of directory separators. In /a/b\c, for example, it will skip over the \ to the /. Probably we want a helper function here to return the last / or \. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev