Skip to content

fix(mount): handle snapshot root path#2261

Open
ousamabenyounes wants to merge 1 commit into
PlakarKorp:mainfrom
ousamabenyounes:fix/issue-2086-mount-to
Open

fix(mount): handle snapshot root path#2261
ousamabenyounes wants to merge 1 commit into
PlakarKorp:mainfrom
ousamabenyounes:fix/issue-2086-mount-to

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Jul 10, 2026

Copy link
Copy Markdown

What

Fix plakar mount -to <path> <snapshotID> when the selected snapshot path resolves to the snapshot root. The mount path preparation now keeps the full snapshot filesystem for / instead of calling fs.Sub with an empty path.

Related to #2086

Why

A root snapshot selection can produce / from locate.OpenSnapshotByPath; trimming that to an empty subpath makes fs.Sub return sub : invalid argument before the mount can proceed.

Original issue repro status

I re-ran the exact issue steps on unmodified origin/main in Docker/Linux. The original symptom was not reproduced in this environment: the command got past the fs.Sub path and failed later at FUSE mount setup.

snapshot=7adcc28f
/tmp/plakar: mount: fusermount: exit status 1
2026/07/16 16:05:09 mount helper error: fusermount: mount failed: Permission denied

Full repro log: /tmp/see-real-bug_PlakarKorp-plakar_2086_rerun.log.

So this PR should be treated as a targeted root-path regression fix, not as a fully confirmed reproduction of #2086 on Linux. The issue reporter reproduced on macOS; I do not have a macOS/FUSE environment here to confirm the original plakar: sub : invalid argument symptom end-to-end.

Regression proof (RED -> GREEN)

The regression test exercises the failing root-path branch directly.

RED, after temporarily removing the / branch from snapshotSubFS:

--- FAIL: TestSnapshotSubFSRootPathUsesSnapshotRoot (0.00s)
    mount_parse_test.go:57:
        Error: Received unexpected error:
               sub : invalid argument
FAIL
FAIL github.com/PlakarKorp/plakar/subcommands/mount 0.016s

GREEN after restoring the fix:

ok github.com/PlakarKorp/plakar/subcommands/mount 0.438s

Coverage added

  • Added a root-path unit test for the mount snapshot filesystem helper.
  • The test fails when the root-path branch is reverted, proving it covers the root-path regression.

Test plan

  • docker run --rm -v "$PWD":/src -v /tmp/plakar-go-cache:/go/pkg/mod -v /tmp/plakar-go-build:/root/.cache/go-build -w /src golang:1.25 go test ./subcommands/mount -run TestSnapshotSubFSRootPathUsesSnapshotRoot -count=1
  • docker run --rm -v "$PWD":/src -v /tmp/plakar-go-cache:/go/pkg/mod -v /tmp/plakar-go-build:/root/.cache/go-build -w /src golang:1.25 go test ./subcommands/mount -count=1
  • docker run --rm -v "$PWD":/src -v /tmp/plakar-go-cache:/go/pkg/mod -v /tmp/plakar-go-build:/root/.cache/go-build -w /src golang:1.25 sh -c 'go build -v ./... && go test ./...'

Full validation result:

exit:0
go build -v ./...: pass
go test ./...: pass

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.

1 participant