From 69815096fee92291df90ed3539f3a21ab9505d0c Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sat, 17 Oct 2020 10:39:31 +1100 Subject: [PATCH] exportfs does better arg parsing now, can export ro or rw --- MTFS/OpenOS/usr/bin/exportfs.lua | 19 +++++++++---------- MTFS/OpenOS/usr/lib/fsproxy.lua | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/MTFS/OpenOS/usr/bin/exportfs.lua b/MTFS/OpenOS/usr/bin/exportfs.lua index 97d00f6..99ff63b 100644 --- a/MTFS/OpenOS/usr/bin/exportfs.lua +++ b/MTFS/OpenOS/usr/bin/exportfs.lua @@ -1,17 +1,16 @@ local fsproxy = require "fsproxy" -local rpc = require "rpc" local fs = require "filesystem" +local shell = require "shell" +local rpc = require "rpc" -local tA = {...} +local tA, tO = shell.parse(...) if #tA < 1 then - print("Usage: exportfs [directory] ...") + print("Usage: exportfs [--rw] [--name=]") return end - -for k,v in pairs(tA) do - local px = fsproxy.new(v) - for l,m in pairs(px) do - rpc.register("fs_"..v.."_"..l,m) - end - print(v) +local px = fsproxy.new(tA[1], not tO.rw) +local name = tO.name or tA[1] +for l,m in pairs(px) do + rpc.register("fs_"..name.."_"..l,m) end +print(string.format("%s (%s)", name, (tO.rw and "rw") or "ro")) diff --git a/MTFS/OpenOS/usr/lib/fsproxy.lua b/MTFS/OpenOS/usr/lib/fsproxy.lua index e3cc55d..2f0bd07 100644 --- a/MTFS/OpenOS/usr/lib/fsproxy.lua +++ b/MTFS/OpenOS/usr/lib/fsproxy.lua @@ -30,7 +30,7 @@ function fsproxy.new(path,wp) -- string boolean -- table -- Returns a proxy obje end local handles = {} function proxy.isReadOnly() - return originalProxy.isReadOnly() + return wp or originalProxy.isReadOnly() end function proxy.getLabel() return originalProxy.getLabel()