Skip to content

B1-1: Add mount / unmount / version subcommands to CLI #134

Closed

Description

@scttfrdmn

Context

configs/systemd/[email protected] calls objectfs mount --config ... --foreground and objectfs version in its ExecStartPre and ExecStart lines. Neither of these works today — cmd/objectfs/main.go only accepts two positional arguments (<URI> <mountpoint>) with no subcommand routing. The systemd unit is broken on every installed system.

What to implement

Restructure cmd/objectfs/main.go with stdlib subcommand dispatch (no new framework). Check os.Args[1] and route:

mount subcommand:

  • Flags: --config string, --foreground bool, --mount-point string, --log-level string, --cache-size string, --max-concurrency int
  • Positional: <URI> and <mountpoint> (or --mount-point flag)
  • When --foreground is absent, daemonize (fork and re-exec self with --foreground)

unmount subcommand:

  • Accepts a single mountpoint argument
  • Calls fusermount3 -u <mountpoint> or equivalent

version subcommand:

  • Prints objectfs version <VERSION> and exits 0
  • Used in systemd ExecStartPre

Backward compatibility:

  • If os.Args[1] starts with s3://, treat as legacy form and route to mount path — no config file required, use defaults

Acceptance criteria

  • objectfs mount s3://bucket /mnt/point works
  • objectfs mount --config /etc/objectfs/foo.yaml --foreground s3://bucket /mnt/point works
  • objectfs unmount /mnt/point works
  • objectfs version prints version and exits 0
  • objectfs s3://bucket /mnt/point still works (backward compat)
  • objectfs --help shows all subcommands

Sequencing

Must land before B1-2 (systemd fix depends on mount subcommand) and B1-3 (fstab helper execs objectfs mount).

Activity

  1. added
    type: bug
    priority: critical
    area: core
    on Apr 7, 2026
  2. added
    effort: medium
    on Aug 3, 2026
  3. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Landed in e8750eb on v0.11.0-cli-subcommands.

    objectfs mount, objectfs unmount (also spelled umount), version, help, dispatched on args[0] with stdlib flag and no new dependency. The legacy form is preserved rather than deprecated: a first argument carrying a URI scheme or a leading dash routes to mount, so every pre-v0.11.0 invocation still works, while a bare word that is not a command is a usage error naming itself — objectfs moutn s3://b /mnt does not become an attempt to mount a bucket called moutn.

    Three things the issue did not anticipate:

    Each subcommand needs its own FlagSet. flag.CommandLine cannot parse a flag that appears after a positional argument, so a single package-level flag set could not have accepted objectfs mount --config x s3://b /mnt at all. Related: Go's flag stops at the first non-flag argument, so objectfs mount s3://b /mnt --foreground previously left --foreground as a third positional and silently did not apply it. It is now reported.

    main() had to shrink for any of this to be testable. It called log.Fatalf, which calls os.Exit, which takes the test binary with it — that is why .coverage-floors recorded this package as untestable. It is now three lines around run(args, stdout, stderr) int, and cmd/objectfs has a coverage floor for the first time at 77%. What remains uncovered is the mount lifecycle, which needs /dev/fuse.

    New flags: --mount-point, so a mount point can come from a flag rather than a positional (which is what makes the systemd template in #135 possible), and --foreground, which names what already happens — ObjectFS does not fork — accepted because init systems pass it and refusing it would break invocations that are correct about the behaviour.

    Also in this commit: internal/awsname, so bucket names and storage URIs have one validator instead of a check at each call site. It is deliberately narrower than S3's CreateBucket rules, verified against real S3 in us-west-2: HeadBucket on MyBucket returns 404 and on my_bucket returns 403 — well-formed names for buckets this account cannot see — while b and ab return 400. Uppercase and underscore names were creatable in us-east-1 until 2018 and still exist, so applying the creation rules would refuse to mount a bucket S3 will serve.

    Documentation is gated rather than transcribed: internal/config/docs_symbols_test.go now scrapes both the flag set and the subcommand set from main.go — flags by regexp, subcommands by go/parser finding the switch whose tag is args[0] — and checks every objectfs command line in every markdown file against them. objectfs mount is approved and objectfs status is still rejected without anyone maintaining a list.

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: coreeffort: mediumpriority: criticaltype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions