From 6ad0e5b529dbfd7a2401a0622eb4ea5269124ceb Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 16 Sep 2010 01:01:06 +0200 Subject: [PATCH] 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 Reviewed-by: Rod Widdowson Reviewed-by: Jeffrey Altman --- src/WINNT/afsd/fs.c | 7 ++++++- src/WINNT/afsd/symlink.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/WINNT/afsd/fs.c b/src/WINNT/afsd/fs.c index c4a7edaac2..892d0348d2 100644 --- a/src/WINNT/afsd/fs.c +++ b/src/WINNT/afsd/fs.c @@ -293,7 +293,12 @@ Parent(char *apath) } tp = strrchr(tspace, '\\'); if (tp) { - *(tp+1) = 0; /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */ + if (tp - tspace > 2 && + tspace[1] == ':' && + &tspace[2] == tp) + *(tp+1) = 0; /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */ + else + *tp = 0; } else { fs_ExtractDriveLetter(apath, tspace); diff --git a/src/WINNT/afsd/symlink.c b/src/WINNT/afsd/symlink.c index 43f0bf7ed1..50b47e63ca 100644 --- a/src/WINNT/afsd/symlink.c +++ b/src/WINNT/afsd/symlink.c @@ -256,13 +256,18 @@ static BOOL IsAdmin (void) } /* return a static pointer to a buffer */ -static char *Parent(apath) -char *apath; { +static char *Parent(char *apath) +{ char *tp; strcpy(tspace, apath); tp = strrchr(tspace, '\\'); if (tp) { - *(tp+1) = 0; /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */ + if (tp - tspace > 2 && + tspace[1] == ':' && + &tspace[2] == tp) + *(tp+1) = 0; /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */ + else + *tp = 0; } else { fs_ExtractDriveLetter(apath, tspace);