Author: dquintana
Date: Wed Sep  9 00:49:47 2015
New Revision: 69135

URL: http://svn.reactos.org/svn/reactos?rev=69135&view=rev
Log:
[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.

Modified:
    trunk/reactos/boot/CMakeLists.txt
    trunk/reactos/tools/fatten/fatfs/ff.c
    trunk/reactos/tools/fatten/fatten.c

Modified: trunk/reactos/boot/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/CMakeLists.txt?rev=69135&r1=69134&r2=69135&view=diff
==============================================================================
--- trunk/reactos/boot/CMakeLists.txt   [iso-8859-1] (original)
+++ trunk/reactos/boot/CMakeLists.txt   [iso-8859-1] Wed Sep  9 00:49:47 2015
@@ -16,8 +16,8 @@
 endif()
 
 add_custom_target(efisys
-    COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 
-mkdir EFI -mkdir EFI/BOOT -add $<TARGET_FILE:bootmgfw> 
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 $<TARGET_FILE:bootmgfw> EFI/BOOT/boot${EFI_PLATFORM_ID}.EFI
+    DEPENDS native-fatten bootmgfw fat
     VERBATIM)
 
 ##bootcd

Modified: trunk/reactos/tools/fatten/fatfs/ff.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatfs/ff.c?rev=69135&r1=69134&r2=69135&view=diff
==============================================================================
--- trunk/reactos/tools/fatten/fatfs/ff.c       [iso-8859-1] (original)
+++ trunk/reactos/tools/fatten/fatfs/ff.c       [iso-8859-1] Wed Sep  9 
00:49:47 2015
@@ -4058,7 +4058,7 @@
 /*-----------------------------------------------------------------------*/
 #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 (

Modified: trunk/reactos/tools/fatten/fatten.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatten.c?rev=69135&r1=69134&r2=69135&view=diff
==============================================================================
--- trunk/reactos/tools/fatten/fatten.c [iso-8859-1] (original)
+++ trunk/reactos/tools/fatten/fatten.c [iso-8859-1] Wed Sep  9 00:49:47 2015
@@ -193,10 +193,58 @@
         }
         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)
         {


Reply via email to