From 3fc2e9a247cd6e2725168d49b908b6a0821c2516 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 14 Oct 2018 01:22:14 +0900 Subject: [PATCH] udev: replace udev_device by sd_device from prototype of udev builtin commands --- src/udev/udev-builtin-blkid.c | 3 +-- src/udev/udev-builtin-btrfs.c | 4 ++-- src/udev/udev-builtin-hwdb.c | 3 +-- src/udev/udev-builtin-input_id.c | 4 ++-- src/udev/udev-builtin-keyboard.c | 3 +-- src/udev/udev-builtin-kmod.c | 2 +- src/udev/udev-builtin-net_id.c | 3 +-- src/udev/udev-builtin-net_setup_link.c | 3 +-- src/udev/udev-builtin-path_id.c | 3 +-- src/udev/udev-builtin-uaccess.c | 3 +-- src/udev/udev-builtin-usb_id.c | 3 +-- src/udev/udev-builtin.c | 3 ++- src/udev/udev-builtin.h | 5 +++-- 13 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 674bdee285d..f521357aba3 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -210,14 +210,13 @@ 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(sd_device *dev, int argc, char *argv[], bool test) { const char *devnode, *root_partition = NULL, *data, *name; _cleanup_(blkid_free_probep) blkid_probe pr = NULL; bool noraid = false, is_gpt = false; _cleanup_close_ int fd = -1; int64_t offset = 0; int nvals, i, r; - sd_device *dev = _dev->device; static const struct option options[] = { { "offset", required_argument, NULL, 'o' }, diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c index 4d6787e3afe..93fc29f56c1 100644 --- a/src/udev/udev-builtin-btrfs.c +++ b/src/udev/udev-builtin-btrfs.c @@ -15,7 +15,7 @@ #include "udev-builtin.h" #include "util.h" -static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test) { +static int builtin_btrfs(sd_device *dev, int argc, char *argv[], bool test) { struct btrfs_ioctl_vol_args args = {}; _cleanup_close_ int fd = -1; int err; @@ -32,7 +32,7 @@ static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool t if (err < 0) return EXIT_FAILURE; - udev_builtin_add_property(dev->device, test, "ID_BTRFS_READY", one_zero(err == 0)); + udev_builtin_add_property(dev, test, "ID_BTRFS_READY", one_zero(err == 0)); return EXIT_SUCCESS; } diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c index 8073c9d1a3a..89bf527c378 100644 --- a/src/udev/udev-builtin-hwdb.c +++ b/src/udev/udev-builtin-hwdb.c @@ -113,7 +113,7 @@ next: return r; } -static int builtin_hwdb(struct udev_device *_dev, int argc, char *argv[], bool test) { +static int builtin_hwdb(sd_device *dev, int argc, char *argv[], bool test) { static const struct option options[] = { { "filter", required_argument, NULL, 'f' }, { "device", required_argument, NULL, 'd' }, @@ -126,7 +126,6 @@ static int builtin_hwdb(struct udev_device *_dev, int argc, char *argv[], bool t const char *subsystem = NULL; const char *prefix = NULL; _cleanup_(sd_device_unrefp) sd_device *srcdev = NULL; - sd_device *dev = _dev->device; if (!hwdb) return EXIT_FAILURE; diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index 46310c9495a..a96db58c7a2 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -299,8 +299,8 @@ static bool test_key(sd_device *dev, return ret; } -static int builtin_input_id(struct udev_device *_dev, int argc, char *argv[], bool test) { - sd_device *pdev, *dev = _dev->device; +static int builtin_input_id(sd_device *dev, int argc, char *argv[], bool test) { + sd_device *pdev; unsigned long bitmask_ev[NBITS(EV_MAX)]; unsigned long bitmask_abs[NBITS(ABS_MAX)]; unsigned long bitmask_key[NBITS(KEY_MAX)]; diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index 2fc3d7f9a60..79d98266217 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -183,13 +183,12 @@ static int open_device(const char *devnode) { return fd; } -static int builtin_keyboard(struct udev_device *_dev, int argc, char *argv[], bool test) { +static int builtin_keyboard(sd_device *dev, int argc, char *argv[], bool test) { unsigned release[1024]; unsigned release_count = 0; _cleanup_close_ int fd = -1; const char *node, *key, *value; int has_abs = -1, r; - sd_device *dev = _dev->device; r = sd_device_get_devname(dev, &node); if (r < 0) { diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c index 6ed0210ee60..052c7aa3119 100644 --- a/src/udev/udev-builtin-kmod.c +++ b/src/udev/udev-builtin-kmod.c @@ -21,7 +21,7 @@ _printf_(6,0) static void udev_kmod_log(void *data, int priority, const char *fi log_internalv(priority, 0, file, line, fn, format, args); } -static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) { +static int builtin_kmod(sd_device *dev, int argc, char *argv[], bool test) { int i; if (!ctx) diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 7e6b5a82afb..341eadba2f3 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -805,12 +805,11 @@ static int ieee_oui(sd_device *dev, struct netnames *names, bool test) { return 0; } -static int builtin_net_id(struct udev_device *_dev, int argc, char *argv[], bool test) { +static int builtin_net_id(sd_device *dev, int argc, char *argv[], bool test) { const char *s, *p, *devtype, *prefix = "en"; struct netnames names = {}; unsigned long i; int r; - sd_device *dev = _dev->device; /* handle only ARPHRD_ETHER, ARPHRD_SLIP and ARPHRD_INFINIBAND devices */ r = sd_device_get_sysattr_value(dev, "type", &s); diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c index e328e5ecd8e..b971e6b2381 100644 --- a/src/udev/udev-builtin-net_setup_link.c +++ b/src/udev/udev-builtin-net_setup_link.c @@ -8,12 +8,11 @@ static link_config_ctx *ctx = NULL; -static int builtin_net_setup_link(struct udev_device *_dev, int argc, char **argv, bool test) { +static int builtin_net_setup_link(sd_device *dev, int argc, char **argv, bool test) { _cleanup_free_ char *driver = NULL; const char *name = NULL; link_config *link; int r; - sd_device *dev = _dev->device; if (argc > 1) { log_error("This program takes no arguments."); diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index ac49135369f..ef8adcdab47 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -519,13 +519,12 @@ static sd_device *handle_ap(sd_device *parent, char **path) { return skip_subsystem(parent, "ap"); } -static int builtin_path_id(struct udev_device *_dev, int argc, char *argv[], bool test) { +static int builtin_path_id(sd_device *dev, int argc, char *argv[], bool test) { sd_device *parent; _cleanup_free_ char *path = NULL; bool supported_transport = false; bool supported_parent = false; const char *subsystem; - sd_device *dev = _dev->device; assert(dev); diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c index 6806b9ee095..7be17f32c7d 100644 --- a/src/udev/udev-builtin-uaccess.c +++ b/src/udev/udev-builtin-uaccess.c @@ -15,12 +15,11 @@ #include "log.h" #include "udev-builtin.h" -static int builtin_uaccess(struct udev_device *_dev, int argc, char *argv[], bool test) { +static int builtin_uaccess(sd_device *dev, int argc, char *argv[], bool test) { int r; const char *path = NULL, *seat; bool changed_acl = false; uid_t uid; - sd_device *dev = _dev->device; umask(0022); diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index f946e938c8e..376cda1d3d0 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -223,7 +223,7 @@ static int dev_if_packed_info(sd_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(sd_device *dev, int argc, char *argv[], bool test) { char vendor_str[64] = ""; char vendor_str_enc[256]; const char *vendor_id; @@ -248,7 +248,6 @@ static int builtin_usb_id(struct udev_device *_dev, int argc, char *argv[], bool const char *syspath, *sysname, *devtype, *interface_syspath; int r; - sd_device *dev = _dev->device; assert(dev); diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index d1f58deaf50..88dd4e99e6c 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -5,6 +5,7 @@ #include #include "device-private.h" +#include "libudev-device-internal.h" #include "string-util.h" #include "strv.h" #include "udev-builtin.h" @@ -115,7 +116,7 @@ int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const c /* we need '0' here to reset the internal state */ optind = 0; - return builtins[cmd]->cmd(dev, strv_length(argv), argv, test); + return builtins[cmd]->cmd(dev->device, strv_length(argv), argv, test); } int udev_builtin_add_property(sd_device *dev, bool test, const char *key, const char *val) { diff --git a/src/udev/udev-builtin.h b/src/udev/udev-builtin.h index 497bf184ebf..1c316b162c9 100644 --- a/src/udev/udev-builtin.h +++ b/src/udev/udev-builtin.h @@ -3,8 +3,9 @@ #include +#include "sd-device.h" + #include "libudev.h" -#include "libudev-device-internal.h" enum udev_builtin_cmd { #if HAVE_BLKID @@ -29,7 +30,7 @@ enum udev_builtin_cmd { struct udev_builtin { const char *name; - int (*cmd)(struct udev_device *dev, int argc, char *argv[], bool test); + int (*cmd)(sd_device *dev, int argc, char *argv[], bool test); const char *help; int (*init)(void); void (*exit)(void);