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.
36 /////////////////////////////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////////////////////////////
42 * BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType);
45 BOOL
FsRecognizeVolume(ULONG DriveNumber
, ULONG VolumeStartSector
, UCHAR
* VolumeType
)
48 DbgPrint((DPRINT_FILESYSTEM
, "FsRecognizeVolume() DriveNumber: 0x%x VolumeStartSector: %d\n", DriveNumber
, VolumeStartSector
));
50 if (FsRecIsExt2(DriveNumber
, VolumeStartSector
))
52 *VolumeType
= PARTITION_EXT2
;
55 else if (FsRecIsFat(DriveNumber
, VolumeStartSector
))
57 *VolumeType
= PARTITION_FAT32
;
60 else if (FsRecIsNtfs(DriveNumber
, VolumeStartSector
))
62 *VolumeType
= PARTITION_NTFS
;
69 BOOL
FsRecIsIso9660(ULONG DriveNumber
)
71 PUCHAR Sector
= (PUCHAR
)DISKREADBUFFER
;
73 if (!MachDiskReadLogicalSectors(DriveNumber
, 16, 1, Sector
))
75 FileSystemError("Failed to read the PVD.");
79 return (Sector
[0] == 1 &&
87 BOOL
FsRecIsExt2(ULONG DriveNumber
, ULONG VolumeStartSector
)
89 PEXT2_SUPER_BLOCK SuperBlock
= (PEXT2_SUPER_BLOCK
)DISKREADBUFFER
;
91 if (!MachDiskReadLogicalSectors(DriveNumber
, VolumeStartSector
+ 2, 2, SuperBlock
))
93 FileSystemError("Failed to read the super block.");
97 if (SuperBlock
->s_magic
== EXT3_SUPER_MAGIC
)
105 BOOL
FsRecIsFat(ULONG DriveNumber
, ULONG VolumeStartSector
)
107 PFAT_BOOTSECTOR BootSector
= (PFAT_BOOTSECTOR
)DISKREADBUFFER
;
108 PFAT32_BOOTSECTOR BootSector32
= (PFAT32_BOOTSECTOR
)DISKREADBUFFER
;
109 PFATX_BOOTSECTOR BootSectorX
= (PFATX_BOOTSECTOR
)DISKREADBUFFER
;
110 if (!MachDiskReadLogicalSectors(DriveNumber
, VolumeStartSector
, 1, BootSector
))
112 FileSystemError("Failed to read the boot sector.");
116 if (strncmp(BootSector
->FileSystemType
, "FAT12 ", 8) == 0 ||
117 strncmp(BootSector
->FileSystemType
, "FAT16 ", 8) == 0 ||
118 strncmp(BootSector32
->FileSystemType
, "FAT32 ", 8) == 0 ||
119 strncmp(BootSectorX
->FileSystemType
, "FATX", 4) == 0)
127 BOOL
FsRecIsNtfs(ULONG DriveNumber
, ULONG VolumeStartSector
)
129 PNTFS_BOOTSECTOR BootSector
= (PNTFS_BOOTSECTOR
)DISKREADBUFFER
;
130 if (!MachDiskReadLogicalSectors(DriveNumber
, VolumeStartSector
, 1, BootSector
))
132 FileSystemError("Failed to read the boot sector.");
136 if (!RtlCompareMemory(BootSector
->SystemId
, "NTFS", 4))