[SETUPLIB] Code re-organization in bootsup.c and fsutil.c.

- Move the actual VBR bootcode installation helpers into fsutil.c
  (they depend on the selected filesystem).

- Introduce InstallBootCodeToDisk() and InstallBootCodeToFile()
  and bootcode.c helpers, in order to replace the several functions
  that were duplicating the same code.
This commit is contained in:
Hermès Bélusca-Maïto 2020-10-17 20:29:47 +02:00
parent b51b8ee2d5
commit 593bcce999
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
7 changed files with 784 additions and 1312 deletions

View file

@ -3,7 +3,7 @@
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Filesystem support functions
* COPYRIGHT: Copyright 2003-2019 Casper S. Hornstrup (chorns@users.sourceforge.net)
* Copyright 2017-2019 Hermes Belusca-Maito
* Copyright 2017-2020 Hermes Belusca-Maito
*/
#pragma once
@ -61,6 +61,42 @@ FormatFileSystem(
IN PFMIFSCALLBACK Callback);
//
// Bootsector routines
//
#define FAT_BOOTSECTOR_SIZE (1 * SECTORSIZE)
#define FAT32_BOOTSECTOR_SIZE (1 * SECTORSIZE) // Counts only the primary sector.
#define BTRFS_BOOTSECTOR_SIZE (3 * SECTORSIZE)
typedef NTSTATUS
(/*NTAPI*/ *PFS_INSTALL_BOOTCODE)(
IN PCWSTR SrcPath, // Bootsector source file (on the installation medium)
IN HANDLE DstPath, // Where to save the bootsector built from the source + partition information
IN HANDLE RootPartition); // Partition holding the (old) bootsector data information
NTSTATUS
InstallFat1216BootCode(
IN PCWSTR SrcPath,
IN HANDLE DstPath,
IN HANDLE RootPartition);
#define InstallFat12BootCode InstallFat1216BootCode
#define InstallFat16BootCode InstallFat1216BootCode
NTSTATUS
InstallFat32BootCode(
IN PCWSTR SrcPath,
IN HANDLE DstPath,
IN HANDLE RootPartition);
NTSTATUS
InstallBtrfsBootCode(
IN PCWSTR SrcPath,
IN HANDLE DstPath,
IN HANDLE RootPartition);
//
// Formatting routines
//