Get the drive root directories from the symlinks in dosdevices/ if
they exist. Added creation of drive symlinks in the device transition code.
This commit is contained in:
parent
21e5909ac1
commit
0701b0748c
@ -148,6 +148,30 @@ static char *get_dos_device_path( LPCWSTR name )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* create symlinks for the DOS drives; helper for VOLUME_CreateDevices */
|
||||||
|
static int create_drives(void)
|
||||||
|
{
|
||||||
|
WCHAR name[3], rootW[MAX_PATHNAME_LEN];
|
||||||
|
int i, count = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 26; i++)
|
||||||
|
{
|
||||||
|
const char *root = DRIVE_GetRoot( i );
|
||||||
|
if (!root) continue;
|
||||||
|
name[0] = 'a' + i;
|
||||||
|
name[1] = ':';
|
||||||
|
name[2] = 0;
|
||||||
|
if (MultiByteToWideChar( CP_UNIXCP, 0, root, -1, rootW, MAX_PATHNAME_LEN ) &&
|
||||||
|
DefineDosDeviceW( DDD_RAW_TARGET_PATH, name, rootW ))
|
||||||
|
{
|
||||||
|
MESSAGE( "Created symlink %s/dosdevices/%c: -> %s\n", wine_get_config_dir(), 'a' + i, root );
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* VOLUME_CreateDevices
|
* VOLUME_CreateDevices
|
||||||
*
|
*
|
||||||
@ -161,7 +185,7 @@ void VOLUME_CreateDevices(void)
|
|||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
if (!(buffer = HeapAlloc( GetProcessHeap(), 0,
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0,
|
||||||
strlen(config_dir) + sizeof("/dosdevices") )))
|
strlen(config_dir) + sizeof("/dosdevices") + 3 )))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
strcpy( buffer, config_dir );
|
strcpy( buffer, config_dir );
|
||||||
@ -245,10 +269,29 @@ void VOLUME_CreateDevices(void)
|
|||||||
}
|
}
|
||||||
NtClose( hkey );
|
NtClose( hkey );
|
||||||
}
|
}
|
||||||
|
count += create_drives();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* it is possible that the serial/parallel devices have been created but */
|
||||||
|
/* not the drives; check for at least one drive symlink to catch that case */
|
||||||
|
strcat( buffer, "/a:" );
|
||||||
|
for (i = 0; i < 26; i++)
|
||||||
|
{
|
||||||
|
buffer[strlen(buffer)-2] = 'a' + i;
|
||||||
|
if (!lstat( buffer, &st )) break;
|
||||||
|
}
|
||||||
|
if (i == 26) count += create_drives();
|
||||||
|
}
|
||||||
|
|
||||||
if (count)
|
if (count)
|
||||||
MESSAGE( "\nYou can now remove the [SerialPorts] and [ParallelPorts] sections\n"
|
MESSAGE( "\nYou can now remove the [SerialPorts] and [ParallelPorts] sections\n"
|
||||||
"in your configuration file, they are replaced by the above symlinks.\n\n" );
|
"in your configuration file, as well as the \"Path=\" definitions in\n"
|
||||||
}
|
"the drive sections, they are replaced by the above symlinks.\n\n" );
|
||||||
|
|
||||||
HeapFree( GetProcessHeap(), 0, buffer );
|
HeapFree( GetProcessHeap(), 0, buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ static inline UINT DRIVE_GetDriveType( INT drive, LPCWSTR value )
|
|||||||
*/
|
*/
|
||||||
int DRIVE_Init(void)
|
int DRIVE_Init(void)
|
||||||
{
|
{
|
||||||
int i, len, count = 0;
|
int i, len, symlink_count = 0, count = 0;
|
||||||
WCHAR driveW[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\',
|
WCHAR driveW[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\',
|
||||||
'W','i','n','e','\\','W','i','n','e','\\',
|
'W','i','n','e','\\','W','i','n','e','\\',
|
||||||
'C','o','n','f','i','g','\\','D','r','i','v','e',' ','A',0};
|
'C','o','n','f','i','g','\\','D','r','i','v','e',' ','A',0};
|
||||||
@ -144,6 +144,8 @@ int DRIVE_Init(void)
|
|||||||
DWORD dummy;
|
DWORD dummy;
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
UNICODE_STRING nameW;
|
UNICODE_STRING nameW;
|
||||||
|
char *root;
|
||||||
|
const char *config_dir = wine_get_config_dir();
|
||||||
|
|
||||||
static const WCHAR PathW[] = {'P','a','t','h',0};
|
static const WCHAR PathW[] = {'P','a','t','h',0};
|
||||||
static const WCHAR TypeW[] = {'T','y','p','e',0};
|
static const WCHAR TypeW[] = {'T','y','p','e',0};
|
||||||
@ -157,6 +159,45 @@ int DRIVE_Init(void)
|
|||||||
attr.SecurityDescriptor = NULL;
|
attr.SecurityDescriptor = NULL;
|
||||||
attr.SecurityQualityOfService = NULL;
|
attr.SecurityQualityOfService = NULL;
|
||||||
|
|
||||||
|
/* get the root of the drives from symlinks */
|
||||||
|
|
||||||
|
root = NULL;
|
||||||
|
for (i = 0, drive = DOSDrives; i < MAX_DOS_DRIVES; i++, drive++)
|
||||||
|
{
|
||||||
|
if (!root)
|
||||||
|
{
|
||||||
|
root = HeapAlloc( GetProcessHeap(), 0, strlen(config_dir) + sizeof("/dosdevices/a:") );
|
||||||
|
strcpy( root, config_dir );
|
||||||
|
strcat( root, "/dosdevices/a:" );
|
||||||
|
}
|
||||||
|
root[strlen(root)-2] = 'a' + i;
|
||||||
|
if (stat( root, &drive_stat_buffer ))
|
||||||
|
{
|
||||||
|
if (!lstat( root, &drive_stat_buffer))
|
||||||
|
MESSAGE("Could not stat %s (%s), ignoring drive %c:\n",
|
||||||
|
root, strerror(errno), 'a' + i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!S_ISDIR(drive_stat_buffer.st_mode))
|
||||||
|
{
|
||||||
|
MESSAGE("%s is not a directory, ignoring drive %c:\n", root, 'a' + i );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
drive->root = root;
|
||||||
|
drive->dos_cwd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(drive->dos_cwd[0]));
|
||||||
|
drive->unix_cwd = heap_strdup( "" );
|
||||||
|
drive->device = NULL;
|
||||||
|
drive->flags = 0;
|
||||||
|
drive->dev = drive_stat_buffer.st_dev;
|
||||||
|
drive->ino = drive_stat_buffer.st_ino;
|
||||||
|
drive->type = DRIVE_FIXED;
|
||||||
|
root = NULL;
|
||||||
|
symlink_count++;
|
||||||
|
}
|
||||||
|
if (root) HeapFree( GetProcessHeap(), 0, root );
|
||||||
|
|
||||||
|
/* now get the parameters from the config file */
|
||||||
|
|
||||||
for (i = 0, drive = DOSDrives; i < MAX_DOS_DRIVES; i++, drive++)
|
for (i = 0, drive = DOSDrives; i < MAX_DOS_DRIVES; i++, drive++)
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString( &nameW, driveW );
|
RtlInitUnicodeString( &nameW, driveW );
|
||||||
@ -164,6 +205,8 @@ int DRIVE_Init(void)
|
|||||||
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
|
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
|
||||||
|
|
||||||
/* Get the root path */
|
/* Get the root path */
|
||||||
|
if (!symlink_count)
|
||||||
|
{
|
||||||
RtlInitUnicodeString( &nameW, PathW );
|
RtlInitUnicodeString( &nameW, PathW );
|
||||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
||||||
{
|
{
|
||||||
@ -214,7 +257,12 @@ int DRIVE_Init(void)
|
|||||||
drive->flags = 0;
|
drive->flags = 0;
|
||||||
drive->dev = drive_stat_buffer.st_dev;
|
drive->dev = drive_stat_buffer.st_dev;
|
||||||
drive->ino = drive_stat_buffer.st_ino;
|
drive->ino = drive_stat_buffer.st_ino;
|
||||||
|
drive->type = DRIVE_FIXED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drive->root)
|
||||||
|
{
|
||||||
/* Get the drive type */
|
/* Get the drive type */
|
||||||
RtlInitUnicodeString( &nameW, TypeW );
|
RtlInitUnicodeString( &nameW, TypeW );
|
||||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
||||||
@ -222,7 +270,6 @@ int DRIVE_Init(void)
|
|||||||
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
||||||
drive->type = DRIVE_GetDriveType( i, data );
|
drive->type = DRIVE_GetDriveType( i, data );
|
||||||
}
|
}
|
||||||
else drive->type = DRIVE_FIXED;
|
|
||||||
|
|
||||||
/* Get the device */
|
/* Get the device */
|
||||||
RtlInitUnicodeString( &nameW, DeviceW );
|
RtlInitUnicodeString( &nameW, DeviceW );
|
||||||
@ -266,7 +313,7 @@ int DRIVE_Init(void)
|
|||||||
NtClose( hkey );
|
NtClose( hkey );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count)
|
if (!count && !symlink_count)
|
||||||
{
|
{
|
||||||
MESSAGE("Warning: no valid DOS drive found, check your configuration file.\n" );
|
MESSAGE("Warning: no valid DOS drive found, check your configuration file.\n" );
|
||||||
/* Create a C drive pointing to Unix root dir */
|
/* Create a C drive pointing to Unix root dir */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user