+Changes in v1.8.7 (4/22/2003) (brianp)
+
+- Added a file system recognizer to get around problems where
+ the partition id did not match the file system type.
+
Changes in v1.8.6 (4/14/2003) (brianp)
- Fixed a bug in fathelp.asm where is wasn't adding the hidden sector
FS_OBJS = fs.o \
fat.o \
iso.o \
- ext2.o
+ ext2.o \
+ fsrec.o
UI_OBJS = tui.o \
tuimenu.o \
#include "fat.h"
#include "iso.h"
#include "ext2.h"
+#include "fsrec.h"
#include <disk.h>
#include <rtl.h>
#include <ui.h>
{
PARTITION_TABLE_ENTRY PartitionTableEntry;
UCHAR ErrorText[80];
+ U8 VolumeType;
DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", DriveNumber, PartitionNumber));
}
// Check for ISO9660 file system type
- if (DriveNumber > 0x80 && IsIsoFs(DriveNumber))
+ if (DriveNumber > 0x80 && FsRecIsIso9660(DriveNumber))
{
DbgPrint((DPRINT_FILESYSTEM, "Drive is a cdrom drive. Assuming ISO-9660 file system.\n"));
return FALSE;
}
- switch (PartitionTableEntry.SystemIndicator)
+ // Try to recognize the file system
+ if (!FsRecognizeVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition, &VolumeType))
+ {
+ sprintf(ErrorText, "Unrecognized file system. Type: 0x%x", PartitionTableEntry.SystemIndicator);
+ FileSystemError(ErrorText);
+ }
+
+ //switch (PartitionTableEntry.SystemIndicator)
+ switch (VolumeType)
{
case PARTITION_FAT_12:
case PARTITION_FAT_16:
--- /dev/null
+/*
+ * FreeLoader
+ * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <freeldr.h>
+#include <fs.h>
+#include "fsrec.h"
+#include "fat.h"
+#include "iso.h"
+#include "ext2.h"
+#include <disk.h>
+#include <rtl.h>
+#include <arch.h>
+#include <debug.h>
+
+
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+// FUNCTIONS
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+/*
+ *
+ * BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
+ *
+ */
+BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType)
+{
+
+ DbgPrint((DPRINT_FILESYSTEM, "FsRecognizeVolume() DriveNumber: 0x%x VolumeStartSector: %d\n", DriveNumber, VolumeStartSector));
+
+ if (FsRecIsExt2(DriveNumber, VolumeStartSector))
+ {
+ *VolumeType = PARTITION_EXT2;
+ return TRUE;
+ }
+ else if (FsRecIsFat(DriveNumber, VolumeStartSector))
+ {
+ *VolumeType = PARTITION_FAT32;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOL FsRecIsIso9660(U32 DriveNumber)
+{
+ PUCHAR Sector = (PUCHAR)DISKREADBUFFER;
+
+ if (!DiskReadLogicalSectors(DriveNumber, 16, 1, Sector))
+ {
+ FileSystemError("Failed to read the PVD.");
+ return FALSE;
+ }
+
+ return (Sector[0] == 1 &&
+ Sector[1] == 'C' &&
+ Sector[2] == 'D' &&
+ Sector[3] == '0' &&
+ Sector[4] == '0' &&
+ Sector[5] == '1');
+}
+
+BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector)
+{
+ PEXT2_SUPER_BLOCK SuperBlock = (PEXT2_SUPER_BLOCK)DISKREADBUFFER;
+
+ if (!DiskReadLogicalSectors(DriveNumber, VolumeStartSector + 2, 2, SuperBlock))
+ {
+ FileSystemError("Failed to read the super block.");
+ return FALSE;
+ }
+
+ if (SuperBlock->s_magic == EXT3_SUPER_MAGIC)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector)
+{
+ PFAT_BOOTSECTOR BootSector = (PFAT_BOOTSECTOR)DISKREADBUFFER;
+
+ if (!DiskReadLogicalSectors(DriveNumber, VolumeStartSector, 1, BootSector))
+ {
+ FileSystemError("Failed to read the boot sector.");
+ return FALSE;
+ }
+
+ if (strncmp(BootSector->FileSystemType, "FAT12 ", 8) == 0 ||
+ strncmp(BootSector->FileSystemType, "FAT16 ", 8) == 0 ||
+ strncmp(BootSector->FileSystemType, "FAT32 ", 8) == 0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
--- /dev/null
+/*
+ * FreeLoader
+ * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __FSREC_H
+#define __FSREC_H
+
+BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
+BOOL FsRecIsIso9660(U32 DriveNumber);
+BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector);
+BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector);
+
+#endif // #defined __FSREC_H
U32 IsoDriveNumber = 0;
-BOOL IsIsoFs(U32 DriveNumber)
-{
- PUCHAR Sector = (PUCHAR)DISKREADBUFFER;
-
- if (!DiskReadLogicalSectors(DriveNumber, 16, 1, Sector))
- {
- FileSystemError("Failed to read the PVD.");
- return FALSE;
- }
-
- return (Sector[0] == 1 &&
- Sector[1] == 'C' &&
- Sector[2] == 'D' &&
- Sector[3] == '0' &&
- Sector[4] == '0' &&
- Sector[5] == '1');
-}
-
-
BOOL IsoOpenVolume(U32 DriveNumber)
{
PPVD Pvd = (PPVD)DISKREADBUFFER;
} ISO_FILE_INFO, * PISO_FILE_INFO;
-BOOL IsIsoFs(U32 DriveNumber);
BOOL IsoOpenVolume(U32 DriveNumber);
FILE* IsoOpenFile(PUCHAR FileName);
BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
/* just some stuff */
-#define VERSION "FreeLoader v1.8.6"
+#define VERSION "FreeLoader v1.8.7"
#define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>"
#define AUTHOR_EMAIL "<brianp@sginet.com>"
#define BY_AUTHOR "by Brian Palmer"
//
#define FREELOADER_MAJOR_VERSION 1
#define FREELOADER_MINOR_VERSION 8
-#define FREELOADER_PATCH_VERSION 6
+#define FREELOADER_PATCH_VERSION 7
PUCHAR GetFreeLoaderVersionString(VOID);