feat(libSceAppContent): report the download data block size #19934

Merged
sarveshgamers merged 1 commit from upstream-pr/19934 into main 2026-11-14 13:28:56 +00:00
sarveshgamers commented 2026-11-14 08:33:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sarveshgamers on 2026-11-14T08:33:08Z.


What

Implement sceAppContentDownloadDataGetBlockSize:

  • Validates the library state, the mount point and the output pointer, copies the guest mount point and rejects anything that is not /download0-/download2 with NOT_MOUNTED.
  • Creates the backing directory as sceAppContentDownloadDataGetAvailableSpaceKb does, then reports the host filesystem's allocation unit for it: the cluster size from GetDiskFreeSpaceW on Windows and st_blksize on POSIX.
  • An unwritable output returns PARAMETER and preserves guest errno; a host volume that reports no usable size throws instead of inventing a value.
  • docs/dev/debt/libSceAppContent.md records that the console's value and whether it follows the volume or a fixed format size are unmeasured.

Tested

Windows 11, MinGW-w64 GCC 16.2.0: built libSceAppContent and guest_appcontent_download_tests and ran ctest -R ^guest_appcontent_download (passed, 5/5). The test checks a null mount and a null output against 0x80D90002 without writing the output, a /download0 block size that is positive and a power of two, and that /temp0 returns 0x80D90004. python tools/check_conventions.py --base upstream/main passed; python tools/pr_overlap.py --names sceAppContentDownloadDataGetBlockSize reported no open PR for this function.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5309276390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19934). Originally posted by [sarveshgamers](https://github.com/sarveshgamers) on 2026-11-14T08:33:08Z. --- ### What Implement `sceAppContentDownloadDataGetBlockSize`: - Validates the library state, the mount point and the output pointer, copies the guest mount point and rejects anything that is not `/download0`-`/download2` with `NOT_MOUNTED`. - Creates the backing directory as `sceAppContentDownloadDataGetAvailableSpaceKb` does, then reports the host filesystem's allocation unit for it: the cluster size from `GetDiskFreeSpaceW` on Windows and `st_blksize` on POSIX. - An unwritable output returns `PARAMETER` and preserves guest errno; a host volume that reports no usable size throws instead of inventing a value. - `docs/dev/debt/libSceAppContent.md` records that the console's value and whether it follows the volume or a fixed format size are unmeasured. ### Tested Windows 11, MinGW-w64 GCC 16.2.0: built `libSceAppContent` and `guest_appcontent_download_tests` and ran `ctest -R ^guest_appcontent_download` (passed, 5/5). The test checks a null mount and a null output against `0x80D90002` without writing the output, a `/download0` block size that is positive and a power of two, and that `/temp0` returns `0x80D90004`. `python tools/check_conventions.py --base upstream/main` passed; `python tools/pr_overlap.py --names sceAppContentDownloadDataGetBlockSize` reported no open PR for this function. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-14 08:51:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T08:51:49Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against eb36d22dd3:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_appcontent_download_tests built cleanly.
  • CTest (guest_appcontent_download_0, guest_appcontent_download_1, guest_appcontent_download_18014398509481983, guest_appcontent_download_18014398509481984, guest_appcontent_download_18446744073709551615):
    1/5 Test #3039: guest_appcontent_download_1 ......................   Passed    0.01 sec
    2/5 Test #3042: guest_appcontent_download_18446744073709551615 ...   Passed    0.01 sec
    3/5 Test #3038: guest_appcontent_download_0 ......................   Passed    0.01 sec
    4/5 Test #3041: guest_appcontent_download_18014398509481984 ......   Passed    0.01 sec
    5/5 Test #3040: guest_appcontent_download_18014398509481983 ......   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 5
    
  • Negative control: with core/libs/prx/libSceAppContent/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/5 Test #3039: guest_appcontent_download_1 ......................Subprocess aborted***Exception:   0.22 sec
    2/5 Test #3042: guest_appcontent_download_18446744073709551615 ...Subprocess aborted***Exception:   0.32 sec
    3/5 Test #3038: guest_appcontent_download_0 ......................Subprocess aborted***Exception:   0.23 sec
    4/5 Test #3041: guest_appcontent_download_18014398509481984 ......Subprocess aborted***Exception:   0.32 sec
    5/5 Test #3040: guest_appcontent_download_18014398509481983 ......Subprocess aborted***Exception:   0.23 sec
    0% tests passed, 5 tests failed out of 5
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libSceAppContent/Export.cpp: Verified argument validation and exact return codes in sceAppContentDownloadDataGetBlockSize; returns SCE_APP_CONTENT_ERROR_NOT_INITIALIZED (0x80D90001) when uninitialized, SCE_APP_CONTENT_ERROR_PARAMETER (0x80D90002) for null/invalid mountPoint or blockSize, and SCE_APP_CONTENT_ERROR_NOT_MOUNTED (0x80D90004) for non-download mount points.
    • core/libs/prx/libSceAppContent/Export.cpp: Verified memory and pointer safety; CopyMountPoint safely copies guest input structures and GuestCopyOut_nid_no_patch validates output destination writability, returning SCE_APP_CONTENT_ERROR_PARAMETER while preserving guest errno.
    • core/libs/prx/libSceAppContent/Export.cpp: Verified platform-specific allocation unit query logic; Windows uses GetDiskFreeSpaceW with root_path() to calculate sectorsPerCluster * bytesPerSector, while POSIX uses stat() on the backing directory to read st_blksize, with both paths throwing std::runtime_error on invalid or non-positive sizes.
    • core/libs/prx/libSceAppContent/Export.cpp: Verified LP64/LLP64 portability and type safety; 64-bit block size arithmetic, upper bound checks against std::numeric_limits<size_t>::max(), and size_t casting are sound across Linux and Windows.
    • core/libs/tests/GuestAppContentDownload.cpp: Verified test coverage exercises null mount validation without clobbering output memory, null output pointer handling, valid /download0 power-of-two block size reporting, and /temp0 rejection with error code 0x80D90004.
    • docs/dev/debt/libSceAppContent.md: Verified AGENTS.md compliance; no unauthorized comments were introduced into C++ code, and technical debt entry accurately documents unmeasured console block size behavior.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5903287918 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19934#pullrequestreview-5903287918). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T08:51:49Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `eb36d22dd3`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_appcontent_download_tests` built cleanly. - **CTest** (`guest_appcontent_download_0`, `guest_appcontent_download_1`, `guest_appcontent_download_18014398509481983`, `guest_appcontent_download_18014398509481984`, `guest_appcontent_download_18446744073709551615`): ``` 1/5 Test #3039: guest_appcontent_download_1 ...................... Passed 0.01 sec 2/5 Test #3042: guest_appcontent_download_18446744073709551615 ... Passed 0.01 sec 3/5 Test #3038: guest_appcontent_download_0 ...................... Passed 0.01 sec 4/5 Test #3041: guest_appcontent_download_18014398509481984 ...... Passed 0.01 sec 5/5 Test #3040: guest_appcontent_download_18014398509481983 ...... Passed 0.01 sec 100% tests passed, 0 tests failed out of 5 ``` - **Negative control**: with `core/libs/prx/libSceAppContent/Export.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/5 Test #3039: guest_appcontent_download_1 ......................Subprocess aborted***Exception: 0.22 sec 2/5 Test #3042: guest_appcontent_download_18446744073709551615 ...Subprocess aborted***Exception: 0.32 sec 3/5 Test #3038: guest_appcontent_download_0 ......................Subprocess aborted***Exception: 0.23 sec 4/5 Test #3041: guest_appcontent_download_18014398509481984 ......Subprocess aborted***Exception: 0.32 sec 5/5 Test #3040: guest_appcontent_download_18014398509481983 ......Subprocess aborted***Exception: 0.23 sec 0% tests passed, 5 tests failed out of 5 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libSceAppContent/Export.cpp: Verified argument validation and exact return codes in sceAppContentDownloadDataGetBlockSize; returns SCE_APP_CONTENT_ERROR_NOT_INITIALIZED (0x80D90001) when uninitialized, SCE_APP_CONTENT_ERROR_PARAMETER (0x80D90002) for null/invalid mountPoint or blockSize, and SCE_APP_CONTENT_ERROR_NOT_MOUNTED (0x80D90004) for non-download mount points. - core/libs/prx/libSceAppContent/Export.cpp: Verified memory and pointer safety; CopyMountPoint safely copies guest input structures and GuestCopyOut_nid_no_patch validates output destination writability, returning SCE_APP_CONTENT_ERROR_PARAMETER while preserving guest errno. - core/libs/prx/libSceAppContent/Export.cpp: Verified platform-specific allocation unit query logic; Windows uses GetDiskFreeSpaceW with root_path() to calculate sectorsPerCluster * bytesPerSector, while POSIX uses stat() on the backing directory to read st_blksize, with both paths throwing std::runtime_error on invalid or non-positive sizes. - core/libs/prx/libSceAppContent/Export.cpp: Verified LP64/LLP64 portability and type safety; 64-bit block size arithmetic, upper bound checks against std::numeric_limits<size_t>::max(), and size_t casting are sound across Linux and Windows. - core/libs/tests/GuestAppContentDownload.cpp: Verified test coverage exercises null mount validation without clobbering output memory, null output pointer handling, valid /download0 power-of-two block size reporting, and /temp0 rejection with error code 0x80D90004. - docs/dev/debt/libSceAppContent.md: Verified AGENTS.md compliance; no unauthorized comments were introduced into C++ code, and technical debt entry accurately documents unmeasured console block size behavior. - Note: the AI-assisted checkbox can stay. Looks Good To Me
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!19934
No description provided.