From 5ec7a43c6f0a6cd1369da101fa0e3f1f12d99973 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 13 Jan 2009 16:01:06 +0000 Subject: Modified fs.lua to survive nil parameters. Added create_directory and used within create_file and write_file. Reviewed each read_file call to make sure handles nil return value. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed --- health-model.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'health-model.lua') diff --git a/health-model.lua b/health-model.lua index 641a804..e012bf1 100644 --- a/health-model.lua +++ b/health-model.lua @@ -71,7 +71,7 @@ get_storage = function (self) storage.hd.value[name].used = string.match(line, name.."%s*%S*%s*%S*%s*%S*%s*(%S*)%%") end end - storage.partitions = cfe({ value=fs.read_file("/proc/partitions"), label="Partitions" }) + storage.partitions = cfe({ value=fs.read_file("/proc/partitions") or "", label="Partitions" }) return cfe({ type="group", value=storage }) end @@ -90,14 +90,14 @@ end get_proc = function (self) local proc = {} - proc.processor = cfe({ value=fs.read_file("/proc/cpuinfo"), label="Processor" }) - proc.memory = cfe({ value=fs.read_file("/proc/meminfo"), label="Memory" }) + proc.processor = cfe({ value=fs.read_file("/proc/cpuinfo") or "", label="Processor" }) + proc.memory = cfe({ value=fs.read_file("/proc/meminfo") or "", label="Memory" }) return cfe({ type="group", value=proc }) end get_networkstats = function () local stats = cfe({ type="structure", value={}, label="Network Stats", timestamp=os.time() }) - local result = fs.read_file("/proc/net/dev") + local result = fs.read_file("/proc/net/dev") or "" -- parse the result local i=0 for line in string.gmatch(result, "[^\n]+\n?") do -- cgit v1.2.3