3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /////////////////////////////////////////////////////////////////////////////////////////////
27 /////////////////////////////////////////////////////////////////////////////////////////////
31 * BOOLEAN FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType);
34 BOOLEAN
FsRecognizeVolume(ULONG DriveNumber
, ULONG VolumeStartSector
, UCHAR
* VolumeType
)
37 DbgPrint((DPRINT_FILESYSTEM
, "FsRecognizeVolume() DriveNumber: 0x%x VolumeStartSector: %d\n", DriveNumber
, VolumeStartSector
));
39 if (FsRecIsExt2(DriveNumber
, VolumeStartSector
))
41 *VolumeType
= PARTITION_EXT2
;
44 else if (FsRecIsFat(DriveNumber
, VolumeStartSector
))
46 *VolumeType
= PARTITION_FAT32
;
49 else if (FsRecIsNtfs(DriveNumber
, VolumeStartSector
))
51 *VolumeType
= PARTITION_NTFS
;
58 BOOLEAN
FsRecIsIso9660(ULONG DriveNumber
)
60 PUCHAR Sector
= (PUCHAR
)DISKREADBUFFER
;
62 if (!MachDiskReadLogicalSectors(DriveNumber
, 16, 1, Sector
))
64 FileSystemError("Failed to read the PVD.");
68 return (Sector
[0] == 1 &&
76 BOOLEAN
FsRecIsExt2(ULONG DriveNumber
, ULONG VolumeStartSector
)
78 PEXT2_SUPER_BLOCK SuperBlock
= (PEXT2_SUPER_BLOCK
)DISKREADBUFFER
;
80 if (!MachDiskReadLogicalSectors(DriveNumber
, VolumeStartSector
+ 2, 2, SuperBlock
))
82 FileSystemError("Failed to read the super block.");
86 if (SuperBlock
->s_magic
== EXT3_SUPER_MAGIC
)
94 BOOLEAN
FsRecIsFat(ULONG DriveNumber
, ULONG VolumeStartSector
)
96 PFAT_BOOTSECTOR BootSector
= (PFAT_BOOTSECTOR
)DISKREADBUFFER
;
97 PFAT32_BOOTSECTOR BootSector32
= (PFAT32_BOOTSECTOR
)DISKREADBUFFER
;
98 PFATX_BOOTSECTOR BootSectorX
= (PFATX_BOOTSECTOR
)DISKREADBUFFER
;
99 if (!MachDiskReadLogicalSectors(DriveNumber
, VolumeStartSector
, 1, BootSector
))
101 FileSystemError("Failed to read the boot sector.");
105 if (strncmp(BootSector
->FileSystemType
, "FAT12 ", 8) == 0 ||
106 strncmp(BootSector
->FileSystemType
, "FAT16 ", 8) == 0 ||
107 strncmp(BootSector32
->FileSystemType
, "FAT32 ", 8) == 0 ||
108 strncmp(BootSectorX
->FileSystemType
, "FATX", 4) == 0)
116 BOOLEAN
FsRecIsNtfs(ULONG DriveNumber
, ULONG VolumeStartSector
)
118 PNTFS_BOOTSECTOR BootSector
= (PNTFS_BOOTSECTOR
)DISKREADBUFFER
;
119 if (!MachDiskReadLogicalSectors(DriveNumber
, VolumeStartSector
, 1, BootSector
))
121 FileSystemError("Failed to read the boot sector.");
125 if (RtlEqualMemory(BootSector
->SystemId
, "NTFS", 4))