https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c5a9f22d4eab1b36a240e…
commit c5a9f22d4eab1b36a240ef306ec927784219d111
Author: Adam Słaboń <asaillen(a)protonmail.com>
AuthorDate: Sat Mar 2 23:56:51 2024 +0100
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Oct 7 11:16:03 2024 +0200
[FORMAT] Use QueryDeviceInformation for retrieving the volume size before formatting it
QueryDeviceInformation returns more reliable volume length and works
with unformatted volumes. It will return volume length only on ROS and Vista+ however,
so also keep the GetFreeDiskSpaceExW as a fallback for XP/2003.
---
base/system/format/format.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/base/system/format/format.c b/base/system/format/format.c
index 0d7e642c598..c8805af5e69 100644
--- a/base/system/format/format.c
+++ b/base/system/format/format.c
@@ -360,6 +360,7 @@ static VOID Usage(LPWSTR ProgramName)
int wmain(int argc, WCHAR *argv[])
{
int badArg;
+ DEVICE_INFORMATION DeviceInformation = {0};
FMIFS_MEDIA_FLAG media = FMIFS_HARDDISK;
DWORD driveType;
WCHAR fileSystem[1024];
@@ -479,7 +480,19 @@ int wmain(int argc, WCHAR *argv[])
return -1;
}
- if (!GetDiskFreeSpaceExW(RootDirectory,
+ if (QueryDeviceInformation(RootDirectory,
+ &DeviceInformation,
+ sizeof(DeviceInformation)))
+ {
+ totalNumberOfBytes.QuadPart = DeviceInformation.SectorSize *
+ DeviceInformation.SectorCount.QuadPart;
+ }
+
+ /* QueryDeviceInformation returns more accurate volume length and works with
+ * unformatted volumes, however it will NOT return volume length on XP/2003.
+ * Fallback to GetFreeDiskSpaceExW if we did not get any volume length. */
+ if (totalNumberOfBytes.QuadPart == 0 &&
+ !GetDiskFreeSpaceExW(RootDirectory,
&freeBytesAvailableToCaller,
&totalNumberOfBytes,
&totalNumberOfFreeBytes))
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=764881a94b4129538d62f…
commit 764881a94b4129538d62fda2c99cfcd1ad518ce5
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Oct 3 11:16:20 2024 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Oct 3 12:32:45 2024 +0200
[FREELDR] Remove the "setupldr" build target (#7419)
The setupldr and freeldr binaries are the same since commit 948e82af1
(r65832), because both their functionality have been shared.
---
boot/freeldr/bootsect/isoboot.S | 50 ++++++++++++++++++++---------------------
boot/freeldr/freeldr/pcat.cmake | 16 +------------
2 files changed, 26 insertions(+), 40 deletions(-)
diff --git a/boot/freeldr/bootsect/isoboot.S b/boot/freeldr/bootsect/isoboot.S
index da52eba9bfe..845bc34059b 100644
--- a/boot/freeldr/bootsect/isoboot.S
+++ b/boot/freeldr/bootsect/isoboot.S
@@ -115,28 +115,28 @@ relocated:
call pollchar_and_empty
// If we're booting in hybrid mode and our boot drive is the first HDD (drive 80h),
- // we have no other option than booting into SETUPLDR.
+ // we have no other option than booting into FREELDR.
cmp word ptr ds:[GetlinsecPtr], offset getlinsec_ebios
jne .read_mbr
cmp byte ptr ds:[DriveNumber], HEX(80)
- je .boot_setupldr
+ je .boot_freeldr
.read_mbr:
// Read the first sector (MBR) from the first hard disk (drive 80h) to 7C00h.
// If we then decide to boot from HDD, we already have it at the right place.
- // In case of an error (indicated by the Carry Flag), just boot SETUPLDR from our ReactOS medium.
+ // In case of an error (indicated by the Carry Flag), just boot FREELDR from our ReactOS medium.
mov ax, HEX(0201)
mov dx, HEX(0080)
mov cx, HEX(0001)
mov bx, HEX(7C00)
call int13
- jc .boot_setupldr
+ jc .boot_freeldr
// Verify the signature of the read MBR.
- // If it's invalid, there is probably no OS installed and we just boot SETUPLDR from our ReactOS medium.
+ // If it's invalid, there is probably no OS installed and we just boot FREELDR from our ReactOS medium.
mov ax, word ptr ds:[HEX(7C00)+510]
cmp ax, HEX(AA55)
- jne .boot_setupldr
+ jne .boot_freeldr
#ifdef WAIT_FOR_KEY
// We could either boot from the ReactOS medium or from hard disk. Let the user decide!
@@ -155,9 +155,9 @@ relocated:
add eax, 19
.poll_again:
- // Check for a keypress, boot SETUPLDR from our ReactOS medium if a key was pressed.
+ // Check for a keypress, boot FREELDR from our ReactOS medium if a key was pressed.
call pollchar_and_empty
- jnz .boot_setupldr
+ jnz .boot_freeldr
// Check if another second has passed (in BIOS Timer ticks).
mov ebx, ds:[BIOS_timer]
@@ -185,7 +185,7 @@ relocated:
ljmp16 0, HEX(7C00)
-.boot_setupldr:
+.boot_freeldr:
#ifdef WAIT_FOR_KEY
call crlf_early
call crlf_early
@@ -266,26 +266,26 @@ found_drive:
xchg eax, dword ptr ds:[si+file_sector]
mov dword ptr ds:[CurrentDir+dir_lba], eax
- // Look for the "SETUPLDR.SYS" file.
- mov di, offset setupldr_sys
+ // Look for the "FREELDR.SYS" file.
+ mov di, offset freeldr_sys
call searchdir
- jnz .setupldr_found
+ jnz .freeldr_found
- // The SETUPLDR file was not found, so bail out with an error message.
- mov si, offset no_setupldr_msg
+ // The FREELDR file was not found, so bail out with an error message.
+ mov si, offset no_freeldr_msg
call writemsg
jmp kaboom
-.setupldr_found:
+.freeldr_found:
// Calculate the rounded up number of 2K sectors that need to be read.
mov ecx, eax
shr ecx, SECTOR_SHIFT
test eax, HEX(7FF)
- jz .load_setupldr
+ jz .load_freeldr
inc ecx
-.load_setupldr:
- // Load the entire SETUPLDR.SYS (parameter CX = FFFFh) to its designated base address FREELDR_BASE.
+.load_freeldr:
+ // Load the entire FREELDR.SYS (parameter CX = FFFFh) to its designated base address FREELDR_BASE.
// Using a high segment address with offset 0 instead of segment 0 with offset FREELDR_BASE apparently increases compatibility with some BIOSes.
mov bx, FREELDR_BASE / 16
mov es, bx
@@ -293,15 +293,15 @@ found_drive:
mov cx, HEX(FFFF)
call getfssec
- // Pass two parameters to SETUPLDR:
+ // Pass two parameters to FREELDR:
// DL = BIOS Drive Number
// DH = Boot Partition (0 for HDD booting in hybrid mode, FFh for CD booting)
movzx dx, byte ptr ds:[DriveNumber]
cmp word ptr ds:[GetlinsecPtr], offset getlinsec_ebios
- je .jump_to_setupldr
+ je .jump_to_freeldr
mov dh, HEX(FF)
-.jump_to_setupldr:
+.jump_to_freeldr:
// Transfer execution to the bootloader.
ljmp16 0, FREELDR_BASE
@@ -1086,10 +1086,10 @@ loader_dir:
.ascii "/LOADER", NUL
no_dir_msg:
.ascii "LOADER dir not found.", CR, LF, NUL
-setupldr_sys:
- .ascii "SETUPLDR.SYS", NUL
-no_setupldr_msg:
- .ascii "SETUPLDR.SYS not found.", CR, LF, NUL
+freeldr_sys:
+ .ascii "FREELDR.SYS", NUL
+no_freeldr_msg:
+ .ascii "FREELDR.SYS not found.", CR, LF, NUL
.align 4
BufSafe:
diff --git a/boot/freeldr/freeldr/pcat.cmake b/boot/freeldr/freeldr/pcat.cmake
index 0a9c96cdee5..ac18b0e00ec 100644
--- a/boot/freeldr/freeldr/pcat.cmake
+++ b/boot/freeldr/freeldr/pcat.cmake
@@ -250,18 +250,4 @@ else()
add_custom_target(freeldr ALL DEPENDS freeldr_pe)
endif()
-# Rename freeldr on livecd to setupldr.sys because isoboot.bin looks for setupldr.sys
-add_cd_file(TARGET freeldr FILE ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys DESTINATION loader NO_CAB FOR bootcd regtest)
-add_cd_file(TARGET freeldr FILE ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys DESTINATION loader NO_CAB NOT_IN_HYBRIDCD FOR livecd hybridcd NAME_ON_CD setupldr.sys)
-
-if(NOT ARCH STREQUAL "arm")
- concatenate_files(
- ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys
- ${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
- ${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:freeldr_pe>)
- add_custom_target(setupldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys)
-else()
- add_custom_target(setupldr ALL DEPENDS freeldr_pe)
-endif()
-
-add_cd_file(TARGET setupldr FILE ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys DESTINATION loader NO_CAB FOR bootcd regtest)
+add_cd_file(TARGET freeldr FILE ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys DESTINATION loader NO_CAB NOT_IN_HYBRIDCD FOR bootcd livecd hybridcd regtest)
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3b928898ef09ece59ba63…
commit 3b928898ef09ece59ba63ece3efdd4467195d74a
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed Oct 2 19:24:42 2024 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Oct 3 11:47:31 2024 +0200
[FREELDR] Simplify some control branches in loops (#7417)
Collapse some tests; remove redundant `continue;`
Pointed out by Serge Gautherie.
---
boot/freeldr/freeldr/arch/i386/pc/pcdisk.c | 42 ++++++++------------------
boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c | 21 ++++---------
boot/freeldr/freeldr/lib/fs/fat.c | 4 +--
3 files changed, 20 insertions(+), 47 deletions(-)
diff --git a/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c b/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
index 1bd498e6730..cf13ed663dc 100644
--- a/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
+++ b/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
@@ -605,22 +605,13 @@ PcDiskReadLogicalSectorsLBA(
Int386(0x13, &RegsIn, &RegsOut);
- /* If it worked return TRUE */
- if (INT386_SUCCESS(RegsOut))
- {
- return TRUE;
- }
- /* If it was a corrected ECC error then the data is still good */
- else if (RegsOut.b.ah == 0x11)
- {
+ /* If it worked, or if it was a corrected ECC error
+ * and the data is still good, return success */
+ if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x11))
return TRUE;
- }
- /* If it failed then do the next retry */
- else
- {
- DiskResetController(DriveNumber);
- continue;
- }
+
+ /* It failed, do the next retry */
+ DiskResetController(DriveNumber);
}
/* If we get here then the read failed */
@@ -715,22 +706,13 @@ PcDiskReadLogicalSectorsCHS(
{
Int386(0x13, &RegsIn, &RegsOut);
- /* If it worked break out */
- if (INT386_SUCCESS(RegsOut))
- {
+ /* If it worked, or if it was a corrected ECC error
+ * and the data is still good, break out */
+ if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x11))
break;
- }
- /* If it was a corrected ECC error then the data is still good */
- else if (RegsOut.b.ah == 0x11)
- {
- break;
- }
- /* If it failed then do the next retry */
- else
- {
- DiskResetController(DriveNumber);
- continue;
- }
+
+ /* It failed, do the next retry */
+ DiskResetController(DriveNumber);
}
/* If we retried 3 times then fail */
diff --git a/boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c b/boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c
index 9eef9d45f71..e6f98d136f7 100644
--- a/boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c
+++ b/boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c
@@ -219,22 +219,13 @@ Pc98DiskReadLogicalSectorsLBA(
{
Int386(0x1B, &RegsIn, &RegsOut);
- /* If it worked return TRUE */
- if (INT386_SUCCESS(RegsOut))
- {
- return TRUE;
- }
- /* If it was a corrected ECC error then the data is still good */
- else if (RegsOut.b.ah == 0x08)
- {
+ /* If it worked, or if it was a corrected ECC error
+ * and the data is still good, return success */
+ if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x08))
return TRUE;
- }
- /* If it failed the do the next retry */
- else
- {
- DiskResetController(DiskDrive);
- continue;
- }
+
+ /* It failed, do the next retry */
+ DiskResetController(DiskDrive);
}
}
diff --git a/boot/freeldr/freeldr/lib/fs/fat.c b/boot/freeldr/freeldr/lib/fs/fat.c
index 556f8086430..257f1e43c63 100644
--- a/boot/freeldr/freeldr/lib/fs/fat.c
+++ b/boot/freeldr/freeldr/lib/fs/fat.c
@@ -668,7 +668,8 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory
// See if the file name matches either the short or long name
//
if (((strlen(FileName) == strlen(LfnNameBuffer)) && (_stricmp(FileName, LfnNameBuffer) == 0)) ||
- ((strlen(FileName) == strlen(ShortNameBuffer)) && (_stricmp(FileName, ShortNameBuffer) == 0))) {
+ ((strlen(FileName) == strlen(ShortNameBuffer)) && (_stricmp(FileName, ShortNameBuffer) == 0)))
+ {
//
// We found the entry, now fill in the FAT_FILE_INFO struct
//
@@ -702,7 +703,6 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory
//
RtlZeroMemory(ShortNameBuffer, 13 * sizeof(UCHAR));
RtlZeroMemory(LfnNameBuffer, 261 * sizeof(UCHAR));
- continue;
}
return FALSE;