mirror of
https://github.com/AuxXxilium/eudev.git
synced 2025-02-20 08:37:55 +07:00
Remove hardcoded path /run and configure using --with-rootrundir=
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
This commit is contained in:
parent
3cda11ed7c
commit
6a398265f3
12
configure.ac
12
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}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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) \
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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=\
|
||||
|
@ -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;
|
||||
|
@ -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)\" \
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 \
|
||||
|
@ -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" },
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user