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.

Closes #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.

RED -> GREEN

RED, before the helper/fix existed:

# github.com/PlakarKorp/plakar/subcommands/mount [github.com/PlakarKorp/plakar/subcommands/mount.test]
subcommands/mount/mount_parse_test.go:56:16: undefined: snapshotSubFS
FAIL github.com/PlakarKorp/plakar/subcommands/mount [build failed]

GREEN, after implementing snapshotSubFS with root-path handling:

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

Revert proof, 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 again after restoring the fix:

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

Coverage added

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.

[Bug]: mount: unable to mount a snapshot to a specific path

1 participant