Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ For a complete list of available command-line options, please run:
gpiod-sysfs-proxy --help
```

## Integration

To integrate with systemd, there are sample service files under the `share`
directory.

## Caveats

Due to how FUSE works, there are certain limitations to the level of
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ authors = [
Homepage = "https://github.com/brgl/gpiod-sysfs-proxy"
Issues = "https://github.com/brgl/gpiod-sysfs-proxy/issues"

[tool.setuptools.data-files]
"lib/systemd/system" = [
"share/gpiod-sysfs-proxy.service",
"share/run-gpio-sys.mount",
"share/sys-class.mount",
]
"lib/systemd/system/sysinit.target.wants" = [
"share/sysinit.target.wants/run-gpio-sys.mount",
"share/sysinit.target.wants/sys-class.mount",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This installs these files unconditionally. In my meta-openembedded recipe I only do this if the user selected the - admittedly quite intrusive - sys-class-mount PACKAGECONFIG switch. Should we have a corresponding switch here as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This installs these files unconditionally. In my meta-openembedded recipe I only do this if the user selected the - admittedly quite intrusive - sys-class-mount PACKAGECONFIG switch. Should we have a corresponding switch here as well?

Not sure if we can have a switch here without a lot of fudging around - that's why I made the python package install the most useful default service by default.

Do we really need to support both paths? I don't know enough about this really, but I suspect it'd make sense to support one by default in distros like debian etc?

Perhaps it'd make sense to install using a default path and push users to README for information to use alternate paths? again, I am not entirely sure here, but surely for modern installs there is a sensibe default? :-)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I never really considered this could be packaged in Debian. :) Is mounting an overlay over /sys/class something Debian would accept as the default? Sounds quite risky to me.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me, if you install this you kind of need it to work :-)

Alternatively in the python install we could install 2x systemd services (one for each path, or a template and 2x services extending the template) to a doc dir (e.g. not install them), then in yocto/debian we could install the script by default and have the services as as separate packages, and let users choose which package they want to install (and in yocto you can keep the same var, just install different services to the right place) ?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or (for yocto) possibly two mutually-exclusive packages: gpiod-sysfs-proxy-systemd-overlay and gpiod-sysfs-proxy-systemd-tmp with the former installing the /sys/class overlay units?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, and in this python installer i should put the service files into a documentation dir.

Need to figure out how to make the services extend another service so we don't duplicate code.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be too much to ask to also update the yocto recipe if you're doing it? :)

]

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
17 changes: 17 additions & 0 deletions share/gpiod-sysfs-proxy.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

[Unit]
Description=User-space, libgpiod-based compatibility layer for linux GPIO sysfs interface

# There are two standard locations for the mountpoint `/sys/class/gpio` and `/run/gpio`.
# This example service uses the former.
[Service]
RuntimeDirectory=gpio
Type=simple
ExecStart=/usr/bin/gpiod-sysfs-proxy /sys/class/gpio -f -o nonempty -o allow_other -o default_permissions -o entry_timeout=0 -o attr_timeout=0
ExecStop=/bin/umount /sys/class/gpio
Restart=always

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions share/run-gpio-sys.mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

[Unit]
Description=Remount of sysfs for gpiod-sysfs-proxy
ConditionPathExists=!/sys/class/gpio

[Mount]
DirectoryMode=0700
What=sysfs
Where=/run/gpio/sys
Type=sysfs
Options=nosuid,nodev,noexec
16 changes: 16 additions & 0 deletions share/sys-class.mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

[Unit]
Description=Overlay on top of /sys/class adding the gpio class directory
Before=gpiod-sysfs-proxy.service
After=run-gpio-sys.mount
ConditionPathExists=!/sys/class/gpio

[Mount]
RuntimeDirectory=gpio/class/gpio
DirectoryMode=0755
What=overlay
Where=/sys/class
Type=overlay
Options=upperdir=/run/gpio/class,lowerdir=/run/gpio/sys/class,workdir=/run/gpio/work,ro,nosuid,nodev,noexec,relatime
1 change: 1 addition & 0 deletions share/sysinit.target.wants/run-gpio-sys.mount
1 change: 1 addition & 0 deletions share/sysinit.target.wants/sys-class.mount