mount: check for more requisite mountpoint conditions#5718
Merged
MichaelEischer merged 4 commits intoFeb 19, 2026
Conversation
In order to be able to mount a repository over a mountpoint target directory via FUSE, that target directory needs to be both writeable and executable for the UID performing the mount. Without this patch, `restic mount` only checks for the target pathname's existence, which can lead to a lot of data transfer and/or computation for large repos to be performed before eventually croaking with a fatal "fusermount: failed to chdir to mountpoint: Permission denied" (or similar) error. FUSE does allow for mounting over a target path that refers to a regular (writeable) file, but the result is not accessible via chdir(), so we prevent that as well, and accept only directory inodes as the intended target mountpoint path.
MichaelEischer
requested changes
Feb 18, 2026
MichaelEischer
left a comment
Member
There was a problem hiding this comment.
Please add a small changelog entry, see https://github.com/restic/restic/blob/master/changelog/TEMPLATE for the template.
| // Check the existence of the mount point at the earliest stage to | ||
| // prevent unnecessary computations while opening the repository. | ||
| if _, err := os.Stat(mountpoint); errors.Is(err, os.ErrNotExist) { | ||
| mountpoint_stat, err := os.Stat(mountpoint) |
Member
There was a problem hiding this comment.
Suggested change
| mountpoint_stat, err := os.Stat(mountpoint) | |
| stat, err := os.Stat(mountpoint) |
Or mountpointStat. Go uses camel case.
Contributor
Author
There was a problem hiding this comment.
Ack, I pushed a change to rectify that :)
I hope the changelog entry is satisfactory!
MichaelEischer
approved these changes
Feb 19, 2026
MichaelEischer
left a comment
Member
There was a problem hiding this comment.
LGTM. Thanks! I've slightly tweaked the changelog summary, we reserve change for breaking changes.
Contributor
Author
|
Thanks very much for merging! Apologies for causing the small bit of extra work - I wasn't aware of the special meaning of these words in the changelog context and mistook "change" for the most neutral/innocent of the three options ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR change? What problem does it solve?
Esp. with large repositories,
restic mountmay waste a lot of time and resources on preparing for a fuse mount that ultimately cannot succeed due conditions that are not checked for.In order to be able to mount a repository over a mountpoint target directory via FUSE, that target directory needs to be both writeable and executable for the UID performing the mount, which this patch ensures.
FUSE does allow for mounting over a target path that refers to a regular (writeable) file, but the result is not accessible via chdir(), so we prevent that as well, and accept only directory inodes as the intended target mountpoint path.
Was the change previously discussed in an issue or on the forum?
No.
Checklist
changelog/unreleased/that describes the changes for our users (see template).