summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorDavid Cortarello <dcortarello@gmail.com>2015-03-25 01:48:36 -0300
committerAnthony G. Basile <blueness@gentoo.org>2015-03-27 11:34:13 -0400
commit6a398265f3bd30a252cba2b1ada04ff1c617cf96 (patch)
tree2a0761e4c4b46b8bb433e24032a4353cab3bed58 /src/udev
parent3cda11ed7c226adc9f4818cecfb21974239d632b (diff)
Remove hardcoded path /run and configure using --with-rootrundir=
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev')
-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
7 files changed, 31 insertions, 30 deletions
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);