-
Notifications
You must be signed in to change notification settings - Fork 1
Add systemd integration via a template unit #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # SPDX-License-Identifier: CC0-1.0 | ||
| # SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | ||
|
|
||
| # Template unit: the instance name is the systemd-escaped mountpoint, e.g. | ||
| # | ||
| # systemctl enable --now gpiod-sysfs-proxy@run-gpio.service | ||
| # systemctl enable --now gpiod-sysfs-proxy@sys-class-gpio.service | ||
| # | ||
| # Generate the instance name from a path with: | ||
| # | ||
| # systemd-escape --path /run/gpio | ||
| # systemd-escape --path /sys/class/gpio | ||
| # | ||
| # Inside the unit %I expands back to the unescaped mountpoint path. | ||
| # | ||
| # Mounting over /sys/class/gpio only works when that directory already exists | ||
| # (i.e. the kernel sysfs GPIO interface is enabled). To expose it on a kernel | ||
| # where sysfs GPIO is disabled, see the overlay .mount example units shipped | ||
| # alongside this file. | ||
|
|
||
| [Unit] | ||
| Description=User-space, libgpiod-based GPIO sysfs compatibility layer at %I | ||
|
|
||
| [Service] | ||
| RuntimeDirectory=gpio | ||
| Type=simple | ||
| ExecStart=/usr/bin/gpiod-sysfs-proxy %I -f -o allow_other -o default_permissions | ||
| ExecStop=/bin/umount %I | ||
| Restart=always | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
14 changes: 14 additions & 0 deletions
14
share/gpiod-sysfs-proxy@sys-class-gpio.service.d/overlay.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # SPDX-License-Identifier: CC0-1.0 | ||
| # SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | ||
|
|
||
| # Instance-specific drop-in: only the sys-class-gpio instance needs the | ||
| # /sys/class overlay. Pulling the mounts in here (rather than in the template) | ||
| # keeps other instances, e.g. gpiod-sysfs-proxy@run-gpio.service, free of it. | ||
| # | ||
| # The mount units carry ConditionPathExists=!/sys/class/gpio, so on a kernel | ||
| # where the sysfs GPIO interface is enabled they become no-ops and the proxy | ||
| # simply mounts over the existing directory. | ||
|
|
||
| [Unit] | ||
| Requires=run-gpio-sys.mount sys-class.mount | ||
| After=run-gpio-sys.mount sys-class.mount |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # SPDX-License-Identifier: CC0-1.0 | ||
| # SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | ||
|
|
||
| [Unit] | ||
| Description=Remount of sysfs for gpiod-sysfs-proxy | ||
| PartOf=gpiod-sysfs-proxy@sys-class-gpio.service | ||
| ConditionPathExists=!/sys/class/gpio | ||
|
|
||
| [Mount] | ||
| DirectoryMode=0700 | ||
| What=sysfs | ||
| Where=/run/gpio/sys | ||
| Type=sysfs | ||
| Options=nosuid,nodev,noexec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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=Overlay on top of /sys/class adding the gpio class directory | ||
| Before=gpiod-sysfs-proxy@sys-class-gpio.service | ||
| After=run-gpio-sys.mount | ||
| PartOf=gpiod-sysfs-proxy@sys-class-gpio.service | ||
| 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.