Skip to content

Fix UDF trimming for BD-R dumps - #437

Open
whatever-industries wants to merge 2 commits into
superg:mainfrom
whatever-industries:whatever-redumper
Open

Fix UDF trimming for BD-R dumps#437
whatever-industries wants to merge 2 commits into
superg:mainfrom
whatever-industries:whatever-redumper

Conversation

@whatever-industries

@whatever-industries whatever-industries commented Aug 15, 2026

Copy link
Copy Markdown

Summary

  • detect UDF from the validated primary Anchor Volume Descriptor Pointer at LBA 256 even when the volume-recognition sequence is absent or not recognized
  • preserve the reserve Volume Descriptor Sequence extent and include it when calculating the trimmed filesystem size
  • include the trailing AVDP after the larger of the partition end and reserve-VDS end
  • add overflow checks and focused UDF size regression tests

Root cause

The existing trimming path used the partition end plus one sector. On affected BD-R media, the reserve VDS starts at the partition end and extends for another 16 sectors, followed by the trailing AVDP. Trimming at the partition boundary therefore produced a structurally incomplete image.

UDF parsing was also gated on recognizing NSR02 or NSR03 in the volume-recognition sequence. A valid primary AVDP is sufficient to identify and process the UDF layout, so this change restores that fallback.

Impact

Profile-mismatched BD-R media can now be trimmed to the complete recorded UDF filesystem instead of either stopping at the partition boundary or reading the remaining recordable-media capacity.

Validation

  • release build completed successfully on macOS arm64
  • all 362 tests passed, including the new UDF regression cases
  • physical BD-R test with an HL-DT-ST BU40N:
    • READ CAPACITY: 23,729,248 sectors
    • detected UDF size: 23,728,976 sectors
    • SCSI errors: 0
    • EDC errors: 0
    • output size: 48,596,942,848 bytes
    • CRC32: 03fd2843
    • MD5: 5283760b72c644cb56cb21a3df5c6acd
    • SHA-1: 3225512d4f07a14cc08bd3b31aaaee4f42a8ec9a

The physical-disc output matches Redump #93203.

Fixes #398

Summary by CodeRabbit

  • Bug Fixes

    • Improved UDF volume-size detection for discs with reserve and main volume descriptor sequences.
    • Added validation for invalid sector sizes, partition boundaries, and overflowing volume calculations.
    • Improved handling of primary volume descriptor locations and trailing volume descriptors.
  • Tests

    • Added coverage for reserve metadata, partition-end fallback, metadata endpoint selection, and invalid inputs.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 859f0d84-c613-4f62-98f6-694968daaf68

📥 Commits

Reviewing files that changed from the base of the PR and between 1874b39 and 9960777.

📒 Files selected for processing (5)
  • CMakeLists.txt
  • dvd/dvd_dump.ixx
  • filesystem/udf/udf_size.ixx
  • tests/gtest/CMakeLists.txt
  • tests/gtest/test_udf.cc

📝 Walkthrough

Walkthrough

UDF volume-size detection now validates primary AVDPs, tracks reserve VDS metadata, and calculates the final sector count through a new tested module. CMake includes the module and its GoogleTest target.

Changes

UDF volume sizing

Layer / File(s) Summary
UDF size calculation helper
filesystem/udf/udf_size.ixx, tests/gtest/test_udf.cc, CMakeLists.txt, tests/gtest/CMakeLists.txt
Adds udf::get_volume_sectors_count, validates overflow and zero values, calculates metadata endpoints, and adds GoogleTest coverage.
DVD UDF detection integration
dvd/dvd_dump.ixx
Validates primary AVDP locations, queues VDS extents, retains reserve VDS metadata, and uses the calculated sector count.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 99607

The change completes UDF filesystem trimming for affected BD-R images, including required reserve metadata and trailing descriptors; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant DVDDump
  participant FilesystemContext
  participant UDFSize
  DVDDump->>FilesystemContext: validate primary AVDP at current LBA
  DVDDump->>FilesystemContext: retain and queue VDS extents
  DVDDump->>UDFSize: pass partition end and reserve VDS metadata
  UDFSize-->>DVDDump: return optional volume sector count
  DVDDump->>FilesystemContext: record size and clear UDF mode
Loading

Possibly related PRs

Suggested reviewers: superg

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing UDF trimming for BD-R dumps.
Linked Issues check ✅ Passed The changes address issue #398 by improving UDF detection and size calculation for complete BD-R filesystem trimming.
Out of Scope Changes check ✅ Passed All code, build, and test changes support the stated UDF trimming fix and related regression coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@whatever-industries
whatever-industries marked this pull request as ready for review August 15, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BD-R Dumping Error

1 participant