mount-watcher

Crates.iomount-watcher
lib.rsmount-watcher
version0.5.0
created_at2025-06-05 15:53:59.086269+00
updated_at2025-07-07 12:27:12.232913+00
descriptionGet notified when a filesystem is mounted/unmounted
homepage
repositoryhttps://github.com/TheElectronWill/rust-mount-watcher/
max_upload_size
id1701732
size48,648
Guillaume Raffin (TheElectronWill)

documentation

README

Mount Watcher

Get notified when a filesystem is mounted/unmounted! (Linux only)

Key features:

  • Uses epoll to watch /proc/mounts in an efficient way: no busy polling.
  • Emits high-level events with the newly mounted/unmounted filesystems.
  • Can be stopped from the event handler, or from the outside.
  • Can coalesce multiple events into one, on demand.

Crates.io Version docs.rs

Example

let watch = MountWatcher::new(|event| {
    if event.initial {
        println!("initial mount points: {:?}", event.mounted);
    } else {
        println!("new mounts: {:?}", event.mounted);
        println!("removed mounts: {:?}", event.unmounted);
    }
    WatchControl::Continue
});
// store the watcher somewhere (it will stop on drop)
Commit count: 10

cargo fmt