mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
udevd: use parse_sec() to parse --exec-delay option
This commit is contained in:
parent
216e8bbe34
commit
6b92f42934
@ -42,7 +42,7 @@ typedef struct Spawn {
|
||||
size_t result_len;
|
||||
} Spawn;
|
||||
|
||||
struct udev_event *udev_event_new(sd_device *dev, int exec_delay, sd_netlink *rtnl) {
|
||||
struct udev_event *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_netlink *rtnl) {
|
||||
struct udev_event *event;
|
||||
|
||||
assert(dev);
|
||||
@ -54,7 +54,7 @@ struct udev_event *udev_event_new(sd_device *dev, int exec_delay, sd_netlink *rt
|
||||
*event = (struct udev_event) {
|
||||
.dev = sd_device_ref(dev),
|
||||
.birth_usec = now(CLOCK_MONOTONIC),
|
||||
.exec_delay = exec_delay,
|
||||
.exec_delay_usec = exec_delay_usec,
|
||||
.rtnl = sd_netlink_ref(rtnl),
|
||||
};
|
||||
|
||||
@ -896,9 +896,9 @@ void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, usec_
|
||||
if (builtin_cmd >= 0 && builtin_cmd < _UDEV_BUILTIN_MAX)
|
||||
udev_builtin_run(event->dev, builtin_cmd, command, false);
|
||||
else {
|
||||
if (event->exec_delay > 0) {
|
||||
if (event->exec_delay_usec > 0) {
|
||||
log_debug("delay execution of '%s'", command);
|
||||
sleep(event->exec_delay);
|
||||
(void) usleep(event->exec_delay_usec);
|
||||
}
|
||||
|
||||
udev_event_spawn(event, timeout_usec, timeout_warn_usec, false, command, NULL, 0);
|
||||
|
@ -30,7 +30,7 @@ struct udev_event {
|
||||
gid_t gid;
|
||||
Hashmap *seclabel_list;
|
||||
Hashmap *run_list;
|
||||
int exec_delay;
|
||||
usec_t exec_delay_usec;
|
||||
usec_t birth_usec;
|
||||
sd_netlink *rtnl;
|
||||
unsigned builtin_run;
|
||||
@ -59,7 +59,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
|
||||
int udev_rules_apply_static_dev_perms(struct udev_rules *rules);
|
||||
|
||||
/* udev-event.c */
|
||||
struct udev_event *udev_event_new(sd_device *dev, int exec_delay, sd_netlink *rtnl);
|
||||
struct udev_event *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_netlink *rtnl);
|
||||
struct udev_event *udev_event_free(struct udev_event *event);
|
||||
ssize_t udev_event_apply_format(struct udev_event *event,
|
||||
const char *src, char *dest, size_t size,
|
||||
|
@ -63,7 +63,7 @@ static bool arg_debug = false;
|
||||
static int arg_daemonize = false;
|
||||
static int arg_resolve_names = 1;
|
||||
static unsigned arg_children_max = 0;
|
||||
static int arg_exec_delay = 0;
|
||||
static usec_t arg_exec_delay_usec = 0;
|
||||
static usec_t arg_event_timeout_usec = 180 * USEC_PER_SEC;
|
||||
static usec_t arg_event_timeout_warn_usec = 180 * USEC_PER_SEC / 3;
|
||||
|
||||
@ -409,7 +409,7 @@ static void worker_spawn(Manager *manager, struct event *event) {
|
||||
assert(dev);
|
||||
|
||||
log_debug("seq %llu running", udev_device_get_seqnum(dev));
|
||||
udev_event = udev_event_new(dev->device, arg_exec_delay, rtnl);
|
||||
udev_event = udev_event_new(dev->device, arg_exec_delay_usec, rtnl);
|
||||
if (!udev_event) {
|
||||
r = -ENOMEM;
|
||||
goto out;
|
||||
@ -1479,7 +1479,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
||||
r = safe_atoi(value, &arg_exec_delay);
|
||||
r = parse_sec(value, &arg_exec_delay_usec);
|
||||
|
||||
} else if (startswith(key, "udev."))
|
||||
log_warning("Unknown udev kernel command line option \"%s\"", key);
|
||||
@ -1549,9 +1549,9 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
log_warning("Invalid --children-max ignored: %s", optarg);
|
||||
break;
|
||||
case 'e':
|
||||
r = safe_atoi(optarg, &arg_exec_delay);
|
||||
r = parse_sec(optarg, &arg_exec_delay_usec);
|
||||
if (r < 0)
|
||||
log_warning("Invalid --exec-delay ignored: %s", optarg);
|
||||
log_warning_errno(r, "Failed to parse --exec-delay= value '%s', ignoring: %m", optarg);
|
||||
break;
|
||||
case 't':
|
||||
r = safe_atou64(optarg, &arg_event_timeout_usec);
|
||||
|
Loading…
Reference in New Issue
Block a user