From db0e4ad7c529ecaf2e4bbaa4555889769c1eba8d Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 17 Jun 2022 09:39:41 +0200 Subject: [PATCH] fsSize() adapted parsing linux --- lib/filesystem.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/filesystem.js b/lib/filesystem.js index fd25068..5a3533a 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -49,12 +49,17 @@ function fsSize(callback) { return 'HFS'; } + function isLinuxTmpFs(fs) { + const linuxTmpFileSystems = ['rootfs', 'unionfs', 'squashfs', 'cramfs', 'initrd', 'initramfs', 'devtmpfs', 'tmpfs', 'udev', 'devfs', 'specfs']; + return (linuxTmpFileSystems.includes(fs.toLowerCase())); + } + function parseDf(lines) { let data = []; lines.forEach(function (line) { if (line !== '') { line = line.replace(/ +/g, ' ').split(' '); - if (line && ((line[0].startsWith('/')) || (line[6] && line[6] === '/') || (line[0].indexOf('/') > 0) || (line[0].indexOf(':') === 1))) { + if (line && ((line[0].startsWith('/')) || (line[6] && line[6] === '/') || (line[0].indexOf('/') > 0) || (line[0].indexOf(':') === 1) || !_darwin && !isLinuxTmpFs(line[1]))) { const fs = line[0]; const fsType = ((_linux || _freebsd || _openbsd || _netbsd) ? line[1] : getmacOsFsType(line[0])); const size = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])) * 1024; @@ -96,7 +101,7 @@ function fsSize(callback) { macOsDisks = []; } } - if (_linux) { cmd = 'df -lkPTx squashfs | grep -E "^/|^.\\:"'; } + if (_linux) { cmd = 'df -lkPTx squashfs'; } // cmd = 'df -lkPTx squashfs | grep -E "^/|^.\\:"'; if (_freebsd || _openbsd || _netbsd) { cmd = 'df -lkPT'; } exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) { if (!error) {