#disk #list #info #diskinfo #information

bin+lib disk_list

获取磁盘列表信息并将其收集到 Vec 中

18 个版本

0.2.10 2022 年 8 月 17 日
0.2.9 2022 年 8 月 14 日
0.2.8 2022 年 7 月 10 日
0.2.2 2022 年 6 月 20 日
0.1.6 2022 年 4 月 16 日

#885 in 开发工具

MIT 许可证

7KB

获取磁盘列表信息并将其收集到 Vec 中

crates.io API Docs unlicense

支持的平台
FreeBSD
Linux
OpenBSD
Windows
macOS

示例

use disk_list;
fn get(){
     let list = disk_list::get_disk_list();
    //get disk info vec![vec![mount_from,file_type,mount_on,available_space,total_space]]
     #[cfg(target_os = "windows")]
    assert_eq!(
        vec![
            vec!["C", "NTFS", "C:\\", "18.2 GB", "107.4 GB"],
            vec!["FILE", "FAT32", "D:\\", "191.1 GB", "214.7 GB"],
            vec!["DATA", "NTFS", "E:\\", "678.5 GB", "785.5 GB"]
        ],
        list
    );
    //linux
    #[cfg(target_os = "linux")]
    assert_eq!(
        vec![
            vec!["proc", "proc", "/proc", "0 B", "0 B"],
            vec!["sys", "sysfs", "/sys", "0 B", "0 B"],
            vec!["dev", "devtmpfs", "/dev", "4.1 GB", "4.1 GB"],
            vec!["run", "tmpfs", "/run", "4.1 GB", "4.1 GB"],
            vec![
                "efivarfs",
                "efivarfs",
                "/sys/firmware/efi/efivars",
                "0 B",
                "0 B"
            ],
            vec!["/dev/nvme0n1p5", "ext4", "/", "28.7 GB", "52.5 GB"],
            vec![
                "securityfs",
                "securityfs",
                "/sys/kernel/security",
                "0 B",
                "0 B"
            ],
            vec!["tmpfs", "tmpfs", "/dev/shm", "4.0 GB", "4.1 GB"],
            vec!["devpts", "devpts", "/dev/pts", "0 B", "0 B"],
            vec!["cgroup2", "cgroup2", "/sys/fs/cgroup", "0 B", "0 B"],
            vec!["pstore", "pstore", "/sys/fs/pstore", "0 B", "0 B"],
            vec!["bpf", "bpf", "/sys/fs/bpf", "0 B", "0 B"],
            vec![
                "systemd-1",
                "autofs",
                "/proc/sys/fs/binfmt_misc",
                "0 B",
                "0 B"
            ],
            vec!["hugetlbfs", "hugetlbfs", "/dev/hugepages", "0 B", "0 B"],
            vec!["mqueue", "mqueue", "/dev/mqueue", "0 B", "0 B"],
            vec!["debugfs", "debugfs", "/sys/kernel/debug", "0 B", "0 B"],
            vec!["tracefs", "tracefs", "/sys/kernel/tracing", "0 B", "0 B"],
            vec!["configfs", "configfs", "/sys/kernel/config", "0 B", "0 B"],
            vec![
                "ramfs",
                "ramfs",
                "/run/credentials/systemd-sysusers.service",
                "0 B",
                "0 B"
            ],
            vec![
                "fusectl",
                "fusectl",
                "/sys/fs/fuse/connections",
                "0 B",
                "0 B"
            ],
            vec!["tmpfs", "tmpfs", "/tmp", "4.1 GB", "4.1 GB"],
            vec!["/dev/nvme0n1p6", "ext4", "/home", "32.8 GB", "69.5 GB"],
            vec![
                "/dev/nvme0n1p3",
                "vfat",
                "/boot/efi",
                "287.7 MB",
                "313.9 MB"
            ],
            vec!["tmpfs", "tmpfs", "/run/user/1000", "821.5 MB", "821.5 MB"],
            vec![
                "gvfsd-fuse",
                "fuse.gvfsd-fuse",
                "/run/user/1000/gvfs",
                "0 B",
                "0 B"
            ],
            vec![
                "/dev/sda2",
                "fuseblk",
                "/run/media/andry/DATA",
                "670.1 GB",
                "785.5 GB"
            ],
            vec![
                "/dev/sda1",
                "vfat",
                "/run/media/andry/FILE",
                "191.1 GB",
                "214.7 GB"
            ],
            vec![
                "/dev/nvme0n1p2",
                "fuseblk",
                "/run/media/andry/C",
                "15.3 GB",
                "107.4 GB"
            ]
        ],
        list
    );
}

依赖项

~1.2–7MB
~35K SLoC