Conversation
The builtin driver used sftp.NewServer, which serves the whole host file system to the guest. On Linux and macOS hosts, it now uses sftp.NewRequestServer with handlers rooted at LocalPath: reads go through os.Root, and writes open each parent directory with O_NOFOLLOW, so they never follow a symlink. A path outside the root gets EACCES. Windows keeps sftp.NewServer. Setting the mode fails on a symlink, on macOS as on Linux. On Linux kernels without fchmodat2 (< 6.6), it goes through /proc/self/fd of an O_PATH fd, as glibc does, so it needs no read permission. ReadonlyNames makes a path read-only when any of its components matches one of these names, compared case-insensitively and ignoring the code points that HFS+ ignores, as git does. For example, [".git"] keeps the working tree writable while hooks and config stay read-only. Setting ReadonlyNames selects the builtin driver in auto mode, and fails with the OpenSSH driver or on Windows. Setting the times of a read-only name to its current mtime is a no-op that succeeds, because this is how the Lima guest agent triggers IN_ATTRIB for host changes (mountInotify). Addresses lima-vm#6 for Linux and macOS hosts. Assisted-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Sylvain Zimmer <sylvain@sylvainzimmer.com>
ExpectRemove(hostPath) makes the next Remove or Rmdir of hostPath from the guest succeed without touching the host, if it arrives within 5 seconds. It lets the caller relay a deletion done on the host: the guest removes the path in the mount, so the guest kernel emits IN_DELETE, while the host keeps the path if it was created again in the meantime. It returns false when unsupported, i.e. without the rooted builtin server of Linux and macOS hosts. Assisted-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Sylvain Zimmer <sylvain@sylvainzimmer.com>
sylvinus
marked this pull request as draft
September 23, 2026 22:31
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.
Depends on #118 (this branch includes its commit; only the last commit is new).
Needed for lima-vm/lima#5530
ExpectRemove(hostPath)makes the next Remove/Rmdir of that path from the guest, within 5 seconds, succeed without touching the host. Lima uses it to relay host deletions to the guest: the guest removes the path so that it emits IN_DELETE, and the host keeps the file if it was created again meanwhile.Returns false when unsupported (not the rooted builtin server).
Tested with unit tests and the sshfs e2e test (deletion cases, including a file recreated before the guest's removal arrives).
Assisted-by: Claude Opus 5.5 (1M context)