[systemd-devel] [PATCH] backlight: don't hardcode path in binary
Michal Sekletar
msekleta at redhat.com
Mon Feb 24 08:19:59 PST 2014
Not that we are going to move things around but it is nicer to have paths
configurable rather than hardcoded in the source.
---
Added trailing slash. Thanks!
Makefile.am | 2 ++
src/backlight/backlight.c | 6 +++---
units/systemd-backlight at .service.in | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 2ed987d..39a63e6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -169,6 +169,7 @@ AM_CPPFLAGS = \
-DROOTPREFIX=\"$(rootprefix)\" \
-DRANDOM_SEED_DIR=\"$(localstatedir)/lib/systemd/\" \
-DRANDOM_SEED=\"$(localstatedir)/lib/systemd/random-seed\" \
+ -DBACKLIGHT_DIR=\"$(localstatedir)/lib/systemd/backlight/\" \
-DSYSTEMD_CRYPTSETUP_PATH=\"$(rootlibexecdir)/systemd-cryptsetup\" \
-DSYSTEM_GENERATOR_PATH=\"$(systemgeneratordir)\" \
-DUSER_GENERATOR_PATH=\"$(usergeneratordir)\" \
@@ -4579,6 +4580,7 @@ substitutions = \
'|PACKAGE_URL=$(PACKAGE_URL)|' \
'|RANDOM_SEED_DIR=$(localstatedir)/lib/systemd/|' \
'|RANDOM_SEED=$(localstatedir)/lib/systemd/random-seed|' \
+ '|BACKLIGHT_DIR=$(localstatedir)/lib/systemd/backlight/|' \
'|prefix=$(prefix)|' \
'|exec_prefix=$(exec_prefix)|' \
'|libdir=$(libdir)|' \
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 86f10cc..19dd86c 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -210,7 +210,7 @@ int main(int argc, char *argv[]) {
umask(0022);
- r = mkdir_p("/var/lib/systemd/backlight", 0755);
+ r = mkdir_p(BACKLIGHT_DIR, 0755);
if (r < 0) {
log_error("Failed to create backlight directory: %s", strerror(-r));
return EXIT_FAILURE;
@@ -272,9 +272,9 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
- saved = strjoin("/var/lib/systemd/backlight/", escaped_path_id, ":", escaped_ss, ":", escaped_sysname, NULL);
+ saved = strjoin(BACKLIGHT_DIR, escaped_path_id, ":", escaped_ss, ":", escaped_sysname, NULL);
} else
- saved = strjoin("/var/lib/systemd/backlight/", escaped_ss, ":", escaped_sysname, NULL);
+ saved = strjoin(BACKLIGHT_DIR, escaped_ss, ":", escaped_sysname, NULL);
if (!saved) {
log_oom();
diff --git a/units/systemd-backlight at .service.in b/units/systemd-backlight at .service.in
index 5caa5d5..6940d50 100644
--- a/units/systemd-backlight at .service.in
+++ b/units/systemd-backlight at .service.in
@@ -9,7 +9,7 @@
Description=Load/Save Screen Backlight Brightness of %I
Documentation=man:systemd-backlight at .service(8)
DefaultDependencies=no
-RequiresMountsFor=/var/lib/systemd/backlight
+RequiresMountsFor=@BACKLIGHT_DIR@
Conflicts=shutdown.target
After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-remount-fs.service
Before=sysinit.target shutdown.target
--
1.8.4.2
More information about the systemd-devel
mailing list