Skip to content

Make chmod +x stick, so builds can run inside the mount - #54

Open
franzjeger wants to merge 1 commit into
mainfrom
claude/exec-bit
Open

franzjeger wants to merge 1 commit into
mainfrom
claude/exec-bit

Conversation

@franzjeger

Copy link
Copy Markdown
Owner

The mount reported a hardcoded 644 for every file and accepted chmod without doing anything.

let perm: u16 = if item.is_folder { 0o755 } else { 0o644 };
// setattr: accept time/mode/uid/gid changes silently — we do not persist
// them to OneDrive, but returning ENOSYS breaks tools like `touch`.

So marking a script executable silently did nothing: chmod reported success, ls -l kept saying 644, and running it failed with exit 126 — the shell's "found it, cannot execute it". Cargo writes a build script, marks it executable and runs it, so no Rust build could work inside the mount, and nothing in the error said why.

Same shape as the fsync bug in #50: an operation reporting success for something it did not do. That is worse than refusing, because there is nothing to debug.

What changed

setattr honours the executable bit. Only that bit — OneDrive stores no POSIX mode, and read/write are governed by the mount options rather than by us. But exec is the one that decides whether a program runs.

It is kept in two places, each for a different failure mode:

  • On the cached copy. getattr already stats it for size and mtime, so reporting the mode costs nothing on a path a file manager hits constantly.
  • In the database. A later download replaces the cached copy and the mode would go with it. It is re-applied after a download, and carried across the ID change when an upload adopts the real OneDrive ID.

The exec_bits table is deliberately separate from items: the bit is local-only, it must survive the row being replaced during adoption, and delta sync must never touch it.

Testing

A mount round trip doing exactly what cargo does — write a script, chmod +x, stat it, run it, check its output.

Confirmed to fail before the fix with left: 0, right: 73 — 73 is 0o111, the bit that was not there.

15 consecutive runs of the full mount suite pass. cargo fmt, cargo clippy --workspace --all-targets -- -D warnings, and ONEDRIVE_REQUIRE_FUSE=1 cargo test --workspace pass.


Generated by Claude Code

The mount reported a hardcoded 644 for every file and accepted chmod
without doing anything. Marking a script executable silently did nothing:
chmod reported success, ls -l kept saying 644, and running it failed with
exit 126 — "found it, cannot execute it". Cargo writes a build script,
marks it executable and runs it, so no Rust build could work inside the
mount, and nothing in the error said why.

setattr now honours the executable bit. Only that bit: OneDrive stores no
POSIX mode, and read/write are governed by the mount options rather than
by us — but exec is the one that decides whether a program runs.

It is kept in two places, each for a different failure. On the cached
copy, which getattr already stats for size and mtime, so reporting it
costs nothing on a path a file manager hits constantly. And in the
database, because a later download replaces the cached copy and the mode
would go with it; it is re-applied after a download and carried across
the ID change when an upload adopts the real OneDrive ID.

The table is deliberately separate from `items`: the bit is local-only,
it must survive the row being replaced during adoption, and delta sync
must never touch it.

Tests: a mount round trip doing what cargo does — write a script, chmod
+x, stat it, run it, check its output. Confirmed to fail before the fix
with "left: 0, right: 73", which is the missing 0o111.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XfrYQTqjBaP4gDF77Ux1wZ
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.

2 participants