diff options
author | Rosy Song <rosysong@rosinson.com> | 2018-09-08 15:07:01 +0800 |
---|---|---|
committer | Rosy Song <rosysong@rosinson.com> | 2018-09-08 15:07:01 +0800 |
commit | 9840d310e2e3a54a3d53fc206f2d406402b42128 (patch) | |
tree | ae8b47a33c239034093c300f41a24492247b8418 /modules/luci-base | |
parent | 18b4483fe76885061ea8d57e01a2fafc25de7790 (diff) |
modules: add backup module for mtdblock devices
Signed-off-by: Rosy Song <rosysong@rosinson.com>
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/luasrc/sys.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua index 823e20770c..1436a3a235 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. |