From ffbee95174ad1fffecff2889e80e168cea60a531 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 16 Aug 2008 17:48:17 +0000 Subject: [PATCH] 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. --- src/sys/pioctl_nt.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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] == ':' ) { -- 2.39.5