summaryrefslogtreecommitdiffhomepage
path: root/libs/uvl
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-10-12 22:24:41 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-10-12 22:24:41 +0000
commit725719c221b497b49cb2d1c2fc181bdc5d15d1ef (patch)
tree013f2e99f13c1f08ac9d27c247b6f142b35a4a11 /libs/uvl
parentfd7072de2dcb93cecb37bc193e4931f8dfe28ef5 (diff)
* luci/libs/uvl: add new datatype "device"
Diffstat (limited to 'libs/uvl')
-rw-r--r--libs/uvl/luasrc/uvl/datatypes.lua16
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