Repository navigation
Never delete into a filesystem mounted inside a marked directory - #10
Merged
Merged
Conversation
remove_dir_all crosses mount boundaries, so permanently deleting a marked directory emptied anything mounted below it (sshfs, NFS, a USB disk, a bind mount) before failing with EBUSY on the mount point. A one-filesystem scan never shows that content, so it was data the user never saw. The plan now refuses a target with a mount point beneath it, and the removal walks the tree itself with openat(O_NOFOLLOW), stopping at a directory on another device or mount (statx mount ID, which also sees same-filesystem bind mounts). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A repository's .git/config can set core.fsmonitor to a program, which git runs on every status; safe.directory does not cover repos the user owns. Selecting a directory now overrides fsmonitor, hooksPath and pager on the command line, which outranks repository config. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
pull Bot
pushed a commit
to jasonkneen/disktree
that referenced
this pull request
Sep 25, 2026
disktree built and drew on macOS already, through GPUI's Metal backend, but the Linux plumbing underneath did not carry over. This makes it work well there, without unsafe code, and tightens removal safety for every platform on the way. Trash and removal - On macOS always the system Trash, through NSFileManager (the trash crate): the same move as Finder's, into the item's own disk's Trash. gio/trash-put/XDG would put files in ~/.local/share/Trash, which Finder never shows. - Refuse a directory holding the home directory (/Users is on the same volume as / on macOS) or a system tree (/opt holds /opt/homebrew); add /System, /Library, /private, /opt/homebrew, /cores, /Network. - Refuse a directory with a mount inside it; on macOS the mount list comes from /sbin/mount, read on a background thread. - Permanent deletion walks the tree itself and stops at a mount boundary, like rm -rf --one-file-system (the walker is from tobi#10). - Guards see through /System/Volumes/Data spellings and, on macOS, case. Scanning - Skip /System/Volumes/Data when scanning /: it is /Users, /Applications and the rest again under firmlinks, so / was counted twice. - Whole disk (g, --disk) works: the disk root and device come from statfs. - Never list cloud-only (dataless) iCloud/File Provider folders, which would download them. - Keep a file's identity only when it has more than one name. App - Explain unreadable items when Full Disk Access is missing, with a button to the privacy settings. - A menu bar: Open Folder… (⌘O), Show in Finder (o, ⌘⇧R), Rescan (⌘R), Hide, Quit; closing the window quits; other ⌘ chords are not read as plain letters; help shows ⌘. - Follow the system light/dark appearance when no Omarchy theme exists. - Worth a look knows Xcode DerivedData, DeviceSupport and ~/Library/Logs. - git: skipped without the developer tools (its stub opens a dialog), and never runs a checkout's programs: fsmonitor, hooks and pager off, and no status for a checkout that defines its own filter drivers. Packaging - cargo xtask bundle builds disktree.app and a zip: Info.plist (bundle id io.github.tobi.disktree, macOS 11+), an icon drawn from an SVG on the macOS grid, ad-hoc or Developer ID signing, and --notarize. - make install on macOS puts the app in ~/Applications and links ~/.local/bin/disktree to it. - CI lints, tests and bundles on macOS; the release adds an arm64 macOS zip, signed and notarized when the repository has the Apple secrets.
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.
Fixes #9.
Mounts inside a target (
removal.rs)fs::remove_dir_allcrosses mount boundaries. Permanently deleting a marked directory therefore emptied anything mounted below it, and only then failed withEBUSYon the mount point. A one-filesystem scan never shows that content./proc/self/mountsentry strictly beneath it is blocked, and the review screen shows the reason.remove_permanentlywalks the tree itself. Each directory is opened relative to its parent withopenat(O_DIRECTORY|O_NOFOLLOW)through rustix, which is already a dependency. The walk stops with an error at a child directory whosest_devorstatxmount ID differs from the target's.st_dev, and a device check alone still deleted through it in testing.st_dev, so the walk won't descend into it. That matchesrm --one-file-systemand the existingis_mount_pointrule.git status in untrusted checkouts (
git.rs)A repository's
.git/configcan setcore.fsmonitorto a program, and git runs it on everystatus.safe.directorydoesn't apply to repos the user owns. The git calls now pass-c core.fsmonitor=false -c core.hooksPath=/dev/null -c core.pager=cat; command-line config outranks the repository's own config.Verification
cargo xtask lintandcargo xtask testpass. New tests cover:unshare -rm), with a same-filesystem bind mount and a tmpfs mounted under a marked directory:planblocks the target, andremove_permanentlycalled directly stops at the mount with nothing on it touched/etcis still removed completely🤖 Generated with Claude Code