diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2008-10-12 22:24:41 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2008-10-12 22:24:41 +0000 |
commit | 725719c221b497b49cb2d1c2fc181bdc5d15d1ef (patch) | |
tree | 013f2e99f13c1f08ac9d27c247b6f142b35a4a11 /libs/uvl | |
parent | fd7072de2dcb93cecb37bc193e4931f8dfe28ef5 (diff) |
* luci/libs/uvl: add new datatype "device"
Diffstat (limited to 'libs/uvl')
-rw-r--r-- | libs/uvl/luasrc/uvl/datatypes.lua | 16 |
1 files changed, 16 insertions, 0 deletions
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 |