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>
(backported from commit
ad3509bf3bb5dfa79af634c841d584408068fb0a)
block:close()
+ local swaps = io.open("/proc/swaps", "r")
+ if swaps then
+ while true do
+ local ln = swaps:read("*l")
+ if not ln then
+ break
+ end
+
+ local dev, s = ln:match("^(/%S+)%s+%S+%s+(%d+)")
+ if dev and s then
+ rv["swap:" .. dev] = {
+ dev = dev:gsub("\\(%d%d%d)",
+ function(n)
+ return string.char(tonumber(n, 8))
+ end),
+ size = s * 1024,
+ type = "swap"
+ }
+ end
+ end
+
+ swaps:close()
+ end
+
return rv
else
return { error = "Unable to execute block utility" }