mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
Better LBA support
Correctly determines FAT type based on cluster count instead of partition id svn path=/trunk/; revision=2528
This commit is contained in:
parent
c5c65dd160
commit
5db0abce79
56 changed files with 248 additions and 157 deletions
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
2
freeldr/freeldr/cache/Makefile
vendored
2
freeldr/freeldr/cache/Makefile
vendored
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
2
freeldr/freeldr/cache/blocklist.c
vendored
2
freeldr/freeldr/cache/blocklist.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
2
freeldr/freeldr/cache/cache.c
vendored
2
freeldr/freeldr/cache/cache.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
2
freeldr/freeldr/cache/cm.h
vendored
2
freeldr/freeldr/cache/cm.h
vendored
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
@ -22,8 +22,8 @@
|
|||
|
||||
|
||||
/* just some stuff */
|
||||
#define VERSION "FreeLoader v0.8"
|
||||
#define COPYRIGHT "Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>"
|
||||
#define VERSION "FreeLoader v0.9"
|
||||
#define COPYRIGHT "Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>"
|
||||
|
||||
#define ROSLDR_MAJOR_VERSION 0
|
||||
#define ROSLDR_MINOR_VERSION 8
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
@ -91,20 +91,8 @@ BOOL IsEndOfFile(PFILE FileHandle);
|
|||
|
||||
#define EOF -1
|
||||
|
||||
#define ATTR_NORMAL 0x00
|
||||
#define ATTR_READONLY 0x01
|
||||
#define ATTR_HIDDEN 0x02
|
||||
#define ATTR_SYSTEM 0x04
|
||||
#define ATTR_VOLUMENAME 0x08
|
||||
#define ATTR_DIRECTORY 0x10
|
||||
#define ATTR_ARCHIVE 0x20
|
||||
|
||||
#define FS_FAT 1
|
||||
#define FS_NTFS 2
|
||||
#define FS_EXT2 3
|
||||
|
||||
#define FAT12 1
|
||||
#define FAT16 2
|
||||
#define FAT32 3
|
||||
|
||||
#endif // #defined __FS_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
@ -41,9 +41,13 @@ ULONG FatType = 0; // FAT12, FAT16, or FAT32
|
|||
ULONG FatDriveNumber = 0;
|
||||
|
||||
|
||||
BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartHead, ULONG VolumeStartTrack, ULONG VolumeStartSector, ULONG FatFileSystemType)
|
||||
BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||
{
|
||||
FatType = FatFileSystemType;
|
||||
ULONG PhysicalTrack;
|
||||
ULONG PhysicalHead;
|
||||
ULONG PhysicalSector;
|
||||
|
||||
// Store the drive number
|
||||
FatDriveNumber = DriveNumber;
|
||||
|
||||
//
|
||||
|
@ -72,14 +76,32 @@ BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartHead, ULONG VolumeStartTr
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Now try to read the boot sector
|
||||
// If this fails then abort
|
||||
//
|
||||
if (!BiosInt13Read(DriveNumber, VolumeStartHead, VolumeStartTrack, VolumeStartSector, 1, FatVolumeBootSector))
|
||||
if (BiosInt13ExtensionsSupported(DriveNumber))
|
||||
{
|
||||
return FALSE;
|
||||
if (!BiosInt13ReadExtended(DriveNumber, VolumeStartSector, 1, FatVolumeBootSector))
|
||||
{
|
||||
FileSystemError("Disk read error.");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate the physical disk offsets
|
||||
PhysicalSector = 1 + (VolumeStartSector % get_sectors(DriveNumber));
|
||||
PhysicalHead = (VolumeStartSector / get_sectors(DriveNumber)) % get_heads(DriveNumber);
|
||||
PhysicalTrack = (VolumeStartSector / get_sectors(DriveNumber)) / get_heads(DriveNumber);
|
||||
|
||||
if (!BiosInt13Read(DriveNumber, PhysicalHead, PhysicalTrack, PhysicalSector, 1, FatVolumeBootSector))
|
||||
{
|
||||
FileSystemError("Disk read error.");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the FAT type
|
||||
FatType = FatDetermineFatType(FatVolumeBootSector);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
|
@ -238,6 +260,38 @@ BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartHead, ULONG VolumeStartTr
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector)
|
||||
{
|
||||
ULONG RootDirSectors;
|
||||
ULONG DataSectorCount;
|
||||
ULONG SectorsPerFat;
|
||||
ULONG TotalSectors;
|
||||
ULONG CountOfClusters;
|
||||
PFAT32_BOOTSECTOR Fat32BootSector = (PFAT32_BOOTSECTOR)FatBootSector;
|
||||
|
||||
RootDirSectors = ((FatBootSector->RootDirEntries * 32) + (FatBootSector->BytesPerSector - 1)) / FatBootSector->BytesPerSector;
|
||||
SectorsPerFat = FatBootSector->SectorsPerFat ? FatBootSector->SectorsPerFat : Fat32BootSector->SectorsPerFatBig;
|
||||
TotalSectors = FatBootSector->TotalSectors ? FatBootSector->TotalSectors : FatBootSector->TotalSectorsBig;
|
||||
DataSectorCount = TotalSectors - (FatBootSector->ReservedSectors + (FatBootSector->NumberOfFats * SectorsPerFat) + RootDirSectors);
|
||||
CountOfClusters = DataSectorCount / FatBootSector->SectorsPerCluster;
|
||||
|
||||
if (CountOfClusters < 4085)
|
||||
{
|
||||
/* Volume is FAT12 */
|
||||
return FAT12;
|
||||
}
|
||||
else if (CountOfClusters < 65525)
|
||||
{
|
||||
/* Volume is FAT16 */
|
||||
return FAT16;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Volume is FAT32 */
|
||||
return FAT32;
|
||||
}
|
||||
}
|
||||
|
||||
PVOID FatBufferDirectory(UINT32 DirectoryStartCluster, PUINT32 EntryCountPointer, BOOL RootDirectory)
|
||||
{
|
||||
UINT32 RootDirectoryStartSector;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
@ -126,7 +126,8 @@ typedef struct
|
|||
|
||||
|
||||
|
||||
BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartHead, ULONG VolumeStartTrack, ULONG VolumeStartSector, ULONG FatFileSystemType);
|
||||
BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector);
|
||||
ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector);
|
||||
PVOID FatBufferDirectory(UINT32 DirectoryStartCluster, PUINT32 EntryCountPointer, BOOL RootDirectory);
|
||||
BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, UINT32 EntryCount, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
|
||||
BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
|
||||
|
@ -147,8 +148,6 @@ ULONG FatGetFilePointer(FILE *FileHandle);
|
|||
BOOL FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
|
||||
|
||||
|
||||
#define EOF -1
|
||||
|
||||
#define ATTR_NORMAL 0x00
|
||||
#define ATTR_READONLY 0x01
|
||||
#define ATTR_HIDDEN 0x02
|
||||
|
|
30
freeldr/freeldr/fs/filesys.h
Normal file
30
freeldr/freeldr/fs/filesys.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2002 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 <fs.h>
|
||||
|
||||
#ifndef __FILESYS_H
|
||||
#define __FILESYS_H
|
||||
|
||||
BOOL FsInternalIsDiskPartitioned(ULONG DriveNumber); // Returns TRUE if the disk contains partitions, FALSE if floppy disk
|
||||
BOOL FsInternalGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); // Returns the active partition table entry
|
||||
BOOL FsInternalGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); // Returns the active partition table entry
|
||||
ULONG FsInternalGetPartitionCount(ULONG DriveNumber); // Returns the number of partitions on the disk
|
||||
|
||||
#endif // #defined __FILESYS_H
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <freeldr.h>
|
||||
#include <fs.h>
|
||||
#include "filesys.h"
|
||||
#include "fat.h"
|
||||
#include <disk.h>
|
||||
#include <rtl.h>
|
||||
|
@ -31,10 +32,7 @@
|
|||
// DATA
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GEOMETRY DriveGeometry;
|
||||
ULONG VolumeHiddenSectors;
|
||||
ULONG CurrentlyOpenDriveNumber;
|
||||
ULONG FileSystemType = 0; // Type of filesystem on boot device, set by OpenDiskDrive()
|
||||
ULONG FileSystemType = 0; // Type of filesystem on boot device, set by OpenDiskDrive()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
|
@ -73,27 +71,19 @@ VOID FileSystemError(PUCHAR ErrorString)
|
|||
*/
|
||||
BOOL OpenDiskDrive(ULONG DriveNumber, ULONG PartitionNumber)
|
||||
{
|
||||
ULONG BootablePartitionCount = 0;
|
||||
ULONG BootPartition = 0;
|
||||
ULONG PartitionStartHead;
|
||||
ULONG PartitionStartSector;
|
||||
ULONG PartitionStartCylinder;
|
||||
MASTER_BOOT_RECORD DriveMasterBootRecord;
|
||||
MASTER_BOOT_RECORD DriveMasterBootRecord;
|
||||
PARTITION_TABLE_ENTRY PartitionTableEntry;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "OpenDiskDrive() DriveNumber: 0x%x PartitionNumber: 0x%x\n", DriveNumber, PartitionNumber));
|
||||
|
||||
CurrentlyOpenDriveNumber = DriveNumber;
|
||||
|
||||
//
|
||||
// Check and see if it is a floppy drive
|
||||
// If so then just assume FAT12 file system type
|
||||
//
|
||||
if (DriveNumber < 0x80)
|
||||
if (FsInternalIsDiskPartitioned(DriveNumber) == FALSE)
|
||||
{
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Drive is a floppy diskette drive. Assuming FAT12 file system.\n"));
|
||||
|
||||
FileSystemType = FS_FAT;
|
||||
return FatOpenVolume(DriveNumber, 0, 0, 1, FAT12);
|
||||
return FatOpenVolume(DriveNumber, 0);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -130,98 +120,48 @@ BOOL OpenDiskDrive(ULONG DriveNumber, ULONG PartitionNumber)
|
|||
#endif // defined DEBUG
|
||||
|
||||
|
||||
//
|
||||
// Check the partition table magic value
|
||||
//
|
||||
if (DriveMasterBootRecord.MasterBootRecordMagic != 0xaa55)
|
||||
{
|
||||
FileSystemError("Invalid partition table magic (0xaa55)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Get the requested partition entry
|
||||
if (PartitionNumber == 0)
|
||||
{
|
||||
//
|
||||
// Count the bootable partitions
|
||||
//
|
||||
if (DriveMasterBootRecord.PartitionTable[0].BootIndicator == 0x80)
|
||||
// Partition requested was zero which means the boot partition
|
||||
if (FsInternalGetActivePartitionEntry(DriveNumber, &PartitionTableEntry) == FALSE)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
BootPartition = 1;
|
||||
}
|
||||
if (DriveMasterBootRecord.PartitionTable[1].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
BootPartition = 2;
|
||||
}
|
||||
if (DriveMasterBootRecord.PartitionTable[2].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
BootPartition = 3;
|
||||
}
|
||||
if (DriveMasterBootRecord.PartitionTable[3].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
BootPartition = 4;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure there was only one bootable partition
|
||||
//
|
||||
if (BootablePartitionCount != 1)
|
||||
{
|
||||
FileSystemError("Too many bootable partitions or none found.");
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get requested partition
|
||||
if (FsInternalGetPartitionEntry(DriveNumber, PartitionNumber, &PartitionTableEntry) == FALSE)
|
||||
{
|
||||
//
|
||||
// We found the boot partition, so set the partition number
|
||||
//
|
||||
PartitionNumber = BootPartition;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Right now the partition number is one-based
|
||||
// and we need zero based
|
||||
//
|
||||
PartitionNumber--;
|
||||
|
||||
//
|
||||
// Check for valid partition
|
||||
//
|
||||
if (DriveMasterBootRecord.PartitionTable[PartitionNumber].SystemIndicator == PARTITION_ENTRY_UNUSED)
|
||||
if (PartitionTableEntry.SystemIndicator == PARTITION_ENTRY_UNUSED)
|
||||
{
|
||||
FileSystemError("Invalid partition.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PartitionStartHead = DriveMasterBootRecord.PartitionTable[PartitionNumber].StartHead;
|
||||
PartitionStartSector = DriveMasterBootRecord.PartitionTable[PartitionNumber].StartSector & 0x3F;
|
||||
PartitionStartCylinder = MAKE_CYLINDER(
|
||||
DriveMasterBootRecord.PartitionTable[PartitionNumber].StartCylinder,
|
||||
DriveMasterBootRecord.PartitionTable[PartitionNumber].StartSector);
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "PartitionStartHead: %d\n", PartitionStartHead));
|
||||
DbgPrint((DPRINT_FILESYSTEM, "PartitionStartSector: %d\n", PartitionStartSector));
|
||||
DbgPrint((DPRINT_FILESYSTEM, "PartitionStartCylinder: %d\n", PartitionStartCylinder));
|
||||
DbgPrint((DPRINT_FILESYSTEM, "PartitionNumber: %d\n", PartitionNumber));
|
||||
|
||||
switch (DriveMasterBootRecord.PartitionTable[PartitionNumber].SystemIndicator)
|
||||
switch (PartitionTableEntry.SystemIndicator)
|
||||
{
|
||||
case PARTITION_FAT_12:
|
||||
FileSystemType = FS_FAT;
|
||||
return FatOpenVolume(DriveNumber, PartitionStartHead, PartitionStartCylinder, PartitionStartSector, FAT12);
|
||||
case PARTITION_FAT_16:
|
||||
case PARTITION_HUGE:
|
||||
case PARTITION_XINT13:
|
||||
FileSystemType = FS_FAT;
|
||||
return FatOpenVolume(DriveNumber, PartitionStartHead, PartitionStartCylinder, PartitionStartSector, FAT16);
|
||||
case PARTITION_FAT32:
|
||||
case PARTITION_FAT32_XINT13:
|
||||
FileSystemType = FS_FAT;
|
||||
return FatOpenVolume(DriveNumber, PartitionStartHead, PartitionStartCylinder, PartitionStartSector, FAT32);
|
||||
return FatOpenVolume(DriveNumber, PartitionTableEntry.StartSector);
|
||||
default:
|
||||
FileSystemType = 0;
|
||||
FileSystemError("Unsupported file system.");
|
||||
|
@ -231,6 +171,87 @@ BOOL OpenDiskDrive(ULONG DriveNumber, ULONG PartitionNumber)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL FsInternalIsDiskPartitioned(ULONG DriveNumber)
|
||||
{
|
||||
// Hard disks use drive numbers >= 0x80
|
||||
// So if the drive number indicates a hard disk
|
||||
// then return TRUE
|
||||
if (DriveNumber >= 0x80)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Drive is a floppy diskette so return FALSE
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL FsInternalGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
{
|
||||
ULONG BootablePartitionCount = 0;
|
||||
MASTER_BOOT_RECORD MasterBootRecord;
|
||||
|
||||
// Read master boot record
|
||||
if (!BiosInt13Read(DriveNumber, 0, 0, 1, 1, &MasterBootRecord))
|
||||
{
|
||||
FileSystemError("Disk read error.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Count the bootable partitions
|
||||
if (MasterBootRecord.PartitionTable[0].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
BootPartition = 0;
|
||||
}
|
||||
if (MasterBootRecord.PartitionTable[1].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
BootPartition = 1;
|
||||
}
|
||||
if (MasterBootRecord.PartitionTable[2].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
BootPartition = 2;
|
||||
}
|
||||
if (MasterBootRecord.PartitionTable[3].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
BootPartition = 3;
|
||||
}
|
||||
|
||||
// Make sure there was only one bootable partition
|
||||
if (BootablePartitionCount != 1)
|
||||
{
|
||||
FileSystemError("Too many bootable partitions or none found.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Copy the partition table entry
|
||||
RtlCopyMemory(PartitionTableEntry, &MasterBootRecord.PartitionTable[BootPartition], sizeof(PARTITION_TABLE_ENTRY));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL FsInternalGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
{
|
||||
MASTER_BOOT_RECORD MasterBootRecord;
|
||||
|
||||
// Read master boot record
|
||||
if (!BiosInt13Read(DriveNumber, 0, 0, 1, 1, &MasterBootRecord))
|
||||
{
|
||||
FileSystemError("Disk read error.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// PartitionNumber is one-based and we need it zero-based
|
||||
PartitionNumber--;
|
||||
|
||||
// Copy the partition table entry
|
||||
RtlCopyMemory(PartitionTableEntry, &MasterBootRecord.PartitionTable[PartitionNumber], sizeof(PARTITION_TABLE_ENTRY));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PFILE OpenFile(PUCHAR FileName)
|
||||
{
|
||||
PFILE FileHandle = NULL;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
*
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
*
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
*
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
# Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000, 2001 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1999, 2000 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright (C) 1998-2002 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
|
||||
|
|
Loading…
Reference in a new issue