2 * DOS drives handling functions
4 * Copyright 1993 Erik Bos
5 * Copyright 1996 Alexandre Julliard
11 #include <sys/types.h>
14 #if defined(__linux__) || defined(sun) || defined(hpux)
17 #if defined(__NetBSD__) || defined(__FreeBSD__)
18 #include <sys/param.h>
19 #include <sys/mount.h>
20 #include <sys/errno.h>
22 #if defined(__svr4__) || defined(_SCO_DS) || defined(__EMX__)
23 #include <sys/statfs.h>
39 char *root
; /* root dir in Unix format without trailing / */
40 char *dos_cwd
; /* cwd in DOS format without leading or trailing \ */
41 char *unix_cwd
; /* cwd in Unix format without leading or trailing / */
42 char label
[12]; /* drive label */
43 DWORD serial
; /* drive serial number */
44 DRIVETYPE type
; /* drive type */
45 UINT32 flags
; /* drive flags */
49 static const char * const DRIVE_Types
[] =
51 "floppy", /* TYPE_FLOPPY */
53 "cdrom", /* TYPE_CDROM */
54 "network" /* TYPE_NETWORK */
58 /* Known filesystem types */
66 static const FS_DESCR DRIVE_Filesystems
[] =
68 { "unix", DRIVE_CASE_SENSITIVE
| DRIVE_CASE_PRESERVING
},
69 { "msdos", DRIVE_SHORT_NAMES
},
70 { "dos", DRIVE_SHORT_NAMES
},
71 { "fat", DRIVE_SHORT_NAMES
},
72 { "vfat", DRIVE_CASE_PRESERVING
},
73 { "win95", DRIVE_CASE_PRESERVING
},
78 static DOSDRIVE DOSDrives
[MAX_DOS_DRIVES
];
79 static int DRIVE_CurDrive
= -1;
81 static HTASK16 DRIVE_LastTask
= 0;
84 /***********************************************************************
87 static DRIVETYPE
DRIVE_GetDriveType( const char *name
)
92 PROFILE_GetWineIniString( name
, "Type", "hd", buffer
, sizeof(buffer
) );
93 for (i
= 0; i
< sizeof(DRIVE_Types
)/sizeof(DRIVE_Types
[0]); i
++)
95 if (!lstrcmpi32A( buffer
, DRIVE_Types
[i
] )) return (DRIVETYPE
)i
;
97 fprintf( stderr
, "%s: unknown type '%s', defaulting to 'hd'.\n",
103 /***********************************************************************
106 static UINT32
DRIVE_GetFSFlags( const char *name
, const char *value
)
108 const FS_DESCR
*descr
;
110 for (descr
= DRIVE_Filesystems
; descr
->name
; descr
++)
111 if (!lstrcmpi32A( value
, descr
->name
)) return descr
->flags
;
112 fprintf( stderr
, "%s: unknown filesystem type '%s', defaulting to 'unix'.\n",
114 return DRIVE_CASE_SENSITIVE
| DRIVE_CASE_PRESERVING
;
118 /***********************************************************************
123 int i
, len
, count
= 0;
124 char name
[] = "Drive A";
125 char path
[MAX_PATHNAME_LEN
];
130 for (i
= 0, drive
= DOSDrives
; i
< MAX_DOS_DRIVES
; i
++, name
[6]++, drive
++)
132 PROFILE_GetWineIniString( name
, "Path", "", path
, sizeof(path
)-1 );
135 p
= path
+ strlen(path
) - 1;
136 while ((p
> path
) && ((*p
== '/') || (*p
== '\\'))) *p
-- = '\0';
138 drive
->root
= HEAP_strdupA( SystemHeap
, 0, path
);
140 drive
->root
= HEAP_strdupA( SystemHeap
, 0, "/" );
141 drive
->dos_cwd
= HEAP_strdupA( SystemHeap
, 0, "" );
142 drive
->unix_cwd
= HEAP_strdupA( SystemHeap
, 0, "" );
143 drive
->type
= DRIVE_GetDriveType( name
);
146 /* Get the drive label */
147 PROFILE_GetWineIniString( name
, "Label", name
, drive
->label
, 12 );
148 if ((len
= strlen(drive
->label
)) < 11)
150 /* Pad label with spaces */
151 memset( drive
->label
+ len
, ' ', 11 - len
);
152 drive
->label
[12] = '\0';
155 /* Get the serial number */
156 PROFILE_GetWineIniString( name
, "Serial", "12345678",
157 buffer
, sizeof(buffer
) );
158 drive
->serial
= strtoul( buffer
, NULL
, 16 );
160 /* Get the filesystem type */
161 PROFILE_GetWineIniString( name
, "Filesystem", "unix",
162 buffer
, sizeof(buffer
) );
163 drive
->flags
= DRIVE_GetFSFlags( name
, buffer
);
165 /* Make the first hard disk the current drive */
166 if ((DRIVE_CurDrive
== -1) && (drive
->type
== TYPE_HD
))
170 dprintf_dosfs( stddeb
, "%s: path=%s type=%s label='%s' serial=%08lx flags=%08x\n",
171 name
, path
, DRIVE_Types
[drive
->type
],
172 drive
->label
, drive
->serial
, drive
->flags
);
174 else dprintf_dosfs( stddeb
, "%s: not defined\n", name
);
179 fprintf( stderr
, "Warning: no valid DOS drive found, check your configuration file.\n" );
180 /* Create a C drive pointing to Unix root dir */
181 DOSDrives
[2].root
= HEAP_strdupA( SystemHeap
, 0, "/" );
182 DOSDrives
[2].dos_cwd
= HEAP_strdupA( SystemHeap
, 0, "" );
183 DOSDrives
[2].unix_cwd
= HEAP_strdupA( SystemHeap
, 0, "" );
184 strcpy( DOSDrives
[2].label
, "Drive C " );
185 DOSDrives
[2].serial
= 0x12345678;
186 DOSDrives
[2].type
= TYPE_HD
;
187 DOSDrives
[2].flags
= 0;
191 /* Make sure the current drive is valid */
192 if (DRIVE_CurDrive
== -1)
194 for (i
= 0, drive
= DOSDrives
; i
< MAX_DOS_DRIVES
; i
++, drive
++)
196 if (drive
->root
&& !(drive
->flags
& DRIVE_DISABLED
))
208 /***********************************************************************
211 int DRIVE_IsValid( int drive
)
213 if ((drive
< 0) || (drive
>= MAX_DOS_DRIVES
)) return 0;
214 return (DOSDrives
[drive
].root
&&
215 !(DOSDrives
[drive
].flags
& DRIVE_DISABLED
));
219 /***********************************************************************
220 * DRIVE_GetCurrentDrive
222 int DRIVE_GetCurrentDrive(void)
224 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
225 if (pTask
&& (pTask
->curdrive
& 0x80)) return pTask
->curdrive
& ~0x80;
226 return DRIVE_CurDrive
;
230 /***********************************************************************
231 * DRIVE_SetCurrentDrive
233 int DRIVE_SetCurrentDrive( int drive
)
235 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
236 if (!DRIVE_IsValid( drive
))
238 DOS_ERROR( ER_InvalidDrive
, EC_MediaError
, SA_Abort
, EL_Disk
);
241 dprintf_dosfs( stddeb
, "DRIVE_SetCurrentDrive: %c:\n", 'A' + drive
);
242 DRIVE_CurDrive
= drive
;
243 if (pTask
) pTask
->curdrive
= drive
| 0x80;
248 /***********************************************************************
249 * DRIVE_FindDriveRoot
251 * Find a drive for which the root matches the begginning of the given path.
252 * This can be used to translate a Unix path into a drive + DOS path.
253 * Return value is the drive, or -1 on error. On success, path is modified
254 * to point to the beginning of the DOS path.
255 * FIXME: this only does a textual comparison of the path names, and won't
256 * work well in the presence of symbolic links.
258 int DRIVE_FindDriveRoot( const char **path
)
260 int drive
, rootdrive
= -1;
263 dprintf_dosfs( stddeb
, "DRIVE_FindDriveRoot: searching '%s'\n", *path
);
264 for (drive
= 0; drive
< MAX_DOS_DRIVES
; drive
++)
266 if (!DOSDrives
[drive
].root
||
267 (DOSDrives
[drive
].flags
& DRIVE_DISABLED
)) continue;
269 p2
= DOSDrives
[drive
].root
;
270 dprintf_dosfs( stddeb
, "DRIVE_FindDriveRoot: checking %c: '%s'\n",
273 while (*p2
== '/') p2
++;
277 continue; /* Look if there's a better match */
281 while ((*p1
== '\\') || (*p1
== '/')) p1
++;
282 while (*p2
== '/') p2
++;
283 while ((*p1
== *p2
) && (*p2
) && (*p2
!= '/')) p1
++, p2
++;
286 if (IS_END_OF_NAME(*p1
)) /* OK, found it */
294 if (IS_END_OF_NAME(*p1
))
295 continue; /* Go to next path element */
297 break; /* No match, go to next drive */
304 /***********************************************************************
307 const char * DRIVE_GetRoot( int drive
)
309 if (!DRIVE_IsValid( drive
)) return NULL
;
310 return DOSDrives
[drive
].root
;
314 /***********************************************************************
317 const char * DRIVE_GetDosCwd( int drive
)
319 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
320 if (!DRIVE_IsValid( drive
)) return NULL
;
322 /* Check if we need to change the directory to the new task. */
323 if (pTask
&& (pTask
->curdrive
& 0x80) && /* The task drive is valid */
324 ((pTask
->curdrive
& ~0x80) == drive
) && /* and it's the one we want */
325 (DRIVE_LastTask
!= GetCurrentTask())) /* and the task changed */
327 /* Perform the task-switch */
328 if (!DRIVE_Chdir( drive
, pTask
->curdir
)) DRIVE_Chdir( drive
, "\\" );
329 DRIVE_LastTask
= GetCurrentTask();
331 return DOSDrives
[drive
].dos_cwd
;
335 /***********************************************************************
338 const char * DRIVE_GetUnixCwd( int drive
)
340 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
341 if (!DRIVE_IsValid( drive
)) return NULL
;
343 /* Check if we need to change the directory to the new task. */
344 if (pTask
&& (pTask
->curdrive
& 0x80) && /* The task drive is valid */
345 ((pTask
->curdrive
& ~0x80) == drive
) && /* and it's the one we want */
346 (DRIVE_LastTask
!= GetCurrentTask())) /* and the task changed */
348 /* Perform the task-switch */
349 if (!DRIVE_Chdir( drive
, pTask
->curdir
)) DRIVE_Chdir( drive
, "\\" );
350 DRIVE_LastTask
= GetCurrentTask();
352 return DOSDrives
[drive
].unix_cwd
;
356 /***********************************************************************
359 const char * DRIVE_GetLabel( int drive
)
361 if (!DRIVE_IsValid( drive
)) return NULL
;
362 return DOSDrives
[drive
].label
;
366 /***********************************************************************
367 * DRIVE_GetSerialNumber
369 DWORD
DRIVE_GetSerialNumber( int drive
)
371 if (!DRIVE_IsValid( drive
)) return 0;
372 return DOSDrives
[drive
].serial
;
376 /***********************************************************************
377 * DRIVE_SetSerialNumber
379 int DRIVE_SetSerialNumber( int drive
, DWORD serial
)
381 if (!DRIVE_IsValid( drive
)) return 0;
382 DOSDrives
[drive
].serial
= serial
;
387 /***********************************************************************
390 DRIVETYPE
DRIVE_GetType( int drive
)
392 if (!DRIVE_IsValid( drive
)) return TYPE_INVALID
;
393 return DOSDrives
[drive
].type
;
397 /***********************************************************************
400 UINT32
DRIVE_GetFlags( int drive
)
402 if ((drive
< 0) || (drive
>= MAX_DOS_DRIVES
)) return 0;
403 return DOSDrives
[drive
].flags
;
407 /***********************************************************************
410 int DRIVE_Chdir( int drive
, const char *path
)
412 DOS_FULL_NAME full_name
;
413 char buffer
[MAX_PATHNAME_LEN
];
415 BY_HANDLE_FILE_INFORMATION info
;
416 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
418 dprintf_dosfs( stddeb
, "DRIVE_Chdir(%c:,%s)\n", 'A' + drive
, path
);
419 strcpy( buffer
, "A:" );
421 lstrcpyn32A( buffer
+ 2, path
, sizeof(buffer
) - 2 );
423 if (!DOSFS_GetFullName( buffer
, TRUE
, &full_name
)) return 0;
424 if (!FILE_Stat( full_name
.long_name
, &info
)) return 0;
425 if (!(info
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
))
427 DOS_ERROR( ER_FileNotFound
, EC_NotFound
, SA_Abort
, EL_Disk
);
430 unix_cwd
= full_name
.long_name
+ strlen( DOSDrives
[drive
].root
);
431 while (*unix_cwd
== '/') unix_cwd
++;
433 dprintf_dosfs( stddeb
, "DRIVE_Chdir(%c:): unix_cwd=%s dos_cwd=%s\n",
434 'A' + drive
, unix_cwd
, full_name
.short_name
+ 3 );
436 HeapFree( SystemHeap
, 0, DOSDrives
[drive
].dos_cwd
);
437 HeapFree( SystemHeap
, 0, DOSDrives
[drive
].unix_cwd
);
438 DOSDrives
[drive
].dos_cwd
= HEAP_strdupA( SystemHeap
, 0,
439 full_name
.short_name
+ 3 );
440 DOSDrives
[drive
].unix_cwd
= HEAP_strdupA( SystemHeap
, 0, unix_cwd
);
442 if (pTask
&& (pTask
->curdrive
& 0x80) &&
443 ((pTask
->curdrive
& ~0x80) == drive
))
445 lstrcpyn32A( pTask
->curdir
, full_name
.short_name
+ 2,
446 sizeof(pTask
->curdir
) );
447 DRIVE_LastTask
= GetCurrentTask();
453 /***********************************************************************
456 int DRIVE_Disable( int drive
)
458 if ((drive
< 0) || (drive
>= MAX_DOS_DRIVES
) || !DOSDrives
[drive
].root
)
460 DOS_ERROR( ER_InvalidDrive
, EC_MediaError
, SA_Abort
, EL_Disk
);
463 DOSDrives
[drive
].flags
|= DRIVE_DISABLED
;
468 /***********************************************************************
471 int DRIVE_Enable( int drive
)
473 if ((drive
< 0) || (drive
>= MAX_DOS_DRIVES
) || !DOSDrives
[drive
].root
)
475 DOS_ERROR( ER_InvalidDrive
, EC_MediaError
, SA_Abort
, EL_Disk
);
478 DOSDrives
[drive
].flags
&= ~DRIVE_DISABLED
;
483 /***********************************************************************
486 static int DRIVE_GetFreeSpace( int drive
, DWORD
*size
, DWORD
*available
)
490 if (!DRIVE_IsValid(drive
))
492 DOS_ERROR( ER_InvalidDrive
, EC_MediaError
, SA_Abort
, EL_Disk
);
496 #if defined(__svr4__) || defined(_SCO_DS)
497 if (statfs( DOSDrives
[drive
].root
, &info
, 0, 0) < 0)
499 if (statfs( DOSDrives
[drive
].root
, &info
) < 0)
503 fprintf(stderr
,"dosfs: cannot do statfs(%s)\n", DOSDrives
[drive
].root
);
507 *size
= info
.f_bsize
* info
.f_blocks
;
508 #if defined(__svr4__) || defined(_SCO_DS) || defined(__EMX__)
509 *available
= info
.f_bfree
* info
.f_bsize
;
511 *available
= info
.f_bavail
* info
.f_bsize
;
517 /***********************************************************************
518 * GetDiskFreeSpace16 (KERNEL.422)
520 BOOL16
GetDiskFreeSpace16( LPCSTR root
, LPDWORD cluster_sectors
,
521 LPDWORD sector_bytes
, LPDWORD free_clusters
,
522 LPDWORD total_clusters
)
524 return GetDiskFreeSpace32A( root
, cluster_sectors
, sector_bytes
,
525 free_clusters
, total_clusters
);
529 /***********************************************************************
530 * GetDiskFreeSpace32A (KERNEL32.206)
532 BOOL32
GetDiskFreeSpace32A( LPCSTR root
, LPDWORD cluster_sectors
,
533 LPDWORD sector_bytes
, LPDWORD free_clusters
,
534 LPDWORD total_clusters
)
537 DWORD size
,available
;
539 if (!root
) drive
= DRIVE_GetCurrentDrive();
542 if ((root
[1] != ':') || (root
[2] != '\\'))
544 fprintf( stderr
, "GetDiskFreeSpaceA: invalid root '%s'\n", root
);
547 drive
= toupper(root
[0]) - 'A';
549 if (!DRIVE_GetFreeSpace(drive
, &size
, &available
)) return FALSE
;
554 *cluster_sectors
= 1;
555 while (*cluster_sectors
* 65530 < size
) *cluster_sectors
*= 2;
556 *free_clusters
= available
/ *cluster_sectors
;
557 *total_clusters
= size
/ *cluster_sectors
;
562 /***********************************************************************
563 * GetDiskFreeSpace32W (KERNEL32.207)
565 BOOL32
GetDiskFreeSpace32W( LPCWSTR root
, LPDWORD cluster_sectors
,
566 LPDWORD sector_bytes
, LPDWORD free_clusters
,
567 LPDWORD total_clusters
)
572 xroot
= HEAP_strdupWtoA( GetProcessHeap(), 0, root
);
573 ret
= GetDiskFreeSpace32A( xroot
,cluster_sectors
, sector_bytes
,
574 free_clusters
, total_clusters
);
575 HeapFree( GetProcessHeap(), 0, xroot
);
580 /***********************************************************************
581 * GetDriveType16 (KERNEL.136)
583 UINT16
GetDriveType16( UINT16 drive
)
585 dprintf_dosfs( stddeb
, "GetDriveType16(%c:)\n", 'A' + drive
);
586 switch(DRIVE_GetType(drive
))
588 case TYPE_FLOPPY
: return DRIVE_REMOVABLE
;
589 case TYPE_HD
: return DRIVE_FIXED
;
590 case TYPE_CDROM
: return DRIVE_REMOTE
;
591 case TYPE_NETWORK
: return DRIVE_REMOTE
;
593 default: return DRIVE_CANNOTDETERMINE
;
598 /***********************************************************************
599 * GetDriveType32A (KERNEL32.208)
601 UINT32
GetDriveType32A( LPCSTR root
)
603 dprintf_dosfs( stddeb
, "GetDriveType32A(%s)\n", root
);
606 fprintf( stderr
, "GetDriveType32A: invalid root '%s'\n", root
);
607 return DRIVE_DOESNOTEXIST
;
609 switch(DRIVE_GetType(toupper(root
[0]) - 'A'))
611 case TYPE_FLOPPY
: return DRIVE_REMOVABLE
;
612 case TYPE_HD
: return DRIVE_FIXED
;
613 case TYPE_CDROM
: return DRIVE_CDROM
;
614 case TYPE_NETWORK
: return DRIVE_REMOTE
;
616 default: return DRIVE_CANNOTDETERMINE
;
621 /***********************************************************************
622 * GetDriveType32W (KERNEL32.209)
624 UINT32
GetDriveType32W( LPCWSTR root
)
626 LPSTR xpath
= HEAP_strdupWtoA( GetProcessHeap(), 0, root
);
627 UINT32 ret
= GetDriveType32A( xpath
);
628 HeapFree( GetProcessHeap(), 0, xpath
);
633 /***********************************************************************
634 * GetCurrentDirectory16 (KERNEL.411)
636 UINT16
GetCurrentDirectory16( UINT16 buflen
, LPSTR buf
)
638 return (UINT16
)GetCurrentDirectory32A( buflen
, buf
);
642 /***********************************************************************
643 * GetCurrentDirectory32A (KERNEL32.196)
645 * Returns "X:\\path\\etc\\".
647 UINT32
GetCurrentDirectory32A( UINT32 buflen
, LPSTR buf
)
650 const char *s
= DRIVE_GetDosCwd( DRIVE_GetCurrentDrive() );
656 lstrcpyn32A( buf
, pref
, MIN( 4, buflen
) );
657 if (buflen
) buf
[0] += DRIVE_GetCurrentDrive();
658 if (buflen
> 3) lstrcpyn32A( buf
+ 3, s
, buflen
- 3 );
659 return strlen(s
) + 3; /* length of WHOLE current directory */
663 /***********************************************************************
664 * GetCurrentDirectory32W (KERNEL32.197)
666 UINT32
GetCurrentDirectory32W( UINT32 buflen
, LPWSTR buf
)
668 LPSTR xpath
= HeapAlloc( GetProcessHeap(), 0, buflen
+1 );
669 UINT32 ret
= GetCurrentDirectory32A( buflen
, xpath
);
670 lstrcpyAtoW( buf
, xpath
);
671 HeapFree( GetProcessHeap(), 0, xpath
);
676 /***********************************************************************
677 * SetCurrentDirectory (KERNEL.412)
679 BOOL16
SetCurrentDirectory16( LPCSTR dir
)
681 return SetCurrentDirectory32A( dir
);
685 /***********************************************************************
686 * SetCurrentDirectory32A (KERNEL32.479)
688 BOOL32
SetCurrentDirectory32A( LPCSTR dir
)
690 int drive
= DRIVE_GetCurrentDrive();
692 if (dir
[0] && (dir
[1]==':'))
694 drive
= tolower( *dir
) - 'a';
695 if (!DRIVE_IsValid( drive
))
697 DOS_ERROR( ER_InvalidDrive
, EC_MediaError
, SA_Abort
, EL_Disk
);
702 /* FIXME: what about empty strings? Add a \\ ? */
703 if (!DRIVE_Chdir( drive
, dir
)) return FALSE
;
704 if (drive
== DRIVE_GetCurrentDrive()) return TRUE
;
705 return DRIVE_SetCurrentDrive( drive
);
709 /***********************************************************************
710 * SetCurrentDirectory32W (KERNEL32.480)
712 BOOL32
SetCurrentDirectory32W( LPCWSTR dirW
)
714 LPSTR dir
= HEAP_strdupWtoA( GetProcessHeap(), 0, dirW
);
715 BOOL32 res
= SetCurrentDirectory32A( dir
);
716 HeapFree( GetProcessHeap(), 0, dir
);
721 /***********************************************************************
722 * GetLogicalDriveStrings32A (KERNEL32.231)
724 UINT32
GetLogicalDriveStrings32A( UINT32 len
, LPSTR buffer
)
728 for (drive
= count
= 0; drive
< MAX_DOS_DRIVES
; drive
++)
729 if (DRIVE_IsValid(drive
)) count
++;
730 if (count
* 4 * sizeof(char) <= len
)
733 for (drive
= 0; drive
< MAX_DOS_DRIVES
; drive
++)
734 if (DRIVE_IsValid(drive
))
743 return count
* 4 * sizeof(char);
747 /***********************************************************************
748 * GetLogicalDriveStrings32W (KERNEL32.232)
750 UINT32
GetLogicalDriveStrings32W( UINT32 len
, LPWSTR buffer
)
754 for (drive
= count
= 0; drive
< MAX_DOS_DRIVES
; drive
++)
755 if (DRIVE_IsValid(drive
)) count
++;
756 if (count
* 4 * sizeof(WCHAR
) <= len
)
759 for (drive
= 0; drive
< MAX_DOS_DRIVES
; drive
++)
760 if (DRIVE_IsValid(drive
))
762 *p
++ = (WCHAR
)('a' + drive
);
769 return count
* 4 * sizeof(WCHAR
);
773 /***********************************************************************
774 * GetLogicalDrives (KERNEL32.233)
776 DWORD
GetLogicalDrives(void)
781 for (drive
= 0; drive
< MAX_DOS_DRIVES
; drive
++)
782 if (DRIVE_IsValid(drive
)) ret
|= (1 << drive
);
787 /***********************************************************************
788 * GetVolumeInformation32A (KERNEL32.309)
790 BOOL32
GetVolumeInformation32A( LPCSTR root
, LPSTR label
, DWORD label_len
,
791 DWORD
*serial
, DWORD
*filename_len
,
792 DWORD
*flags
, LPSTR fsname
, DWORD fsname_len
)
796 /* FIXME, SetLastErrors missing */
798 if (!root
) drive
= DRIVE_GetCurrentDrive();
801 if ((root
[1] != ':') || (root
[2] != '\\'))
803 fprintf( stderr
, "GetVolumeInformation: invalid root '%s'\n",root
);
806 drive
= toupper(root
[0]) - 'A';
808 if (!DRIVE_IsValid( drive
)) return FALSE
;
809 if (label
) lstrcpyn32A( label
, DOSDrives
[drive
].label
, label_len
);
810 if (serial
) *serial
= DOSDrives
[drive
].serial
;
812 /* Set the filesystem information */
813 /* Note: we only emulate a FAT fs at the present */
815 if (filename_len
) *filename_len
= 12;
816 if (flags
) *flags
= 0;
817 if (fsname
) lstrcpyn32A( fsname
, "FAT", fsname_len
);
822 /***********************************************************************
823 * GetVolumeInformation32W (KERNEL32.310)
825 BOOL32
GetVolumeInformation32W( LPCWSTR root
, LPWSTR label
, DWORD label_len
,
826 DWORD
*serial
, DWORD
*filename_len
,
827 DWORD
*flags
, LPWSTR fsname
, DWORD fsname_len
)
829 LPSTR xroot
= HEAP_strdupWtoA( GetProcessHeap(), 0, root
);
830 LPSTR xvolname
= label
? HeapAlloc(GetProcessHeap(),0,label_len
) : NULL
;
831 LPSTR xfsname
= fsname
? HeapAlloc(GetProcessHeap(),0,fsname_len
) : NULL
;
832 BOOL32 ret
= GetVolumeInformation32A( xroot
, xvolname
, label_len
, serial
,
833 filename_len
, flags
, xfsname
,
837 if (label
) lstrcpyAtoW( label
, xvolname
);
838 if (fsname
) lstrcpyAtoW( fsname
, xfsname
);
840 HeapFree( GetProcessHeap(), 0, xroot
);
841 HeapFree( GetProcessHeap(), 0, xvolname
);
842 HeapFree( GetProcessHeap(), 0, xfsname
);