Skip to content

Commit 71b307d

Browse files
committed
handle FUSE 2 command-line options that changed or disappeared in FUSE 3
- Accept and ignore -f/--foreground: pyfuse3 always runs in the foreground since the event loop is managed by the caller via trio - Silently drop 'nonempty': FUSE 3 removed this option; mounting over a non-empty directory is unconditionally allowed - Intercept entry_timeout=N and attr_timeout=N: these are no longer FUSE mount options in FUSE 3; they are per-entry fields in EntryAttributes, so parse them into globals used at entry creation time instead of forwarding them to pyfuse3.init() This makes the existing systemd ExecStart line work unchanged: gpiod-sysfs-proxy /sys/class/gpio -f -o nonempty -o allow_other \ -o default_permissions -o entry_timeout=0 -o attr_timeout=0 Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
1 parent 9e986c3 commit 71b307d

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

gpiod-sysfs-proxy

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ _inode_lock = Lock()
2323
_inode_counter = pyfuse3.ROOT_INODE + 1
2424
_inode_map = {}
2525

26+
_entry_timeout = 300.0
27+
_attr_timeout = 300.0
28+
2629

2730
def _alloc_inode(entry):
2831
global _inode_counter
@@ -116,8 +119,8 @@ class Entry:
116119
self._attr.st_ctime_ns = now_ns
117120
self._attr.st_rdev = 0
118121
self._attr.generation = 0
119-
self._attr.entry_timeout = 300
120-
self._attr.attr_timeout = 300
122+
self._attr.entry_timeout = _entry_timeout
123+
self._attr.attr_timeout = _attr_timeout
121124

122125
@property
123126
def inode(self):
@@ -825,8 +828,16 @@ class GpioSysFuse(pyfuse3.Operations):
825828

826829

827830
def main():
831+
global _entry_timeout, _attr_timeout
832+
828833
parser = argparse.ArgumentParser(description="GPIO sysfs FUSE proxy")
829834
parser.add_argument("mountpoint", help="Filesystem mount point")
835+
parser.add_argument(
836+
"-f",
837+
"--foreground",
838+
action="store_true",
839+
help=argparse.SUPPRESS, # pyfuse3 always runs in the foreground
840+
)
830841
parser.add_argument(
831842
"-o",
832843
dest="options",
@@ -837,13 +848,20 @@ def main():
837848
)
838849
args = parser.parse_args()
839850

840-
root = Root(args.mountpoint)
841-
fs = GpioSysFuse()
842-
843851
fuse_options = set(pyfuse3.default_options)
844852
fuse_options.add("fsname=gpiod-sysfs-proxy")
845853
for opt in args.options:
846-
fuse_options.add(opt)
854+
if opt == "nonempty":
855+
pass # removed in FUSE 3; mounting over non-empty dirs is always allowed
856+
elif opt.startswith("entry_timeout="):
857+
_entry_timeout = float(opt.split("=", 1)[1])
858+
elif opt.startswith("attr_timeout="):
859+
_attr_timeout = float(opt.split("=", 1)[1])
860+
else:
861+
fuse_options.add(opt)
862+
863+
root = Root(args.mountpoint)
864+
fs = GpioSysFuse()
847865

848866
pyfuse3.init(fs, args.mountpoint, fuse_options)
849867

0 commit comments

Comments
 (0)