From: Jeffrey Altman Date: Wed, 28 Jul 2004 04:54:19 +0000 (+0000) Subject: unc-paths-current-directory-20040727 X-Git-Tag: BP-openafs-stable-1_4_x~73 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=b20129a33794c2c1b28852cb2e6af51eb2e9e06d;p=packages%2Fo%2Fopenafs.git unc-paths-current-directory-20040727 fix the handling of unc paths in pioctl calls when the current directory is the unc path. (not likely to be the case with cmd.exe since it does not support pure unc path environments. 4nt.exe shows the problem though.) --- diff --git a/src/sys/pioctl_nt.c b/src/sys/pioctl_nt.c index 3bed3772e..a03117c53 100644 --- a/src/sys/pioctl_nt.c +++ b/src/sys/pioctl_nt.c @@ -309,8 +309,24 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize) GetCurrentDirectory(sizeof(tpath), tpath); if (tpath[1] == ':') strcpy(outPathp, tpath + 2); /* skip drive letter */ - else - strcpy(outPathp, tpath); /* copy entire UNC path */ + else if ( tpath[0] == '\\' && tpath[1] == '\\') { + /* UNC path - strip off the server and sharename */ + int i, count; + for ( i=2,count=2; count < 4 && tpath[i]; i++ ) { + if ( tpath[i] == '\\' || tpath[i] == '/' ) { + count++; + } + } + if ( tpath[i] == 0 ) { + strcpy(outPathp,"\\"); + } else { + strcpy(outPathp,&tpath[--i]); + } + } else { + /* this should never happen */ + strcpy(outPathp, tpath); + } + /* if there is a non-null name after the drive, append it */ if (*firstp != 0) { int len = strlen(outPathp);