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.
34 /////////////////////////////////////////////////////////////////////////////////////////////
36 /////////////////////////////////////////////////////////////////////////////////////////////
40 * BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
43 BOOL
FsRecognizeVolume(U32 DriveNumber
, U32 VolumeStartSector
, U8
* VolumeType
)
46 DbgPrint((DPRINT_FILESYSTEM
, "FsRecognizeVolume() DriveNumber: 0x%x VolumeStartSector: %d\n", DriveNumber
, VolumeStartSector
));
48 if (FsRecIsExt2(DriveNumber
, VolumeStartSector
))
50 *VolumeType
= PARTITION_EXT2
;
53 else if (FsRecIsFat(DriveNumber
, VolumeStartSector
))
55 *VolumeType
= PARTITION_FAT32
;
62 BOOL
FsRecIsIso9660(U32 DriveNumber
)
64 PUCHAR Sector
= (PUCHAR
)DISKREADBUFFER
;
66 if (!DiskReadLogicalSectors(DriveNumber
, 16, 1, Sector
))
68 FileSystemError("Failed to read the PVD.");
72 return (Sector
[0] == 1 &&
80 BOOL
FsRecIsExt2(U32 DriveNumber
, U32 VolumeStartSector
)
82 PEXT2_SUPER_BLOCK SuperBlock
= (PEXT2_SUPER_BLOCK
)DISKREADBUFFER
;
84 if (!DiskReadLogicalSectors(DriveNumber
, VolumeStartSector
+ 2, 2, SuperBlock
))
86 FileSystemError("Failed to read the super block.");
90 if (SuperBlock
->s_magic
== EXT3_SUPER_MAGIC
)
98 BOOL
FsRecIsFat(U32 DriveNumber
, U32 VolumeStartSector
)
100 PFAT_BOOTSECTOR BootSector
= (PFAT_BOOTSECTOR
)DISKREADBUFFER
;
102 if (!DiskReadLogicalSectors(DriveNumber
, VolumeStartSector
, 1, BootSector
))
104 FileSystemError("Failed to read the boot sector.");
108 if (strncmp(BootSector
->FileSystemType
, "FAT12 ", 8) == 0 ||
109 strncmp(BootSector
->FileSystemType
, "FAT16 ", 8) == 0 ||
110 strncmp(BootSector
->FileSystemType
, "FAT32 ", 8) == 0)