overlay: change to normalized, fix error handling

This commit is contained in:
ohrensessel 2014-08-18 12:10:54 +02:00
parent 4e76436932
commit 0e95c90e21

View File

@ -2,6 +2,8 @@ local fs = require "nixio.fs"
local opkg = require "luci.model.ipkg" local opkg = require "luci.model.ipkg"
local st = fs.statvfs(opkg.overlay_root()) local st = fs.statvfs(opkg.overlay_root())
local used = 100*((st.blocks - st.bfree) / st.blocks) or 0 local blocks = st.blockss or 0
local bfree = st.bfree or 0
local used = ((blocks - bfree) / blocks)
return math.floor(used * 1000 + 0.5) / 1000 return math.floor(used * 1000 + 0.5) / 1000