Windows: Fix Parent(path) computation to permit mp and symlink creation

The parent path computation was leaving trailing slashes on the
path names which prevented the creation of mount points and symlinks
when UNC paths were used that contained mount points.

LICENSE MIT

Change-Id: I50cba9cb8a2b0ad45f84995d05f368052be683cc
Reviewed-on: http://gerrit.openafs.org/2886
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Jeffrey Altman 2010-09-16 01:01:06 +02:00 committed by Jeffrey Altman
parent 61b73864d7
commit 6ad0e5b529
2 changed files with 14 additions and 4 deletions

View File

@ -293,7 +293,12 @@ Parent(char *apath)
} }
tp = strrchr(tspace, '\\'); tp = strrchr(tspace, '\\');
if (tp) { if (tp) {
if (tp - tspace > 2 &&
tspace[1] == ':' &&
&tspace[2] == tp)
*(tp+1) = 0; /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */ *(tp+1) = 0; /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */
else
*tp = 0;
} }
else { else {
fs_ExtractDriveLetter(apath, tspace); fs_ExtractDriveLetter(apath, tspace);

View File

@ -256,13 +256,18 @@ static BOOL IsAdmin (void)
} }
/* return a static pointer to a buffer */ /* return a static pointer to a buffer */
static char *Parent(apath) static char *Parent(char *apath)
char *apath; { {
char *tp; char *tp;
strcpy(tspace, apath); strcpy(tspace, apath);
tp = strrchr(tspace, '\\'); tp = strrchr(tspace, '\\');
if (tp) { if (tp) {
if (tp - tspace > 2 &&
tspace[1] == ':' &&
&tspace[2] == tp)
*(tp+1) = 0; /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */ *(tp+1) = 0; /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */
else
*tp = 0;
} }
else { else {
fs_ExtractDriveLetter(apath, tspace); fs_ExtractDriveLetter(apath, tspace);