From 0aba709fb156263789c699c51d1eb0a3a54ab5c4 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Thu, 1 Aug 2019 22:41:43 +1000 Subject: [PATCH] added a filesyste manager program, for auto (un)mounting of filesystems --- service/fsmanager.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 service/fsmanager.lua diff --git a/service/fsmanager.lua b/service/fsmanager.lua new file mode 100644 index 0000000..68ec330 --- /dev/null +++ b/service/fsmanager.lua @@ -0,0 +1,11 @@ +while true do + local tE = {coroutine.yield()} + if tE[1] == "component_added" and tE[3] == "filesystem" then + local w, doesExist = pcall(fs.exists,"/"..tE[2]:sub(1,3)) + if not w or not doesExist then + fs.mounts[tE[2]:sub(1,3)] = component.proxy(tE[2]) + end + elseif tE[1] == "component_removed" and tE[3] == "filesystem" then + fs.mounts[tE[2]:sub(1,3)] = nil + end +end