Skip to content

test(drvfs): add O_APPEND ftruncate coverage, skip on virtiofs - #41032

Merged
Ben Hillis (benhillis) merged 1 commit into
masterfrom
benhillis/drvfs-virtiofs-ftruncate-test
Jul 8, 2026
Merged

test(drvfs): add O_APPEND ftruncate coverage, skip on virtiofs#41032
Ben Hillis (benhillis) merged 1 commit into
masterfrom
benhillis/drvfs-virtiofs-ftruncate-test

Conversation

@benhillis

Copy link
Copy Markdown
Member

Summary

Adds an ftruncate-on-O_APPEND regression check to the drvfs Basic unit test. This scenario (open(O_APPEND | O_WRONLY) → write → ftruncate) was previously uncovered, and it currently fails on virtiofs with EACCES, breaking real-world workloads (see #40987).

Root cause is in the Windows lxutil file server (wsldevicehost): opening with O_APPEND strips FILE_WRITE_DATA from the NT access mask to enforce append-only writes, but the truncate path is issued on that same handle, so SetEndOfFile is denied. plan9 is unaffected because it doesn't map append semantics to a reduced NT access mask.

Changes

  • test/linux/unit_tests/drvfs.c — new ftruncate-on-O_APPEND coverage in DrvFsTestBasic. It runs on plan9 and is skipped on virtiofs (gated on g_LxtFsInfo.FsType == LxtFsTypeVirtioFs) with a LxtLogInfo note, since the backend fix hasn't shipped yet.
  • packages.config — TODO above Microsoft.WSL.DeviceHost to bump the package to a build containing the virtiofs fix and then remove the virtiofs skip.

Validation

Built Debug and ran locally:

Test Transport Result
WSL2VirtioFs::DrvFs virtiofs Passed (ftruncate check skipped, logs issue reference)
WSL2Plan9::DrvFs plan9 Passed (ftruncate check runs)

Without the skip, WSL2VirtioFs::DrvFs fails with ftruncate(Fd, 0) failed: errno 13 (Permission denied), confirming the test reproduces the bug. clang-format clean.

Once an updated Microsoft.WSL.DeviceHost with the fix is consumed, the virtiofs skip should be removed so the check runs on both transports.

Adds an ftruncate-on-O_APPEND check to the drvfs Basic test. It runs on
plan9 (passes) and is skipped on virtiofs, which currently fails with
EACCES due to a wsldevicehost bug (#40987): the Windows
lxutil file server strips FILE_WRITE_DATA for O_APPEND, so SetEndOfFile
is denied. A TODO in packages.config tracks removing the skip once an
updated Microsoft.WSL.DeviceHost package ships the fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 18:14
@benhillis
Ben Hillis (benhillis) requested a review from a team as a code owner July 8, 2026 18:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens drvfs Linux unit test coverage by adding a regression check for ftruncate() behavior on a file descriptor opened with O_APPEND, while temporarily skipping the check on virtiofs where the underlying backend bug is still present.

Changes:

  • Extend DrvFsTestBasic to validate that ftruncate() succeeds on an O_APPEND | O_WRONLY descriptor (and that the resulting file size matches expectations).
  • Skip the new check on virtiofs (with an informational log) to avoid known failures until the backend fix ships.
  • Add a TODO note in packages.config to bump Microsoft.WSL.DeviceHost and remove the virtiofs skip once the fix is available.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/linux/unit_tests/drvfs.c Adds O_APPEND + ftruncate regression coverage in DrvFsTestBasic, with a virtiofs skip gate and log message.
packages.config Documents the dependency bump TODO needed to remove the virtiofs skip once the fix is consumed.

@benhillis
Ben Hillis (benhillis) merged commit 45b8f8e into master Jul 8, 2026
12 checks passed
@benhillis
Ben Hillis (benhillis) deleted the benhillis/drvfs-virtiofs-ftruncate-test branch July 8, 2026 20:19
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.

3 participants