summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/root/usr/share/rpcd/ucode
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2023-04-28 14:55:09 +0200
committerJo-Philipp Wich <jo@mein.io>2023-04-28 14:55:09 +0200
commitad3509bf3bb5dfa79af634c841d584408068fb0a (patch)
treea9df49464e9233dd6ca5ed1fe71202961014c6e7 /modules/luci-base/root/usr/share/rpcd/ucode
parentd25d5c28b7daddd9cfdf650b15642f1e89b2c2e5 (diff)
luci-base: rpcd: handle swap entries in getBlockDevices
Add entries from `/proc/swaps` to the result array as well in order to let the ui properly deal with swap files. Fixes: #6350 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/root/usr/share/rpcd/ucode')
-rw-r--r--modules/luci-base/root/usr/share/rpcd/ucode/luci22
1 files changed, 21 insertions, 1 deletions
diff --git a/modules/luci-base/root/usr/share/rpcd/ucode/luci b/modules/luci-base/root/usr/share/rpcd/ucode/luci
index f4d204cf22..35f592578b 100644
--- a/modules/luci-base/root/usr/share/rpcd/ucode/luci
+++ b/modules/luci-base/root/usr/share/rpcd/ucode/luci
@@ -419,13 +419,33 @@ const methods = {
size: +readfile(`/sys/class/block/${dev}/size`) * 512
};
- for (m in match(line, / (\w+)="([^"]+)"/g))
+ for (let m in match(line, / (\w+)="([^"]+)"/g))
e[lc(m[1])] = m[2];
}
}
block.close();
+ const swaps = open('/proc/swaps', 'r');
+
+ if (swaps) {
+ for (let line = swaps.read('line'); length(line); line = swaps.read('line')) {
+ let m = match(line, /^(\/\S+)\s+\S+\s+(\d+)/);
+
+ if (m) {
+ let dev = replace(m[1], /\\(\d\d\d)/g, (_, n) => chr(int(n, 8)));
+
+ result[`swap:${m[1]}`] = {
+ dev,
+ type: 'swap',
+ size: +m[2] * 1024
+ };
+ }
+ }
+
+ swaps.close();
+ }
+
return result;
}
else {