mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
KDFS-windows-pioctl-drive-subst-20081226
LICENSE MIT GetDriveType() will return "REMOTE" for drive letters that are mapped to network devices via the SUBST command. Recursively check drive letters for the final substitution before checking to see if the drive letter is in fact an AFS device. (cherry picked from commit 238ad07e13a85366bcf49a309e3735d26ff51ff2)
This commit is contained in:
parent
7f8144b11d
commit
a33eee0418
@ -504,6 +504,45 @@ GetLSAPrincipalName(char * szUser, DWORD *dwSize)
|
||||
return success;
|
||||
}
|
||||
|
||||
//
|
||||
// Recursively evaluate drivestr to find the final
|
||||
// dos drive letter to which the source is mapped.
|
||||
//
|
||||
static BOOL
|
||||
DriveSubstitution(char *drivestr, char *subststr)
|
||||
{
|
||||
char device[MAX_PATH];
|
||||
|
||||
if ( QueryDosDevice(drivestr, device, MAX_PATH) )
|
||||
{
|
||||
if ( device[0] == '\\' &&
|
||||
device[1] == '?' &&
|
||||
device[2] == '?' &&
|
||||
device[3] == '\\' &&
|
||||
isalpha(device[4]) &&
|
||||
device[5] == ':')
|
||||
{
|
||||
device[0] = device[4];
|
||||
device[1] = ':';
|
||||
device[2] = '\0';
|
||||
if ( DriveSubstitution(device, subststr) )
|
||||
{
|
||||
return TRUE;
|
||||
} else {
|
||||
subststr[0] = device[0];
|
||||
subststr[1] = ':';
|
||||
subststr[2] = '\0';
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// drivestr - is "<drive-letter>:"
|
||||
//
|
||||
static BOOL
|
||||
DriveIsMappedToAFS(char *drivestr, char *NetbiosName)
|
||||
{
|
||||
@ -514,6 +553,17 @@ DriveIsMappedToAFS(char *drivestr, char *NetbiosName)
|
||||
LPNETRESOURCE lpnrLocal; // pointer to enumerated structures
|
||||
DWORD i;
|
||||
BOOL bIsAFS = FALSE;
|
||||
char subststr[3];
|
||||
|
||||
//
|
||||
// Handle drive letter substitution created with "SUBST <drive> <path>".
|
||||
// If a substitution has occurred, use the target drive letter instead
|
||||
// of the source.
|
||||
//
|
||||
if ( DriveSubstitution(drivestr, subststr) )
|
||||
{
|
||||
drivestr = subststr;
|
||||
}
|
||||
|
||||
//
|
||||
// Call the WNetOpenEnum function to begin the enumeration.
|
||||
|
Loading…
x
Reference in New Issue
Block a user