Extras for enabling ext2 in reactos.
Modified: branches/ext2/reactos/Makefile
Modified: branches/ext2/reactos/boot/freeldr/freeldr/reactos/setupldr.c
Modified: branches/ext2/reactos/subsys/system/usetup/bootsup.c

Modified: branches/ext2/reactos/Makefile
--- branches/ext2/reactos/Makefile	2005-01-20 01:19:52 UTC (rev 13149)
+++ branches/ext2/reactos/Makefile	2005-01-20 02:09:33 UTC (rev 13150)
@@ -39,7 +39,7 @@
 
 # Filesystem libraries
 # vfatlib
-LIB_FSLIB = vfatlib
+LIB_FSLIB = vfatlib ext2lib
 
 # Static libraries
 LIB_STATIC = string rosrtl epsapi uuid libwine zlib rtl tgetopt pseh adns dxguid strmiids
@@ -84,7 +84,7 @@
 
 # Kernel mode file system drivers
 # cdfs ext2 fs_rec ms np vfat
-FS_DRIVERS = cdfs fs_rec ms np vfat mup ntfs
+FS_DRIVERS = cdfs fs_rec ms np vfat ext2 mup ntfs
 
 # Kernel mode networking drivers
 # afd ndis npf tcpip tdi wshtcpip

Modified: branches/ext2/reactos/boot/freeldr/freeldr/reactos/setupldr.c
--- branches/ext2/reactos/boot/freeldr/freeldr/reactos/setupldr.c	2005-01-20 01:19:52 UTC (rev 13149)
+++ branches/ext2/reactos/boot/freeldr/freeldr/reactos/setupldr.c	2005-01-20 02:09:33 UTC (rev 13150)
@@ -556,6 +556,9 @@
   if (!LoadDriver(SourcePath, "vfatfs.sys"))
     return;
 
+  /* Load ext2.sys (could be loaded by the setup prog!) */
+  if (!LoadDriver(SourcePath, "ext2.sys"))
+    return;
 
   /* Load keyboard driver */
   if (!LoadDriver(SourcePath, "keyboard.sys"))

Modified: branches/ext2/reactos/subsys/system/usetup/bootsup.c
--- branches/ext2/reactos/subsys/system/usetup/bootsup.c	2005-01-20 01:19:52 UTC (rev 13149)
+++ branches/ext2/reactos/subsys/system/usetup/bootsup.c	2005-01-20 02:09:33 UTC (rev 13150)
@@ -1541,7 +1541,6 @@
   return(Status);
 }
 
-
 NTSTATUS
 InstallExt2BootCodeToDisk(PWSTR SrcPath,
 			   PWSTR RootPath)
@@ -1751,215 +1750,6 @@
 }
 
 
