From 231541859a4623ac649455924229166d6c80dcfe Mon Sep 17 00:00:00 2001 From: Tobi Lutke Date: Sat, 26 Sep 2026 21:59:57 -0400 Subject: [PATCH] Refuse media exceptions for stacked mount points --- crates/disktree-core/src/removal.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/disktree-core/src/removal.rs b/crates/disktree-core/src/removal.rs index 1fef87d..4c6361c 100644 --- a/crates/disktree-core/src/removal.rs +++ b/crates/disktree-core/src/removal.rs @@ -569,6 +569,9 @@ fn media_roots(mounts: &[crate::space::MountView]) -> Vec { .filter(|mount| { mount.point.starts_with("/run/media") && mount.point != Path::new("/run/media") + // An overmounted disk can remain in mountinfo. Ambiguous + // stacked views must never grant a deletion exception. + && mounts.iter().filter(|other| other.point == mount.point).count() == 1 && mount.fs_root == Path::new("/") && mount.source.starts_with("/dev/") && matches!( @@ -1591,6 +1594,11 @@ mod tests { ] { assert!(!on_media(Path::new(path), &points, &media), "{path}"); } + let mut stacked = views.clone(); + let mut covering = views[3].clone(); + covering.point = PathBuf::from("/run/media/user/Games"); + stacked.push(covering); + assert!(media_roots(&stacked).is_empty(), "overmounted disk"); assert!(media_roots(&[]).is_empty()); }