summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--udev/udev-builtin-kmod.c19
-rw-r--r--udev/udev-ctrl.c10
-rw-r--r--udev/udev-rules.c5
-rw-r--r--udev/udev.h6
-rw-r--r--udev/udevadm-control.c9
-rw-r--r--udev/udevadm-test-builtin.c1
-rw-r--r--udev/udevadm.xml9
-rw-r--r--udev/udevd.c34
8 files changed, 50 insertions, 43 deletions
diff --git a/udev/udev-builtin-kmod.c b/udev/udev-builtin-kmod.c
index 8e7a50a020..6f3e2589c2 100644
--- a/udev/udev-builtin-kmod.c
+++ b/udev/udev-builtin-kmod.c
@@ -321,11 +321,17 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
struct udev *udev = udev_device_get_udev(dev);
int i;
- if (!ctx)
- return EXIT_FAILURE;
+ if (!ctx) {
+ ctx = kmod_new(NULL, NULL);
+ if (!ctx)
+ return -ENOMEM;
- if (argc < 3) {
- err(udev, "missing command + argument\n");
+ info(udev, "load module index\n");
+ kmod_load_resources(ctx);
+ }
+
+ if (argc < 3 || strcmp(argv[1], "load")) {
+ err(udev, "expect: %s load <module>\n", argv[0]);
return EXIT_FAILURE;
}
@@ -339,12 +345,15 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
static int builtin_kmod_init(struct udev *udev)
{
- kmod_unref(ctx);
+ if (ctx)
+ return 0;
+
ctx = kmod_new(NULL, NULL);
if (!ctx)
return -ENOMEM;
info(udev, "load module index\n");
+ kmod_load_resources(ctx);
return 0;
}
diff --git a/udev/udev-ctrl.c b/udev/udev-ctrl.c
index e4348c314d..fab1108de0 100644
--- a/udev/udev-ctrl.c
+++ b/udev/udev-ctrl.c
@@ -30,7 +30,7 @@ enum udev_ctrl_msg_type {
UDEV_CTRL_SET_LOG_LEVEL,
UDEV_CTRL_STOP_EXEC_QUEUE,
UDEV_CTRL_START_EXEC_QUEUE,
- UDEV_CTRL_RELOAD_RULES,
+ UDEV_CTRL_RELOAD,
UDEV_CTRL_SET_ENV,
UDEV_CTRL_SET_CHILDREN_MAX,
UDEV_CTRL_PING,
@@ -310,9 +310,9 @@ int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl, int timeout)
return ctrl_send(uctrl, UDEV_CTRL_START_EXEC_QUEUE, 0, NULL, timeout);
}
-int udev_ctrl_send_reload_rules(struct udev_ctrl *uctrl, int timeout)
+int udev_ctrl_send_reload(struct udev_ctrl *uctrl, int timeout)
{
- return ctrl_send(uctrl, UDEV_CTRL_RELOAD_RULES, 0, NULL, timeout);
+ return ctrl_send(uctrl, UDEV_CTRL_RELOAD, 0, NULL, timeout);
}
int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key, int timeout)
@@ -458,9 +458,9 @@ int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg)
return -1;
}
-int udev_ctrl_get_reload_rules(struct udev_ctrl_msg *ctrl_msg)
+int udev_ctrl_get_reload(struct udev_ctrl_msg *ctrl_msg)
{
- if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_RELOAD_RULES)
+ if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_RELOAD)
return 1;
return -1;
}
diff --git a/udev/udev-rules.c b/udev/udev-rules.c
index 4226d0b4e0..aa750219da 100644
--- a/udev/udev-rules.c
+++ b/udev/udev-rules.c
@@ -1890,16 +1890,17 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
return rules;
}
-void udev_rules_unref(struct udev_rules *rules)
+struct udev_rules *udev_rules_unref(struct udev_rules *rules)
{
if (rules == NULL)
- return;
+ return NULL;
free(rules->tokens);
free(rules->buf);
free(rules->trie_nodes);
free(rules->uids);
free(rules->gids);
free(rules);
+ return NULL;
}
static int match_key(struct udev_rules *rules, struct token *token, const char *val)
diff --git a/udev/udev.h b/udev/udev.h
index 430958a457..7bd2228a6b 100644
--- a/udev/udev.h
+++ b/udev/udev.h
@@ -66,7 +66,7 @@ struct udev_watch {
/* udev-rules.c */
struct udev_rules;
struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names);
-void udev_rules_unref(struct udev_rules *rules);
+struct udev_rules *udev_rules_unref(struct udev_rules *rules);
int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event, const sigset_t *sigmask);
void udev_rules_apply_static_dev_perms(struct udev_rules *rules);
@@ -109,7 +109,7 @@ int udev_ctrl_get_fd(struct udev_ctrl *uctrl);
int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority, int timeout);
int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl, int timeout);
int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl, int timeout);
-int udev_ctrl_send_reload_rules(struct udev_ctrl *uctrl, int timeout);
+int udev_ctrl_send_reload(struct udev_ctrl *uctrl, int timeout);
int udev_ctrl_send_ping(struct udev_ctrl *uctrl, int timeout);
int udev_ctrl_send_exit(struct udev_ctrl *uctrl, int timeout);
int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key, int timeout);
@@ -125,7 +125,7 @@ struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg);
int udev_ctrl_get_set_log_level(struct udev_ctrl_msg *ctrl_msg);
int udev_ctrl_get_stop_exec_queue(struct udev_ctrl_msg *ctrl_msg);
int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg);
-int udev_ctrl_get_reload_rules(struct udev_ctrl_msg *ctrl_msg);
+int udev_ctrl_get_reload(struct udev_ctrl_msg *ctrl_msg);
int udev_ctrl_get_ping(struct udev_ctrl_msg *ctrl_msg);
int udev_ctrl_get_exit(struct udev_ctrl_msg *ctrl_msg);
const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg);
diff --git a/udev/udevadm-control.c b/udev/udevadm-control.c
index 130a71b3d0..dd1d5d783f 100644
--- a/udev/udevadm-control.c
+++ b/udev/udevadm-control.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2008 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2005-2011 Kay Sievers <kay.sievers@vrfy.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,9 +32,9 @@ static void print_help(void)
printf("Usage: udevadm control COMMAND\n"
" --exit instruct the daemon to cleanup and exit\n"
" --log-priority=<level> set the udev log level for the daemon\n"
- " --stop-exec-queue keep udevd from executing events, queue only\n"
+ " --stop-exec-queue do not execute events, queue only\n"
" --start-exec-queue execute events, flush queue\n"
- " --reload-rules reloads the rules files\n"
+ " --reload reload rules and databases\n"
" --property=<KEY>=<value> set a global property for all events\n"
" --children-max=<N> maximum number of children\n"
" --timeout=<seconds> maximum time to block for a reply\n"
@@ -52,6 +52,7 @@ static int adm_control(struct udev *udev, int argc, char *argv[])
{ "log-priority", required_argument, NULL, 'l' },
{ "stop-exec-queue", no_argument, NULL, 's' },
{ "start-exec-queue", no_argument, NULL, 'S' },
+ { "reload", no_argument, NULL, 'R' },
{ "reload-rules", no_argument, NULL, 'R' },
{ "property", required_argument, NULL, 'p' },
{ "env", required_argument, NULL, 'p' },
@@ -111,7 +112,7 @@ static int adm_control(struct udev *udev, int argc, char *argv[])
rc = 0;
break;
case 'R':
- if (udev_ctrl_send_reload_rules(uctrl, timeout) < 0)
+ if (udev_ctrl_send_reload(uctrl, timeout) < 0)
rc = 2;
else
rc = 0;
diff --git a/udev/udevadm-test-builtin.c b/udev/udevadm-test-builtin.c
index 66043c76d6..253fcd0c8f 100644
--- a/udev/udevadm-test-builtin.c
+++ b/udev/udevadm-test-builtin.c
@@ -124,4 +124,5 @@ const struct udevadm_cmd udevadm_test_builtin = {
.name = "test-builtin",
.cmd = adm_builtin,
.help = "test a built-in command",
+ .debug = true,
};
diff --git a/udev/udevadm.xml b/udev/udevadm.xml
index 09c22c44b1..455ce80ca9 100644
--- a/udev/udevadm.xml
+++ b/udev/udevadm.xml
@@ -339,12 +339,11 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--reload-rules</option></term>
+ <term><option>--reload</option></term>
<listitem>
- <para>Signal udevd to reload the rules files.
- The udev daemon detects changes automatically, this option is
- usually not needed. Reloading rules does not apply any changes
- to already existing devices.</para>
+ <para>Signal udevd to reload the rules files and other databases like the kernel
+ module index. Reloading rules and databases does not apply any changes to already
+ existing devices; the new configuration will only be applied to new events.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/udev/udevd.c b/udev/udevd.c
index 3a39b6a50a..299f5d3f59 100644
--- a/udev/udevd.c
+++ b/udev/udevd.c
@@ -76,7 +76,7 @@ static int fd_signal = -1;
static int fd_ep = -1;
static int fd_inotify = -1;
static bool stop_exec_queue;
-static bool reload_config;
+static bool reload;
static int children;
static int children_max;
static int exec_delay;
@@ -662,9 +662,9 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl)
stop_exec_queue = false;
}
- if (udev_ctrl_get_reload_rules(ctrl_msg) > 0) {
- info(udev, "udevd message (RELOAD_RULES) received\n");
- reload_config = true;
+ if (udev_ctrl_get_reload(ctrl_msg) > 0) {
+ info(udev, "udevd message (RELOAD) received\n");
+ reload = true;
}
str = udev_ctrl_get_set_env(ctrl_msg);
@@ -745,7 +745,7 @@ static int handle_inotify(struct udev *udev)
continue;
if (strlen(s) != strlen(".rules"))
continue;
- reload_config = true;
+ reload = true;
continue;
}
@@ -831,7 +831,7 @@ static void handle_signal(struct udev *udev, int signo)
}
break;
case SIGHUP:
- reload_config = true;
+ reload = true;
break;
}
}
@@ -1658,8 +1658,12 @@ int main(int argc, char *argv[])
}
/* start new events */
- if (!udev_list_node_is_empty(&event_list) && !udev_exit && !stop_exec_queue)
- event_queue_start(udev);
+ if (!udev_list_node_is_empty(&event_list) && !udev_exit && !stop_exec_queue) {
+ if (rules == NULL)
+ rules = udev_rules_new(udev, resolve_names);
+ if (rules != NULL)
+ event_queue_start(udev);
+ }
if (is_signal) {
struct signalfd_siginfo fdsi;
@@ -1691,19 +1695,11 @@ int main(int argc, char *argv[])
ctrl_conn = handle_ctrl_msg(udev_ctrl);
/* rules changed, set by inotify or a HUP signal */
- if (reload_config) {
- struct udev_rules *rules_new;
-
+ if (reload) {
worker_kill(udev, 0);
- rules_new = udev_rules_new(udev, resolve_names);
- if (rules_new != NULL) {
- udev_rules_unref(rules);
- rules = rules_new;
- }
- reload_config = 0;
-
+ rules = udev_rules_unref(rules);
udev_builtin_exit(udev);
- udev_builtin_init(udev);
+ reload = 0;
}
}