-NTSTATUS
-InstallExt2BootCodeToDisk(PWSTR SrcPath,
-			   PWSTR RootPath)
-{
-  OBJECT_ATTRIBUTES ObjectAttributes;
-  IO_STATUS_BLOCK IoStatusBlock;
-  UNICODE_STRING Name;
-  HANDLE FileHandle;
-  NTSTATUS Status;
-  PUCHAR OrigBootSector;
-  PUCHAR NewBootSector;
-  LARGE_INTEGER FileOffset;
-  USHORT BackupBootSector;
-
-  /* Allocate buffer for original bootsector */
-  OrigBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
-					   0,
-					   SECTORSIZE);
-  if (OrigBootSector == NULL)
-    return(STATUS_INSUFFICIENT_RESOURCES);
-
-  /* Read current boot sector into buffer */
-  RtlInitUnicodeString(&Name,
-		       RootPath);
-
-  InitializeObjectAttributes(&ObjectAttributes,
-			     &Name,
-			     OBJ_CASE_INSENSITIVE,
-			     NULL,
-			     NULL);
-
-  Status = NtOpenFile(&FileHandle,
-		      FILE_READ_ACCESS,
-		      &ObjectAttributes,
-		      &IoStatusBlock,
-		      0,
-		      FILE_SYNCHRONOUS_IO_NONALERT);
-  if (!NT_SUCCESS(Status))
-  {
-    RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
-    return(Status);
-  }
-
-  Status = NtReadFile(FileHandle,
-		      NULL,
-		      NULL,
-		      NULL,
-		      &IoStatusBlock,
-		      OrigBootSector,
-		      SECTORSIZE,
-		      NULL,
-		      NULL);
-  NtClose(FileHandle);
-  if (!NT_SUCCESS(Status))
-  {
-    RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
-    return(Status);
-  }
-
-
-  /* Allocate buffer for new bootsector (2 sectors) */
-  NewBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
-					  0,
-					  2 * SECTORSIZE);
-  if (NewBootSector == NULL)
-  {
-    RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
-    return(STATUS_INSUFFICIENT_RESOURCES);
-  }
-
-  /* Read new bootsector from SrcPath */
-  RtlInitUnicodeString(&Name,
-		       SrcPath);
-
-  InitializeObjectAttributes(&ObjectAttributes,
-			     &Name,
-			     OBJ_CASE_INSENSITIVE,
-			     NULL,
-			     NULL);
-
-  Status = NtOpenFile(&FileHandle,
-		      FILE_READ_ACCESS,
-		      &ObjectAttributes,
-		      &IoStatusBlock,
-		      0,
-		      FILE_SYNCHRONOUS_IO_NONALERT);
-  if (!NT_SUCCESS(Status))
-  {
-    RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
-    RtlFreeHeap(ProcessHeap, 0, NewBootSector);
-    return(Status);
-  }
-
-  Status = NtReadFile(FileHandle,
-		      NULL,
-		      NULL,
-		      NULL,
-		      &IoStatusBlock,
-		      NewBootSector,
-		      2 * SECTORSIZE,
-		      NULL,
-		      NULL);
-  NtClose(FileHandle);
-  if (!NT_SUCCESS(Status))
-  {
-    RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
-    RtlFreeHeap(ProcessHeap, 0, NewBootSector);
-    return(Status);
-  }
-
-  /* Adjust bootsector (copy a part of the FAT32 BPB) */
-  memcpy((NewBootSector + 3),
-	 (OrigBootSector + 3),
-	 87); /* FAT32 BPB length */
-
-  /* Get the location of the backup boot sector */
-  BackupBootSector = (OrigBootSector[0x33] << 8) + OrigBootSector[0x32];
-
-  /* Free the original boot sector */
-  RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
-
-  /* Write the first sector of the new bootcode to DstPath */
-  RtlInitUnicodeString(&Name,
-		       RootPath);
-
-  InitializeObjectAttributes(&ObjectAttributes,
-			     &Name,
-			     0,
-			     NULL,
-			     NULL);
-
-  Status = NtOpenFile(&FileHandle,
-		      FILE_WRITE_ACCESS | FILE_WRITE_ATTRIBUTES,
-		      &ObjectAttributes,
-		      &IoStatusBlock,
-		      0,
-		      FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY);
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT1("NtOpenFile() failed (Status %lx)\n", Status);
-    RtlFreeHeap(ProcessHeap, 0, NewBootSector);
-    return(Status);
-  }
-
-  /* Write sector 0 */
-  FileOffset.QuadPart = 0ULL;
-  Status = NtWriteFile(FileHandle,
-		       NULL,
-		       NULL,
-		       NULL,
-		       &IoStatusBlock,
-		       NewBootSector,
-		       SECTORSIZE,
-		       &FileOffset,
-		       NULL);
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT1("NtWriteFile() failed (Status %lx)\n", Status);
-    NtClose(FileHandle);
-    RtlFreeHeap(ProcessHeap, 0, NewBootSector);
-    return(Status);
-  }
-
-  /* Write backup boot sector */
-  if ((BackupBootSector != 0x0000) && (BackupBootSector != 0xFFFF))
-  {
-    FileOffset.QuadPart = (ULONGLONG)((ULONG)BackupBootSector * SECTORSIZE);
-    Status = NtWriteFile(FileHandle,
-			 NULL,
-			 NULL,
-			 NULL,
-			 &IoStatusBlock,
-			 NewBootSector,
-			 SECTORSIZE,
-			 &FileOffset,
-			 NULL);
-    if (!NT_SUCCESS(Status))
-    {
-      DPRINT1("NtWriteFile() failed (Status %lx)\n", Status);
-      NtClose(FileHandle);
-      RtlFreeHeap(ProcessHeap, 0, NewBootSector);
-      return(Status);
-    }
-  }
-
-  /* Write sector 14 */
-  FileOffset.QuadPart = (ULONGLONG)(14 * SECTORSIZE);
-  Status = NtWriteFile(FileHandle,
-		       NULL,
-		       NULL,
-		       NULL,
-		       &IoStatusBlock,
-		       (NewBootSector + SECTORSIZE),
-		       SECTORSIZE,
-		       &FileOffset,
-		       NULL);
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT1("NtWriteFile() failed (Status %lx)\n", Status);
-  }
-  NtClose(FileHandle);
-
-  /* Free the new boot sector */
-  RtlFreeHeap(ProcessHeap, 0, NewBootSector);
-
-  return(Status);
-}
-
-
 static NTSTATUS
 UnprotectBootIni(PWSTR FileName,
 		 PULONG Attributes)