]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: Fix Parent(path) computation to permit mp and symlink creation
authorJeffrey Altman <jaltman@your-file-system.com>
Wed, 15 Sep 2010 23:01:06 +0000 (01:01 +0200)
committerDerrick Brashear <shadow@dementia.org>
Mon, 25 Oct 2010 21:44:45 +0000 (14:44 -0700)
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

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>
(cherry picked from commit 6ad0e5b529dbfd7a2401a0622eb4ea5269124ceb)
Change-Id: I55e67817c019dceab045973171bd53db468dfc2c
Reviewed-on: http://gerrit.openafs.org/3043
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/WINNT/afsd/fs.c
src/WINNT/afsd/symlink.c

index c4a7edaac277202a757708e1a67db9c4b76a1bd0..892d0348d22a97e76b00408132ea960758f68e88 100644 (file)
@@ -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);
index 43f0bf7ed1a467a0c68eb4764d12f532e4a88f42..50b47e63ca31af5daa11a4095014854bf0080160 100644 (file)
@@ -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);