diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm index 655a4b2..94ec93a 100644 --- a/PVE/Diskmanage.pm +++ b/PVE/Diskmanage.pm @@ -157,7 +157,7 @@ sub get_smart_data { } sub get_lsblk_info() { - my $cmd = [$LSBLK, '--json', '-o', 'path,parttype']; + my $cmd = [$LSBLK, '--json', '-o', 'path,parttype,fstype']; my $output = ""; my $res = {}; eval { @@ -174,7 +174,10 @@ sub get_lsblk_info() { my $list = $parsed->{blockdevices} // []; $res = { map { - $_->{path} => { parttype => $_->{parttype} } + $_->{path} => { + parttype => $_->{parttype}, + fstype => $_->{fstype} + } } @{$list} }; return $res; @@ -564,6 +567,14 @@ sub get_disks { $used = 'ZFS' if $zfshash->{$devpath}; + if (defined($lsblk_info->{$devpath})) { + my $fstype = $lsblk_info->{$devpath}->{fstype}; + if (defined($fstype)) { + $used = $fstype; + $used .= ' (mounted)' if $mounted->{$devpath}; + } + } + # we replaced cciss/ with cciss! above # but in the result we need cciss/ again # because the caller might want to check the diff --git a/test/disk_tests/usages/disklist b/test/disk_tests/usages/disklist index 92c3622..648bea5 100644 --- a/test/disk_tests/usages/disklist +++ b/test/disk_tests/usages/disklist @@ -11,3 +11,4 @@ sdj sdk sdl sdm +sdn diff --git a/test/disk_tests/usages/disklist_expected.json b/test/disk_tests/usages/disklist_expected.json index b2e37c0..93dc251 100644 --- a/test/disk_tests/usages/disklist_expected.json +++ b/test/disk_tests/usages/disklist_expected.json @@ -203,5 +203,20 @@ "rpm" : 0, "type" : "hdd", "osdid" : -1 + }, + "sdn" : { + "serial" : "SERIAL1", + "vendor" : "ATA", + "wwn" : "0x0000000000000000", + "devpath" : "/dev/sdn", + "model" : "MODEL1", + "used" : "xfs", + "wearout" : "N/A", + "health" : "UNKNOWN", + "gpt" : 0, + "size" : 1536000, + "rpm" : 0, + "type" : "hdd", + "osdid" : -1 } } diff --git a/test/disk_tests/usages/lsblk b/test/disk_tests/usages/lsblk index cbb18b9..6a725ab 100644 --- a/test/disk_tests/usages/lsblk +++ b/test/disk_tests/usages/lsblk @@ -1,7 +1,8 @@ { "blockdevices": [ - {"path":"/dev/sdm", "parttype":null}, - {"path":"/dev/sdm1", "parttype":"6a898cc3-1dd2-11b2-99a6-080020736631"}, - {"path":"/dev/sdm9", "parttype":"6a945a3b-1dd2-11b2-99a6-080020736631"} + {"path":"/dev/sdm", "parttype":null, "fstype":null}, + {"path":"/dev/sdm1", "parttype":"6a898cc3-1dd2-11b2-99a6-080020736631", "fstype":"zfs_member"}, + {"path":"/dev/sdm9", "parttype":"6a945a3b-1dd2-11b2-99a6-080020736631", "fstype":null}, + {"path":"/dev/sdn", "parttype":null, "fstype":"xfs"} ] } diff --git a/test/disk_tests/usages/sdn/device/vendor b/test/disk_tests/usages/sdn/device/vendor new file mode 100644 index 0000000..531030d --- /dev/null +++ b/test/disk_tests/usages/sdn/device/vendor @@ -0,0 +1 @@ +ATA diff --git a/test/disk_tests/usages/sdn/queue/rotational b/test/disk_tests/usages/sdn/queue/rotational new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/disk_tests/usages/sdn/queue/rotational @@ -0,0 +1 @@ +1 diff --git a/test/disk_tests/usages/sdn/size b/test/disk_tests/usages/sdn/size new file mode 100644 index 0000000..13de30f --- /dev/null +++ b/test/disk_tests/usages/sdn/size @@ -0,0 +1 @@ +3000 diff --git a/test/disk_tests/usages/sdn_udevadm b/test/disk_tests/usages/sdn_udevadm new file mode 100644 index 0000000..5ec4a92 --- /dev/null +++ b/test/disk_tests/usages/sdn_udevadm @@ -0,0 +1,14 @@ +E: DEVNAME=/dev/sdn +E: DEVTYPE=disk +E: ID_ATA_ROTATION_RATE_RPM=0 +E: ID_BUS=ata +E: ID_MODEL=MODEL1 +E: ID_SERIAL=SERIAL1 +E: ID_SERIAL_SHORT=SERIAL1 +E: ID_TYPE=disk +E: ID_FS_UUID=ab54fba8-48fe-4d37-bbe7-b403f94d3bed +E: ID_FS_UUID_ENC=ab54fba8-48fe-4d37-bbe7-b403f94d3bed +E: ID_FS_TYPE=xfs +E: ID_FS_USAGE=filesystem +E: ID_WWN=0x0000000000000000 +E: ID_WWN_WITH_EXTENSION=0x0000000000000000