* PROJECT: ReactOS text-mode setup
* FILE: base/setup/usetup/bootsup.c
* PURPOSE: Bootloader support functions
- * PROGRAMMER: Eric Kohl
+ * PROGRAMMER:
*/
#include "usetup.h"
} FAT32_BOOTSECTOR, *PFAT32_BOOTSECTOR;
-typedef struct _EXT2_BOOTSECTOR
+typedef struct _BTRFS_BOOTSECTOR
{
- // The EXT2 bootsector is completely user-specific.
- // No FS data is stored there.
- UCHAR Fill[1024];
-} EXT2_BOOTSECTOR, *PEXT2_BOOTSECTOR;
+ UCHAR JumpBoot[3];
+ UCHAR ChunkMapSize;
+ UCHAR BootDrive;
+ ULONGLONG PartitionStartLBA;
+ UCHAR Fill[1521]; // 1536 - 15
+ USHORT BootSectorMagic;
+} BTRFS_BOOTSECTOR, *PBTRFS_BOOTSECTOR;
+C_ASSERT(sizeof(BTRFS_BOOTSECTOR) == 3 * 512);
// TODO: Add more bootsector structures!
static
NTSTATUS
CreateFreeLoaderIniForReactOSAndBootSector(
- PWCHAR IniPath,
- PWCHAR ArcPath,
- PWCHAR Section,
- PWCHAR Description,
- PWCHAR BootDrive,
- PWCHAR BootPartition,
- PWCHAR BootSector)
+ IN PCWSTR IniPath,
+ IN PCWSTR ArcPath,
+ IN PCWSTR Section,
+ IN PCWSTR Description,
+ IN PCWSTR BootDrive,
+ IN PCWSTR BootPartition,
+ IN PCWSTR BootSector)
{
PINICACHE IniCache;
PINICACHESECTION IniSection;
CreateCommonFreeLoaderSections(IniCache);
/* Add the ReactOS entries */
- CreateFreeLoaderReactOSEntries(IniCache, ArcPath);
+ CreateFreeLoaderReactOSEntries(IniCache, (PWCHAR)ArcPath);
/* Get "Operating Systems" section */
IniSection = IniCacheGetSection(IniCache, L"Operating Systems");
IniCacheInsertKey(IniSection,
NULL,
INSERT_LAST,
- Section,
- Description);
+ (PWCHAR)Section,
+ (PWCHAR)Description);
/* Create new section */
- IniSection = IniCacheAppendSection(IniCache, Section);
+ IniSection = IniCacheAppendSection(IniCache, (PWCHAR)Section);
/* BootType=BootSector */
IniCacheInsertKey(IniSection,
NULL,
INSERT_LAST,
L"BootDrive",
- BootDrive);
+ (PWCHAR)BootDrive);
/* BootPartition= */
IniCacheInsertKey(IniSection,
NULL,
INSERT_LAST,
L"BootPartition",
- BootPartition);
+ (PWCHAR)BootPartition);
/* BootSector= */
IniCacheInsertKey(IniSection,
NULL,
INSERT_LAST,
L"BootSectorFile",
- BootSector);
+ (PWCHAR)BootSector);
/* Save the INI file */
- IniCacheSave(IniCache, IniPath);
+ IniCacheSave(IniCache, (PWCHAR)IniPath);
IniCacheDestroy(IniCache);
return STATUS_SUCCESS;
return Status;
}
- /* Copy partition table from old MBR to new */
+ /*
+ * Copy the disk signature, the reserved fields and
+ * the partition table from the old MBR to the new one.
+ */
RtlCopyMemory(&NewBootSector->Signature,
&OrigBootSector->Signature,
sizeof(PARTITION_SECTOR) - offsetof(PARTITION_SECTOR, Signature) /* Length of partition table */);
static
NTSTATUS
-InstallExt2BootCodeToDisk(
+InstallBtrfsBootCodeToDisk(
PWSTR SrcPath,
PWSTR RootPath)
{
HANDLE FileHandle;
LARGE_INTEGER FileOffset;
// PEXT2_BOOTSECTOR OrigBootSector;
- PEXT2_BOOTSECTOR NewBootSector;
+ PBTRFS_BOOTSECTOR NewBootSector;
// USHORT BackupBootSector;
+ PARTITION_INFORMATION_EX PartInfo;
#if 0
/* Allocate buffer for original bootsector */
#endif
/* Allocate buffer for new bootsector */
- NewBootSector = RtlAllocateHeap(ProcessHeap, 0, sizeof(EXT2_BOOTSECTOR));
+ NewBootSector = RtlAllocateHeap(ProcessHeap, 0, sizeof(BTRFS_BOOTSECTOR));
if (NewBootSector == NULL)
{
// RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
NULL,
&IoStatusBlock,
NewBootSector,
- sizeof(EXT2_BOOTSECTOR),
+ sizeof(BTRFS_BOOTSECTOR),
NULL,
NULL);
NtClose(FileHandle);
return Status;
}
+ /* Obtaining partition info and writing it to bootsector */
+ Status = NtDeviceIoControlFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatusBlock,
+ IOCTL_DISK_GET_PARTITION_INFO_EX,
+ NULL,
+ 0,
+ &PartInfo,
+ sizeof(PartInfo));
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("IOCTL_DISK_GET_PARTITION_INFO_EX failed (Status %lx)\n", Status);
+ NtClose(FileHandle);
+ RtlFreeHeap(ProcessHeap, 0, NewBootSector);
+ return Status;
+ }
+
+ NewBootSector->PartitionStartLBA = PartInfo.StartingOffset.QuadPart / SECTORSIZE;
+
/* Write sector 0 */
FileOffset.QuadPart = 0ULL;
Status = NtWriteFile(FileHandle,
NULL,
&IoStatusBlock,
NewBootSector,
- sizeof(EXT2_BOOTSECTOR),
+ sizeof(BTRFS_BOOTSECTOR),
&FileOffset,
NULL);
#if 0
/* FAT or FAT32 partition */
DPRINT("System path: '%wZ'\n", SystemRootPath);
- /* Copy FreeLoader to the system partition */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\freeldr.sys");
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.sys");
+ /* Copy FreeLoader to the system partition, always overwriting the older version */
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
Status = SetupCopyFile(SrcPath, DstPath);
return Status;
}
- /* Prepare for possibly copying 'freeldr.ini' */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.ini");
+ /* Prepare for possibly updating 'freeldr.ini' */
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
- DoesFreeLdrExist = DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini");
+ DoesFreeLdrExist = DoesFileExist(NULL, DstPath);
if (DoesFreeLdrExist)
{
/* Update existing 'freeldr.ini' */
/* Check for NT and other bootloaders */
// FIXME: Check for Vista+ bootloader!
- if (DoesFileExist(SystemRootPath->Buffer, L"ntldr") == TRUE ||
- DoesFileExist(SystemRootPath->Buffer, L"boot.ini") == TRUE)
+ /*** Status = FindNTOSBootLoader(PartitionHandle, NtLdr, &Version); ***/
+ /*** Status = FindNTOSBootLoader(PartitionHandle, BootMgr, &Version); ***/
+ if (DoesFileExist_2(SystemRootPath->Buffer, L"NTLDR") == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"BOOT.INI") == TRUE)
{
- /* Search root directory for 'ntldr' and 'boot.ini' */
+ /* Search root directory for 'NTLDR' and 'BOOT.INI' */
DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
/* Create or update 'freeldr.ini' */
{
/* Create new 'freeldr.ini' */
DPRINT1("Create new 'freeldr.ini'\n");
- // wcscpy(DstPath, SystemRootPath->Buffer);
- // wcscat(DstPath, L"\\freeldr.ini");
+ // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer);
if (!NT_SUCCESS(Status))
}
/* Install new bootcode into a file */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\bootsect.ros");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"bootsect.ros");
if (PartitionType == PARTITION_FAT32 ||
PartitionType == PARTITION_FAT32_XINT13)
{
/* Install FAT32 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat32.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin");
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, DstPath);
Status = InstallFat32BootCodeToFile(SrcPath, DstPath,
else
{
/* Install FAT16 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
Status = InstallFat16BootCodeToFile(SrcPath, DstPath,
}
/* Update 'boot.ini' */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\boot.ini");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"boot.ini");
+ /* Windows' NTLDR loads an external bootsector file when the specified drive
+ letter is C:, otherwise it will interpret it as a boot DOS path specifier. */
DPRINT1("Update 'boot.ini': %S\n", DstPath);
Status = UpdateBootIni(DstPath,
L"C:\\bootsect.ros",
{
/* Non-NT bootloaders: install our own bootloader */
- PWCHAR Section;
- PWCHAR Description;
- PWCHAR BootDrive;
- PWCHAR BootPartition;
- PWCHAR BootSector;
- PWCHAR BootSectorFileName;
+ PCWSTR Section;
+ PCWSTR Description;
+ PCWSTR BootDrive;
+ PCWSTR BootPartition;
+ PCWSTR BootSector;
+
+ /* Search for COMPAQ MS-DOS 1.x (1.11, 1.12, based on MS-DOS 1.25) boot loader */
+ if (DoesFileExist_2(SystemRootPath->Buffer, L"IOSYS.COM") == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"MSDOS.COM") == TRUE)
+ {
+ DPRINT1("Found COMPAQ MS-DOS 1.x (1.11, 1.12) / MS-DOS 1.25 boot loader\n");
- if (DoesFileExist(SystemRootPath->Buffer, L"io.sys") == TRUE ||
- DoesFileExist(SystemRootPath->Buffer, L"msdos.sys") == TRUE)
+ Section = L"DOS";
+ Description = L"\"COMPAQ MS-DOS 1.x / MS-DOS 1.25\"";
+ BootDrive = L"hd0";
+ BootPartition = L"1";
+ BootSector = L"BOOTSECT.DOS";
+ }
+ else
+ /* Search for Microsoft DOS or Windows 9x boot loader */
+ if (DoesFileExist_2(SystemRootPath->Buffer, L"IO.SYS") == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"MSDOS.SYS") == TRUE)
+ // WINBOOT.SYS
{
- /* Search for root directory for 'io.sys' and 'msdos.sys' */
DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
Section = L"DOS";
- Description = L"\"DOS/Windows\"";
+ Description = L"\"MS-DOS/Windows\"";
BootDrive = L"hd0";
BootPartition = L"1";
BootSector = L"BOOTSECT.DOS";
+ }
+ else
+ /* Search for IBM PC-DOS or DR-DOS 5.x boot loader */
+ if (DoesFileExist_2(SystemRootPath->Buffer, L"IBMIO.COM" ) == TRUE || // Some people refer to this file instead of IBMBIO.COM...
+ DoesFileExist_2(SystemRootPath->Buffer, L"IBMBIO.COM") == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"IBMDOS.COM") == TRUE)
+ {
+ DPRINT1("Found IBM PC-DOS or DR-DOS 5.x or IBM OS/2 1.0\n");
- BootSectorFileName = L"\\bootsect.dos";
+ Section = L"DOS";
+ Description = L"\"IBM PC-DOS or DR-DOS 5.x or IBM OS/2 1.0\"";
+ BootDrive = L"hd0";
+ BootPartition = L"1";
+ BootSector = L"BOOTSECT.DOS";
}
else
- if (DoesFileExist(SystemRootPath->Buffer, L"kernel.sys") == TRUE)
+ /* Search for DR-DOS 3.x boot loader */
+ if (DoesFileExist_2(SystemRootPath->Buffer, L"DRBIOS.SYS") == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"DRBDOS.SYS") == TRUE)
+ {
+ DPRINT1("Found DR-DOS 3.x\n");
+
+ Section = L"DOS";
+ Description = L"\"DR-DOS 3.x\"";
+ BootDrive = L"hd0";
+ BootPartition = L"1";
+ BootSector = L"BOOTSECT.DOS";
+ }
+ else
+ /* Search for MS OS/2 1.x */
+ if (DoesFileExist_2(SystemRootPath->Buffer, L"OS2BOOT.COM") == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"OS2BIO.COM" ) == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"OS2DOS.COM" ) == TRUE)
+ {
+ DPRINT1("Found MS OS/2 1.x\n");
+
+ Section = L"DOS";
+ Description = L"\"MS OS/2 1.x\"";
+ BootDrive = L"hd0";
+ BootPartition = L"1";
+ BootSector = L"BOOTSECT.OS2";
+ }
+ else
+ /* Search for MS or IBM OS/2 */
+ if (DoesFileExist_2(SystemRootPath->Buffer, L"OS2BOOT") == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"OS2LDR" ) == TRUE ||
+ DoesFileExist_2(SystemRootPath->Buffer, L"OS2KRNL") == TRUE)
+ {
+ DPRINT1("Found MS/IBM OS/2\n");
+
+ Section = L"DOS";
+ Description = L"\"MS/IBM OS/2\"";
+ BootDrive = L"hd0";
+ BootPartition = L"1";
+ BootSector = L"BOOTSECT.OS2";
+ }
+ else
+ /* Search for FreeDOS boot loader */
+ if (DoesFileExist_2(SystemRootPath->Buffer, L"kernel.sys") == TRUE)
{
- /* Search for root directory for 'kernel.sys' */
DPRINT1("Found FreeDOS boot loader\n");
Section = L"DOS";
BootDrive = L"hd0";
BootPartition = L"1";
BootSector = L"BOOTSECT.DOS";
-
- BootSectorFileName = L"\\bootsect.dos";
}
else
{
BootDrive = L"hd0";
BootPartition = L"1";
BootSector = L"BOOTSECT.OLD";
-
- BootSectorFileName = L"\\bootsect.old";
}
/* Create or update 'freeldr.ini' */
{
/* Create new 'freeldr.ini' */
DPRINT1("Create new 'freeldr.ini'\n");
- // wcscpy(DstPath, SystemRootPath->Buffer);
- // wcscat(DstPath, L"\\freeldr.ini");
+ // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
if (IsThereAValidBootSector(SystemRootPath->Buffer))
{
}
/* Save current bootsector */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, BootSectorFileName);
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSector);
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
Status = SaveBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE);
PartitionType == PARTITION_FAT32_XINT13)
{
/* Install FAT32 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat32.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin");
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
Status = InstallFat32BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
else
{
/* Install FAT16 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
DPRINT1("Install FAT16 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
Status = InstallFat16BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
static
NTSTATUS
-InstallExt2BootcodeToPartition(
+InstallBtrfsBootcodeToPartition(
PUNICODE_STRING SystemRootPath,
PUNICODE_STRING SourceRootPath,
PUNICODE_STRING DestinationArcPath,
WCHAR SrcPath[MAX_PATH];
WCHAR DstPath[MAX_PATH];
- /* EXT2 partition */
+ /* BTRFS partition */
DPRINT("System path: '%wZ'\n", SystemRootPath);
- /* Copy FreeLoader to the system partition */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\freeldr.sys");
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.sys");
+ /* Copy FreeLoader to the system partition, always overwriting the older version */
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
Status = SetupCopyFile(SrcPath, DstPath);
}
/* Prepare for possibly copying 'freeldr.ini' */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.ini");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
- DoesFreeLdrExist = DoesFileExist(SystemRootPath->Buffer, L"freeldr.ini");
+ DoesFreeLdrExist = DoesFileExist(NULL, DstPath);
if (DoesFreeLdrExist)
{
/* Update existing 'freeldr.ini' */
{
/* Create new 'freeldr.ini' */
DPRINT1("Create new 'freeldr.ini'\n");
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.ini");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
/* Certainly SysLinux, GRUB, LILO... or an unknown boot loader */
DPRINT1("*nix or unknown boot loader found\n");
if (IsThereAValidBootSector(SystemRootPath->Buffer))
{
+ PCWSTR BootSector = L"BOOTSECT.OLD";
+
Status = CreateFreeLoaderIniForReactOSAndBootSector(
DstPath, DestinationArcPath->Buffer,
L"Linux", L"\"Linux\"",
- L"hd0", L"1", L"BOOTSECT.OLD");
+ L"hd0", L"1", BootSector);
if (!NT_SUCCESS(Status))
{
DPRINT1("CreateFreeLoaderIniForReactOSAndBootSector() failed (Status %lx)\n", Status);
}
/* Save current bootsector */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\bootsect.old");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSector);
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
- Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR));
+ Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(BTRFS_BOOTSECTOR));
if (!NT_SUCCESS(Status))
{
DPRINT1("SaveBootSector() failed (Status %lx)\n", Status);
/* Install new bootsector on the disk */
// if (PartitionType == PARTITION_EXT2)
{
- /* Install EXT2 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\ext2.bin");
+ /* Install BTRFS bootcode */
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\btrfs.bin");
- DPRINT1("Install EXT2 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
- Status = InstallExt2BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
+ DPRINT1("Install BTRFS bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
+ Status = InstallBtrfsBootCodeToDisk(SrcPath, SystemRootPath->Buffer);
if (!NT_SUCCESS(Status))
{
- DPRINT1("InstallExt2BootCodeToDisk() failed (Status %lx)\n", Status);
+ DPRINT1("InstallBtrfsBootCodeToDisk() failed (Status %lx)\n", Status);
return Status;
}
}
PartitionType);
}
- case PARTITION_EXT2:
+ case PARTITION_LINUX:
{
- return InstallExt2BootcodeToPartition(SystemRootPath,
- SourceRootPath,
- DestinationArcPath,
- PartitionType);
+ return InstallBtrfsBootcodeToPartition(SystemRootPath,
+ SourceRootPath,
+ DestinationArcPath,
+ PartitionType);
}
case PARTITION_IFS:
+ DPRINT1("Partitions of type NTFS or HPFS are not supported yet!\n");
break;
default:
PUNICODE_STRING DestinationArcPath)
{
NTSTATUS Status;
- UNICODE_STRING FloppyDevice = RTL_CONSTANT_STRING(L"\\Device\\Floppy0");
+ PFILE_SYSTEM FatFS;
+ UNICODE_STRING FloppyDevice = RTL_CONSTANT_STRING(L"\\Device\\Floppy0\\");
WCHAR SrcPath[MAX_PATH];
WCHAR DstPath[MAX_PATH];
/* Format the floppy first */
- Status = VfatFormat(&FloppyDevice,
- FMIFS_FLOPPY,
- NULL,
- TRUE,
- 0,
- NULL);
+ FatFS = GetFileSystemByName(L"FAT");
+ if (!FatFS)
+ {
+ DPRINT1("FAT FS non existent on this system?!\n");
+ return STATUS_NOT_SUPPORTED;
+ }
+ Status = FatFS->FormatFunc(&FloppyDevice,
+ FMIFS_FLOPPY,
+ NULL,
+ TRUE,
+ 0,
+ NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("VfatFormat() failed (Status %lx)\n", Status);
}
/* Copy FreeLoader to the boot partition */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\freeldr.sys");
-
- wcscpy(DstPath, L"\\Device\\Floppy0\\freeldr.sys");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice.Buffer, L"freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
Status = SetupCopyFile(SrcPath, DstPath);
}
/* Create new 'freeldr.ini' */
- wcscpy(DstPath, L"\\Device\\Floppy0\\freeldr.ini");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice.Buffer, L"freeldr.ini");
DPRINT("Create new 'freeldr.ini'\n");
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer);
return Status;
}
- /* Install FAT12/16 boosector */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat.bin");
-
- wcscpy(DstPath, L"\\Device\\Floppy0");
+ /* Install FAT12 boosector */
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
+ RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), FloppyDevice.Buffer);
DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath);
if (!NT_SUCCESS(Status))
{
- DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status);
+ DPRINT1("InstallFat12BootCodeToFloppy() failed (Status %lx)\n", Status);
return Status;
}