udev: replace udev_device by sd_device from prototype of udev builtin commands
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 13 Oct 2018 16:22:14 +0000 (01:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Oct 2018 09:28:38 +0000 (18:28 +0900)
13 files changed:
src/udev/udev-builtin-blkid.c
src/udev/udev-builtin-btrfs.c
src/udev/udev-builtin-hwdb.c
src/udev/udev-builtin-input_id.c
src/udev/udev-builtin-keyboard.c
src/udev/udev-builtin-kmod.c
src/udev/udev-builtin-net_id.c
src/udev/udev-builtin-net_setup_link.c
src/udev/udev-builtin-path_id.c
src/udev/udev-builtin-uaccess.c
src/udev/udev-builtin-usb_id.c
src/udev/udev-builtin.c
src/udev/udev-builtin.h

index 674bdee..f521357 100644 (file)
@@ -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' },
index 4d6787e..93fc29f 100644 (file)
@@ -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;
 }
 
index 8073c9d..89bf527 100644 (file)
@@ -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;
index 46310c9..a96db58 100644 (file)
@@ -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)];
index 2fc3d7f..79d9826 100644 (file)
@@ -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) {
index 6ed0210..052c7aa 100644 (file)
@@ -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)
index 7e6b5a8..341eadb 100644 (file)
@@ -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);
index e328e5e..b971e6b 100644 (file)
@@ -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.");
index ac49135..ef8adcd 100644 (file)
@@ -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);
 
index 6806b9e..7be17f3 100644 (file)
 #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);
 
index f946e93..376cda1 100644 (file)
@@ -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);
 
index d1f58de..88dd4e9 100644 (file)
@@ -5,6 +5,7 @@
 #include <string.h>
 
 #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) {
index 497bf18..1c316b1 100644 (file)
@@ -3,8 +3,9 @@
 
 #include <stdbool.h>
 
+#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);