Skip to content

Fix #1612, preserve source files after copy close errors - #1613

Open
pranav256 wants to merge 1 commit into
nasa:devfrom
pranav256:fix/file-close-errors
Open

pranav256 wants to merge 1 commit into
nasa:devfrom
pranav256:fix/file-close-errors

Conversation

@pranav256

@pranav256 pranav256 commented Nov 20, 2026 •

Copy link
Copy Markdown

Checklist

Describe the contribution

Fixes #1612.

OS_mv() can delete the source after a failed destination close because OS_cp() still reports success. Return native close errors through OS_close() and OS_cp() so the fallback move keeps the source.

The native descriptor and OSAL ID are still released after close, even on error. Passing that error to OS_ObjectIdFinalizeDelete() would restore an ID whose native descriptor is already invalid, so cleanup is finalized separately from the returned status. Copy closes both handles and keeps the first error.

Testing performed

cmake -S . -B build -DENABLE_UNIT_TESTS=true \
  -DOSAL_SYSTEM_BSPTYPE=generic-linux \
  -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=TRUE
cmake --build build -j6
ctest --test-dir build --output-on-failure -j6
  • 85/85 CTest executables pass on the updated branch.
  • New regression checks fail against upstream production code: six shared assertions and one portable assertion. All pass with the fix.
  • Linux probe with real cross-filesystem rename fallback and injected destination-close EIO: baseline returns success and deletes the source; the fix returns OS_ERROR and retains it. Repeated failures exceed the file-handle limit without exhausting IDs. The successful-move control passes.
  • Clang-format 19 and git diff --check pass.
  • Cppcheck 2.19.0 reports no new diagnostics in the changed production files; the same three const-pointer suggestions occur on the baseline.

Fork checks passed: build, tests and coverage, format, and static analysis. Both OSAL CodeQL and cFS build CodeQL completed successfully.

CodeQL ran on a fork-only CI branch that adds the missing caller permission security-events: write; its C sources match this PR. The standalone scan has no added findings compared with upstream.

Upstream checks are waiting for maintainer approval.

Expected behavior changes

No signature change. Native close errors now reach callers; the OSAL handle is released once native close has been attempted. Copy reports a close failure if no earlier error occurred, which prevents move from removing the source.

System(s) tested on

x86-64 PC; Ubuntu 26.04.1 under WSL2; GCC 15.2.0; CMake 3.31.6. Based on OSAL dev at ffc9d26.

Additional context

Flight targets and COSMOS were not tested. This does not add fsync or remove partial destinations. CLA completion is still pending.

Third party code

None.

Contributor Info

Pranav (@pranav256), Personal.

@pranav256
pranav256 marked this pull request as ready for review November 20, 2026 03:56
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.

OS_mv removes source after destination close fails

1 participant