[systemd-commits] 4 commits - Makefile.am man/systemd-udevd.service.xml man/udev.xml src/test src/udev
Kay Sievers
kay at kemper.freedesktop.org
Tue Jul 29 06:56:32 PDT 2014
Makefile.am | 3 -
man/systemd-udevd.service.xml | 18 ++++++
man/udev.xml | 7 --
src/test/test-udev.c | 5 -
src/udev/udev-builtin-blkid.c | 9 +--
src/udev/udev-builtin-btrfs.c | 3 -
src/udev/udev-builtin-firmware.c | 9 +--
src/udev/udev-builtin-hwdb.c | 9 +--
src/udev/udev-builtin-input_id.c | 12 +---
src/udev/udev-builtin-kmod.c | 18 ++----
src/udev/udev-builtin-path_id.c | 42 ++++----------
src/udev/udev-builtin-uaccess.c | 3 -
src/udev/udev-builtin-usb_id.c | 15 +----
src/udev/udev-builtin.c | 27 +++------
src/udev/udev-ctrl.c | 90 ++++++++++---------------------
src/udev/udev-event.c | 72 +++++++++++-------------
src/udev/udev-node.c | 15 +----
src/udev/udev-rules.c | 113 ++++++++++++---------------------------
src/udev/udev-watch.c | 15 +----
src/udev/udev.h | 8 +-
src/udev/udevadm-control.c | 6 --
src/udev/udevadm-info.c | 30 +++-------
src/udev/udevadm-monitor.c | 9 +--
src/udev/udevadm-settle.c | 3 -
src/udev/udevadm-test-builtin.c | 6 --
src/udev/udevadm-test.c | 5 -
src/udev/udevadm-trigger.c | 9 +--
src/udev/udevadm.c | 15 +----
src/udev/udevd.c | 93 +++++++++++++-------------------
29 files changed, 248 insertions(+), 421 deletions(-)
New commits:
commit 9ec6e95b046de71c0198cb9d17acc5462dc76c74
Author: Kay Sievers <kay at vrfy.org>
Date: Tue Jul 29 15:47:41 2014 +0200
udev: place opening { at the same line as the function declaration
diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c
index cf194c0..810f27d 100644
--- a/src/udev/udev-builtin-blkid.c
+++ b/src/udev/udev-builtin-blkid.c
@@ -34,8 +34,7 @@
#include "efivars.h"
#include "udev.h"
-static void print_property(struct udev_device *dev, bool test, const char *name, const char *value)
-{
+static void print_property(struct udev_device *dev, bool test, const char *name, const char *value) {
char s[256];
s[0] = '\0';
@@ -182,8 +181,7 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) {
return 0;
}
-static int probe_superblocks(blkid_probe pr)
-{
+static int probe_superblocks(blkid_probe pr) {
struct stat st;
int rc;
@@ -215,8 +213,7 @@ static int probe_superblocks(blkid_probe pr)
return blkid_do_safeprobe(pr);
}
-static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool test)
-{
+static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool test) {
const char *root_partition;
int64_t offset = 0;
bool noraid = false;
diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c
index 2baafe6..4e80a1d 100644
--- a/src/udev/udev-builtin-btrfs.c
+++ b/src/udev/udev-builtin-btrfs.c
@@ -35,8 +35,7 @@ struct btrfs_ioctl_vol_args {
#define BTRFS_IOCTL_MAGIC 0x94
#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, struct btrfs_ioctl_vol_args)
-static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test)
-{
+static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test) {
struct btrfs_ioctl_vol_args args;
_cleanup_close_ int fd = -1;
int err;
diff --git a/src/udev/udev-builtin-firmware.c b/src/udev/udev-builtin-firmware.c
index 8cfeed6..bd8c2fb 100644
--- a/src/udev/udev-builtin-firmware.c
+++ b/src/udev/udev-builtin-firmware.c
@@ -27,8 +27,7 @@
#include "udev.h"
-static bool set_loading(struct udev *udev, char *loadpath, const char *state)
-{
+static bool set_loading(struct udev *udev, char *loadpath, const char *state) {
FILE *ldfile;
ldfile = fopen(loadpath, "we");
@@ -41,8 +40,7 @@ static bool set_loading(struct udev *udev, char *loadpath, const char *state)
return true;
}
-static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size)
-{
+static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size) {
char *buf;
FILE *fsource = NULL, *ftarget = NULL;
bool ret = false;
@@ -74,8 +72,7 @@ exit:
return ret;
}
-static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], bool test)
-{
+static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], bool test) {
struct udev *udev = udev_device_get_udev(dev);
static const char *searchpath[] = { FIRMWARE_PATH };
char loadpath[UTIL_PATH_SIZE];
diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c
index d6aa96b..cac97e7 100644
--- a/src/udev/udev-builtin-hwdb.c
+++ b/src/udev/udev-builtin-hwdb.c
@@ -183,8 +183,7 @@ static int builtin_hwdb(struct udev_device *dev, int argc, char *argv[], bool te
}
/* called at udev startup and reload */
-static int builtin_hwdb_init(struct udev *udev)
-{
+static int builtin_hwdb_init(struct udev *udev) {
if (hwdb)
return 0;
hwdb = udev_hwdb_new(udev);
@@ -194,14 +193,12 @@ static int builtin_hwdb_init(struct udev *udev)
}
/* called on udev shutdown and reload request */
-static void builtin_hwdb_exit(struct udev *udev)
-{
+static void builtin_hwdb_exit(struct udev *udev) {
hwdb = udev_hwdb_unref(hwdb);
}
/* called every couple of seconds during event activity; 'true' if config has changed */
-static bool builtin_hwdb_validate(struct udev *udev)
-{
+static bool builtin_hwdb_validate(struct udev *udev) {
return udev_hwdb_validate(hwdb);
}
diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index 3b2e897..1a1121e 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -47,8 +47,7 @@
static void get_cap_mask(struct udev_device *dev,
struct udev_device *pdev, const char* attr,
unsigned long *bitmask, size_t bitmask_size,
- bool test)
-{
+ bool test) {
char text[4096];
unsigned i;
char* word;
@@ -96,8 +95,7 @@ static void test_pointers (struct udev_device *dev,
const unsigned long* bitmask_abs,
const unsigned long* bitmask_key,
const unsigned long* bitmask_rel,
- bool test)
-{
+ bool test) {
int is_mouse = 0;
int is_touchpad = 0;
@@ -154,8 +152,7 @@ static void test_pointers (struct udev_device *dev,
static void test_key (struct udev_device *dev,
const unsigned long* bitmask_ev,
const unsigned long* bitmask_key,
- bool test)
-{
+ bool test) {
unsigned i;
unsigned long found;
unsigned long mask;
@@ -193,8 +190,7 @@ static void test_key (struct udev_device *dev,
udev_builtin_add_property(dev, test, "ID_INPUT_KEYBOARD", "1");
}
-static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], bool test)
-{
+static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], bool test) {
struct udev_device *pdev;
unsigned long bitmask_ev[NBITS(EV_MAX)];
unsigned long bitmask_abs[NBITS(ABS_MAX)];
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c
index 5880c38..454ee2e 100644
--- a/src/udev/udev-builtin-kmod.c
+++ b/src/udev/udev-builtin-kmod.c
@@ -33,8 +33,7 @@
static struct kmod_ctx *ctx;
-static int load_module(struct udev *udev, const char *alias)
-{
+static int load_module(struct udev *udev, const char *alias) {
struct kmod_list *list = NULL;
struct kmod_list *l;
int err;
@@ -66,13 +65,11 @@ static int load_module(struct udev *udev, const char *alias)
_printf_(6,0)
static void udev_kmod_log(void *data, int priority, const char *file, int line,
- const char *fn, const char *format, va_list args)
-{
+ const char *fn, const char *format, va_list args) {
udev_main_log(data, priority, file, line, fn, format, args);
}
-static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test)
-{
+static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) {
struct udev *udev = udev_device_get_udev(dev);
int i;
@@ -93,8 +90,7 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
}
/* called at udev startup and reload */
-static int builtin_kmod_init(struct udev *udev)
-{
+static int builtin_kmod_init(struct udev *udev) {
if (ctx)
return 0;
@@ -109,15 +105,13 @@ static int builtin_kmod_init(struct udev *udev)
}
/* called on udev shutdown and reload request */
-static void builtin_kmod_exit(struct udev *udev)
-{
+static void builtin_kmod_exit(struct udev *udev) {
log_debug("unload module index");
ctx = kmod_unref(ctx);
}
/* called every couple of seconds during event activity; 'true' if config has changed */
-static bool builtin_kmod_validate(struct udev *udev)
-{
+static bool builtin_kmod_validate(struct udev *udev) {
log_debug("validate module index");
if (!ctx)
return false;
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
index 3ca59e0..ac0f71f 100644
--- a/src/udev/udev-builtin-path_id.c
+++ b/src/udev/udev-builtin-path_id.c
@@ -33,8 +33,7 @@
#include "udev.h"
_printf_(2,3)
-static int path_prepend(char **path, const char *fmt, ...)
-{
+static int path_prepend(char **path, const char *fmt, ...) {
va_list va;
char *pre;
int err = 0;
@@ -65,8 +64,7 @@ out:
** Linux only supports 32 bit luns.
** See drivers/scsi/scsi_scan.c::scsilun_to_int() for more details.
*/
-static int format_lun_number(struct udev_device *dev, char **path)
-{
+static int format_lun_number(struct udev_device *dev, char **path) {
unsigned long lun = strtoul(udev_device_get_sysnum(dev), NULL, 10);
/* address method 0, peripheral device addressing with bus id of zero */
@@ -76,8 +74,7 @@ static int format_lun_number(struct udev_device *dev, char **path)
return path_prepend(path, "lun-0x%04lx%04lx00000000", lun & 0xffff, (lun >> 16) & 0xffff);
}
-static struct udev_device *skip_subsystem(struct udev_device *dev, const char *subsys)
-{
+static struct udev_device *skip_subsystem(struct udev_device *dev, const char *subsys) {
struct udev_device *parent = dev;
while (parent != NULL) {
@@ -92,8 +89,7 @@ static struct udev_device *skip_subsystem(struct udev_device *dev, const char *s
return dev;
}
-static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent, char **path)
-{
+static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent, char **path) {
struct udev *udev = udev_device_get_udev(parent);
struct udev_device *targetdev;
struct udev_device *fcdev = NULL;
@@ -122,8 +118,7 @@ out:
return parent;
}
-static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **path)
-{
+static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **path) {
struct udev *udev = udev_device_get_udev(parent);
struct udev_device *targetdev;
struct udev_device *target_parent;
@@ -159,8 +154,7 @@ out:
return parent;
}
-static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **path)
-{
+static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **path) {
struct udev *udev = udev_device_get_udev(parent);
struct udev_device *transportdev;
struct udev_device *sessiondev = NULL;
@@ -218,8 +212,7 @@ out:
return parent;
}
-static struct udev_device *handle_scsi_default(struct udev_device *parent, char **path)
-{
+static struct udev_device *handle_scsi_default(struct udev_device *parent, char **path) {
struct udev_device *hostdev;
int host, bus, target, lun;
const char *name;
@@ -339,8 +332,7 @@ static struct udev_device *handle_scsi_hyperv(struct udev_device *parent, char *
return parent;
}
-static struct udev_device *handle_scsi(struct udev_device *parent, char **path)
-{
+static struct udev_device *handle_scsi(struct udev_device *parent, char **path) {
const char *devtype;
const char *name;
const char *id;
@@ -401,8 +393,7 @@ out:
return parent;
}
-static struct udev_device *handle_cciss(struct udev_device *parent, char **path)
-{
+static struct udev_device *handle_cciss(struct udev_device *parent, char **path) {
const char *str;
unsigned int controller, disk;
@@ -415,8 +406,7 @@ static struct udev_device *handle_cciss(struct udev_device *parent, char **path)
return parent;
}
-static void handle_scsi_tape(struct udev_device *dev, char **path)
-{
+static void handle_scsi_tape(struct udev_device *dev, char **path) {
const char *name;
/* must be the last device in the syspath */
@@ -430,8 +420,7 @@ static void handle_scsi_tape(struct udev_device *dev, char **path)
path_prepend(path, "st%c", name[2]);
}
-static struct udev_device *handle_usb(struct udev_device *parent, char **path)
-{
+static struct udev_device *handle_usb(struct udev_device *parent, char **path) {
const char *devtype;
const char *str;
const char *port;
@@ -453,8 +442,7 @@ static struct udev_device *handle_usb(struct udev_device *parent, char **path)
return parent;
}
-static struct udev_device *handle_bcma(struct udev_device *parent, char **path)
-{
+static struct udev_device *handle_bcma(struct udev_device *parent, char **path) {
const char *sysname;
unsigned int core;
@@ -466,8 +454,7 @@ static struct udev_device *handle_bcma(struct udev_device *parent, char **path)
return parent;
}
-static struct udev_device *handle_ccw(struct udev_device *parent, struct udev_device *dev, char **path)
-{
+static struct udev_device *handle_ccw(struct udev_device *parent, struct udev_device *dev, char **path) {
struct udev_device *scsi_dev;
scsi_dev = udev_device_get_parent_with_subsystem_devtype(dev, "scsi", "scsi_device");
@@ -491,8 +478,7 @@ out:
return parent;
}
-static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool test)
-{
+static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool test) {
struct udev_device *parent;
char *path = NULL;
bool some_transport = false;
diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c
index ddb0157..e2b276e 100644
--- a/src/udev/udev-builtin-uaccess.c
+++ b/src/udev/udev-builtin-uaccess.c
@@ -34,8 +34,7 @@
#include "udev.h"
#include "util.h"
-static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool test)
-{
+static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool test) {
int r;
const char *path = NULL, *seat;
bool changed_acl = false;
diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c
index 883e11e..06d4191 100644
--- a/src/udev/udev-builtin-usb_id.c
+++ b/src/udev/udev-builtin-usb_id.c
@@ -31,8 +31,7 @@
#include "udev.h"
-static void set_usb_iftype(char *to, int if_class_num, size_t len)
-{
+static void set_usb_iftype(char *to, int if_class_num, size_t len) {
const char *type = "generic";
switch (if_class_num) {
@@ -82,8 +81,7 @@ static void set_usb_iftype(char *to, int if_class_num, size_t len)
to[len-1] = '\0';
}
-static int set_usb_mass_storage_ifsubtype(char *to, const char *from, size_t len)
-{
+static int set_usb_mass_storage_ifsubtype(char *to, const char *from, size_t len) {
int type_num = 0;
char *eptr;
const char *type = "generic";
@@ -114,8 +112,7 @@ static int set_usb_mass_storage_ifsubtype(char *to, const char *from, size_t len
return type_num;
}
-static void set_scsi_type(char *to, const char *from, size_t len)
-{
+static void set_scsi_type(char *to, const char *from, size_t len) {
int type_num;
char *eptr;
const char *type = "generic";
@@ -148,8 +145,7 @@ static void set_scsi_type(char *to, const char *from, size_t len)
#define USB_DT_DEVICE 0x01
#define USB_DT_INTERFACE 0x04
-static int dev_if_packed_info(struct udev_device *dev, char *ifs_str, size_t len)
-{
+static int dev_if_packed_info(struct udev_device *dev, char *ifs_str, size_t len) {
_cleanup_free_ char *filename = NULL;
_cleanup_close_ int fd = -1;
ssize_t size;
@@ -232,8 +228,7 @@ static int dev_if_packed_info(struct udev_device *dev, char *ifs_str, size_t len
* 6.) If the device supplies a serial number, this number
* is concatenated with the identification with an underscore '_'.
*/
-static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool test)
-{
+static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool test) {
char vendor_str[64];
char vendor_str_enc[256];
const char *vendor_id;
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index fd373d0..05a2726 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -52,8 +52,7 @@ static const struct udev_builtin *builtins[] = {
#endif
};
-void udev_builtin_init(struct udev *udev)
-{
+void udev_builtin_init(struct udev *udev) {
unsigned int i;
if (initialized)
@@ -66,8 +65,7 @@ void udev_builtin_init(struct udev *udev)
initialized = true;
}
-void udev_builtin_exit(struct udev *udev)
-{
+void udev_builtin_exit(struct udev *udev) {
unsigned int i;
if (!initialized)
@@ -80,8 +78,7 @@ void udev_builtin_exit(struct udev *udev)
initialized = false;
}
-bool udev_builtin_validate(struct udev *udev)
-{
+bool udev_builtin_validate(struct udev *udev) {
unsigned int i;
for (i = 0; i < ELEMENTSOF(builtins); i++)
@@ -90,26 +87,22 @@ bool udev_builtin_validate(struct udev *udev)
return false;
}
-void udev_builtin_list(struct udev *udev)
-{
+void udev_builtin_list(struct udev *udev) {
unsigned int i;
for (i = 0; i < ELEMENTSOF(builtins); i++)
fprintf(stderr, " %-12s %s\n", builtins[i]->name, builtins[i]->help);
}
-const char *udev_builtin_name(enum udev_builtin_cmd cmd)
-{
+const char *udev_builtin_name(enum udev_builtin_cmd cmd) {
return builtins[cmd]->name;
}
-bool udev_builtin_run_once(enum udev_builtin_cmd cmd)
-{
+bool udev_builtin_run_once(enum udev_builtin_cmd cmd) {
return builtins[cmd]->run_once;
}
-enum udev_builtin_cmd udev_builtin_lookup(const char *command)
-{
+enum udev_builtin_cmd udev_builtin_lookup(const char *command) {
char name[UTIL_PATH_SIZE];
enum udev_builtin_cmd i;
char *pos;
@@ -124,8 +117,7 @@ enum udev_builtin_cmd udev_builtin_lookup(const char *command)
return UDEV_BUILTIN_MAX;
}
-int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const char *command, bool test)
-{
+int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const char *command, bool test) {
char arg[UTIL_PATH_SIZE];
int argc;
char *argv[128];
@@ -137,8 +129,7 @@ int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const c
return builtins[cmd]->cmd(dev, argc, argv, test);
}
-int udev_builtin_add_property(struct udev_device *dev, bool test, const char *key, const char *val)
-{
+int udev_builtin_add_property(struct udev_device *dev, bool test, const char *key, const char *val) {
struct udev_list_entry *entry;
entry = udev_device_add_property(dev, key, val);
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 74bbd3a..6fb5bb4 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -70,8 +70,7 @@ struct udev_ctrl_connection {
int sock;
};
-struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
-{
+struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
struct udev_ctrl *uctrl;
const int on = 1;
@@ -100,13 +99,11 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
return uctrl;
}
-struct udev_ctrl *udev_ctrl_new(struct udev *udev)
-{
+struct udev_ctrl *udev_ctrl_new(struct udev *udev) {
return udev_ctrl_new_from_fd(udev, -1);
}
-int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl)
-{
+int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) {
int err;
if (!uctrl->bound) {
@@ -135,21 +132,18 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl)
return 0;
}
-struct udev *udev_ctrl_get_udev(struct udev_ctrl *uctrl)
-{
+struct udev *udev_ctrl_get_udev(struct udev_ctrl *uctrl) {
return uctrl->udev;
}
-static struct udev_ctrl *udev_ctrl_ref(struct udev_ctrl *uctrl)
-{
+static struct udev_ctrl *udev_ctrl_ref(struct udev_ctrl *uctrl) {
if (uctrl == NULL)
return NULL;
uctrl->refcount++;
return uctrl;
}
-struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl)
-{
+struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl) {
if (uctrl == NULL)
return NULL;
uctrl->refcount--;
@@ -161,8 +155,7 @@ struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl)
return NULL;
}
-int udev_ctrl_cleanup(struct udev_ctrl *uctrl)
-{
+int udev_ctrl_cleanup(struct udev_ctrl *uctrl) {
if (uctrl == NULL)
return 0;
if (uctrl->cleanup_socket)
@@ -170,15 +163,13 @@ int udev_ctrl_cleanup(struct udev_ctrl *uctrl)
return 0;
}
-int udev_ctrl_get_fd(struct udev_ctrl *uctrl)
-{
+int udev_ctrl_get_fd(struct udev_ctrl *uctrl) {
if (uctrl == NULL)
return -EINVAL;
return uctrl->sock;
}
-struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl)
-{
+struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
struct udev_ctrl_connection *conn;
struct ucred ucred = {};
const int on = 1;
@@ -219,16 +210,14 @@ err:
return NULL;
}
-struct udev_ctrl_connection *udev_ctrl_connection_ref(struct udev_ctrl_connection *conn)
-{
+struct udev_ctrl_connection *udev_ctrl_connection_ref(struct udev_ctrl_connection *conn) {
if (conn == NULL)
return NULL;
conn->refcount++;
return conn;
}
-struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connection *conn)
-{
+struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connection *conn) {
if (conn == NULL)
return NULL;
conn->refcount--;
@@ -241,8 +230,7 @@ struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connect
return NULL;
}
-static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int intval, const char *buf, int timeout)
-{
+static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int intval, const char *buf, int timeout) {
struct udev_ctrl_msg_wire ctrl_msg_wire;
int err = 0;
@@ -296,48 +284,39 @@ out:
return err;
}
-int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority, int timeout)
-{
+int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_SET_LOG_LEVEL, priority, NULL, timeout);
}
-int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_STOP_EXEC_QUEUE, 0, NULL, timeout);
}
-int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl, int timeout)
-{
+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(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_reload(struct udev_ctrl *uctrl, int 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)
-{
+int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_SET_ENV, 0, key, timeout);
}
-int udev_ctrl_send_set_children_max(struct udev_ctrl *uctrl, int count, int timeout)
-{
+int udev_ctrl_send_set_children_max(struct udev_ctrl *uctrl, int count, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_SET_CHILDREN_MAX, count, NULL, timeout);
}
-int udev_ctrl_send_ping(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_ping(struct udev_ctrl *uctrl, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_PING, 0, NULL, timeout);
}
-int udev_ctrl_send_exit(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_exit(struct udev_ctrl *uctrl, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_EXIT, 0, NULL, timeout);
}
-struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn)
-{
+struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
struct udev_ctrl_msg *uctrl_msg;
ssize_t size;
struct cmsghdr *cmsg;
@@ -416,8 +395,7 @@ err:
return NULL;
}
-struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg)
-{
+struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg == NULL)
return NULL;
ctrl_msg->refcount--;
@@ -428,57 +406,49 @@ struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg)
return NULL;
}
-int udev_ctrl_get_set_log_level(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_set_log_level(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_SET_LOG_LEVEL)
return ctrl_msg->ctrl_msg_wire.intval;
return -1;
}
-int udev_ctrl_get_stop_exec_queue(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_stop_exec_queue(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_STOP_EXEC_QUEUE)
return 1;
return -1;
}
-int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_START_EXEC_QUEUE)
return 1;
return -1;
}
-int udev_ctrl_get_reload(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)
return 1;
return -1;
}
-const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg)
-{
+const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_SET_ENV)
return ctrl_msg->ctrl_msg_wire.buf;
return NULL;
}
-int udev_ctrl_get_set_children_max(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_set_children_max(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_SET_CHILDREN_MAX)
return ctrl_msg->ctrl_msg_wire.intval;
return -1;
}
-int udev_ctrl_get_ping(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_ping(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_PING)
return 1;
return -1;
}
-int udev_ctrl_get_exit(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_exit(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_EXIT)
return 1;
return -1;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 6ad80d5..00cd6d4 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -34,8 +34,7 @@
#include "udev.h"
#include "rtnl-util.h"
-struct udev_event *udev_event_new(struct udev_device *dev)
-{
+struct udev_event *udev_event_new(struct udev_device *dev) {
struct udev *udev = udev_device_get_udev(dev);
struct udev_event *event;
@@ -51,8 +50,7 @@ struct udev_event *udev_event_new(struct udev_device *dev)
return event;
}
-void udev_event_unref(struct udev_event *event)
-{
+void udev_event_unref(struct udev_event *event) {
if (event == NULL)
return;
udev_list_cleanup(&event->run_list);
@@ -62,8 +60,7 @@ void udev_event_unref(struct udev_event *event)
free(event);
}
-size_t udev_event_apply_format(struct udev_event *event, const char *src, char *dest, size_t size)
-{
+size_t udev_event_apply_format(struct udev_event *event, const char *src, char *dest, size_t size) {
struct udev_device *dev = event->dev;
enum subst_type {
SUBST_UNKNOWN,
@@ -377,8 +374,7 @@ out:
static int spawn_exec(struct udev_event *event,
const char *cmd, char *const argv[], char **envp, const sigset_t *sigmask,
- int fd_stdout, int fd_stderr)
-{
+ int fd_stdout, int fd_stderr) {
int err;
int fd;
@@ -424,8 +420,7 @@ static void spawn_read(struct udev_event *event,
usec_t timeout_usec,
const char *cmd,
int fd_stdout, int fd_stderr,
- char *result, size_t ressize)
-{
+ char *result, size_t ressize) {
size_t respos = 0;
int fd_ep = -1;
struct epoll_event ep_outpipe, ep_errpipe;
@@ -623,8 +618,7 @@ out:
return err;
}
-int udev_build_argv(struct udev *udev, char *cmd, int *argc, char *argv[])
-{
+int udev_build_argv(struct udev *udev, char *cmd, int *argc, char *argv[]) {
int i = 0;
char *pos;
@@ -750,8 +744,7 @@ out:
return err;
}
-static int rename_netif(struct udev_event *event)
-{
+static int rename_netif(struct udev_event *event) {
struct udev_device *dev = event->dev;
_cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
char name[IFNAMSIZ];
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 200e24f..d42af9a 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -32,8 +32,7 @@
#include "udev.h"
#include "smack-util.h"
-static int node_symlink(struct udev_device *dev, const char *node, const char *slink)
-{
+static int node_symlink(struct udev_device *dev, const char *node, const char *slink) {
struct stat stats;
char target[UTIL_PATH_SIZE];
char *s;
@@ -126,8 +125,7 @@ exit:
}
/* find device node of device with highest priority */
-static const char *link_find_prioritized(struct udev_device *dev, bool add, const char *stackdir, char *buf, size_t bufsize)
-{
+static const char *link_find_prioritized(struct udev_device *dev, bool add, const char *stackdir, char *buf, size_t bufsize) {
struct udev *udev = udev_device_get_udev(dev);
DIR *dir;
int priority = 0;
@@ -180,8 +178,7 @@ static const char *link_find_prioritized(struct udev_device *dev, bool add, cons
}
/* manage "stack of names" with possibly specified device priorities */
-static void link_update(struct udev_device *dev, const char *slink, bool add)
-{
+static void link_update(struct udev_device *dev, const char *slink, bool add) {
struct udev *udev = udev_device_get_udev(dev);
char name_enc[UTIL_PATH_SIZE];
char filename[UTIL_PATH_SIZE * 2];
@@ -224,8 +221,7 @@ static void link_update(struct udev_device *dev, const char *slink, bool add)
}
}
-void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev_old)
-{
+void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev_old) {
struct udev_list_entry *list_entry;
/* update possible left-over symlinks */
@@ -353,8 +349,7 @@ void udev_node_add(struct udev_device *dev, bool apply,
link_update(dev, udev_list_entry_get_name(list_entry), true);
}
-void udev_node_remove(struct udev_device *dev)
-{
+void udev_node_remove(struct udev_device *dev) {
struct udev_list_entry *list_entry;
char filename[UTIL_PATH_SIZE];
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index aacde38..59bc124 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -216,8 +216,7 @@ struct rule_tmp {
};
#ifdef DEBUG
-static const char *operation_str(enum operation_type type)
-{
+static const char *operation_str(enum operation_type type) {
static const char *operation_strs[] = {
[OP_UNSET] = "UNSET",
[OP_MATCH] = "match",
@@ -232,8 +231,7 @@ static const char *operation_str(enum operation_type type)
return operation_strs[type];
}
-static const char *string_glob_str(enum string_glob_type type)
-{
+static const char *string_glob_str(enum string_glob_type type) {
static const char *string_glob_strs[] = {
[GL_UNSET] = "UNSET",
[GL_PLAIN] = "plain",
@@ -246,8 +244,7 @@ static const char *string_glob_str(enum string_glob_type type)
return string_glob_strs[type];
}
-static const char *token_str(enum token_type type)
-{
+static const char *token_str(enum token_type type) {
static const char *token_strs[] = {
[TK_UNSET] = "UNSET",
[TK_RULE] = "RULE",
@@ -311,8 +308,7 @@ static const char *token_str(enum token_type type)
return token_strs[type];
}
-static void dump_token(struct udev_rules *rules, struct token *token)
-{
+static void dump_token(struct udev_rules *rules, struct token *token) {
enum token_type type = token->type;
enum operation_type op = token->key.op;
enum string_glob_type glob = token->key.glob;
@@ -421,8 +417,7 @@ static void dump_token(struct udev_rules *rules, struct token *token)
}
}
-static void dump_rules(struct udev_rules *rules)
-{
+static void dump_rules(struct udev_rules *rules) {
unsigned int i;
log_debug("dumping %u (%zu bytes) tokens, %u (%zu bytes) strings",
@@ -438,8 +433,7 @@ static inline void dump_token(struct udev_rules *rules, struct token *token) {}
static inline void dump_rules(struct udev_rules *rules) {}
#endif /* DEBUG */
-static int add_token(struct udev_rules *rules, struct token *token)
-{
+static int add_token(struct udev_rules *rules, struct token *token) {
/* grow buffer if needed */
if (rules->token_cur+1 >= rules->token_max) {
struct token *tokens;
@@ -461,8 +455,7 @@ static int add_token(struct udev_rules *rules, struct token *token)
return 0;
}
-static uid_t add_uid(struct udev_rules *rules, const char *owner)
-{
+static uid_t add_uid(struct udev_rules *rules, const char *owner) {
unsigned int i;
uid_t uid;
unsigned int off;
@@ -502,8 +495,7 @@ static uid_t add_uid(struct udev_rules *rules, const char *owner)
return uid;
}
-static gid_t add_gid(struct udev_rules *rules, const char *group)
-{
+static gid_t add_gid(struct udev_rules *rules, const char *group) {
unsigned int i;
gid_t gid;
unsigned int off;
@@ -543,8 +535,7 @@ static gid_t add_gid(struct udev_rules *rules, const char *group)
return gid;
}
-static int import_property_from_string(struct udev_device *dev, char *line)
-{
+static int import_property_from_string(struct udev_device *dev, char *line) {
char *key;
char *val;
size_t len;
@@ -607,8 +598,7 @@ static int import_property_from_string(struct udev_device *dev, char *line)
return 0;
}
-static int import_file_into_properties(struct udev_device *dev, const char *filename)
-{
+static int import_file_into_properties(struct udev_device *dev, const char *filename) {
FILE *f;
char line[UTIL_LINE_SIZE];
@@ -650,8 +640,7 @@ static int import_program_into_properties(struct udev_event *event,
return 0;
}
-static int import_parent_into_properties(struct udev_device *dev, const char *filter)
-{
+static int import_parent_into_properties(struct udev_device *dev, const char *filter) {
struct udev_device *dev_parent;
struct udev_list_entry *list_entry;
@@ -676,8 +665,7 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi
}
#define WAIT_LOOP_PER_SECOND 50
-static int wait_for_file(struct udev_device *dev, const char *file, int timeout)
-{
+static int wait_for_file(struct udev_device *dev, const char *file, int timeout) {
char filepath[UTIL_PATH_SIZE];
char devicepath[UTIL_PATH_SIZE];
struct stat stats;
@@ -711,8 +699,7 @@ static int wait_for_file(struct udev_device *dev, const char *file, int timeout)
return -1;
}
-static int attr_subst_subdir(char *attr, size_t len)
-{
+static int attr_subst_subdir(char *attr, size_t len) {
bool found = false;
if (strstr(attr, "/*/")) {
@@ -749,8 +736,7 @@ static int attr_subst_subdir(char *attr, size_t len)
return found;
}
-static int get_key(struct udev *udev, char **line, char **key, enum operation_type *op, char **value)
-{
+static int get_key(struct udev *udev, char **line, char **key, enum operation_type *op, char **value) {
char *linepos;
char *temp;
@@ -837,8 +823,7 @@ static int get_key(struct udev *udev, char **line, char **key, enum operation_ty
}
/* extract possible KEY{attr} */
-static const char *get_key_attribute(struct udev *udev, char *str)
-{
+static const char *get_key_attribute(struct udev *udev, char *str) {
char *pos;
char *attr;
@@ -858,8 +843,7 @@ static const char *get_key_attribute(struct udev *udev, char *str)
static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
enum operation_type op,
- const char *value, const void *data)
-{
+ const char *value, const void *data) {
struct token *token = &rule_tmp->token[rule_tmp->token_cur];
const char *attr = NULL;
@@ -1000,8 +984,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
return 0;
}
-static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp)
-{
+static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp) {
unsigned int i;
unsigned int start = 0;
unsigned int end = rule_tmp->token_cur;
@@ -1036,8 +1019,7 @@ static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp)
}
static int add_rule(struct udev_rules *rules, char *line,
- const char *filename, unsigned int filename_off, unsigned int lineno)
-{
+ const char *filename, unsigned int filename_off, unsigned int lineno) {
char *linepos;
const char *attr;
struct rule_tmp rule_tmp;
@@ -1508,8 +1490,7 @@ invalid:
return -1;
}
-static int parse_file(struct udev_rules *rules, const char *filename)
-{
+static int parse_file(struct udev_rules *rules, const char *filename) {
FILE *f;
unsigned int first_token;
unsigned int filename_off;
@@ -1593,8 +1574,7 @@ static int parse_file(struct udev_rules *rules, const char *filename)
return 0;
}
-struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
-{
+struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
struct udev_rules *rules;
struct udev_list file_list;
struct token end_token;
@@ -1664,8 +1644,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
return rules;
}
-struct udev_rules *udev_rules_unref(struct udev_rules *rules)
-{
+struct udev_rules *udev_rules_unref(struct udev_rules *rules) {
if (rules == NULL)
return NULL;
free(rules->tokens);
@@ -1676,16 +1655,14 @@ struct udev_rules *udev_rules_unref(struct udev_rules *rules)
return NULL;
}
-bool udev_rules_check_timestamp(struct udev_rules *rules)
-{
+bool udev_rules_check_timestamp(struct udev_rules *rules) {
if (!rules)
return false;
return paths_check_timestamp(rules_dirs, &rules->dirs_ts_usec, true);
}
-static int match_key(struct udev_rules *rules, struct token *token, const char *val)
-{
+static int match_key(struct udev_rules *rules, struct token *token, const char *val) {
char *key_value = rules_str(rules, token->key.value_off);
char *pos;
bool match = false;
@@ -1758,8 +1735,7 @@ static int match_key(struct udev_rules *rules, struct token *token, const char *
return -1;
}
-static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct udev_event *event, struct token *cur)
-{
+static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct udev_event *event, struct token *cur) {
const char *name;
char nbuf[UTIL_NAME_SIZE];
const char *value;
@@ -2485,8 +2461,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
}
}
-int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
-{
+int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
struct token *cur;
struct token *rule;
uid_t uid = 0;
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c
index cbe0c37..061bd05 100644
--- a/src/udev/udev-watch.c
+++ b/src/udev/udev-watch.c
@@ -36,8 +36,7 @@ static int inotify_fd = -1;
* set to cloexec since we need our children to be able to add
* watches for us
*/
-int udev_watch_init(struct udev *udev)
-{
+int udev_watch_init(struct udev *udev) {
inotify_fd = inotify_init1(IN_CLOEXEC);
if (inotify_fd < 0)
log_error("inotify_init failed: %m");
@@ -47,8 +46,7 @@ int udev_watch_init(struct udev *udev)
/* move any old watches directory out of the way, and then restore
* the watches
*/
-void udev_watch_restore(struct udev *udev)
-{
+void udev_watch_restore(struct udev *udev) {
if (inotify_fd < 0)
return;
@@ -94,8 +92,7 @@ unlink:
}
}
-void udev_watch_begin(struct udev *udev, struct udev_device *dev)
-{
+void udev_watch_begin(struct udev *udev, struct udev_device *dev) {
char filename[UTIL_PATH_SIZE];
int wd;
int r;
@@ -121,8 +118,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev)
udev_device_set_watch_handle(dev, wd);
}
-void udev_watch_end(struct udev *udev, struct udev_device *dev)
-{
+void udev_watch_end(struct udev *udev, struct udev_device *dev) {
int wd;
char filename[UTIL_PATH_SIZE];
@@ -142,8 +138,7 @@ void udev_watch_end(struct udev *udev, struct udev_device *dev)
udev_device_set_watch_handle(dev, -1);
}
-struct udev_device *udev_watch_lookup(struct udev *udev, int wd)
-{
+struct udev_device *udev_watch_lookup(struct udev *udev, int wd) {
char filename[UTIL_PATH_SIZE];
char device[UTIL_NAME_SIZE];
ssize_t len;
diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c
index 3a6c8ef..6e3bc2a 100644
--- a/src/udev/udevadm-control.c
+++ b/src/udev/udevadm-control.c
@@ -28,8 +28,7 @@
#include "udev.h"
#include "udev-util.h"
-static void print_help(void)
-{
+static void print_help(void) {
printf("Usage: udevadm control COMMAND\n"
" -e,--exit instruct the daemon to cleanup and exit\n"
" -l,--log-priority=LEVEL set the udev log level for the daemon\n"
@@ -42,8 +41,7 @@ static void print_help(void)
" -h,--help print this help text\n\n");
}
-static int adm_control(struct udev *udev, int argc, char *argv[])
-{
+static int adm_control(struct udev *udev, int argc, char *argv[]) {
_cleanup_udev_ctrl_unref_ struct udev_ctrl *uctrl = NULL;
int timeout = 60;
int rc = 1, c;
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 8145e6f..22d0826 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -32,8 +32,7 @@
#include "udev.h"
#include "udev-util.h"
-static bool skip_attribute(const char *name)
-{
+static bool skip_attribute(const char *name) {
static const char* const skip[] = {
"uevent",
"dev",
@@ -51,8 +50,7 @@ static bool skip_attribute(const char *name)
return false;
}
-static void print_all_attributes(struct udev_device *device, const char *key)
-{
+static void print_all_attributes(struct udev_device *device, const char *key) {
struct udev_list_entry *sysattr;
udev_list_entry_foreach(sysattr, udev_device_get_sysattr_list_entry(device)) {
@@ -84,8 +82,7 @@ static void print_all_attributes(struct udev_device *device, const char *key)
printf("\n");
}
-static int print_device_chain(struct udev_device *device)
-{
+static int print_device_chain(struct udev_device *device) {
struct udev_device *device_parent;
const char *str;
@@ -130,8 +127,7 @@ static int print_device_chain(struct udev_device *device)
return 0;
}
-static void print_record(struct udev_device *device)
-{
+static void print_record(struct udev_device *device) {
const char *str;
int i;
struct udev_list_entry *list_entry;
@@ -156,8 +152,7 @@ static void print_record(struct udev_device *device)
printf("\n");
}
-static int stat_device(const char *name, bool export, const char *prefix)
-{
+static int stat_device(const char *name, bool export, const char *prefix) {
struct stat statbuf;
if (stat(name, &statbuf) != 0)
@@ -175,8 +170,7 @@ static int stat_device(const char *name, bool export, const char *prefix)
return 0;
}
-static int export_devices(struct udev *udev)
-{
+static int export_devices(struct udev *udev) {
struct udev_enumerate *udev_enumerate;
struct udev_list_entry *list_entry;
@@ -197,8 +191,7 @@ static int export_devices(struct udev *udev)
return 0;
}
-static void cleanup_dir(DIR *dir, mode_t mask, int depth)
-{
+static void cleanup_dir(DIR *dir, mode_t mask, int depth) {
struct dirent *dent;
if (depth <= 0)
@@ -228,8 +221,7 @@ static void cleanup_dir(DIR *dir, mode_t mask, int depth)
}
}
-static void cleanup_db(struct udev *udev)
-{
+static void cleanup_db(struct udev *udev) {
DIR *dir;
unlink("/run/udev/queue.bin");
@@ -265,8 +257,7 @@ static void cleanup_db(struct udev *udev)
}
}
-static struct udev_device *find_device(struct udev *udev, const char *id, const char *prefix)
-{
+static struct udev_device *find_device(struct udev *udev, const char *id, const char *prefix) {
char name[UTIL_PATH_SIZE];
if (prefix && !startswith(id, prefix)) {
@@ -295,8 +286,7 @@ static struct udev_device *find_device(struct udev *udev, const char *id, const
return NULL;
}
-static int uinfo(struct udev *udev, int argc, char *argv[])
-{
+static int uinfo(struct udev *udev, int argc, char *argv[]) {
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
bool root = 0;
bool export = 0;
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index a54aa82..e776fb9 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -37,14 +37,12 @@
static bool udev_exit;
-static void sig_handler(int signum)
-{
+static void sig_handler(int signum) {
if (signum == SIGINT || signum == SIGTERM)
udev_exit = true;
}
-static void print_device(struct udev_device *device, const char *source, int prop)
-{
+static void print_device(struct udev_device *device, const char *source, int prop) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -75,8 +73,7 @@ static void help(void) {
" -h,--help\n\n");
}
-static int adm_monitor(struct udev *udev, int argc, char *argv[])
-{
+static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
struct sigaction act = {};
sigset_t mask;
bool prop = false;
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index fa5b0c2..fae8b4c 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -44,8 +44,7 @@ static void help(void) {
" -h,--help\n\n");
}
-static int adm_settle(struct udev *udev, int argc, char *argv[])
-{
+static int adm_settle(struct udev *udev, int argc, char *argv[]) {
static const struct option options[] = {
{ "seq-start", required_argument, NULL, '\0' }, /* removed */
{ "seq-end", required_argument, NULL, '\0' }, /* removed */
diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c
index 8041878..179f269 100644
--- a/src/udev/udevadm-test-builtin.c
+++ b/src/udev/udevadm-test-builtin.c
@@ -34,16 +34,14 @@
#include "udev.h"
-static void help(struct udev *udev)
-{
+static void help(struct udev *udev) {
fprintf(stderr, "\n");
fprintf(stderr, "Usage: udevadm builtin [--help] COMMAND SYSPATH\n");
udev_builtin_list(udev);
fprintf(stderr, "\n");
}
-static int adm_builtin(struct udev *udev, int argc, char *argv[])
-{
+static int adm_builtin(struct udev *udev, int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{}
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index 52cc26c..0f6cccf 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -32,8 +32,7 @@
#include "udev.h"
#include "udev-util.h"
-static int adm_test(struct udev *udev, int argc, char *argv[])
-{
+static int adm_test(struct udev *udev, int argc, char *argv[]) {
int resolve_names = 1;
char filename[UTIL_PATH_SIZE];
const char *action = "add";
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index 0ee27bb..668791b 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -38,8 +38,7 @@
static int verbose;
static int dry_run;
-static void exec_list(struct udev_enumerate *udev_enumerate, const char *action)
-{
+static void exec_list(struct udev_enumerate *udev_enumerate, const char *action) {
struct udev_list_entry *entry;
udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(udev_enumerate)) {
@@ -60,8 +59,7 @@ static void exec_list(struct udev_enumerate *udev_enumerate, const char *action)
}
}
-static const char *keyval(const char *str, const char **val, char *buf, size_t size)
-{
+static const char *keyval(const char *str, const char **val, char *buf, size_t size) {
char *pos;
strscpy(buf, size,str);
@@ -93,8 +91,7 @@ static void help(void) {
" -h,--help\n\n");
}
-static int adm_trigger(struct udev *udev, int argc, char *argv[])
-{
+static int adm_trigger(struct udev *udev, int argc, char *argv[]) {
static const struct option options[] = {
{ "verbose", no_argument, NULL, 'v' },
{ "dry-run", no_argument, NULL, 'n' },
diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c
index dbca369..1c06c1a 100644
--- a/src/udev/udevadm.c
+++ b/src/udev/udevadm.c
@@ -27,13 +27,11 @@
void udev_main_log(struct udev *udev, int priority,
const char *file, int line, const char *fn,
- const char *format, va_list args)
-{
+ const char *format, va_list args) {
log_metav(priority, file, line, fn, format, args);
}
-static int adm_version(struct udev *udev, int argc, char *argv[])
-{
+static int adm_version(struct udev *udev, int argc, char *argv[]) {
printf("%s\n", VERSION);
return 0;
}
@@ -63,8 +61,7 @@ static const struct udevadm_cmd *udevadm_cmds[] = {
&udevadm_help,
};
-static int adm_help(struct udev *udev, int argc, char *argv[])
-{
+static int adm_help(struct udev *udev, int argc, char *argv[]) {
unsigned int i;
fprintf(stderr, "Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS]\n");
@@ -75,16 +72,14 @@ static int adm_help(struct udev *udev, int argc, char *argv[])
return 0;
}
-static int run_command(struct udev *udev, const struct udevadm_cmd *cmd, int argc, char *argv[])
-{
+static int run_command(struct udev *udev, const struct udevadm_cmd *cmd, int argc, char *argv[]) {
if (cmd->debug)
log_set_max_level(LOG_DEBUG);
log_debug("calling: %s", cmd->name);
return cmd->cmd(udev, argc, argv);
}
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
struct udev *udev;
static const struct option options[] = {
{ "debug", no_argument, NULL, 'd' },
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index dee7a87..b75145e 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -57,8 +57,7 @@ static bool debug;
void udev_main_log(struct udev *udev, int priority,
const char *file, int line, const char *fn,
- const char *format, va_list args)
-{
+ const char *format, va_list args) {
log_metav(priority, file, line, fn, format, args);
}
@@ -106,8 +105,7 @@ struct event {
#endif
};
-static inline struct event *node_to_event(struct udev_list_node *node)
-{
+static inline struct event *node_to_event(struct udev_list_node *node) {
return container_of(node, struct event, node);
}
@@ -137,34 +135,29 @@ struct worker_message {
int exitcode;
};
-static inline struct worker *node_to_worker(struct udev_list_node *node)
-{
+static inline struct worker *node_to_worker(struct udev_list_node *node) {
return container_of(node, struct worker, node);
}
-static void event_queue_delete(struct event *event)
-{
+static void event_queue_delete(struct event *event) {
udev_list_node_remove(&event->node);
udev_device_unref(event->dev);
free(event);
}
-static struct worker *worker_ref(struct worker *worker)
-{
+static struct worker *worker_ref(struct worker *worker) {
worker->refcount++;
return worker;
}
-static void worker_cleanup(struct worker *worker)
-{
+static void worker_cleanup(struct worker *worker) {
udev_list_node_remove(&worker->node);
udev_monitor_unref(worker->monitor);
children--;
free(worker);
}
-static void worker_unref(struct worker *worker)
-{
+static void worker_unref(struct worker *worker) {
worker->refcount--;
if (worker->refcount > 0)
return;
@@ -172,8 +165,7 @@ static void worker_unref(struct worker *worker)
worker_cleanup(worker);
}
-static void worker_list_cleanup(struct udev *udev)
-{
+static void worker_list_cleanup(struct udev *udev) {
struct udev_list_node *loop, *tmp;
udev_list_node_foreach_safe(loop, tmp, &worker_list) {
@@ -183,8 +175,7 @@ static void worker_list_cleanup(struct udev *udev)
}
}
-static void worker_new(struct event *event)
-{
+static void worker_new(struct event *event) {
struct udev *udev = event->udev;
struct worker *worker;
struct udev_monitor *worker_monitor;
@@ -416,8 +407,7 @@ out:
}
}
-static void event_run(struct event *event)
-{
+static void event_run(struct event *event) {
struct udev_list_node *loop;
udev_list_node_foreach(loop, &worker_list) {
@@ -452,8 +442,7 @@ static void event_run(struct event *event)
worker_new(event);
}
-static int event_queue_insert(struct udev_device *dev)
-{
+static int event_queue_insert(struct udev_device *dev) {
struct event *event;
event = new0(struct event, 1);
@@ -482,8 +471,7 @@ static int event_queue_insert(struct udev_device *dev)
return 0;
}
-static void worker_kill(struct udev *udev)
-{
+static void worker_kill(struct udev *udev) {
struct udev_list_node *loop;
udev_list_node_foreach(loop, &worker_list) {
@@ -498,8 +486,7 @@ static void worker_kill(struct udev *udev)
}
/* lookup event for identical, parent, child device */
-static bool is_devpath_busy(struct event *event)
-{
+static bool is_devpath_busy(struct event *event) {
struct udev_list_node *loop;
size_t common;
@@ -576,8 +563,7 @@ static bool is_devpath_busy(struct event *event)
return false;
}
-static void event_queue_start(struct udev *udev)
-{
+static void event_queue_start(struct udev *udev) {
struct udev_list_node *loop;
udev_list_node_foreach(loop, &event_list) {
@@ -594,8 +580,7 @@ static void event_queue_start(struct udev *udev)
}
}
-static void event_queue_cleanup(struct udev *udev, enum event_state match_type)
-{
+static void event_queue_cleanup(struct udev *udev, enum event_state match_type) {
struct udev_list_node *loop, *tmp;
udev_list_node_foreach_safe(loop, tmp, &event_list) {
@@ -608,8 +593,7 @@ static void event_queue_cleanup(struct udev *udev, enum event_state match_type)
}
}
-static void worker_returned(int fd_worker)
-{
+static void worker_returned(int fd_worker) {
for (;;) {
struct worker_message msg;
ssize_t size;
@@ -641,8 +625,7 @@ static void worker_returned(int fd_worker)
}
/* receive the udevd message from userspace */
-static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl)
-{
+static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) {
struct udev *udev = udev_ctrl_get_udev(uctrl);
struct udev_ctrl_connection *ctrl_conn;
struct udev_ctrl_msg *ctrl_msg = NULL;
@@ -831,8 +814,7 @@ static int synthesize_change(struct udev_device *dev) {
return 0;
}
-static int handle_inotify(struct udev *udev)
-{
+static int handle_inotify(struct udev *udev) {
int nbytes, pos;
char *buf;
struct inotify_event *ev;
@@ -871,8 +853,7 @@ static int handle_inotify(struct udev *udev)
return 0;
}
-static void handle_signal(struct udev *udev, int signo)
-{
+static void handle_signal(struct udev *udev, int signo) {
switch (signo) {
case SIGINT:
case SIGTERM:
@@ -932,8 +913,7 @@ static void handle_signal(struct udev *udev, int signo)
}
}
-static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink)
-{
+static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink) {
int ctrl = -1, netlink = -1;
int fd, n;
@@ -974,8 +954,7 @@ static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink)
* udev.children-max=<number of workers> events are fully serialized if set to 1
* udev.exec-delay=<number of seconds> delay execution of every executed program
*/
-static void kernel_cmdline_options(struct udev *udev)
-{
+static void kernel_cmdline_options(struct udev *udev) {
_cleanup_free_ char *line = NULL;
char *w, *state;
size_t l;
commit 51f1ec3bbed72d5c0ee0fbcc346ed0fc82d18c96
Author: Kay Sievers <kay at vrfy.org>
Date: Tue Jul 29 15:20:42 2014 +0200
build-sys: remove systemd-coredumpctl symlink
diff --git a/Makefile.am b/Makefile.am
index 3fb3703..cd3a2d7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4086,9 +4086,6 @@ dist_bashcompletion_DATA += \
dist_zshcompletion_DATA += \
shell-completion/zsh/_coredumpctl
-GENERAL_ALIASES += \
- $(bindir)/coredumpctl $(bindir)/systemd-coredumpctl
-
sysctl_DATA = \
sysctl.d/50-coredump.conf
commit dd5eddd28a74a49607a8fffcaf960040dba98479
Author: Kay Sievers <kay at vrfy.org>
Date: Tue Jul 29 15:18:27 2014 +0200
udev: unify event timeout handling
diff --git a/man/systemd-udevd.service.xml b/man/systemd-udevd.service.xml
index 8de43b1..3053dc7 100644
--- a/man/systemd-udevd.service.xml
+++ b/man/systemd-udevd.service.xml
@@ -99,9 +99,8 @@
<varlistentry>
<term><option>--event-timeout=</option></term>
<listitem>
- <para>Wait for the event to finish up to the given
- number of seconds. After this time the event will
- be terminated. Default is 30.</para>
+ <para>Set the number of seconds to wait for events to finish. After
+ this time the event will be terminated. The default is 30 seconds.</para>
</listitem>
</varlistentry>
@@ -171,7 +170,7 @@
<listitem>
<para>Wait for events to finish up to the given number
of seconds. This option might be useful if events are
- terminated due to a timeout in large configurations.</para>
+ terminated due to kernel drivers taking too long to initialize.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/man/udev.xml b/man/udev.xml
index 4e5f8f0..123c073 100644
--- a/man/udev.xml
+++ b/man/udev.xml
@@ -516,13 +516,6 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><option>event_timeout=</option></term>
- <listitem>
- <para>Number of seconds an event waits for operations to finish before
- giving up and terminating itself.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
<term><option>string_escape=<replaceable>none|replace</replaceable></option></term>
<listitem>
<para>Usually control and other possibly unsafe characters are replaced
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index b057cc8..26d6537 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -80,7 +80,6 @@ out:
return err;
}
-
int main(int argc, char *argv[]) {
_cleanup_udev_unref_ struct udev *udev = NULL;
_cleanup_udev_event_unref_ struct udev_event *event = NULL;
@@ -155,8 +154,8 @@ int main(int argc, char *argv[]) {
}
}
- udev_event_execute_rules(event, rules, &sigmask_orig);
- udev_event_execute_run(event, NULL);
+ udev_event_execute_rules(event, USEC_PER_SEC, rules, &sigmask_orig);
+ udev_event_execute_run(event, USEC_PER_SEC, NULL);
out:
if (event != NULL && event->fd_signal >= 0)
close(event->fd_signal);
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 5213a4a..6ad80d5 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -48,7 +48,6 @@ struct udev_event *udev_event_new(struct udev_device *dev)
udev_list_init(udev, &event->seclabel_list, false);
event->fd_signal = -1;
event->birth_usec = now(CLOCK_MONOTONIC);
- event->timeout_usec = 30 * 1000 * 1000;
return event;
}
@@ -422,9 +421,10 @@ static int spawn_exec(struct udev_event *event,
}
static void spawn_read(struct udev_event *event,
- const char *cmd,
- int fd_stdout, int fd_stderr,
- char *result, size_t ressize)
+ usec_t timeout_usec,
+ const char *cmd,
+ int fd_stdout, int fd_stderr,
+ char *result, size_t ressize)
{
size_t respos = 0;
int fd_ep = -1;
@@ -467,15 +467,15 @@ static void spawn_read(struct udev_event *event,
struct epoll_event ev[4];
int i;
- if (event->timeout_usec > 0) {
+ if (timeout_usec > 0) {
usec_t age_usec;
age_usec = now(CLOCK_MONOTONIC) - event->birth_usec;
- if (age_usec >= event->timeout_usec) {
+ if (age_usec >= timeout_usec) {
log_error("timeout '%s'", cmd);
goto out;
}
- timeout = ((event->timeout_usec - age_usec) / 1000) + 1000;
+ timeout = ((timeout_usec - age_usec) / USEC_PER_MSEC) + MSEC_PER_SEC;
} else {
timeout = -1;
}
@@ -543,8 +543,9 @@ out:
close(fd_ep);
}
-static int spawn_wait(struct udev_event *event, const char *cmd, pid_t pid)
-{
+static int spawn_wait(struct udev_event *event,
+ usec_t timeout_usec,
+ const char *cmd, pid_t pid) {
struct pollfd pfd[1];
int err = 0;
@@ -555,14 +556,14 @@ static int spawn_wait(struct udev_event *event, const char *cmd, pid_t pid)
int timeout;
int fdcount;
- if (event->timeout_usec > 0) {
+ if (timeout_usec > 0) {
usec_t age_usec;
age_usec = now(CLOCK_MONOTONIC) - event->birth_usec;
- if (age_usec >= event->timeout_usec)
+ if (age_usec >= timeout_usec)
timeout = 1000;
else
- timeout = ((event->timeout_usec - age_usec) / 1000) + 1000;
+ timeout = ((timeout_usec - age_usec) / USEC_PER_MSEC) + MSEC_PER_SEC;
} else {
timeout = -1;
}
@@ -657,9 +658,9 @@ out:
}
int udev_event_spawn(struct udev_event *event,
+ usec_t timeout_usec,
const char *cmd, char **envp, const sigset_t *sigmask,
- char *result, size_t ressize)
-{
+ char *result, size_t ressize) {
struct udev *udev = event->udev;
int outpipe[2] = {-1, -1};
int errpipe[2] = {-1, -1};
@@ -728,11 +729,13 @@ int udev_event_spawn(struct udev_event *event,
errpipe[WRITE_END] = -1;
}
- spawn_read(event, cmd,
- outpipe[READ_END], errpipe[READ_END],
- result, ressize);
+ spawn_read(event,
+ timeout_usec,
+ cmd,
+ outpipe[READ_END], errpipe[READ_END],
+ result, ressize);
- err = spawn_wait(event, cmd, pid);
+ err = spawn_wait(event, timeout_usec, cmd, pid);
}
out:
@@ -776,8 +779,9 @@ static int rename_netif(struct udev_event *event)
return r;
}
-void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask)
-{
+void udev_event_execute_rules(struct udev_event *event,
+ usec_t timeout_usec,
+ struct udev_rules *rules, const sigset_t *sigmask) {
struct udev_device *dev = event->dev;
if (udev_device_get_subsystem(dev) == NULL)
@@ -791,7 +795,7 @@ void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules
if (major(udev_device_get_devnum(dev)) != 0)
udev_watch_end(event->udev, dev);
- udev_rules_apply_to_event(rules, event, sigmask);
+ udev_rules_apply_to_event(rules, event, timeout_usec, sigmask);
if (major(udev_device_get_devnum(dev)) != 0)
udev_node_remove(dev);
@@ -808,7 +812,7 @@ void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules
udev_watch_end(event->udev, event->dev_db);
}
- udev_rules_apply_to_event(rules, event, sigmask);
+ udev_rules_apply_to_event(rules, event, timeout_usec, sigmask);
/* rename a new network interface, if needed */
if (udev_device_get_ifindex(dev) > 0 && streq(udev_device_get_action(dev), "add") &&
@@ -883,8 +887,7 @@ void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules
}
}
-void udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask)
-{
+void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, const sigset_t *sigmask) {
struct udev_list_entry *list_entry;
udev_list_entry_foreach(list_entry, udev_list_get_entry(&event->run_list)) {
@@ -907,7 +910,7 @@ void udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask)
udev_event_apply_format(event, cmd, program, sizeof(program));
envp = udev_device_get_properties_envp(event->dev);
- udev_event_spawn(event, program, envp, sigmask, NULL, 0);
+ udev_event_spawn(event, timeout_usec, program, envp, sigmask, NULL, 0);
}
}
}
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 9864016..aacde38 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -137,7 +137,6 @@ enum token_type {
TK_M_PARENTS_MAX,
TK_M_TEST, /* val, mode_t */
- TK_M_EVENT_TIMEOUT, /* int */
TK_M_PROGRAM, /* val */
TK_M_IMPORT_FILE, /* val */
TK_M_IMPORT_PROG, /* val */
@@ -201,7 +200,6 @@ struct token {
uid_t uid;
gid_t gid;
int devlink_prio;
- int event_timeout;
int watch;
enum udev_builtin_cmd builtin_cmd;
};
@@ -275,7 +273,6 @@ static const char *token_str(enum token_type type)
[TK_M_PARENTS_MAX] = "M PARENTS_MAX",
[TK_M_TEST] = "M TEST",
- [TK_M_EVENT_TIMEOUT] = "M EVENT_TIMEOUT",
[TK_M_PROGRAM] = "M PROGRAM",
[TK_M_IMPORT_FILE] = "M IMPORT_FILE",
[TK_M_IMPORT_PROG] = "M IMPORT_PROG",
@@ -409,9 +406,6 @@ static void dump_token(struct udev_rules *rules, struct token *token)
case TK_A_SECLABEL:
log_debug("%s %s '%s' '%s'", token_str(type), operation_str(op), attr, value);
break;
- case TK_M_EVENT_TIMEOUT:
- log_debug("%s %u", token_str(type), token->key.event_timeout);
- break;
case TK_A_GOTO:
log_debug("%s '%s' %u", token_str(type), value, token->key.rule_goto);
break;
@@ -627,8 +621,9 @@ static int import_file_into_properties(struct udev_device *dev, const char *file
return 0;
}
-static int import_program_into_properties(struct udev_event *event, const char *program, const sigset_t *sigmask)
-{
+static int import_program_into_properties(struct udev_event *event,
+ usec_t timeout_usec,
+ const char *program, const sigset_t *sigmask) {
struct udev_device *dev = event->dev;
char **envp;
char result[UTIL_LINE_SIZE];
@@ -636,7 +631,7 @@ static int import_program_into_properties(struct udev_event *event, const char *
int err;
envp = udev_device_get_properties_envp(dev);
- err = udev_event_spawn(event, program, envp, sigmask, result, sizeof(result));
+ err = udev_event_spawn(event, timeout_usec, program, envp, sigmask, result, sizeof(result));
if (err < 0)
return err;
@@ -942,9 +937,6 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
case TK_A_MODE_ID:
token->key.mode = *(mode_t *)data;
break;
- case TK_M_EVENT_TIMEOUT:
- token->key.event_timeout = *(int *)data;
- break;
case TK_RULE:
case TK_M_PARENTS_MIN:
case TK_M_PARENTS_MAX:
@@ -1462,14 +1454,6 @@ static int add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_A_DEVLINK_PRIO, op, NULL, &prio);
}
- pos = strstr(value, "event_timeout=");
- if (pos != NULL) {
- int tout = atoi(&pos[strlen("event_timeout=")]);
-
- rule_add_key(&rule_tmp, TK_M_EVENT_TIMEOUT, op, NULL, &tout);
- }
-
- pos = strstr(value, "string_escape=");
if (pos != NULL) {
pos = &pos[strlen("string_escape=")];
if (startswith(pos, "none"))
@@ -1829,8 +1813,10 @@ enum escape_type {
ESCAPE_REPLACE,
};
-int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event, const sigset_t *sigmask)
-{
+int udev_rules_apply_to_event(struct udev_rules *rules,
+ struct udev_event *event,
+ usec_t timeout_usec,
+ const sigset_t *sigmask) {
struct token *cur;
struct token *rule;
enum escape_type esc = ESCAPE_UNSET;
@@ -2024,10 +2010,6 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
goto nomatch;
break;
}
- case TK_M_EVENT_TIMEOUT:
- log_debug("OPTIONS event_timeout=%u", cur->key.event_timeout);
- event->timeout_usec = cur->key.event_timeout * 1000 * 1000;
- break;
case TK_M_PROGRAM: {
char program[UTIL_PATH_SIZE];
char **envp;
@@ -2042,7 +2024,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
rules_str(rules, rule->rule.filename_off),
rule->rule.filename_line);
- if (udev_event_spawn(event, program, envp, sigmask, result, sizeof(result)) < 0) {
+ if (udev_event_spawn(event, timeout_usec, program, envp, sigmask, result, sizeof(result)) < 0) {
if (cur->key.op != OP_NOMATCH)
goto nomatch;
} else {
@@ -2078,7 +2060,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
rules_str(rules, rule->rule.filename_off),
rule->rule.filename_line);
- if (import_program_into_properties(event, import, sigmask) != 0)
+ if (import_program_into_properties(event, timeout_usec, import, sigmask) != 0)
if (cur->key.op != OP_NOMATCH)
goto nomatch;
break;
diff --git a/src/udev/udev.h b/src/udev/udev.h
index 62538bc..4aca70b 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -43,7 +43,6 @@ struct udev_event {
struct udev_list run_list;
int exec_delay;
usec_t birth_usec;
- usec_t timeout_usec;
int fd_signal;
unsigned int builtin_run;
unsigned int builtin_ret;
@@ -72,7 +71,7 @@ struct udev_rules;
struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names);
struct udev_rules *udev_rules_unref(struct udev_rules *rules);
bool udev_rules_check_timestamp(struct udev_rules *rules);
-int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event, const sigset_t *sigmask);
+int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event, usec_t timeout_usec, const sigset_t *sigmask);
int udev_rules_apply_static_dev_perms(struct udev_rules *rules);
/* udev-event.c */
@@ -82,10 +81,11 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char *
int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string,
char *result, size_t maxsize, int read_value);
int udev_event_spawn(struct udev_event *event,
+ usec_t timeout_usec,
const char *cmd, char **envp, const sigset_t *sigmask,
char *result, size_t ressize);
-void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset);
-void udev_event_execute_run(struct udev_event *event, const sigset_t *sigset);
+void udev_event_execute_rules(struct udev_event *event, usec_t timeout_usec, struct udev_rules *rules, const sigset_t *sigset);
+void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, const sigset_t *sigset);
int udev_build_argv(struct udev *udev, char *cmd, int *argc, char *argv[]);
/* udev-watch.c */
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index 6a2f548..52cc26c 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -138,7 +138,7 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
goto out;
}
- udev_event_execute_rules(event, rules, &sigmask_orig);
+ udev_event_execute_rules(event, 30 * USEC_PER_SEC, rules, &sigmask_orig);
udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev))
printf("%s=%s\n", udev_list_entry_get_name(entry), udev_list_entry_get_value(entry));
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index c5dd739..dee7a87 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -74,7 +74,7 @@ static bool reload;
static int children;
static int children_max;
static int exec_delay;
-static int event_timeout = 30;
+static usec_t event_timeout_usec = 30 * USEC_PER_SEC;
static sigset_t sigmask_orig;
static UDEV_LIST(event_list);
static UDEV_LIST(worker_list);
@@ -313,13 +313,10 @@ static void worker_new(struct event *event)
}
}
- if (event_timeout != 30)
- udev_event->timeout_usec = event_timeout * USEC_PER_SEC;
-
/* apply rules, create node, symlinks */
- udev_event_execute_rules(udev_event, rules, &sigmask_orig);
+ udev_event_execute_rules(udev_event, event_timeout_usec, rules, &sigmask_orig);
- udev_event_execute_run(udev_event, &sigmask_orig);
+ udev_event_execute_run(udev_event, event_timeout_usec, &sigmask_orig);
/* apply/restore inotify watch */
if (udev_event->inotify_watch) {
@@ -1014,15 +1011,14 @@ static void kernel_cmdline_options(struct udev *udev)
} else if (startswith(opt, "udev.exec-delay=")) {
exec_delay = strtoul(opt + 16, NULL, 0);
} else if (startswith(opt, "udev.event-timeout=")) {
- event_timeout = strtoul(opt + 16, NULL, 0);
+ event_timeout_usec = strtoul(opt + 16, NULL, 0) * USEC_PER_SEC;
}
free(s);
}
}
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
struct udev *udev;
sigset_t mask;
int daemonize = false;
@@ -1077,7 +1073,7 @@ int main(int argc, char *argv[])
exec_delay = strtoul(optarg, NULL, 0);
break;
case 't':
- event_timeout = strtoul(optarg, NULL, 0);
+ event_timeout_usec = strtoul(optarg, NULL, 0) * USEC_PER_SEC;
break;
case 'D':
debug = true;
@@ -1103,6 +1099,7 @@ int main(int argc, char *argv[])
" --debug\n"
" --children-max=<maximum number of workers>\n"
" --exec-delay=<seconds to wait before executing RUN=>\n"
+ " --event-timeout=<seconds to wait before terminating an event>\n"
" --resolve-names=early|late|never\n"
" --version\n"
" --help\n"
@@ -1416,20 +1413,17 @@ int main(int argc, char *argv[])
if (worker->state != WORKER_RUNNING)
continue;
- if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > event_timeout * USEC_PER_SEC) {
- log_error("worker [%u] %s timeout; kill it", worker->pid,
- worker->event ? worker->event->devpath : "<idle>");
+ if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > event_timeout_usec) {
+ log_error("worker [%u] %s timeout; kill it", worker->pid, worker->event->devpath);
kill(worker->pid, SIGKILL);
worker->state = WORKER_KILLED;
/* drop reference taken for state 'running' */
worker_unref(worker);
- if (worker->event) {
- log_error("seq %llu '%s' killed", udev_device_get_seqnum(worker->event->dev), worker->event->devpath);
- worker->event->exitcode = -64;
- event_queue_delete(worker->event);
- worker->event = NULL;
- }
+ log_error("seq %llu '%s' killed", udev_device_get_seqnum(worker->event->dev), worker->event->devpath);
+ worker->event->exitcode = -64;
+ event_queue_delete(worker->event);
+ worker->event = NULL;
}
}
commit 9719859c07aa13539ed2cd4b31972cd30f678543
Author: Hannes Reinecke <hare at suse.de>
Date: Tue Jul 29 09:06:14 2014 +0200
udevd: add --event-timeout commandline option
Some events take longer than the default 30 seconds. Killing those
events will leave the machine halfway configured.
Add a commandline option '--event-timeout' to handle these cases.
diff --git a/man/systemd-udevd.service.xml b/man/systemd-udevd.service.xml
index f44b7a0..8de43b1 100644
--- a/man/systemd-udevd.service.xml
+++ b/man/systemd-udevd.service.xml
@@ -44,6 +44,7 @@
<arg><option>--debug</option></arg>
<arg><option>--children-max=</option></arg>
<arg><option>--exec-delay=</option></arg>
+ <arg><option>--event-timeout=</option></arg>
<arg><option>--resolve-names=early|late|never</option></arg>
<arg><option>--version</option></arg>
<arg><option>--help</option></arg>
@@ -96,6 +97,15 @@
</varlistentry>
<varlistentry>
+ <term><option>--event-timeout=</option></term>
+ <listitem>
+ <para>Wait for the event to finish up to the given
+ number of seconds. After this time the event will
+ be terminated. Default is 30.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--resolve-names=</option></term>
<listitem>
<para>Specify when systemd-udevd should resolve names of users and groups.
@@ -156,6 +166,15 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><varname>udev.event-timeout=</varname></term>
+ <term><varname>rd.udev.event-timeout=</varname></term>
+ <listitem>
+ <para>Wait for events to finish up to the given number
+ of seconds. This option might be useful if events are
+ terminated due to a timeout in large configurations.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><varname>net.ifnames=</varname></term>
<listitem>
<para>Network interfaces are renamed to give them predictable names
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index db935d6..c5dd739 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -74,6 +74,7 @@ static bool reload;
static int children;
static int children_max;
static int exec_delay;
+static int event_timeout = 30;
static sigset_t sigmask_orig;
static UDEV_LIST(event_list);
static UDEV_LIST(worker_list);
@@ -312,6 +313,9 @@ static void worker_new(struct event *event)
}
}
+ if (event_timeout != 30)
+ udev_event->timeout_usec = event_timeout * USEC_PER_SEC;
+
/* apply rules, create node, symlinks */
udev_event_execute_rules(udev_event, rules, &sigmask_orig);
@@ -1009,6 +1013,8 @@ static void kernel_cmdline_options(struct udev *udev)
children_max = strtoul(opt + 18, NULL, 0);
} else if (startswith(opt, "udev.exec-delay=")) {
exec_delay = strtoul(opt + 16, NULL, 0);
+ } else if (startswith(opt, "udev.event-timeout=")) {
+ event_timeout = strtoul(opt + 16, NULL, 0);
}
free(s);
@@ -1026,6 +1032,7 @@ int main(int argc, char *argv[])
{ "debug", no_argument, NULL, 'D' },
{ "children-max", required_argument, NULL, 'c' },
{ "exec-delay", required_argument, NULL, 'e' },
+ { "event-timeout", required_argument, NULL, 't' },
{ "resolve-names", required_argument, NULL, 'N' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
@@ -1069,6 +1076,9 @@ int main(int argc, char *argv[])
case 'e':
exec_delay = strtoul(optarg, NULL, 0);
break;
+ case 't':
+ event_timeout = strtoul(optarg, NULL, 0);
+ break;
case 'D':
debug = true;
log_set_max_level(LOG_DEBUG);
@@ -1406,7 +1416,7 @@ int main(int argc, char *argv[])
if (worker->state != WORKER_RUNNING)
continue;
- if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > 30 * USEC_PER_SEC) {
+ if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > event_timeout * USEC_PER_SEC) {
log_error("worker [%u] %s timeout; kill it", worker->pid,
worker->event ? worker->event->devpath : "<idle>");
kill(worker->pid, SIGKILL);
More information about the systemd-commits
mailing list