summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac12
-rw-r--r--src/collect/Makefile.am1
-rw-r--r--src/collect/collect.c2
-rw-r--r--src/libudev/Makefile.am1
-rw-r--r--src/libudev/libudev-device-private.c6
-rw-r--r--src/libudev/libudev-device.c2
-rw-r--r--src/libudev/libudev-enumerate.c2
-rw-r--r--src/libudev/libudev-monitor.c2
-rw-r--r--src/libudev/libudev-queue.c6
-rw-r--r--src/shared/Makefile.am1
-rw-r--r--src/shared/virt.c4
-rw-r--r--src/udev/Makefile.am1
-rw-r--r--src/udev/udev-ctrl.c2
-rw-r--r--src/udev/udev-node.c2
-rw-r--r--src/udev/udev-rules.c8
-rw-r--r--src/udev/udev-watch.c16
-rw-r--r--src/udev/udevadm-info.c12
-rw-r--r--src/udev/udevd.c20
-rw-r--r--test/Makefile.am1
-rw-r--r--test/test-udev.c2
20 files changed, 60 insertions, 43 deletions
diff --git a/configure.ac b/configure.ac
index 4fc220a24b..750042a6aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,6 +135,15 @@ AC_ARG_WITH(
[with_rootlibexecdir=${with_rootlibdir}/udev]
)
+AC_ARG_WITH(
+ [rootrundir],
+ [AS_HELP_STRING(
+ [--with-rootrundir=DIR],
+ [Configurable path for /run])],
+ [],
+ [with_rootrundir=/run]
+)
+
AC_ARG_ENABLE(
[split-usr],
[AS_HELP_STRING(
@@ -180,6 +189,8 @@ AC_SUBST([libgudev_includedir],[${includedir}/gudev-1.0/gudev])
AC_SUBST([girdir], [${datadir}/gir-1.0])
AC_SUBST([typelibsdir], [${libdir}/girepository-1.0])
+AC_SUBST([rootrundir],[${with_rootrundir}])
+
# ------------------------------------------------------------------------------
GOBJECT_INTROSPECTION_CHECK([1.31.1])
@@ -348,6 +359,7 @@ AC_MSG_RESULT([
rootlibdir: ${rootlibdir}
rootlibexecdir: ${rootlibexecdir}
datarootdir: ${datarootdir}
+ rootrundir: ${rootrundir}
udevconfdir: ${udevconfdir}
udevconffile: ${udevconffile}
diff --git a/src/collect/Makefile.am b/src/collect/Makefile.am
index 361a5a2094..a531a2d88a 100644
--- a/src/collect/Makefile.am
+++ b/src/collect/Makefile.am
@@ -1,6 +1,7 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_CPPFLAGS = \
+ -DUDEV_ROOT_RUN=\"$(rootrundir)\" \
-I $(top_srcdir)/src/shared \
-I $(top_srcdir)/src/libudev
diff --git a/src/collect/collect.c b/src/collect/collect.c
index f309f3b98e..2cf1f0054d 100644
--- a/src/collect/collect.c
+++ b/src/collect/collect.c
@@ -422,7 +422,7 @@ int main(int argc, char **argv)
if (debug)
fprintf(stderr, "Using checkpoint '%s'\n", checkpoint);
- strscpyl(tmpdir, sizeof(tmpdir), "/run/udev/collect", NULL);
+ strscpyl(tmpdir, sizeof(tmpdir), UDEV_ROOT_RUN "/udev/collect", NULL);
fd = prepare(tmpdir, checkpoint);
if (fd < 0) {
ret = 3;
diff --git a/src/libudev/Makefile.am b/src/libudev/Makefile.am
index 953199beae..c62bd75858 100644
--- a/src/libudev/Makefile.am
+++ b/src/libudev/Makefile.am
@@ -16,6 +16,7 @@ endef
AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
+ -DUDEV_ROOT_RUN=\"$(rootrundir)\" \
-DUDEV_CONF_FILE=\"$(udevconffile)\" \
-DUDEV_HWDB_BIN=\"$(udevhwdbbin)\" \
-DUDEV_VERSION=$(UDEV_VERSION) \
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c
index b7c0004563..05e772a50f 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -37,7 +37,7 @@ static void udev_device_tag(struct udev_device *dev, const char *tag, bool add)
id = udev_device_get_id_filename(dev);
if (id == NULL)
return;
- strscpyl(filename, sizeof(filename), "/run/udev/tags/", tag, "/", id, NULL);
+ strscpyl(filename, sizeof(filename), UDEV_ROOT_RUN "/udev/tags/", tag, "/", id, NULL);
if (add) {
int fd;
@@ -114,7 +114,7 @@ int udev_device_update_db(struct udev_device *udev_device)
return -1;
has_info = device_has_info(udev_device);
- strscpyl(filename, sizeof(filename), "/run/udev/data/", id, NULL);
+ strscpyl(filename, sizeof(filename), UDEV_ROOT_RUN "/udev/data/", id, NULL);
/* do not store anything for otherwise empty devices */
if (!has_info &&
@@ -182,7 +182,7 @@ int udev_device_delete_db(struct udev_device *udev_device)
id = udev_device_get_id_filename(udev_device);
if (id == NULL)
return -1;
- strscpyl(filename, sizeof(filename), "/run/udev/data/", id, NULL);
+ strscpyl(filename, sizeof(filename), UDEV_ROOT_RUN "/udev/data/", id, NULL);
unlink(filename);
return 0;
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index d510b47cd1..9e6a45efa6 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -610,7 +610,7 @@ static int udev_device_read_db(struct udev_device *udev_device)
if (id == NULL)
return -1;
- strscpyl(filename, sizeof(filename), "/run/udev/data/", id, NULL);
+ strscpyl(filename, sizeof(filename), UDEV_ROOT_RUN "/udev/data/", id, NULL);
f = fopen(filename, "re");
if (f == NULL)
diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c
index 1a880c2a34..7a9a5a4d3c 100644
--- a/src/libudev/libudev-enumerate.c
+++ b/src/libudev/libudev-enumerate.c
@@ -797,7 +797,7 @@ static int scan_devices_tags(struct udev_enumerate *udev_enumerate)
struct dirent *dent;
char path[UTIL_PATH_SIZE];
- strscpyl(path, sizeof(path), "/run/udev/tags/", udev_list_entry_get_name(list_entry), NULL);
+ strscpyl(path, sizeof(path), UDEV_ROOT_RUN "/udev/tags/", udev_list_entry_get_name(list_entry), NULL);
dir = opendir(path);
if (dir == NULL)
continue;
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 55965070b1..07b23e9b35 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -170,7 +170,7 @@ struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const c
* We do not set a netlink multicast group here, so the socket
* will not receive any messages.
*/
- if (access("/run/udev/control", F_OK) < 0 && !udev_has_devtmpfs(udev)) {
+ if (access(UDEV_ROOT_RUN "/udev/control", F_OK) < 0 && !udev_has_devtmpfs(udev)) {
log_debug("the udev service seems not to be active, disable the monitor");
group = UDEV_MONITOR_NONE;
} else
diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c
index 8ef1f3d4b0..9750057c7b 100644
--- a/src/libudev/libudev-queue.c
+++ b/src/libudev/libudev-queue.c
@@ -167,7 +167,7 @@ _public_ unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *ud
**/
_public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue)
{
- return access("/run/udev/control", F_OK) >= 0;
+ return access(UDEV_ROOT_RUN "/udev/control", F_OK) >= 0;
}
/**
@@ -180,7 +180,7 @@ _public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue)
**/
_public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue)
{
- return access("/run/udev/queue", F_OK) < 0;
+ return access(UDEV_ROOT_RUN "/udev/queue", F_OK) < 0;
}
/**
@@ -245,7 +245,7 @@ _public_ int udev_queue_get_fd(struct udev_queue *udev_queue) {
if (fd < 0)
return -errno;
- r = inotify_add_watch(fd, "/run/udev" , IN_DELETE);
+ r = inotify_add_watch(fd, UDEV_ROOT_RUN "/udev" , IN_DELETE);
if (r < 0) {
r = -errno;
close(fd);
diff --git a/src/shared/Makefile.am b/src/shared/Makefile.am
index dde3e27b56..6dfd91f4cf 100644
--- a/src/shared/Makefile.am
+++ b/src/shared/Makefile.am
@@ -1,6 +1,7 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_CPPFLAGS = \
+ -DUDEV_ROOT_RUN=\"$(rootrundir)\" \
-include $(top_builddir)/config.h
libudev_shared_la_SOURCES=\
diff --git a/src/shared/virt.c b/src/shared/virt.c
index 96b3f5671f..358b4403d2 100644
--- a/src/shared/virt.c
+++ b/src/shared/virt.c
@@ -63,11 +63,11 @@ int detect_container(const char **id) {
} else {
/* Otherwise, PID 1 dropped this information into a
- * file in /run. This is better than accessing
+ * file in UDEV_ROOT_RUN. This is better than accessing
* /proc/1/environ, since we don't need CAP_SYS_PTRACE
* for that. */
- r = read_one_line_file("/run/systemd/container", &m);
+ r = read_one_line_file(UDEV_ROOT_RUN "/systemd/container", &m);
if (r == -ENOENT) {
r = 0;
goto finish;
diff --git a/src/udev/Makefile.am b/src/udev/Makefile.am
index b6583f0070..401af01c98 100644
--- a/src/udev/Makefile.am
+++ b/src/udev/Makefile.am
@@ -6,6 +6,7 @@ AM_CPPFLAGS = \
-DUDEV_HWDB_DIR=\"$(udevhwdbdir)\" \
-DUDEV_HWDB_BIN=\"$(udevhwdbbin)\" \
-DUDEV_CONF_DIR=\"$(udevconfdir)\" \
+ -DUDEV_ROOT_RUN=\"$(rootrundir)\" \
-DUDEV_RULES_DIR=\"$(udevrulesdir)\" \
-DUDEV_LIBEXEC_DIR=\"$(udevlibexecdir)\" \
-DUDEV_VERSION=\"$(UDEV_VERSION)\" \
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 64fe9f8d5a..53925fdaa4 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -99,7 +99,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
log_warning_errno(errno, "could not set SO_PASSCRED: %m");
uctrl->saddr.un.sun_family = AF_LOCAL;
- strscpy(uctrl->saddr.un.sun_path, sizeof(uctrl->saddr.un.sun_path), "/run/udev/control");
+ strscpy(uctrl->saddr.un.sun_path, sizeof(uctrl->saddr.un.sun_path), UDEV_ROOT_RUN "/udev/control");
uctrl->addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(uctrl->saddr.un.sun_path);
return uctrl;
}
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 3ac6b9c11f..6ad9fda3bf 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -186,7 +186,7 @@ static void link_update(struct udev_device *dev, const char *slink, bool add) {
char buf[UTIL_PATH_SIZE];
util_path_encode(slink + strlen("/dev"), name_enc, sizeof(name_enc));
- strscpyl(dirname, sizeof(dirname), "/run/udev/links/", name_enc, NULL);
+ strscpyl(dirname, sizeof(dirname), UDEV_ROOT_RUN "/udev/links/", name_enc, NULL);
strscpyl(filename, sizeof(filename), dirname, "/", udev_device_get_id_filename(dev), NULL);
if (!add && unlink(filename) == 0)
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index f63b87b015..5a4792e4d5 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -50,7 +50,7 @@ struct uid_gid {
static const char* const rules_dirs[] = {
UDEV_CONF_DIR "/rules.d",
UDEV_RULES_DIR,
- "/run/udev/rules.d",
+ UDEV_ROOT_RUN "/udev/rules.d",
UDEV_LIBEXEC_DIR "/rules.d",
#ifdef HAVE_SPLIT_USR
"/lib/udev/rules.d",
@@ -2681,7 +2681,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
STRV_FOREACH(t, tags) {
_cleanup_free_ char *unescaped_filename = NULL;
- strscpyl(tags_dir, sizeof(tags_dir), "/run/udev/static_node-tags/", *t, "/", NULL);
+ strscpyl(tags_dir, sizeof(tags_dir), UDEV_ROOT_RUN "/udev/static_node-tags/", *t, "/", NULL);
r = mkdir_p(tags_dir, 0755);
if (r < 0)
return log_error_errno(r, "failed to create %s: %m", tags_dir);
@@ -2745,9 +2745,9 @@ finish:
if (f) {
fflush(f);
fchmod(fileno(f), 0644);
- if (ferror(f) || rename(path, "/run/udev/static_node-tags") < 0) {
+ if (ferror(f) || rename(path, UDEV_ROOT_RUN "/udev/static_node-tags") < 0) {
r = -errno;
- unlink("/run/udev/static_node-tags");
+ unlink(UDEV_ROOT_RUN "/udev/static_node-tags");
unlink(path);
}
fclose(f);
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c
index 6ba8674d77..b6a0d3e93d 100644
--- a/src/udev/udev-watch.c
+++ b/src/udev/udev-watch.c
@@ -50,13 +50,13 @@ void udev_watch_restore(struct udev *udev) {
if (inotify_fd < 0)
return;
- if (rename("/run/udev/watch", "/run/udev/watch.old") == 0) {
+ if (rename(UDEV_ROOT_RUN "/udev/watch", UDEV_ROOT_RUN "/udev/watch.old") == 0) {
DIR *dir;
struct dirent *ent;
- dir = opendir("/run/udev/watch.old");
+ dir = opendir(UDEV_ROOT_RUN "/udev/watch.old");
if (dir == NULL) {
- log_error_errno(errno, "unable to open old watches dir /run/udev/watch.old; old watches will not be restored: %m");
+ log_error_errno(errno, "unable to open old watches dir " UDEV_ROOT_RUN "/udev/watch.old; old watches will not be restored: %m");
return;
}
@@ -85,10 +85,10 @@ unlink:
}
closedir(dir);
- rmdir("/run/udev/watch.old");
+ rmdir(UDEV_ROOT_RUN "/udev/watch.old");
} else if (errno != ENOENT) {
- log_error_errno(errno, "unable to move watches dir /run/udev/watch; old watches will not be restored: %m");
+ log_error_errno(errno, "unable to move watches dir " UDEV_ROOT_RUN "/udev/watch; old watches will not be restored: %m");
}
}
@@ -108,7 +108,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) {
return;
}
- snprintf(filename, sizeof(filename), "/run/udev/watch/%d", wd);
+ snprintf(filename, sizeof(filename), UDEV_ROOT_RUN "/udev/watch/%d", wd);
mkdir_parents(filename, 0755);
unlink(filename);
r = symlink(udev_device_get_id_filename(dev), filename);
@@ -132,7 +132,7 @@ void udev_watch_end(struct udev *udev, struct udev_device *dev) {
log_debug("removing watch on '%s'", udev_device_get_devnode(dev));
inotify_rm_watch(inotify_fd, wd);
- snprintf(filename, sizeof(filename), "/run/udev/watch/%d", wd);
+ snprintf(filename, sizeof(filename), UDEV_ROOT_RUN "/udev/watch/%d", wd);
unlink(filename);
udev_device_set_watch_handle(dev, -1);
@@ -146,7 +146,7 @@ struct udev_device *udev_watch_lookup(struct udev *udev, int wd) {
if (inotify_fd < 0 || wd < 0)
return NULL;
- snprintf(filename, sizeof(filename), "/run/udev/watch/%d", wd);
+ snprintf(filename, sizeof(filename), UDEV_ROOT_RUN "/udev/watch/%d", wd);
len = readlink(filename, device, sizeof(device));
if (len <= 0 || (size_t)len == sizeof(device))
return NULL;
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 0e53d2e46c..5e86856142 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -225,33 +225,33 @@ static void cleanup_dir(DIR *dir, mode_t mask, int depth) {
static void cleanup_db(struct udev *udev) {
DIR *dir;
- unlink("/run/udev/queue.bin");
+ unlink(UDEV_ROOT_RUN "/udev/queue.bin");
- dir = opendir("/run/udev/data");
+ dir = opendir(UDEV_ROOT_RUN "/udev/data");
if (dir != NULL) {
cleanup_dir(dir, S_ISVTX, 1);
closedir(dir);
}
- dir = opendir("/run/udev/links");
+ dir = opendir(UDEV_ROOT_RUN "/udev/links");
if (dir != NULL) {
cleanup_dir(dir, 0, 2);
closedir(dir);
}
- dir = opendir("/run/udev/tags");
+ dir = opendir(UDEV_ROOT_RUN "/udev/tags");
if (dir != NULL) {
cleanup_dir(dir, 0, 2);
closedir(dir);
}
- dir = opendir("/run/udev/static_node-tags");
+ dir = opendir(UDEV_ROOT_RUN "/udev/static_node-tags");
if (dir != NULL) {
cleanup_dir(dir, 0, 2);
closedir(dir);
}
- dir = opendir("/run/udev/watch");
+ dir = opendir(UDEV_ROOT_RUN "/udev/watch");
if (dir != NULL) {
cleanup_dir(dir, 0, 1);
closedir(dir);
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 7eeceb42c0..1bc292fbed 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -912,13 +912,13 @@ static void event_queue_update(void) {
int r;
if (!udev_list_node_is_empty(&event_list)) {
- r = touch("/run/udev/queue");
+ r = touch(UDEV_ROOT_RUN "/udev/queue");
if (r < 0)
- log_warning_errno(r, "could not touch /run/udev/queue: %m");
+ log_warning_errno(r, "could not touch " UDEV_ROOT_RUN "/udev/queue: %m");
} else {
- r = unlink("/run/udev/queue");
+ r = unlink(UDEV_ROOT_RUN "/udev/queue");
if (r < 0 && errno != ENOENT)
- log_warning("could not unlink /run/udev/queue: %m");
+ log_warning("could not unlink " UDEV_ROOT_RUN "/udev/queue: %m");
}
}
@@ -1124,9 +1124,9 @@ int main(int argc, char *argv[]) {
udev_list_init(udev, &properties_list, true);
- r = mkdir("/run/udev", 0755);
+ r = mkdir(UDEV_ROOT_RUN "/udev", 0755);
if (r < 0 && errno != EEXIST) {
- log_error_errno(errno, "could not create /run/udev: %m");
+ log_error_errno(errno, "could not create " UDEV_ROOT_RUN "/udev: %m");
goto exit;
}
@@ -1241,10 +1241,10 @@ int main(int argc, char *argv[]) {
inotify_add_watch(fd_inotify, UDEV_CONF_DIR "/rules.d",
IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
- if (access("/run/udev/rules.d", F_OK) < 0) {
- mkdir_p("/run/udev/rules.d", 0755);
+ if (access(UDEV_ROOT_RUN "/udev/rules.d", F_OK) < 0) {
+ mkdir_p(UDEV_ROOT_RUN "/udev/rules.d", 0755);
}
- inotify_add_watch(fd_inotify, "/run/udev/rules.d",
+ inotify_add_watch(fd_inotify, UDEV_ROOT_RUN "/udev/rules.d",
IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
udev_watch_restore(udev);
@@ -1477,7 +1477,7 @@ int main(int argc, char *argv[]) {
rc = EXIT_SUCCESS;
exit:
udev_ctrl_cleanup(udev_ctrl);
- unlink("/run/udev/queue");
+ unlink(UDEV_ROOT_RUN "/udev/queue");
exit_daemonize:
if (fd_ep >= 0)
close(fd_ep);
diff --git a/test/Makefile.am b/test/Makefile.am
index 0920e5a9b4..f6d68c24b8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -2,6 +2,7 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
+ -DUDEV_ROOT_RUN=\"$(rootrundir)\" \
-DVERSION=\"@VERSION@\" \
-I $(top_srcdir)/src/shared \
-I $(top_srcdir)/src/libudev \
diff --git a/test/test-udev.c b/test/test-udev.c
index 817f08fda8..6bed8d61c4 100644
--- a/test/test-udev.c
+++ b/test/test-udev.c
@@ -54,7 +54,7 @@ static int fake_filesystems(void) {
} fakefss[] = {
{ "test/sys", "/sys", "failed to mount test /sys" },
{ "test/dev", "/dev", "failed to mount test /dev" },
- { "test/run", "/run", "failed to mount test /run" },
+ { "test/run", UDEV_ROOT_RUN, "failed to mount test " UDEV_ROOT_RUN },
{ "test/run", "/etc/udev/rules.d", "failed to mount empty /etc/udev/rules.d" },
{ "test/run", "/lib/udev/rules.d", "failed to mount empty /lib/udev/rules.d" },
};