336
336
reasonable = num_boot_sectors < total_sectors &&
338
338
bytes_per_sector >= 512 && bytes_per_sector % 512 == 0 &&
339
sectors_per_cluster > 1;
339
sectors_per_cluster >= 1;
340
340
if (!reasonable) return FS_UNKNOWN;
341
341
sectors = total_sectors - num_boot_sectors - num_fats * sect_per_fat -
342
342
(num_root_dir_ents * 32 + bytes_per_sector - 1) / bytes_per_sector;
513
513
static const WCHAR fat32W[] = {'F','A','T','3','2',0};
514
514
static const WCHAR ntfsW[] = {'N','T','F','S',0};
515
515
static const WCHAR cdfsW[] = {'C','D','F','S',0};
516
static const WCHAR default_rootW[] = {'\\',0};
517
518
WCHAR device[] = {'\\','\\','.','\\','A',':',0};
520
UNICODE_STRING nt_name;
519
522
enum fs_type type = FS_UNKNOWN;
523
WCHAR path[MAX_PATH];
524
GetCurrentDirectoryW( MAX_PATH, path );
529
if (!root[0] || root[1] != ':' || root[lstrlenW(root)-1] != '\\' )
531
SetLastError( ERROR_INVALID_NAME );
525
if (!root) root = default_rootW;
526
if (!RtlDosPathNameToNtPathName_U( root, &nt_name, NULL, NULL ))
528
SetLastError( ERROR_PATH_NOT_FOUND );
531
/* there must be exactly one backslash in the name, at the end */
532
p = memchrW( nt_name.Buffer + 4, '\\', (nt_name.Length - 4) / sizeof(WCHAR) );
533
if (p != nt_name.Buffer + nt_name.Length / sizeof(WCHAR) - 1)
535
SetLastError( ERROR_INVALID_NAME );
538
device[4] = nt_name.Buffer[4];
537
540
/* try to open the device */
567
570
CloseHandle( handle );
568
571
TRACE( "%s: found fs type %d\n", debugstr_w(device), type );
569
if (type == FS_ERROR) return FALSE;
572
if (type == FS_ERROR) goto done;
571
574
if (label && label_len) VOLUME_GetSuperblockLabel( device, type, superblock, label, label_len );
572
575
if (serial) *serial = VOLUME_GetSuperblockSerial( device, type, superblock );