Know which Filesystem a File is on?

If I have 2 files is it possible to know if they are mounted on different filesystems?

I can not see anything described in the Metadata here: https://doc.rust-lang.org/std/fs/struct.Metadata.html.

Is it possible to work it out from a File's inode?

The reason I ask is because it has been raised as an issue on my project: https://github.com/bootandy/dust/issues/50

For Unix machines there's device ID: https://doc.rust-lang.org/std/os/unix/fs/trait.MetadataExt.html

1 Like

If you're using walkdir (or ignore), then you can use its same_file_system option.

Otherwise, you can copy the implementation which works on Windows: https://github.com/BurntSushi/walkdir/blob/bab4066b218dc20a625d405e02433d882237d59c/src/util.rs#L1

1 Like