Skip to content

A read-only mount: --read-only for objectfs mount, and ro for the fstab helper #532

Closed

Description

@scttfrdmn

There is no read-only mount in ObjectFS. objectfs mount has no --read-only flag and the mount is
always read-write, so -o ro in /etc/fstab has nothing to translate into.

The mount helper added in #136 therefore refuses ro rather than accepting it, and refuses it even
under -s (mount's "sloppy" flag), because the alternative is worse than an error: an operator whose
fstab says ro would get a writable filesystem, and the first thing they would learn about it is a
write that succeeded. That refusal is a placeholder for this issue, not a position.

What a real implementation needs:

  • A --read-only flag on objectfs mount, plumbed to a config field.
  • internal/fuse failing the write paths with EROFS: Write, Create, Mkdir, Rmdir, Unlink,
    Rename, Setattr (the size/mode/time arms), Link, Symlink, Setxattr, Removexattr, and
    Open/OpenDir with a write intent in the flags. EROFS specifically — EACCES would read to the
    caller as a permissions problem on the object, which is a different thing to debug.
  • The kernel told as well, so it can refuse some of those without a round trip: MS_RDONLY in the
    mount options go-fuse passes.
  • internal/vfs refusing to create a dirty range at all, so the guarantee does not depend on every
    FUSE entry point remembering to check. The interesting property is that a read-only mount cannot
    produce a PUT, and the place to assert that is the backend: a differential test in
    internal/difftest running a write-heavy sequence against a read-only mount and asserting the
    substrate endpoint saw zero writes.
  • Then -o ro in the option table, which is a one-line change once the flag exists, and the removal of
    the refusal and its test.

Worth doing for its own sake beyond the fstab case: a read-only mount is how a shared dataset gets
handed to a job that must not modify it, and it is the mount an operator reaches for when they suspect
something is writing to a bucket it should not be.

Activity

  1. added
    type: enhancement
    priority: medium
    area: fuse
    area: cli
    effort: medium
    on Sep 18, 2026
  2. scttfrdmn commented on Sep 19, 2026

    @scttfrdmn
    OwnerAuthor

    Traced the current state before planning this, and it changes the shape of the issue: the enforcement
    layer is already complete. It is just unreachable.

    Layer State
    internal/fuse EROFS gates Complete. filesystem.go:653,696,789,854,944,1330 (Mkdir, Create, Unlink, Rmdir, Open-with-write-intent, Write), rename.go:92, attributes.go:267,423 (Setattr ×2), xattr.go:256,337,414,431 (Set/Removexattr ×2 each)
    FUSE ro option Present. internal/fuse/mount.go:523 appends "ro" to opts.Options when Options.ReadOnly
    MountOptions.ReadOnly → Config.ReadOnly Wired. internal/fuse/platform.go:93
    Anything setting MountOptions.ReadOnly Nothing. internal/adapter/adapter.go:204 is the only production fuse.MountConfig{}; its Options: a.buildMountOptions() (adapter.go:945) sets FSName, Subtype, MaxWrite, Debug, DirectIO, KeepCache, SyncRead — and never ReadOnly
    internal/config No read_only key anywhere. grep -rn 'read_only|ReadOnly' internal/config/*.go configs/*.yaml → empty
    vfs.ErrReadOnly Defined and errno-mapped, never returned. internal/vfs/errors.go:33, mapped to EROFS at internal/fuse/errno.go:58; the only other reference in the tree is errno_test.go:86

    The yaml:"read_only" tag on internal/fuse/mount.go:92 is a red herring — nothing YAML-unmarshals into
    internal/fuse's structs. A config file unmarshals into internal/config.Configuration, which has no
    such key, and config.go:974 uses yaml.UnmarshalStrict, so read_only: in a config would be
    rejected as unknown rather than silently honoured. Either way there is no path to a read-only mount.

    This is the same defect class internal/fuse/platform.go:43 already records in the past tense — "It
    also hardcoded ReadOnly to false, which meant read_only: true mounted a writable filesystem"
    — and the
    class #180 was about: nine MountOptions fields naming real FUSE capabilities and reaching nothing.

    So the EROFS half of the acceptance criteria is done, and what remains is plumbing plus proof:

    1. ReadOnly bool on internal/config's FUSEConfig (config.go:75). Its zero value being the default
      is already pinned by TestFUSEZeroValueIsTheDefault, and false = writable is the right default.
    2. One line in buildMountOptions() — whose doc comment already explains it exists as a method so the
      mapping can be asserted without a mount
      , which is exactly the test this needs.
    3. --read-only on newMountFlagSet (cmd/objectfs/main.go:179) and an arm in
      applyCommandLineOverrides (main.go:610), following the --dry-run / --debug pattern.
    4. The internal/vfs backstop this issue asks for: refuse to create a dirty range at all, returning the
      ErrReadOnly that already exists and has never had a caller. Construction-time field, not a per-call
      argument — the point is that the guarantee does not depend on every entry point remembering.
    5. The zero-writes proof. No new harness capability needed: internal/testaws/recorder.go:710
      already exposes TestServer.Writes(key) []Request (PUT, POST and attribute-storing requests) and
      testaws.go:999 exposes Operations(op) int.
    6. cmd/mount.objectfs/main.go:418 turns ro from kindRefuse into a translation; the note at
      main.go:38 naming this issue goes away, along with the three main_test.go cases asserting the
      refusal (:149, :260, :569).

    Worth stating because of how the missing half hides: step 2's absence passes every presence check. The
    mutation that has to fail is deleting that one line and watching the zero-writes assertion go red.

    Milestoned for v0.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliarea: fuseeffort: mediumpriority: mediumtype: enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions