summaryrefslogtreecommitdiffhomepage
path: root/libs/sys
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-14 21:55:53 +0000
committerSteven Barth <steven@midlink.org>2008-08-14 21:55:53 +0000
commitff30f2292c0df63b22e19579cf1bdea889eefb32 (patch)
treee4b2933b115be2d300239bf337ce1a08e3f3b5a5 /libs/sys
parent2b0e8c6d7fc72c5c4d090dd3311c341f280e2237 (diff)
libs/sys: Added luci.sys.mounts
Diffstat (limited to 'libs/sys')
-rw-r--r--libs/sys/luasrc/sys.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua
index c8d7a54770..779e2025fe 100644
--- a/libs/sys/luasrc/sys.lua
+++ b/libs/sys/luasrc/sys.lua
@@ -45,6 +45,36 @@ function flash(image, kpattern)
return os.execute(cmd)
end
+--- Retrieve information about currently mounted file systems.
+-- @return Table containing mount information
+function mounts()
+ local data = {}
+ local k = {"fs", "blocks", "used", "available", "percent", "mountpoint"}
+ local ps = luci.util.execi("df")
+
+ if not ps then
+ return
+ else
+ ps()
+ end
+
+ for line in ps do
+ local row = {}
+
+ local j = 1
+ for value in line:gmatch("[^%s]+") do
+ row[k[j]] = value
+ j = j + 1
+ end
+
+ if row[k[1]] then
+ table.insert(data, row)
+ end
+ end
+
+ return data
+end
+
--- Retrieve environment variables. If no variable is given then a table
-- containing the whole environment is returned otherwise this function returns
-- the corresponding string value for the given name or nil if no such variable