luci-app-diskman: sync with upstream source

This commit is contained in:
CN_SZTL 2020-01-26 23:58:05 +08:00
parent 45cefdaa9c
commit 4b78488d23
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
2 changed files with 22 additions and 9 deletions

View File

@ -172,7 +172,7 @@ v_device.render = function(self, section, scope)
end
end
v_device.write = function(self, section, value)
_mount_point.device = value
_mount_point.device = value and value:gsub("%s+", "") or ""
end
local v_fs = table_mp:option(Value, "fs", translate("File System"))
v_fs.render = function(self, section, scope)
@ -188,7 +188,7 @@ v_fs.render = function(self, section, scope)
end
end
v_fs.write = function(self, section, value)
_mount_point.fs = value
_mount_point.fs = value and value:gsub("%s+", "") or ""
end
local v_mount_option = table_mp:option(Value, "mount_options", translate("Mount Options"))
v_mount_option.render = function(self, section, scope)
@ -199,11 +199,19 @@ v_mount_option.render = function(self, section, scope)
Value.render(self, section, scope)
else
self.template = "cbi/dvalue"
local mp = mount_point[section].mount_options
mount_point[section].mount_options = nil
for k in mp:gmatch("([^,]+)") do
mount_point[section].mount_options = mount_point[section].mount_options and mount_point[section].mount_options .. "," or ""
if #mount_point[section].mount_options > 50 then mount_point[section].mount_options = mount_point[section].mount_options.. " " end
mount_point[section].mount_options= mount_point[section].mount_options.. k
end
-- mount_point[section].mount_options = #mount_point[section].mount_options > 50 and mount_point[section].mount_options:sub(1,50) .. "..." or mount_point[section].mount_options
DummyValue.render(self, section, scope)
end
end
v_mount_option.write = function(self, section, value)
_mount_point.mount_options = value
_mount_point.mount_options = value and value:gsub("%s+", "") or ""
end
local v_mount_point = table_mp:option(Value, "mount_point", translate("Mount Point"))
v_mount_point.render = function(self, section, scope)
@ -236,7 +244,7 @@ btn_umount.write = function(self, section, value)
local res
if value == translate("Mount") then
luci.util.exec("mkdir -p ".. _mount_point.mount_point)
res = luci.util.exec("mount ".. _mount_point.device .. (_mount_point.fs and (" -t ".. _mount_point.fs )or "") .. (_mount_point.mount_options and (" -o " .. _mount_point.mount_options) or " ").._mount_point.mount_point .. " 2>&1")
res = luci.util.exec("mount ".. _mount_point.device .. (_mount_point.fs and (" -t ".. _mount_point.fs )or "") .. (_mount_point.mount_options and (" -o " .. _mount_point.mount_options.. " ") or " ").._mount_point.mount_point .. " 2>&1")
elseif value == translate("Umount") then
res = luci.util.exec("umount "..mount_point[section].mount_point .. " 2>&1")
end

View File

@ -117,15 +117,15 @@ end
local get_mount_point = function(partition)
local mount_point, dk_root_dir
-- if use luci-in-dokcer, exclude the docker overlay mounts
if ver.distname == "LuCI in Docker" then
-- if ver.distname == "LuCI in Docker" then
local _o, dk = pcall(require,"luci.docker")
if _o and dk then
dk_root_dir = dk.new():info().body.DockerRootDir
end
end
-- end
for m in mounts:gmatch("/dev/"..partition.." ([^ ]*)") do
if dk_root_dir and m:match("/host" .. dk_root_dir) then
if dk_root_dir and m:match(dk_root_dir) then
else
mount_point = (mount_point and (mount_point .. " ") or "") .. m
end
@ -257,12 +257,17 @@ end
-- return {{device="", mount_points="", fs="", mount_options="", dump="", pass=""}..}
d.get_mount_points = function()
local mount
local mount, dk_root_dir
local res = {}
local h ={"device", "mount_point", "fs", "mount_options", "dump", "pass"}
local _o, dk = pcall(require,"luci.docker")
if _o and dk then
dk_root_dir = dk.new():info().body.DockerRootDir
end
for mount in mounts:gmatch("[^\n]+") do
local device = mount:match("^([^%s]+)%s+.+")
if "overlay" ~= device and "cgroup" ~= device and "sysfs" ~= device and "proc" ~= device and "udev" ~= device and "devpts" ~= device and "hugetlbfs" ~= device and "mqueue" ~= device then
-- only show /dev/xxx device, and not show docker root dir mounts
if device:match("/dev/") and not mount:match(dk_root_dir)then
res[#res+1] = {}
local i = 0
for v in mount:gmatch("[^%s]+") do