Commit ca37b4d
committed
system/nxpkg: Harden the on-disk store against interrupted writes.
Every file the package manager owns was written in place, so a reset partway
through left a truncated catalog or database behind. Locking used only the
file modification time, which a card whose clock does not follow
CLOCK_REALTIME reports as decades old, so a lock created a moment earlier
looked stale to the next caller.
Write through a temporary file and rename it, and record a per-boot token
and the owner task in each lock so a contender can tell a live owner from
an abandoned one. Reject a zero-byte write rather than looping on it, and
add the path helpers the download and rollback paths need.
Assisted-by: OpenAI Codex:gpt-5.6-sol
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>1 parent 04e8883 commit ca37b4d
1 file changed
Lines changed: 494 additions & 40 deletions
0 commit comments