From: Jeffrey Altman Date: Sat, 16 Aug 2008 17:50:06 +0000 (+0000) Subject: DEVEL15-windows-pioctl-getdrivetype-20080816 X-Git-Tag: openafs-devel-1_5_52~8 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a8799004695b4c5f4b122ae42d1eb31b08b73207;p=packages%2Fo%2Fopenafs.git DEVEL15-windows-pioctl-getdrivetype-20080816 LICENSE MIT Use GetDriveType() to check if the current path is a local disk. If it is, fail the pioctl attempt immediately. This should avoid the reported 30 second delay in the AFS Shell Extension. (cherry picked from commit ffbee95174ad1fffecff2889e80e168cea60a531) --- diff --git a/src/sys/pioctl_nt.c b/src/sys/pioctl_nt.c index 53f893a0e..17e278efc 100644 --- a/src/sys/pioctl_nt.c +++ b/src/sys/pioctl_nt.c @@ -400,11 +400,11 @@ GetLSAPrincipalName(char * szUser, DWORD *dwSize) static long GetIoctlHandle(char *fileNamep, HANDLE * handlep) { - char *drivep; + char *drivep = NULL; char netbiosName[MAX_NB_NAME_LENGTH]; DWORD CurrentState = 0; char HostName[64] = ""; - char tbuffer[256]=""; + char tbuffer[MAX_PATH]=""; HANDLE fh; HKEY hk; char szUser[128] = ""; @@ -427,9 +427,21 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep) if (fileNamep) { drivep = strchr(fileNamep, ':'); if (drivep && (drivep - fileNamep) >= 1) { + UINT driveType; tbuffer[0] = *(drivep - 1); tbuffer[1] = ':'; - strcpy(tbuffer + 2, SMB_IOCTL_FILENAME); + tbuffer[2] = '\\'; + tbuffer[3] = '\0'; + + driveType = GetDriveType(tbuffer); + switch (driveType) { + case DRIVE_UNKNOWN: + case DRIVE_REMOTE: + strcpy(&tbuffer[2], SMB_IOCTL_FILENAME); + break; + default: + return -1; + } } else if (fileNamep[0] == fileNamep[1] && (fileNamep[0] == '\\' || fileNamep[0] == '/')) { @@ -447,7 +459,7 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep) tbuffer[i] = 0; strcat(tbuffer, SMB_IOCTL_FILENAME); } else { - char curdir[256]=""; + char curdir[MAX_PATH]=""; GetCurrentDirectory(sizeof(curdir), curdir); if ( curdir[1] == ':' ) {