[BUG] Preserve file state on zero-byte positioned writes #5

Closed
opened 2026-09-30 13:51:17 +02:00 by erikinkinen · 0 comments
Owner

Summary

Ramfsd's positioned-write implementation grows a regular file when the requested byte count is zero and the offset lies past EOF. The code zeros the gap and assigns max(old_size, offset + data_len) even when there are no bytes to write. This makes an empty operation change file size and can confuse status/build-tool decisions.

Reproduction

Source-derived input, not an executed reproduction: create a retained regular file containing four bytes in a volatile instance whose per-node byte capacity is at least eight. Call write_at with that original handle, offset8, data_len0 and an empty byte slice. At the revision below, the source fills bytes4..8 with zeros and publishes size8. No tests, builds, images or CI were executed.

Expected and actual behavior

Expected: a zero-byte write returns zero and preserves file size, file contents and timestamp observations, including when its offset exceeds the provisioned data extent. Actual source behavior: a within-capacity offset past EOF extends the file; an offset beyond the fixed extent is refused even though it requires no byte storage. Validate the original retained handle and file kind before the empty-write return; do not acquire any new authority or touch another object.

Environment and identity

  • Component/revision: Ramfsd 5e973fcc, positioned-write source.
  • Image profile, digest and runtime configuration: none executed; source-derived finding.
  • Hardware, architecture, firmware and toolchain: no runtime execution involved.
  • Input/session authority: original live provider-private regular-file handle; no new route or capability.
  • Last known working revision: unknown.

Evidence and prior checks

The published implementation unconditionally computes end from offset plus data_len, clears a gap beyond old_size, copies the zero-length slice, then assigns max(old_size, end). Add independent controls for an in-range offset past EOF, an offset beyond provisioned capacity, unchanged bytes/metadata and stale/directory-handle refusal. Tests are authored but remain unrun under the user's execution override. This is not a runtime pass or an observed CI regression.

Tracking

Resolved in ramfsd d5388880 within the coherent signed metadata dependency closure. Appropriate regression controls are authored and unrun. Source repair and publication are complete; testing and CI execution remain waived, with no executed reproduction or pass claimed.

Repair within source-qualified status and directory iteration, and update the Phase6 master and the existing Ramfsd review. The source repair and coherent dependency revisions are signed and published. Use the bug_report template and bug/phase-6 metadata; deferred test execution does not waive a known code defect.

## Summary Ramfsd's positioned-write implementation grows a regular file when the requested byte count is zero and the offset lies past EOF. The code zeros the gap and assigns max(old_size, offset + data_len) even when there are no bytes to write. This makes an empty operation change file size and can confuse status/build-tool decisions. ## Reproduction Source-derived input, not an executed reproduction: create a retained regular file containing four bytes in a volatile instance whose per-node byte capacity is at least eight. Call write_at with that original handle, offset8, data_len0 and an empty byte slice. At the revision below, the source fills bytes4..8 with zeros and publishes size8. No tests, builds, images or CI were executed. ## Expected and actual behavior Expected: a zero-byte write returns zero and preserves file size, file contents and timestamp observations, including when its offset exceeds the provisioned data extent. Actual source behavior: a within-capacity offset past EOF extends the file; an offset beyond the fixed extent is refused even though it requires no byte storage. Validate the original retained handle and file kind before the empty-write return; do not acquire any new authority or touch another object. ## Environment and identity - Component/revision: [Ramfsd `5e973fcc`](https://git.erikinkinen.fi/erix/ramfsd/commit/5e973fccb37ad8b754d20c85e6f66c18b491d757), [positioned-write source](https://git.erikinkinen.fi/erix/ramfsd/src/commit/5e973fccb37ad8b754d20c85e6f66c18b491d757/src/instances.rs). - Image profile, digest and runtime configuration: none executed; source-derived finding. - Hardware, architecture, firmware and toolchain: no runtime execution involved. - Input/session authority: original live provider-private regular-file handle; no new route or capability. - Last known working revision: unknown. ## Evidence and prior checks The published implementation unconditionally computes end from offset plus data_len, clears a gap beyond old_size, copies the zero-length slice, then assigns max(old_size, end). Add independent controls for an in-range offset past EOF, an offset beyond provisioned capacity, unchanged bytes/metadata and stale/directory-handle refusal. Tests are authored but remain unrun under the user's execution override. This is not a runtime pass or an observed CI regression. ## Tracking Resolved in [ramfsd `d5388880`](https://git.erikinkinen.fi/erix/ramfsd/commit/d5388880d0347090e42bbf8a921247eb5b2a9014) within the coherent signed metadata dependency closure. Appropriate regression controls are authored and unrun. Source repair and publication are complete; testing and CI execution remain waived, with no executed reproduction or pass claimed. Repair within [source-qualified status and directory iteration](https://git.erikinkinen.fi/erix/posixd/issues/25), and update the [Phase6 master](https://git.erikinkinen.fi/erix/integration/issues/65) and the existing Ramfsd review. The source repair and coherent dependency revisions are signed and published. Use the bug_report template and bug/phase-6 metadata; deferred test execution does not waive a known code defect.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:35:11 +01:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set

Reference
erix/ramfsd#5
No description provided.