Stay compatible with ubuntu's util-linux package

This commit is contained in:
Johannes Zellner
2023-01-23 18:43:34 +01:00
parent a6fdb96fbf
commit 8ab7a4ff58

View File

@@ -339,13 +339,14 @@ async function getBlockDevices() {
let info;
try {
info = JSON.parse(execSync('lsblk --paths --json --list --noempty', { encoding: 'utf8' }));
info = JSON.parse(execSync('lsblk --paths --json --list --bytes', { encoding: 'utf8' }));
} catch (e) {
console.error('Failed to list disks:', e);
throw new BoxError(BoxError.INTERNAL_ERROR, e);
}
const devices = info.blockdevices;
// remove empty disks (disks with partitions)
const devices = info.blockdevices.filter(d => d.size);
debug(`getBlockDevices: Found ${devices.length} devices. ${devices.map(d => d.name).join(', ')}`);
@@ -355,7 +356,7 @@ async function getBlockDevices() {
path: d.name,
size: d.size,
type: d.type,
mountpoint: d.mountpoints[0] // we only support one mountpoint here
mountpoint: d.mountpoints ? d.mountpoints[0] : d.mountpoint // we only support one mountpoint here old lsblk only exposed one via .mountpoint
};
});
}