Skip to content

Commit 4ecf1f9

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 f57fb30 commit 4ecf1f9

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
@@ -119,8 +122,8 @@ class Entry:
119122
self._attr.st_ctime_ns = now_ns
120123
self._attr.st_rdev = 0
121124
self._attr.generation = 0
122-
self._attr.entry_timeout = 300
123-
self._attr.attr_timeout = 300
125+
self._attr.entry_timeout = _entry_timeout
126+
self._attr.attr_timeout = _attr_timeout
124127

125128
@property
126129
def inode(self):
@@ -829,8 +832,16 @@ class GpioSysFuse(pyfuse3.Operations):
829832

830833

831834
def main():
835+
global _entry_timeout, _attr_timeout
836+
832837
parser = argparse.ArgumentParser(description="GPIO sysfs FUSE proxy")
833838
parser.add_argument("mountpoint", help="Filesystem mount point")
839+
parser.add_argument(
840+
"-f",
841+
"--foreground",
842+
action="store_true",
843+
help=argparse.SUPPRESS, # pyfuse3 always runs in the foreground
844+
)
834845
parser.add_argument(
835846
"-o",
836847
dest="options",
@@ -841,13 +852,20 @@ def main():
841852
)
842853
args = parser.parse_args()
843854

844-
root = Root(args.mountpoint)
845-
fs = GpioSysFuse()
846-
847855
fuse_options = set(pyfuse3.default_options)
848856
fuse_options.add("fsname=gpiod-sysfs-proxy")
849857
for opt in args.options:
850-
fuse_options.add(opt)
858+
if opt == "nonempty":
859+
pass # removed in FUSE 3; mounting over non-empty dirs is always allowed
860+
elif opt.startswith("entry_timeout="):
861+
_entry_timeout = float(opt.split("=", 1)[1])
862+
elif opt.startswith("attr_timeout="):
863+
_attr_timeout = float(opt.split("=", 1)[1])
864+
else:
865+
fuse_options.add(opt)
866+
867+
root = Root(args.mountpoint)
868+
fs = GpioSysFuse()
851869

852870
pyfuse3.init(fs, args.mountpoint, fuse_options)
853871

0 commit comments

Comments
 (0)