From: Jo-Philipp Wich Date: Sun, 12 Oct 2008 22:24:41 +0000 (+0000) Subject: * luci/libs/uvl: add new datatype "device" X-Git-Tag: 0.9.0~1110 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=725719c221b497b49cb2d1c2fc181bdc5d15d1ef * luci/libs/uvl: add new datatype "device" --- diff --git a/libs/uvl/luasrc/uvl/datatypes.lua b/libs/uvl/luasrc/uvl/datatypes.lua index fc37fa3c6..615e2946d 100644 --- a/libs/uvl/luasrc/uvl/datatypes.lua +++ b/libs/uvl/luasrc/uvl/datatypes.lua @@ -169,3 +169,19 @@ function file( val, seen ) return false end + +function device( val, seen ) + local s = fs.stat( val ) + seen = seen or { } + + if s and not seen[s.ino] then + seen[s.ino] = true + if s.type == "character device" or s.type == "block device" then + return true + elseif s.type == "link" then + return device( fs.readlink(val), seen ) + end + end + + return false +end