[UDFS] Fix C bool literals, add typedef aliases, remove legacy x86 asm paths, thread PH_TMP_BUFFER through sector I/O, and add chunked bitmap infrastructure#275
Closed
Copilot wants to merge 43 commits into
Conversation
…tibility Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/02366975-c32a-410d-85df-c6f874a8dd3e Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/02366975-c32a-410d-85df-c6f874a8dd3e Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Apply all pull requests from assorted/reactos
[DDK/scsi] Move nested struct typedefs out of anonymous unions for UDFS C++ compatibility
Apr 16, 2026
…onymous unions Restore _PLAY_CD and _LOG_PARAMETER to have nested struct definitions inside the anonymous union bodies (original ReactOS style), superseded by the C++ to C conversion PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Directories need to be converted to external allocation on first write to allow for preallocation and efficient growth. Only regular files should stay in inline (IN_ICB) mode during writes. Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Removed directory exclusion from inline preservation logic. Small directories (with few entries) can now stay in IN_ICB mode just like small files. When directories grow beyond inline capacity, they are converted to external allocation with optional preallocation. Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Added ExtPrint messages to clearly show: - When data is in IN_ICB vs EXTERNAL mode - When converting from IN_ICB to external allocation This will help diagnose issues with inline data handling. Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
When files or directories with inline (IN_ICB) data are deleted, the actual data content must be zeroed before freeing the FileEntry space. This prevents sensitive data from remaining in freed sectors where it could potentially be recovered. Changes: - Added inline data wiping in UDFUnlinkFile__ before flushing - Zeros the data area at DataLoc.Offset for DataLoc.Length bytes - Marks FE as modified to ensure zeroed data is written to disk - Adds bounds checking to prevent buffer overflow Security impact: Prevents data leakage from deleted inline files. Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Simplify APC check to KeGetCurrentIrql() >= APC_LEVEL Co-Authored-By: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…rites Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…terlocked casts Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Owner
|
@copilot Please undo the spacing changes done to scsi.h. |
Author
Done in 582a2ad — restored the three blank lines between |
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/cde1ab9c-62b1-4e05-a55f-b3e8d4086b54 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/df6882fc-ccf0-439e-8bbd-a2afae6f1229 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/3dcd238c-3d98-44d0-8304-bcccad17e060 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Initialize all uninitialized local variables in the UDFS driver to prevent MSVC debug builds from filling them with 0xCCCCCCCC: - NTSTATUS/NTSTATUS variables initialized to STATUS_SUCCESS - BOOLEAN variables initialized to FALSE - ULONG/pointer variables initialized to 0/NULL Also restore accidentally removed code: - if (!FileInfo) check in UDFIndexDirectory (dirtree.cpp) - PUDF_FILE_INFO curFileInfo declaration in UDFPackDirectory__ (dirtree.cpp) - PAGED_CODE() calls in misc.cpp and volinfo.cpp - Comment in misc.cpp AcquireResource function Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/901376db-4acd-42eb-8122-cce62735117e Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Initialize all uninitialized local variables in the Include/ support files: Sys_spec_lib.cpp, phys_lib.cpp, regtools.cpp, mem_tools.cpp, string_lib.cpp. Covers NTSTATUS, BOOLEAN, ULONG, and pointer variables. Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/a5f32228-fa19-4fba-bf7a-cdde18e904ec Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/d748e799-c061-440b-a45e-8e688426533a Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/24682548-17c3-4e3c-9ca3-9caab028ab87 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Applies changes from PR#25: - Fix large I/O INSUFFICIENT_RESOURCES on XP/2003 by using MmCreateMdl - Remove unnecessary scope block around IrpSp in write path - Fix PFN_LIST_CORRUPT BSOD: use MmProbeAndLockPages - Wrap MmProbeAndLockPages in SEH2 exception handler - Add comments explaining IoWriteAccess/IoReadAccess - Fall back to using Buffer directly when NonPagedPool copy allocation fails - Remove unreachable null check after Buffer - Fix UDFLockUserBuffer to use MmCreateMdl Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
- Rename all .cpp files to .c files - Fix C++ constructs incompatible with C (casts, default parameters, etc.) - Fix MSVC C compilation errors: empty structs, enum types, etc. - Fix MinGW/GCC build errors: remove C++-only flags - Fix static/inline conflicts in mem_tools.h - Fix stale .cpp include references after renaming - Fix mixed SEH macro nesting in UDFGetVolumeBitmap - Fix multiple definition issues for MyAllocInit and other symbols - Fix compiler warnings in filesystem driver - Update CMakeLists.txt to use .c files and proper compile flags Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/ec18699c-68b2-4e23-bf16-4d8148a2f398 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/ec18699c-68b2-4e23-bf16-4d8148a2f398 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…g change Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/c691cff6-3b55-47af-8ee4-aaa053d3ed22 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
… C compilation errors Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/9e8e5bf2-5af6-451c-bde1-f711f94ce023 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/557cb5d7-6328-4797-ab6a-488c4b37bb91 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…__ calls Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/4587d9e7-4011-4d05-a20d-96cf2784808d Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/bbf3edee-7573-4e9c-b905-83d50f5c2955 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/89022acd-c6dd-48b4-bc3e-01a2d273cac0 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/d93e3b32-98fa-4365-9550-d0a7e4e6cd61 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
… __debugbreak() Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/c974a8bc-1af0-4576-a1db-2cba7bd89376 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…WriteSectors Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/da7f3da2-2510-48c8-b4de-ee7c50126380 Co-Authored-By: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
b3d5d3a to
d83aa55
Compare
Owner
|
@copilot Please add the changes done by PR #283. |
…antics Add UDF_CHUNKED_BUF: a lazily-allocated chunk array where each chunk is allocated on first write (NULL chunk = all zeros = all FREE). A pointer tagging scheme (UDF_CHUNKED_PTR_TAG = bit 0) lets PCHAR Vat/FSBM_Bitmap fields distinguish flat vs. chunked allocations via UDFIsChunked(). New infrastructure in udf_info.h: - UDFAllocChunked / UDFFreeChunked for lifecycle management - UDFChunkedGetBytePtr / UDFChunkedGetOrAllocBytePtr for read/write access - UDFChunkedFillMemory, UDFChunkedCopyMemory, UDFChunkedAndNotMemory, UDFChunkedOrMemory, UDFChunkedCompareMemory for bulk operations - UDFVatGetEntry / UDFVatSetEntry for VAT element access - UDFReadExtentIntoChunked / UDFWriteExtentFromChunked for disk I/O - UDFSetBit/UDFClrBit/UDFGetBit dispatch to chunked or flat paths - UDFSetBits/UDFClrBits use UDFChunkedFillMemory for the fast-path byte fill (replaces RtlFillMemory/RtlZeroMemory that would corrupt chunked ptrs) Invert FSBM bit semantics: bit=1=USED, bit=0=FREE (was bit=1=FREE). This matches the null-chunk default (all zeros = all FREE), so chunk allocation is only triggered when marking blocks USED, keeping memory usage minimal for mostly-free large disks. Update all call sites: - struct.h: uint32* Vat -> PCHAR Vat - fscntrl.c: Vat/FSBM_Bitmap/BSBM_Bitmap/FSBM_OldBitmap freed via UDFFreeChunked - alloc.c: UDFGetBitmapLen handles chunked; VAT accesses use UDFVatGetEntry/UDFVatSetEntry; UDFMarkBadSpaceAsUsed uses UDFChunkedOrMemory; UDFGetPartFreeSpace uses UDFChunkedGetByte - mount.c: bitmap allocation/copy/compare/free updated throughout; UDFBuildFreeSpaceBitmap uses UDFAllocChunked - remap.c: VAT access via UDFVatGetEntry - udf_info.c: VAT fill/read/write via UDFVatSetEntry/UDFVatGetEntry - udffs.h: UDFPrint/UDFPrintErr macros moved before udf_info.h include so inline functions in the header can reference them Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Match the PR diff exactly: - Use RtlFillMemory(&(((uint32*)Vcb->Vat)[...]) for bulk fill - Use ((uint32*)Vcb->Vat)[i] for direct array access in sync loop - Use ((uint32*)Vcb->Vat)[CurLba] = NWA in UDFUpdateVAT Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Remove redundant re-assignment of i inside UDFAllocChunked call; use the already-computed value from the preceding line. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Author
|
Done in abace10. Applied all changes from PR #283:
|
Copilot
AI
changed the title
[UDFS] Fix C bool literals, add typedef aliases, remove legacy x86 asm paths, and thread PH_TMP_BUFFER through sector I/O
[UDFS] Fix C bool literals, add typedef aliases, remove legacy x86 asm paths, thread PH_TMP_BUFFER through sector I/O, and add chunked bitmap infrastructure
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes several C compatibility issues in the UDFS driver after its conversion from C++ to C, and applies the cleanup changes from PR #277, PR #281, and PR #283.
Changes Made
true→TRUE(C usesTRUE/FALSEfrom<windef.h>)typedef struct Foo Foo;aliases for all 13 struct types (UDFIdentifier,UDFObjectName,CCB,FCB_NONPAGED,FCB_DATA,FCB_INDEX,FCB,VCB,VOLUME_DEVICE_OBJECT,THREAD_CONTEXT,IRP_CONTEXT,IRP_CONTEXT_LITE,IO_CONTEXT) and replaced C++usingaliases withtypedefforPCCBandPIRP_CONTEXT_LITE; changedVatfield type fromuint32*toPCHARto support chunked access#define UDFBreakPoint() __debugbreak()replacing the#ifdef _X86_/__asm int 3block; replaced the x86-specificUDFTouchasm implementation with a single portable version usingvolatile UCHAR+UNREFERENCED_PARAMETER#ifdef _X86_DbgTouchasm branch; single C implementation kept usingvolatile UCHARand(void)a__asm int 3occurrences with__debugbreak()inMyFreePool__()andMyReallocPool__()MyAppendUnicodeToString_,MyInitUnicodeString, andRtlAppendUnicodeToString; changed loop counter fromUSHORTtoULONG, addedi < (MAXUSHORT / sizeof(WCHAR))overflow guard, and added(USHORT)casts on assignments toStr1->LengthandStr1->MaximumLengthFlagsparameter toUDFReadSectorsandUDFWriteSectors; call sites that use a local temporary buffer now passPH_TMP_BUFFERto skip the unnecessary NonPagedPool copy inUDFPhReadSynchronous/UDFPhWriteSynchronousUDFReadSectors/UDFWriteSectorsto pass the appropriateFlagsvalue (PH_TMP_BUFFERwhere a local buffer is already provided,0otherwise)UDF_CHUNK_SHIFT=17,UDF_CHUNKED_BUFstruct, and inline helpersUDFAllocChunked,UDFFreeChunked,UDFReadExtentIntoChunked,UDFWriteExtentFromChunked,UDFChunkedCopyMemory,UDFChunkedCompareMemory,UDFVatGetEntry,UDFVatSetEntry); updatedUDFGetBit/SetBit/ClrBit/GetFreeBit/SetFreeBitmacros to use chunked-aware accessUDFPrintmacro definition before theudf_info/udf_info.hinclude to resolve ordering dependencyDbgFreePoolwithUDFFreeChunkedforVat,FSBM_Bitmap,BSBM_Bitmap, andFSBM_OldBitmapfields on volume teardownUDFGetBitmapLen,UDFMarkBadSpaceAsUsed,UDFMarkSpaceAsXXX, andUDFGetPartFreeSpaceto use the chunked APIUDFAllocChunked/UDFReadExtentIntoChunked/UDFWriteExtentFromChunked/UDFChunkedCopyMemory/UDFChunkedCompareMemoryto reduce mount-time NonPagedPool pressureUDFVatGetEntryto support chunked VAT storagePCHARtype andUDFVatGetEntry/UDFVatSetEntry/UDFChunkedCopyMemory