kernel32: Add a stub implementation for FindFirstVolumeMountPoint{A, W}.
[wine/wine-gecko.git] / dlls / kernel32 / volume.c
blob536fcfac372c879a405ad4e2702541e5a0bda78c
1 /*
2 * Volume management functions
4 * Copyright 1993 Erik Bos
5 * Copyright 1996, 2004 Alexandre Julliard
6 * Copyright 1999 Petr Tomasek
7 * Copyright 2000 Andreas Mohr
8 * Copyright 2003 Eric Pouech
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "config.h"
26 #include "wine/port.h"
28 #include <stdarg.h>
29 #include <stdlib.h>
30 #include <stdio.h>
32 #include "ntstatus.h"
33 #define WIN32_NO_STATUS
34 #include "windef.h"
35 #include "winbase.h"
36 #include "winnls.h"
37 #include "winternl.h"
38 #include "winioctl.h"
39 #include "ntddstor.h"
40 #include "ntddcdrm.h"
41 #include "kernel_private.h"
42 #include "wine/library.h"
43 #include "wine/unicode.h"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(volume);
48 #define SUPERBLOCK_SIZE 2048
50 #define CDFRAMES_PERSEC 75
51 #define CDFRAMES_PERMIN (CDFRAMES_PERSEC * 60)
52 #define FRAME_OF_ADDR(a) ((a)[1] * CDFRAMES_PERMIN + (a)[2] * CDFRAMES_PERSEC + (a)[3])
53 #define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc)->TrackData[(idx) - (toc)->FirstTrack].Address)
55 #define GETWORD(buf,off) MAKEWORD(buf[(off)],buf[(off+1)])
56 #define GETLONG(buf,off) MAKELONG(GETWORD(buf,off),GETWORD(buf,off+2))
58 enum fs_type
60 FS_ERROR, /* error accessing the device */
61 FS_UNKNOWN, /* unknown file system */
62 FS_FAT1216,
63 FS_FAT32,
64 FS_ISO9660
67 static const WCHAR drive_types[][8] =
69 { 0 }, /* DRIVE_UNKNOWN */
70 { 0 }, /* DRIVE_NO_ROOT_DIR */
71 {'f','l','o','p','p','y',0}, /* DRIVE_REMOVABLE */
72 {'h','d',0}, /* DRIVE_FIXED */
73 {'n','e','t','w','o','r','k',0}, /* DRIVE_REMOTE */
74 {'c','d','r','o','m',0}, /* DRIVE_CDROM */
75 {'r','a','m','d','i','s','k',0} /* DRIVE_RAMDISK */
78 /* read a Unix symlink; returned buffer must be freed by caller */
79 static char *read_symlink( const char *path )
81 char *buffer;
82 int ret, size = 128;
84 for (;;)
86 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size )))
88 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
89 return 0;
91 ret = readlink( path, buffer, size );
92 if (ret == -1)
94 FILE_SetDosError();
95 HeapFree( GetProcessHeap(), 0, buffer );
96 return 0;
98 if (ret != size)
100 buffer[ret] = 0;
101 return buffer;
103 HeapFree( GetProcessHeap(), 0, buffer );
104 size *= 2;
108 /* get the path of a dos device symlink in the $WINEPREFIX/dosdevices directory */
109 static char *get_dos_device_path( LPCWSTR name )
111 const char *config_dir = wine_get_config_dir();
112 char *buffer, *dev;
113 int i;
115 if (!(buffer = HeapAlloc( GetProcessHeap(), 0,
116 strlen(config_dir) + sizeof("/dosdevices/") + 5 )))
118 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
119 return NULL;
121 strcpy( buffer, config_dir );
122 strcat( buffer, "/dosdevices/" );
123 dev = buffer + strlen(buffer);
124 /* no codepage conversion, DOS device names are ASCII anyway */
125 for (i = 0; i < 5; i++)
126 if (!(dev[i] = (char)tolowerW(name[i]))) break;
127 dev[5] = 0;
128 return buffer;
132 /* open a handle to a device root */
133 static BOOL open_device_root( LPCWSTR root, HANDLE *handle )
135 static const WCHAR default_rootW[] = {'\\',0};
136 UNICODE_STRING nt_name;
137 OBJECT_ATTRIBUTES attr;
138 IO_STATUS_BLOCK io;
139 NTSTATUS status;
141 if (!root) root = default_rootW;
142 if (!RtlDosPathNameToNtPathName_U( root, &nt_name, NULL, NULL ))
144 SetLastError( ERROR_PATH_NOT_FOUND );
145 return FALSE;
147 attr.Length = sizeof(attr);
148 attr.RootDirectory = 0;
149 attr.Attributes = OBJ_CASE_INSENSITIVE;
150 attr.ObjectName = &nt_name;
151 attr.SecurityDescriptor = NULL;
152 attr.SecurityQualityOfService = NULL;
154 status = NtOpenFile( handle, 0, &attr, &io, 0,
155 FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
156 RtlFreeUnicodeString( &nt_name );
157 if (status != STATUS_SUCCESS)
159 SetLastError( RtlNtStatusToDosError(status) );
160 return FALSE;
162 return TRUE;
166 /* fetch the type of a drive from the registry */
167 static UINT get_registry_drive_type( const WCHAR *root )
169 static const WCHAR drive_types_keyW[] = {'M','a','c','h','i','n','e','\\',
170 'S','o','f','t','w','a','r','e','\\',
171 'W','i','n','e','\\',
172 'D','r','i','v','e','s',0 };
173 OBJECT_ATTRIBUTES attr;
174 UNICODE_STRING nameW;
175 HANDLE hkey;
176 DWORD dummy;
177 UINT ret = DRIVE_UNKNOWN;
178 char tmp[32 + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
179 WCHAR driveW[] = {'A',':',0};
181 attr.Length = sizeof(attr);
182 attr.RootDirectory = 0;
183 attr.ObjectName = &nameW;
184 attr.Attributes = 0;
185 attr.SecurityDescriptor = NULL;
186 attr.SecurityQualityOfService = NULL;
187 RtlInitUnicodeString( &nameW, drive_types_keyW );
188 /* @@ Wine registry key: HKLM\Software\Wine\Drives */
189 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) return DRIVE_UNKNOWN;
191 if (root) driveW[0] = root[0];
192 else
194 WCHAR path[MAX_PATH];
195 GetCurrentDirectoryW( MAX_PATH, path );
196 driveW[0] = path[0];
199 RtlInitUnicodeString( &nameW, driveW );
200 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
202 unsigned int i;
203 WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
205 for (i = 0; i < sizeof(drive_types)/sizeof(drive_types[0]); i++)
207 if (!strcmpiW( data, drive_types[i] ))
209 ret = i;
210 break;
214 NtClose( hkey );
215 return ret;
219 /******************************************************************
220 * VOLUME_FindCdRomDataBestVoldesc
222 static DWORD VOLUME_FindCdRomDataBestVoldesc( HANDLE handle )
224 BYTE cur_vd_type, max_vd_type = 0;
225 BYTE buffer[0x800];
226 DWORD size, offs, best_offs = 0, extra_offs = 0;
228 for (offs = 0x8000; offs <= 0x9800; offs += 0x800)
230 /* if 'CDROM' occurs at position 8, this is a pre-iso9660 cd, and
231 * the volume label is displaced forward by 8
233 if (SetFilePointer( handle, offs, NULL, FILE_BEGIN ) != offs) break;
234 if (!ReadFile( handle, buffer, sizeof(buffer), &size, NULL )) break;
235 if (size != sizeof(buffer)) break;
236 /* check for non-ISO9660 signature */
237 if (!memcmp( buffer + 11, "ROM", 3 )) extra_offs = 8;
238 cur_vd_type = buffer[extra_offs];
239 if (cur_vd_type == 0xff) /* voldesc set terminator */
240 break;
241 if (cur_vd_type > max_vd_type)
243 max_vd_type = cur_vd_type;
244 best_offs = offs + extra_offs;
247 return best_offs;
251 /***********************************************************************
252 * VOLUME_ReadFATSuperblock
254 static enum fs_type VOLUME_ReadFATSuperblock( HANDLE handle, BYTE *buff )
256 DWORD size;
258 /* try a fixed disk, with a FAT partition */
259 if (SetFilePointer( handle, 0, NULL, FILE_BEGIN ) != 0 ||
260 !ReadFile( handle, buff, SUPERBLOCK_SIZE, &size, NULL ) ||
261 size != SUPERBLOCK_SIZE)
262 return FS_ERROR;
264 /* FIXME: do really all FAT have their name beginning with
265 * "FAT" ? (At least FAT12, FAT16 and FAT32 have :)
267 if (!memcmp(buff+0x36, "FAT", 3) || !memcmp(buff+0x52, "FAT", 3))
269 /* guess which type of FAT we have */
270 int reasonable;
271 unsigned int sectors,
272 sect_per_fat,
273 total_sectors,
274 num_boot_sectors,
275 num_fats,
276 num_root_dir_ents,
277 bytes_per_sector,
278 sectors_per_cluster,
279 nclust;
280 sect_per_fat = GETWORD(buff, 0x16);
281 if (!sect_per_fat) sect_per_fat = GETLONG(buff, 0x24);
282 total_sectors = GETWORD(buff, 0x13);
283 if (!total_sectors)
284 total_sectors = GETLONG(buff, 0x20);
285 num_boot_sectors = GETWORD(buff, 0x0e);
286 num_fats = buff[0x10];
287 num_root_dir_ents = GETWORD(buff, 0x11);
288 bytes_per_sector = GETWORD(buff, 0x0b);
289 sectors_per_cluster = buff[0x0d];
290 /* check if the parameters are reasonable and will not cause
291 * arithmetic errors in the calculation */
292 reasonable = num_boot_sectors < 16 &&
293 num_fats < 16 &&
294 bytes_per_sector >= 512 && bytes_per_sector % 512 == 0 &&
295 sectors_per_cluster > 1;
296 if (!reasonable) return FS_UNKNOWN;
297 sectors = total_sectors - num_boot_sectors - num_fats * sect_per_fat -
298 (num_root_dir_ents * 32 + bytes_per_sector - 1) / bytes_per_sector;
299 nclust = sectors / sectors_per_cluster;
300 if ((buff[0x42] == 0x28 || buff[0x42] == 0x29) &&
301 !memcmp(buff+0x52, "FAT", 3)) return FS_FAT32;
302 if (nclust < 65525)
304 if ((buff[0x26] == 0x28 || buff[0x26] == 0x29) &&
305 !memcmp(buff+0x36, "FAT", 3))
306 return FS_FAT1216;
309 return FS_UNKNOWN;
313 /***********************************************************************
314 * VOLUME_ReadCDSuperblock
316 static enum fs_type VOLUME_ReadCDSuperblock( HANDLE handle, BYTE *buff )
318 DWORD size, offs = VOLUME_FindCdRomDataBestVoldesc( handle );
320 if (!offs) return FS_UNKNOWN;
322 if (SetFilePointer( handle, offs, NULL, FILE_BEGIN ) != offs ||
323 !ReadFile( handle, buff, SUPERBLOCK_SIZE, &size, NULL ) ||
324 size != SUPERBLOCK_SIZE)
325 return FS_ERROR;
327 /* check for iso9660 present */
328 if (!memcmp(&buff[1], "CD001", 5)) return FS_ISO9660;
329 return FS_UNKNOWN;
333 /**************************************************************************
334 * VOLUME_GetSuperblockLabel
336 static void VOLUME_GetSuperblockLabel( enum fs_type type, const BYTE *superblock,
337 WCHAR *label, DWORD len )
339 const BYTE *label_ptr = NULL;
340 DWORD label_len;
342 switch(type)
344 case FS_ERROR:
345 case FS_UNKNOWN:
346 label_len = 0;
347 break;
348 case FS_FAT1216:
349 label_ptr = superblock + 0x2b;
350 label_len = 11;
351 break;
352 case FS_FAT32:
353 label_ptr = superblock + 0x47;
354 label_len = 11;
355 break;
356 case FS_ISO9660:
358 BYTE ver = superblock[0x5a];
360 if (superblock[0x58] == 0x25 && superblock[0x59] == 0x2f && /* Unicode ID */
361 ((ver == 0x40) || (ver == 0x43) || (ver == 0x45)))
362 { /* yippee, unicode */
363 unsigned int i;
365 if (len > 17) len = 17;
366 for (i = 0; i < len-1; i++)
367 label[i] = (superblock[40+2*i] << 8) | superblock[41+2*i];
368 label[i] = 0;
369 while (i && label[i-1] == ' ') label[--i] = 0;
370 return;
372 label_ptr = superblock + 40;
373 label_len = 32;
374 break;
377 if (label_len) RtlMultiByteToUnicodeN( label, (len-1) * sizeof(WCHAR),
378 &label_len, (LPCSTR)label_ptr, label_len );
379 label_len /= sizeof(WCHAR);
380 label[label_len] = 0;
381 while (label_len && label[label_len-1] == ' ') label[--label_len] = 0;
385 /**************************************************************************
386 * VOLUME_GetSuperblockSerial
388 static DWORD VOLUME_GetSuperblockSerial( enum fs_type type, const BYTE *superblock )
390 switch(type)
392 case FS_ERROR:
393 case FS_UNKNOWN:
394 break;
395 case FS_FAT1216:
396 return GETLONG( superblock, 0x27 );
397 case FS_FAT32:
398 return GETLONG( superblock, 0x33 );
399 case FS_ISO9660:
401 BYTE sum[4];
402 int i;
404 sum[0] = sum[1] = sum[2] = sum[3] = 0;
405 for (i = 0; i < 2048; i += 4)
407 /* DON'T optimize this into DWORD !! (breaks overflow) */
408 sum[0] += superblock[i+0];
409 sum[1] += superblock[i+1];
410 sum[2] += superblock[i+2];
411 sum[3] += superblock[i+3];
414 * OK, another braindead one... argh. Just believe it.
415 * Me$$ysoft chose to reverse the serial number in NT4/W2K.
416 * It's true and nobody will ever be able to change it.
418 if (GetVersion() & 0x80000000)
419 return (sum[3] << 24) | (sum[2] << 16) | (sum[1] << 8) | sum[0];
420 else
421 return (sum[0] << 24) | (sum[1] << 16) | (sum[2] << 8) | sum[3];
424 return 0;
428 /**************************************************************************
429 * VOLUME_GetAudioCDSerial
431 static DWORD VOLUME_GetAudioCDSerial( const CDROM_TOC *toc )
433 DWORD serial = 0;
434 int i;
436 for (i = 0; i <= toc->LastTrack - toc->FirstTrack; i++)
437 serial += ((toc->TrackData[i].Address[1] << 16) |
438 (toc->TrackData[i].Address[2] << 8) |
439 toc->TrackData[i].Address[3]);
442 * dwStart, dwEnd collect the beginning and end of the disc respectively, in
443 * frames.
444 * There it is collected for correcting the serial when there are less than
445 * 3 tracks.
447 if (toc->LastTrack - toc->FirstTrack + 1 < 3)
449 DWORD dwStart = FRAME_OF_TOC(toc, toc->FirstTrack);
450 DWORD dwEnd = FRAME_OF_TOC(toc, toc->LastTrack + 1);
451 serial += dwEnd - dwStart;
453 return serial;
457 /***********************************************************************
458 * GetVolumeInformationW (KERNEL32.@)
460 BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len,
461 DWORD *serial, DWORD *filename_len, DWORD *flags,
462 LPWSTR fsname, DWORD fsname_len )
464 static const WCHAR audiocdW[] = {'A','u','d','i','o',' ','C','D',0};
465 static const WCHAR fatW[] = {'F','A','T',0};
466 static const WCHAR ntfsW[] = {'N','T','F','S',0};
467 static const WCHAR cdfsW[] = {'C','D','F','S',0};
469 WCHAR device[] = {'\\','\\','.','\\','A',':',0};
470 HANDLE handle;
471 enum fs_type type = FS_UNKNOWN;
473 if (!root)
475 WCHAR path[MAX_PATH];
476 GetCurrentDirectoryW( MAX_PATH, path );
477 device[4] = path[0];
479 else
481 if (!root[0] || root[1] != ':')
483 SetLastError( ERROR_INVALID_NAME );
484 return FALSE;
486 device[4] = root[0];
489 /* try to open the device */
491 handle = CreateFileW( device, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
492 NULL, OPEN_EXISTING, 0, 0 );
493 if (handle != INVALID_HANDLE_VALUE)
495 BYTE superblock[SUPERBLOCK_SIZE];
496 CDROM_TOC toc;
497 DWORD br;
499 /* check for audio CD */
500 /* FIXME: we only check the first track for now */
501 if (DeviceIoControl( handle, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(toc), &br, 0 ))
503 if (!(toc.TrackData[0].Control & 0x04)) /* audio track */
505 TRACE( "%s: found audio CD\n", debugstr_w(device) );
506 if (label) lstrcpynW( label, audiocdW, label_len );
507 if (serial) *serial = VOLUME_GetAudioCDSerial( &toc );
508 CloseHandle( handle );
509 type = FS_ISO9660;
510 goto fill_fs_info;
512 type = VOLUME_ReadCDSuperblock( handle, superblock );
514 else
516 type = VOLUME_ReadFATSuperblock( handle, superblock );
517 if (type == FS_UNKNOWN) type = VOLUME_ReadCDSuperblock( handle, superblock );
519 CloseHandle( handle );
520 TRACE( "%s: found fs type %d\n", debugstr_w(device), type );
521 if (type == FS_ERROR) return FALSE;
523 if (label && label_len) VOLUME_GetSuperblockLabel( type, superblock, label, label_len );
524 if (serial) *serial = VOLUME_GetSuperblockSerial( type, superblock );
525 goto fill_fs_info;
527 else TRACE( "cannot open device %s: err %d\n", debugstr_w(device), GetLastError() );
529 /* we couldn't open the device, fallback to default strategy */
531 switch(GetDriveTypeW( root ))
533 case DRIVE_UNKNOWN:
534 case DRIVE_NO_ROOT_DIR:
535 SetLastError( ERROR_NOT_READY );
536 return FALSE;
537 case DRIVE_REMOVABLE:
538 case DRIVE_FIXED:
539 case DRIVE_REMOTE:
540 case DRIVE_RAMDISK:
541 type = FS_UNKNOWN;
542 break;
543 case DRIVE_CDROM:
544 type = FS_ISO9660;
545 break;
548 if (label && label_len)
550 WCHAR labelW[] = {'A',':','\\','.','w','i','n','d','o','w','s','-','l','a','b','e','l',0};
552 labelW[0] = device[4];
553 handle = CreateFileW( labelW, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
554 OPEN_EXISTING, 0, 0 );
555 if (handle != INVALID_HANDLE_VALUE)
557 char buffer[256], *p;
558 DWORD size;
560 if (!ReadFile( handle, buffer, sizeof(buffer)-1, &size, NULL )) size = 0;
561 CloseHandle( handle );
562 p = buffer + size;
563 while (p > buffer && (p[-1] == ' ' || p[-1] == '\r' || p[-1] == '\n')) p--;
564 *p = 0;
565 if (!MultiByteToWideChar( CP_UNIXCP, 0, buffer, -1, label, label_len ))
566 label[label_len-1] = 0;
568 else label[0] = 0;
570 if (serial)
572 WCHAR serialW[] = {'A',':','\\','.','w','i','n','d','o','w','s','-','s','e','r','i','a','l',0};
574 serialW[0] = device[4];
575 handle = CreateFileW( serialW, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
576 OPEN_EXISTING, 0, 0 );
577 if (handle != INVALID_HANDLE_VALUE)
579 char buffer[32];
580 DWORD size;
582 if (!ReadFile( handle, buffer, sizeof(buffer)-1, &size, NULL )) size = 0;
583 CloseHandle( handle );
584 buffer[size] = 0;
585 *serial = strtoul( buffer, NULL, 16 );
587 else *serial = 0;
590 fill_fs_info: /* now fill in the information that depends on the file system type */
592 switch(type)
594 case FS_ISO9660:
595 if (fsname) lstrcpynW( fsname, cdfsW, fsname_len );
596 if (filename_len) *filename_len = 221;
597 if (flags) *flags = FILE_READ_ONLY_VOLUME;
598 break;
599 case FS_FAT1216:
600 case FS_FAT32:
601 if (fsname) lstrcpynW( fsname, fatW, fsname_len );
602 if (filename_len) *filename_len = 255;
603 if (flags) *flags = FILE_CASE_PRESERVED_NAMES; /* FIXME */
604 break;
605 default:
606 if (fsname) lstrcpynW( fsname, ntfsW, fsname_len );
607 if (filename_len) *filename_len = 255;
608 if (flags) *flags = FILE_CASE_PRESERVED_NAMES;
609 break;
611 return TRUE;
615 /***********************************************************************
616 * GetVolumeInformationA (KERNEL32.@)
618 BOOL WINAPI GetVolumeInformationA( LPCSTR root, LPSTR label,
619 DWORD label_len, DWORD *serial,
620 DWORD *filename_len, DWORD *flags,
621 LPSTR fsname, DWORD fsname_len )
623 WCHAR *rootW = NULL;
624 LPWSTR labelW, fsnameW;
625 BOOL ret;
627 if (root && !(rootW = FILE_name_AtoW( root, FALSE ))) return FALSE;
629 labelW = label ? HeapAlloc(GetProcessHeap(), 0, label_len * sizeof(WCHAR)) : NULL;
630 fsnameW = fsname ? HeapAlloc(GetProcessHeap(), 0, fsname_len * sizeof(WCHAR)) : NULL;
632 if ((ret = GetVolumeInformationW(rootW, labelW, label_len, serial,
633 filename_len, flags, fsnameW, fsname_len)))
635 if (label) FILE_name_WtoA( labelW, -1, label, label_len );
636 if (fsname) FILE_name_WtoA( fsnameW, -1, fsname, fsname_len );
639 HeapFree( GetProcessHeap(), 0, labelW );
640 HeapFree( GetProcessHeap(), 0, fsnameW );
641 return ret;
646 /***********************************************************************
647 * SetVolumeLabelW (KERNEL32.@)
649 BOOL WINAPI SetVolumeLabelW( LPCWSTR root, LPCWSTR label )
651 WCHAR device[] = {'\\','\\','.','\\','A',':',0};
652 HANDLE handle;
653 enum fs_type type = FS_UNKNOWN;
655 if (!root)
657 WCHAR path[MAX_PATH];
658 GetCurrentDirectoryW( MAX_PATH, path );
659 device[4] = path[0];
661 else
663 if (!root[0] || root[1] != ':')
665 SetLastError( ERROR_INVALID_NAME );
666 return FALSE;
668 device[4] = root[0];
671 /* try to open the device */
673 handle = CreateFileW( device, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
674 NULL, OPEN_EXISTING, 0, 0 );
675 if (handle != INVALID_HANDLE_VALUE)
677 BYTE superblock[SUPERBLOCK_SIZE];
679 type = VOLUME_ReadFATSuperblock( handle, superblock );
680 if (type == FS_UNKNOWN) type = VOLUME_ReadCDSuperblock( handle, superblock );
681 CloseHandle( handle );
682 if (type != FS_UNKNOWN)
684 /* we can't set the label on FAT or CDROM file systems */
685 TRACE( "cannot set label on device %s type %d\n", debugstr_w(device), type );
686 SetLastError( ERROR_ACCESS_DENIED );
687 return FALSE;
690 else
692 TRACE( "cannot open device %s: err %d\n", debugstr_w(device), GetLastError() );
693 if (GetLastError() == ERROR_ACCESS_DENIED) return FALSE;
696 /* we couldn't open the device, fallback to default strategy */
698 switch(GetDriveTypeW( root ))
700 case DRIVE_UNKNOWN:
701 case DRIVE_NO_ROOT_DIR:
702 SetLastError( ERROR_NOT_READY );
703 break;
704 case DRIVE_REMOVABLE:
705 case DRIVE_FIXED:
707 WCHAR labelW[] = {'A',':','\\','.','w','i','n','d','o','w','s','-','l','a','b','e','l',0};
709 labelW[0] = device[4];
710 handle = CreateFileW( labelW, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
711 CREATE_ALWAYS, 0, 0 );
712 if (handle != INVALID_HANDLE_VALUE)
714 char buffer[64];
715 DWORD size;
717 if (!WideCharToMultiByte( CP_UNIXCP, 0, label, -1, buffer, sizeof(buffer), NULL, NULL ))
718 buffer[sizeof(buffer)-1] = 0;
719 WriteFile( handle, buffer, strlen(buffer), &size, NULL );
720 CloseHandle( handle );
721 return TRUE;
723 break;
725 case DRIVE_REMOTE:
726 case DRIVE_RAMDISK:
727 case DRIVE_CDROM:
728 SetLastError( ERROR_ACCESS_DENIED );
729 break;
731 return FALSE;
734 /***********************************************************************
735 * SetVolumeLabelA (KERNEL32.@)
737 BOOL WINAPI SetVolumeLabelA(LPCSTR root, LPCSTR volname)
739 WCHAR *rootW = NULL, *volnameW = NULL;
740 BOOL ret;
742 if (root && !(rootW = FILE_name_AtoW( root, FALSE ))) return FALSE;
743 if (volname && !(volnameW = FILE_name_AtoW( volname, TRUE ))) return FALSE;
744 ret = SetVolumeLabelW( rootW, volnameW );
745 HeapFree( GetProcessHeap(), 0, volnameW );
746 return ret;
750 /***********************************************************************
751 * GetVolumeNameForVolumeMountPointA (KERNEL32.@)
753 BOOL WINAPI GetVolumeNameForVolumeMountPointA( LPCSTR path, LPSTR volume, DWORD size )
755 BOOL ret;
756 WCHAR volumeW[50], *pathW = NULL;
757 DWORD len = min( sizeof(volumeW) / sizeof(WCHAR), size );
759 TRACE("(%s, %p, %x)\n", debugstr_a(path), volume, size);
761 if (!path || !(pathW = FILE_name_AtoW( path, TRUE )))
762 return FALSE;
764 if ((ret = GetVolumeNameForVolumeMountPointW( pathW, volumeW, len )))
765 FILE_name_WtoA( volumeW, -1, volume, len );
767 HeapFree( GetProcessHeap(), 0, pathW );
768 return ret;
771 /***********************************************************************
772 * GetVolumeNameForVolumeMountPointW (KERNEL32.@)
774 BOOL WINAPI GetVolumeNameForVolumeMountPointW( LPCWSTR path, LPWSTR volume, DWORD size )
776 BOOL ret = FALSE;
777 static const WCHAR fmt[] =
778 { '\\','\\','?','\\','V','o','l','u','m','e','{','%','0','2','x','}','\\',0 };
780 TRACE("(%s, %p, %x)\n", debugstr_w(path), volume, size);
782 if (!path || !path[0]) return FALSE;
784 if (size >= sizeof(fmt) / sizeof(WCHAR))
786 /* FIXME: will break when we support volume mounts */
787 sprintfW( volume, fmt, tolowerW( path[0] ) - 'a' );
788 ret = TRUE;
790 return ret;
793 /***********************************************************************
794 * DefineDosDeviceW (KERNEL32.@)
796 BOOL WINAPI DefineDosDeviceW( DWORD flags, LPCWSTR devname, LPCWSTR targetpath )
798 DWORD len, dosdev;
799 BOOL ret = FALSE;
800 char *path = NULL, *target, *p;
802 TRACE("%x, %s, %s\n", flags, debugstr_w(devname), debugstr_w(targetpath));
804 if (!(flags & DDD_REMOVE_DEFINITION))
806 if (!(flags & DDD_RAW_TARGET_PATH))
808 FIXME( "(0x%08x,%s,%s) DDD_RAW_TARGET_PATH flag not set, not supported yet\n",
809 flags, debugstr_w(devname), debugstr_w(targetpath) );
810 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
811 return FALSE;
814 len = WideCharToMultiByte( CP_UNIXCP, 0, targetpath, -1, NULL, 0, NULL, NULL );
815 if ((target = HeapAlloc( GetProcessHeap(), 0, len )))
817 WideCharToMultiByte( CP_UNIXCP, 0, targetpath, -1, target, len, NULL, NULL );
818 for (p = target; *p; p++) if (*p == '\\') *p = '/';
820 else
822 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
823 return FALSE;
826 else target = NULL;
828 /* first check for a DOS device */
830 if ((dosdev = RtlIsDosDeviceName_U( devname )))
832 WCHAR name[5];
834 memcpy( name, devname + HIWORD(dosdev)/sizeof(WCHAR), LOWORD(dosdev) );
835 name[LOWORD(dosdev)/sizeof(WCHAR)] = 0;
836 path = get_dos_device_path( name );
838 else if (isalphaW(devname[0]) && devname[1] == ':' && !devname[2]) /* drive mapping */
840 path = get_dos_device_path( devname );
842 else SetLastError( ERROR_FILE_NOT_FOUND );
844 if (path)
846 if (target)
848 TRACE( "creating symlink %s -> %s\n", path, target );
849 unlink( path );
850 if (!symlink( target, path )) ret = TRUE;
851 else FILE_SetDosError();
853 else
855 TRACE( "removing symlink %s\n", path );
856 if (!unlink( path )) ret = TRUE;
857 else FILE_SetDosError();
859 HeapFree( GetProcessHeap(), 0, path );
861 HeapFree( GetProcessHeap(), 0, target );
862 return ret;
866 /***********************************************************************
867 * DefineDosDeviceA (KERNEL32.@)
869 BOOL WINAPI DefineDosDeviceA(DWORD flags, LPCSTR devname, LPCSTR targetpath)
871 WCHAR *devW, *targetW = NULL;
872 BOOL ret;
874 if (!(devW = FILE_name_AtoW( devname, FALSE ))) return FALSE;
875 if (targetpath && !(targetW = FILE_name_AtoW( targetpath, TRUE ))) return FALSE;
876 ret = DefineDosDeviceW(flags, devW, targetW);
877 HeapFree( GetProcessHeap(), 0, targetW );
878 return ret;
882 /***********************************************************************
883 * QueryDosDeviceW (KERNEL32.@)
885 * returns array of strings terminated by \0, terminated by \0
887 DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
889 static const WCHAR auxW[] = {'A','U','X',0};
890 static const WCHAR nulW[] = {'N','U','L',0};
891 static const WCHAR prnW[] = {'P','R','N',0};
892 static const WCHAR comW[] = {'C','O','M',0};
893 static const WCHAR lptW[] = {'L','P','T',0};
894 static const WCHAR rootW[] = {'A',':','\\',0};
895 static const WCHAR com0W[] = {'\\','?','?','\\','C','O','M','0',0};
896 static const WCHAR com1W[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\','C','O','M','1',0,0};
897 static const WCHAR lpt1W[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\','L','P','T','1',0,0};
899 UNICODE_STRING nt_name;
900 ANSI_STRING unix_name;
901 WCHAR nt_buffer[10];
902 NTSTATUS status;
904 if (!bufsize)
906 SetLastError( ERROR_INSUFFICIENT_BUFFER );
907 return 0;
910 if (devname)
912 WCHAR *p, name[5];
913 char *path, *link;
914 DWORD dosdev, ret = 0;
916 if ((dosdev = RtlIsDosDeviceName_U( devname )))
918 memcpy( name, devname + HIWORD(dosdev)/sizeof(WCHAR), LOWORD(dosdev) );
919 name[LOWORD(dosdev)/sizeof(WCHAR)] = 0;
921 else if (devname[0] && devname[1] == ':' && !devname[2])
923 memcpy( name, devname, 3 * sizeof(WCHAR) );
925 else
927 SetLastError( ERROR_BAD_PATHNAME );
928 return 0;
931 if (!(path = get_dos_device_path( name ))) return 0;
932 link = read_symlink( path );
933 HeapFree( GetProcessHeap(), 0, path );
935 if (link)
937 ret = MultiByteToWideChar( CP_UNIXCP, 0, link, -1, target, bufsize );
938 HeapFree( GetProcessHeap(), 0, link );
940 else if (dosdev) /* look for device defaults */
942 if (!strcmpiW( name, auxW ))
944 if (bufsize >= sizeof(com1W)/sizeof(WCHAR))
946 memcpy( target, com1W, sizeof(com1W) );
947 ret = sizeof(com1W)/sizeof(WCHAR);
949 else SetLastError( ERROR_INSUFFICIENT_BUFFER );
950 return ret;
952 if (!strcmpiW( name, prnW ))
954 if (bufsize >= sizeof(lpt1W)/sizeof(WCHAR))
956 memcpy( target, lpt1W, sizeof(lpt1W) );
957 ret = sizeof(lpt1W)/sizeof(WCHAR);
959 else SetLastError( ERROR_INSUFFICIENT_BUFFER );
960 return ret;
963 nt_buffer[0] = '\\';
964 nt_buffer[1] = '?';
965 nt_buffer[2] = '?';
966 nt_buffer[3] = '\\';
967 strcpyW( nt_buffer + 4, name );
968 RtlInitUnicodeString( &nt_name, nt_buffer );
969 status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, TRUE );
970 if (status) SetLastError( RtlNtStatusToDosError(status) );
971 else
973 ret = MultiByteToWideChar( CP_UNIXCP, 0, unix_name.Buffer, -1, target, bufsize );
974 RtlFreeAnsiString( &unix_name );
978 if (ret)
980 if (ret < bufsize) target[ret++] = 0; /* add an extra null */
981 for (p = target; *p; p++) if (*p == '/') *p = '\\';
984 return ret;
986 else /* return a list of all devices */
988 WCHAR *p = target;
989 int i;
991 if (bufsize <= (sizeof(auxW)+sizeof(nulW)+sizeof(prnW))/sizeof(WCHAR))
993 SetLastError( ERROR_INSUFFICIENT_BUFFER );
994 return 0;
997 memcpy( p, auxW, sizeof(auxW) );
998 p += sizeof(auxW) / sizeof(WCHAR);
999 memcpy( p, nulW, sizeof(nulW) );
1000 p += sizeof(nulW) / sizeof(WCHAR);
1001 memcpy( p, prnW, sizeof(prnW) );
1002 p += sizeof(prnW) / sizeof(WCHAR);
1004 strcpyW( nt_buffer, com0W );
1005 RtlInitUnicodeString( &nt_name, nt_buffer );
1007 for (i = 1; i <= 9; i++)
1009 nt_buffer[7] = '0' + i;
1010 if (!wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, TRUE ))
1012 RtlFreeAnsiString( &unix_name );
1013 if (p + 5 >= target + bufsize)
1015 SetLastError( ERROR_INSUFFICIENT_BUFFER );
1016 return 0;
1018 strcpyW( p, comW );
1019 p[3] = '0' + i;
1020 p[4] = 0;
1021 p += 5;
1024 strcpyW( nt_buffer + 4, lptW );
1025 for (i = 1; i <= 9; i++)
1027 nt_buffer[7] = '0' + i;
1028 if (!wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, TRUE ))
1030 RtlFreeAnsiString( &unix_name );
1031 if (p + 5 >= target + bufsize)
1033 SetLastError( ERROR_INSUFFICIENT_BUFFER );
1034 return 0;
1036 strcpyW( p, lptW );
1037 p[3] = '0' + i;
1038 p[4] = 0;
1039 p += 5;
1043 strcpyW( nt_buffer + 4, rootW );
1044 RtlInitUnicodeString( &nt_name, nt_buffer );
1046 for (i = 0; i < 26; i++)
1048 nt_buffer[4] = 'a' + i;
1049 if (!wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, TRUE ))
1051 RtlFreeAnsiString( &unix_name );
1052 if (p + 3 >= target + bufsize)
1054 SetLastError( ERROR_INSUFFICIENT_BUFFER );
1055 return 0;
1057 *p++ = 'A' + i;
1058 *p++ = ':';
1059 *p++ = 0;
1062 *p++ = 0; /* terminating null */
1063 return p - target;
1068 /***********************************************************************
1069 * QueryDosDeviceA (KERNEL32.@)
1071 * returns array of strings terminated by \0, terminated by \0
1073 DWORD WINAPI QueryDosDeviceA( LPCSTR devname, LPSTR target, DWORD bufsize )
1075 DWORD ret = 0, retW;
1076 WCHAR *devnameW = NULL;
1077 LPWSTR targetW;
1079 if (devname && !(devnameW = FILE_name_AtoW( devname, FALSE ))) return 0;
1081 targetW = HeapAlloc( GetProcessHeap(),0, bufsize * sizeof(WCHAR) );
1082 if (!targetW)
1084 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
1085 return 0;
1088 retW = QueryDosDeviceW(devnameW, targetW, bufsize);
1090 ret = FILE_name_WtoA( targetW, retW, target, bufsize );
1092 HeapFree(GetProcessHeap(), 0, targetW);
1093 return ret;
1097 /***********************************************************************
1098 * GetLogicalDrives (KERNEL32.@)
1100 DWORD WINAPI GetLogicalDrives(void)
1102 const char *config_dir = wine_get_config_dir();
1103 struct stat st;
1104 char *buffer, *dev;
1105 DWORD ret = 0;
1106 int i;
1108 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, strlen(config_dir) + sizeof("/dosdevices/a:") )))
1110 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
1111 return 0;
1113 strcpy( buffer, config_dir );
1114 strcat( buffer, "/dosdevices/a:" );
1115 dev = buffer + strlen(buffer) - 2;
1117 for (i = 0; i < 26; i++)
1119 *dev = 'a' + i;
1120 if (!stat( buffer, &st )) ret |= (1 << i);
1122 HeapFree( GetProcessHeap(), 0, buffer );
1123 return ret;
1127 /***********************************************************************
1128 * GetLogicalDriveStringsA (KERNEL32.@)
1130 UINT WINAPI GetLogicalDriveStringsA( UINT len, LPSTR buffer )
1132 DWORD drives = GetLogicalDrives();
1133 UINT drive, count;
1135 for (drive = count = 0; drive < 26; drive++) if (drives & (1 << drive)) count++;
1136 if ((count * 4) + 1 > len) return count * 4 + 1;
1138 for (drive = 0; drive < 26; drive++)
1140 if (drives & (1 << drive))
1142 *buffer++ = 'a' + drive;
1143 *buffer++ = ':';
1144 *buffer++ = '\\';
1145 *buffer++ = 0;
1148 *buffer = 0;
1149 return count * 4;
1153 /***********************************************************************
1154 * GetLogicalDriveStringsW (KERNEL32.@)
1156 UINT WINAPI GetLogicalDriveStringsW( UINT len, LPWSTR buffer )
1158 DWORD drives = GetLogicalDrives();
1159 UINT drive, count;
1161 for (drive = count = 0; drive < 26; drive++) if (drives & (1 << drive)) count++;
1162 if ((count * 4) + 1 > len) return count * 4 + 1;
1164 for (drive = 0; drive < 26; drive++)
1166 if (drives & (1 << drive))
1168 *buffer++ = 'a' + drive;
1169 *buffer++ = ':';
1170 *buffer++ = '\\';
1171 *buffer++ = 0;
1174 *buffer = 0;
1175 return count * 4;
1179 /***********************************************************************
1180 * GetDriveTypeW (KERNEL32.@)
1182 * Returns the type of the disk drive specified. If root is NULL the
1183 * root of the current directory is used.
1185 * RETURNS
1187 * Type of drive (from Win32 SDK):
1189 * DRIVE_UNKNOWN unable to find out anything about the drive
1190 * DRIVE_NO_ROOT_DIR nonexistent root dir
1191 * DRIVE_REMOVABLE the disk can be removed from the machine
1192 * DRIVE_FIXED the disk cannot be removed from the machine
1193 * DRIVE_REMOTE network disk
1194 * DRIVE_CDROM CDROM drive
1195 * DRIVE_RAMDISK virtual disk in RAM
1197 UINT WINAPI GetDriveTypeW(LPCWSTR root) /* [in] String describing drive */
1199 FILE_FS_DEVICE_INFORMATION info;
1200 IO_STATUS_BLOCK io;
1201 NTSTATUS status;
1202 HANDLE handle;
1203 UINT ret;
1205 if (!open_device_root( root, &handle )) return DRIVE_NO_ROOT_DIR;
1207 status = NtQueryVolumeInformationFile( handle, &io, &info, sizeof(info), FileFsDeviceInformation );
1208 NtClose( handle );
1209 if (status != STATUS_SUCCESS)
1211 SetLastError( RtlNtStatusToDosError(status) );
1212 ret = DRIVE_UNKNOWN;
1214 else if ((ret = get_registry_drive_type( root )) == DRIVE_UNKNOWN)
1216 switch (info.DeviceType)
1218 case FILE_DEVICE_CD_ROM_FILE_SYSTEM: ret = DRIVE_CDROM; break;
1219 case FILE_DEVICE_VIRTUAL_DISK: ret = DRIVE_RAMDISK; break;
1220 case FILE_DEVICE_NETWORK_FILE_SYSTEM: ret = DRIVE_REMOTE; break;
1221 case FILE_DEVICE_DISK_FILE_SYSTEM:
1222 if (info.Characteristics & FILE_REMOTE_DEVICE) ret = DRIVE_REMOTE;
1223 else if (info.Characteristics & FILE_REMOVABLE_MEDIA) ret = DRIVE_REMOVABLE;
1224 else ret = DRIVE_FIXED;
1225 break;
1226 default:
1227 ret = DRIVE_UNKNOWN;
1228 break;
1231 TRACE( "%s -> %d\n", debugstr_w(root), ret );
1232 return ret;
1236 /***********************************************************************
1237 * GetDriveTypeA (KERNEL32.@)
1239 * See GetDriveTypeW.
1241 UINT WINAPI GetDriveTypeA( LPCSTR root )
1243 WCHAR *rootW = NULL;
1245 if (root && !(rootW = FILE_name_AtoW( root, FALSE ))) return DRIVE_NO_ROOT_DIR;
1246 return GetDriveTypeW( rootW );
1250 /***********************************************************************
1251 * GetDiskFreeSpaceExW (KERNEL32.@)
1253 * This function is used to acquire the size of the available and
1254 * total space on a logical volume.
1256 * RETURNS
1258 * Zero on failure, nonzero upon success. Use GetLastError to obtain
1259 * detailed error information.
1262 BOOL WINAPI GetDiskFreeSpaceExW( LPCWSTR root, PULARGE_INTEGER avail,
1263 PULARGE_INTEGER total, PULARGE_INTEGER totalfree )
1265 FILE_FS_SIZE_INFORMATION info;
1266 IO_STATUS_BLOCK io;
1267 NTSTATUS status;
1268 HANDLE handle;
1269 UINT units;
1271 TRACE( "%s,%p,%p,%p\n", debugstr_w(root), avail, total, totalfree );
1273 if (!open_device_root( root, &handle )) return FALSE;
1275 status = NtQueryVolumeInformationFile( handle, &io, &info, sizeof(info), FileFsSizeInformation );
1276 NtClose( handle );
1277 if (status != STATUS_SUCCESS)
1279 SetLastError( RtlNtStatusToDosError(status) );
1280 return FALSE;
1283 units = info.SectorsPerAllocationUnit * info.BytesPerSector;
1284 if (total) total->QuadPart = info.TotalAllocationUnits.QuadPart * units;
1285 if (totalfree) totalfree->QuadPart = info.AvailableAllocationUnits.QuadPart * units;
1286 /* FIXME: this one should take quotas into account */
1287 if (avail) avail->QuadPart = info.AvailableAllocationUnits.QuadPart * units;
1288 return TRUE;
1292 /***********************************************************************
1293 * GetDiskFreeSpaceExA (KERNEL32.@)
1295 * See GetDiskFreeSpaceExW.
1297 BOOL WINAPI GetDiskFreeSpaceExA( LPCSTR root, PULARGE_INTEGER avail,
1298 PULARGE_INTEGER total, PULARGE_INTEGER totalfree )
1300 WCHAR *rootW = NULL;
1302 if (root && !(rootW = FILE_name_AtoW( root, FALSE ))) return FALSE;
1303 return GetDiskFreeSpaceExW( rootW, avail, total, totalfree );
1307 /***********************************************************************
1308 * GetDiskFreeSpaceW (KERNEL32.@)
1310 BOOL WINAPI GetDiskFreeSpaceW( LPCWSTR root, LPDWORD cluster_sectors,
1311 LPDWORD sector_bytes, LPDWORD free_clusters,
1312 LPDWORD total_clusters )
1314 FILE_FS_SIZE_INFORMATION info;
1315 IO_STATUS_BLOCK io;
1316 NTSTATUS status;
1317 HANDLE handle;
1318 UINT units;
1320 TRACE( "%s,%p,%p,%p,%p\n", debugstr_w(root),
1321 cluster_sectors, sector_bytes, free_clusters, total_clusters );
1323 if (!open_device_root( root, &handle )) return FALSE;
1325 status = NtQueryVolumeInformationFile( handle, &io, &info, sizeof(info), FileFsSizeInformation );
1326 NtClose( handle );
1327 if (status != STATUS_SUCCESS)
1329 SetLastError( RtlNtStatusToDosError(status) );
1330 return FALSE;
1333 units = info.SectorsPerAllocationUnit * info.BytesPerSector;
1335 if( GetVersion() & 0x80000000) { /* win3.x, 9x, ME */
1336 /* cap the size and available at 2GB as per specs */
1337 if (info.TotalAllocationUnits.QuadPart * units > 0x7fffffff) {
1338 info.TotalAllocationUnits.QuadPart = 0x7fffffff / units;
1339 if (info.AvailableAllocationUnits.QuadPart * units > 0x7fffffff)
1340 info.AvailableAllocationUnits.QuadPart = 0x7fffffff / units;
1342 /* nr. of clusters is always <= 65335 */
1343 while( info.TotalAllocationUnits.QuadPart > 65535 ) {
1344 info.TotalAllocationUnits.QuadPart /= 2;
1345 info.AvailableAllocationUnits.QuadPart /= 2;
1346 info.SectorsPerAllocationUnit *= 2;
1350 if (cluster_sectors) *cluster_sectors = info.SectorsPerAllocationUnit;
1351 if (sector_bytes) *sector_bytes = info.BytesPerSector;
1352 if (free_clusters) *free_clusters = info.AvailableAllocationUnits.u.LowPart;
1353 if (total_clusters) *total_clusters = info.TotalAllocationUnits.u.LowPart;
1354 return TRUE;
1358 /***********************************************************************
1359 * GetDiskFreeSpaceA (KERNEL32.@)
1361 BOOL WINAPI GetDiskFreeSpaceA( LPCSTR root, LPDWORD cluster_sectors,
1362 LPDWORD sector_bytes, LPDWORD free_clusters,
1363 LPDWORD total_clusters )
1365 WCHAR *rootW = NULL;
1367 if (root && !(rootW = FILE_name_AtoW( root, FALSE ))) return FALSE;
1368 return GetDiskFreeSpaceW( rootW, cluster_sectors, sector_bytes, free_clusters, total_clusters );
1371 /***********************************************************************
1372 * GetVolumePathNameA (KERNEL32.@)
1374 BOOL WINAPI GetVolumePathNameA(LPCSTR filename, LPSTR volumepathname, DWORD buflen)
1376 FIXME("(%s, %p, %d), stub!\n", debugstr_a(filename), volumepathname, buflen);
1377 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1378 return FALSE;
1381 /***********************************************************************
1382 * GetVolumePathNameW (KERNEL32.@)
1384 BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD buflen)
1386 FIXME("(%s, %p, %d), stub!\n", debugstr_w(filename), volumepathname, buflen);
1387 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1388 return FALSE;
1391 /***********************************************************************
1392 * FindFirstVolumeMountPointA (KERNEL32.@)
1394 HANDLE WINAPI FindFirstVolumeMountPointA(LPCSTR root, LPSTR mount_point, DWORD len)
1396 FIXME("(%s, %p, %d), stub!\n", debugstr_a(root), mount_point, len);
1397 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1398 return INVALID_HANDLE_VALUE;
1401 /***********************************************************************
1402 * FindFirstVolumeMountPointW (KERNEL32.@)
1404 HANDLE WINAPI FindFirstVolumeMountPointW(LPCWSTR root, LPWSTR mount_point, DWORD len)
1406 FIXME("(%s, %p, %d), stub!\n", debugstr_w(root), mount_point, len);
1407 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1408 return INVALID_HANDLE_VALUE;