diff options
author | Hannu Nyman <hannu.nyman@iki.fi> | 2018-09-14 20:05:36 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-14 20:05:36 +0300 |
commit | 6bea6eebf0f6d05473ee30ed8634c27c02f9c194 (patch) | |
tree | 7b03f3a5e576618dd2a0c3ed13a4c2d48e374bc7 /modules/luci-base | |
parent | 9e5baf9b3a1a52d51489446d4dac06338113c159 (diff) | |
parent | 9840d310e2e3a54a3d53fc206f2d406402b42128 (diff) |
Merge pull request #2122 from rosysong/backup
Backup: add firmware backup for mtdblock devices
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. |