From: David Quintana Date: Wed, 9 Sep 2015 00:49:47 +0000 (+0000) Subject: [FATTEN] X-Git-Tag: ReactOS-0.4.0~912 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=d2e60268e51f7a3f205802e63783b94e07effc2c [FATTEN] * Change the number of FAT copies stored by the formatting code to 2. * Implement /BOOT command, to apply a boot sector to the image (FAT12/16 only, for now). * Make use of the command above to finally get the generated efisys.bin loading in 7zip as a floppy. svn path=/trunk/; revision=69135 --- diff --git a/reactos/boot/CMakeLists.txt b/reactos/boot/CMakeLists.txt index aa03a9958a5..607d0f1b997 100644 --- a/reactos/boot/CMakeLists.txt +++ b/reactos/boot/CMakeLists.txt @@ -16,8 +16,8 @@ else() endif() add_custom_target(efisys - COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 -mkdir EFI -mkdir EFI/BOOT -add $ EFI/BOOT/boot${EFI_PLATFORM_ID}.EFI - DEPENDS native-fatten bootmgfw + COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 -boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin -mkdir EFI -mkdir EFI/BOOT -add $ EFI/BOOT/boot${EFI_PLATFORM_ID}.EFI + DEPENDS native-fatten bootmgfw fat VERBATIM) ##bootcd diff --git a/reactos/tools/fatten/fatfs/ff.c b/reactos/tools/fatten/fatfs/ff.c index 88eb953c547..e97d328fcc1 100644 --- a/reactos/tools/fatten/fatfs/ff.c +++ b/reactos/tools/fatten/fatfs/ff.c @@ -4058,7 +4058,7 @@ FRESULT f_forward ( /*-----------------------------------------------------------------------*/ #define N_ROOTDIR12 224 /* Number of root directory entries for FAT12/16 */ #define N_ROOTDIR16 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ +#define N_FATS 2 /* Number of FATs (1 or 2) */ FRESULT f_mkfs ( diff --git a/reactos/tools/fatten/fatten.c b/reactos/tools/fatten/fatten.c index 90ed6251da5..a94886058ab 100644 --- a/reactos/tools/fatten/fatten.c +++ b/reactos/tools/fatten/fatten.c @@ -193,10 +193,58 @@ int main(int oargc, char* oargv[]) } else if (strcmp(parg, "boot") == 0) { + FILE* fe; + BYTE* temp = buff + 1024; + NEED_PARAMS(1, 1); // Arg 1: boot file - printf("Not Implemented."); + + fe = fopen(argv[0], "rb"); + + if (!fe) + { + printf("Error: unable to open external file '%s' for reading.", argv[0]); + ret = 1; + goto exit; + } + + if(!fread(buff, 512, 1, fe)) + { + printf("Error: unable to read boot sector from file '%s'.", argv[0]); + ret = 1; + goto exit; + } + + NEED_MOUNT(); + + if(disk_read(0, temp, 0, 1)) + { + printf("Error: unable to read existing boot sector from image."); + ret = 1; + goto exit; + } + + if (g_Filesystem.fs_type == FS_FAT32) + { + printf("TODO: writing boot sectors for FAT32 images not yet supported."); + ret = 1; + goto exit; + } + else + { + // Quick&dirty hardcoded length. + memcpy(buff + 2, temp + 2, 0x3E - 0x02); + } + + if (disk_write(0, buff, 0, 1)) + { + printf("Error: unable to write new boot sector to image."); + ret = 1; + goto exit; + } + + fclose(fe); } else if (strcmp(parg, "add") == 0) {