From 9840d310e2e3a54a3d53fc206f2d406402b42128 Mon Sep 17 00:00:00 2001 From: Rosy Song Date: Sat, 8 Sep 2018 15:07:01 +0800 Subject: modules: add backup module for mtdblock devices Signed-off-by: Rosy Song --- modules/luci-base/luasrc/sys.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'modules/luci-base') diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua index 823e20770..1436a3a23 100644 --- a/modules/luci-base/luasrc/sys.lua +++ b/modules/luci-base/luasrc/sys.lua @@ -70,6 +70,24 @@ function mounts() return data end +function mtds() + local data = {} + + if fs.access("/proc/mtd") then + for l in io.lines("/proc/mtd") do + local d, s, e, n = l:match('^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+"([^%s]+)"') + if s and n then + local d = {} + d.size = tonumber(s, 16) + d.name = n + table.insert(data, d) + end + end + end + + return data +end + -- containing the whole environment is returned otherwise this function returns -- the corresponding string value for the given name or nil if no such variable -- exists. -- cgit v1.2.3