diskLayout() fixed linux
This commit is contained in:
Regular → Executable
+10
-10
@@ -722,11 +722,13 @@ function diskLayout(callback) {
|
||||
];
|
||||
|
||||
let result = '';
|
||||
model = model.toUpperCase();
|
||||
diskManufacturers.forEach((manufacturer) => {
|
||||
const re = RegExp(manufacturer.pattern);
|
||||
if (re.test(model)) { result = manufacturer.manufacturer; }
|
||||
});
|
||||
if (model) {
|
||||
model = model.toUpperCase();
|
||||
diskManufacturers.forEach((manufacturer) => {
|
||||
const re = RegExp(manufacturer.pattern);
|
||||
if (re.test(model)) { result = manufacturer.manufacturer; }
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -745,21 +747,21 @@ function diskLayout(callback) {
|
||||
try {
|
||||
const outJSON = JSON.parse(out);
|
||||
if (outJSON && {}.hasOwnProperty.call(outJSON, 'blockdevices')) {
|
||||
devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fstype === null)); });
|
||||
devices = outJSON.blockdevices.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fstype === null)); });
|
||||
}
|
||||
} catch (e) {
|
||||
// fallback to older version of lsblk
|
||||
const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL').toString();
|
||||
let lines = blkStdoutToObject(out2).split('\n');
|
||||
const data = parseBlk(lines);
|
||||
devices = data.filter(item => { return item.group === 'disk' && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fstype === '')); });
|
||||
devices = data.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fstype === '')); });
|
||||
}
|
||||
devices.forEach((device) => {
|
||||
let mediumType = '';
|
||||
const BSDName = '/dev/' + device.name;
|
||||
const logical = device.name;
|
||||
try {
|
||||
mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational').toString().split('\n')[0];
|
||||
mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational 2>/dev/null').toString().split('\n')[0];
|
||||
} catch (e) {
|
||||
util.noop();
|
||||
}
|
||||
@@ -793,8 +795,6 @@ function diskLayout(callback) {
|
||||
util.noop();
|
||||
}
|
||||
}
|
||||
// lshw sometimes returns empty results, try lsblk
|
||||
|
||||
// check S.M.A.R.T. status
|
||||
if (cmd) {
|
||||
cmd = cmd + 'printf "\n"';
|
||||
|
||||
Reference in New Issue
Block a user