mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-09 22:59:59 +00:00
fix(utils): map common Linux filesystem magic values (#3023)
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::os::{DiskInfo, IOStats};
|
||||
use super::{DiskInfo, IOStats, fs_type::get_fs_type};
|
||||
use rustix::fs::statfs;
|
||||
use std::collections::BTreeSet;
|
||||
use std::fs;
|
||||
@@ -86,35 +86,6 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the filesystem type of the underlying mounted filesystem
|
||||
///
|
||||
/// TODO The following mapping could not find the corresponding constant in `nix`:
|
||||
///
|
||||
/// "137d" => "EXT",
|
||||
/// "4244" => "HFS",
|
||||
/// "5346544e" => "NTFS",
|
||||
/// "61756673" => "AUFS",
|
||||
/// "ef51" => "EXT2OLD",
|
||||
/// "2fc12fc1" => "zfs",
|
||||
/// "ff534d42" => "cifs",
|
||||
/// "53464846" => "wslfs",
|
||||
fn get_fs_type(fs_type: u64) -> &'static str {
|
||||
// Magic numbers for various filesystems
|
||||
match fs_type {
|
||||
0x01021994 => "TMPFS",
|
||||
0x4d44 => "MSDOS",
|
||||
0x6969 => "NFS",
|
||||
0xEF53 => "EXT4",
|
||||
0xf15f => "ecryptfs",
|
||||
0x794c7630 => "overlayfs",
|
||||
0x52654973 => "REISERFS",
|
||||
// Additional common ones can be added here:
|
||||
// 0x58465342 => "XFS",
|
||||
// 0x9123683E => "BTRFS",
|
||||
_ => "UNKNOWN",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn same_disk(disk1: &str, disk2: &str) -> std::io::Result<bool> {
|
||||
let stat1 = rustix::fs::stat(disk1)?;
|
||||
let stat2 = rustix::fs::stat(disk2)?;
|
||||
|
||||
Reference in New Issue
Block a user