feat(mount): get fstype for unmounted partitions (#54)
This commit is contained in:
@@ -189,7 +189,7 @@ function M.obtain()
|
|||||||
p.main, p.sub, tbl[#tbl + 1] = main, " " .. sub, p
|
p.main, p.sub, tbl[#tbl + 1] = main, " " .. sub, p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(tbl, function(a, b)
|
table.sort(M.fillin(tbl), function(a, b)
|
||||||
if a.main == b.main then
|
if a.main == b.main then
|
||||||
return a.sub < b.sub
|
return a.sub < b.sub
|
||||||
else
|
else
|
||||||
@@ -199,6 +199,34 @@ function M.obtain()
|
|||||||
return tbl
|
return tbl
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.fillin(tbl)
|
||||||
|
if ya.target_os() ~= "linux" then
|
||||||
|
return tbl
|
||||||
|
end
|
||||||
|
|
||||||
|
local sources, indices = {}, {}
|
||||||
|
for i, p in ipairs(tbl) do
|
||||||
|
if p.sub ~= "" and not p.fstype then
|
||||||
|
sources[#sources + 1], indices[#indices + 1] = p.src, i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #sources == 0 then
|
||||||
|
return tbl
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err = Command("lsblk"):args({ "-n", "-o", "FSTYPE" }):args(sources):output()
|
||||||
|
if err then
|
||||||
|
ya.dbg("Failed to fetch filesystem types for unmounted partitions: " .. err)
|
||||||
|
return tbl
|
||||||
|
end
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
for line in output.stdout:gmatch("[^\r\n]+") do
|
||||||
|
i, tbl[indices[i]].fstype = i + 1, line
|
||||||
|
end
|
||||||
|
return tbl
|
||||||
|
end
|
||||||
|
|
||||||
function M.operate(type)
|
function M.operate(type)
|
||||||
local active = active_partition()
|
local active = active_partition()
|
||||||
if not active then
|
if not active then
|
||||||
|
|||||||
Reference in New Issue
Block a user