udev: replace udev_device by sd_device from prototype of udev builtin commands

This commit is contained in:
Yu Watanabe 2018-10-14 01:22:14 +09:00
parent 71bd61c576
commit 3fc2e9a247
13 changed files with 18 additions and 24 deletions

View file

@ -210,14 +210,13 @@ static int probe_superblocks(blkid_probe pr) {
return blkid_do_safeprobe(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; const char *devnode, *root_partition = NULL, *data, *name;
_cleanup_(blkid_free_probep) blkid_probe pr = NULL; _cleanup_(blkid_free_probep) blkid_probe pr = NULL;
bool noraid = false, is_gpt = false; bool noraid = false, is_gpt = false;
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
int64_t offset = 0; int64_t offset = 0;
int nvals, i, r; int nvals, i, r;
sd_device *dev = _dev->device;
static const struct option options[] = { static const struct option options[] = {
{ "offset", required_argument, NULL, 'o' }, { "offset", required_argument, NULL, 'o' },

View file

@ -15,7 +15,7 @@
#include "udev-builtin.h" #include "udev-builtin.h"
#include "util.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 = {}; struct btrfs_ioctl_vol_args args = {};
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
int err; int err;
@ -32,7 +32,7 @@ static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool t
if (err < 0) if (err < 0)
return EXIT_FAILURE; 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; return EXIT_SUCCESS;
} }

View file

@ -113,7 +113,7 @@ next:
return r; 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[] = { static const struct option options[] = {
{ "filter", required_argument, NULL, 'f' }, { "filter", required_argument, NULL, 'f' },
{ "device", required_argument, NULL, 'd' }, { "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 *subsystem = NULL;
const char *prefix = NULL; const char *prefix = NULL;
_cleanup_(sd_device_unrefp) sd_device *srcdev = NULL; _cleanup_(sd_device_unrefp) sd_device *srcdev = NULL;
sd_device *dev = _dev->device;
if (!hwdb) if (!hwdb)
return EXIT_FAILURE; return EXIT_FAILURE;

View file

@ -299,8 +299,8 @@ static bool test_key(sd_device *dev,
return ret; return ret;
} }
static int builtin_input_id(struct udev_device *_dev, int argc, char *argv[], bool test) { static int builtin_input_id(sd_device *dev, int argc, char *argv[], bool test) {
sd_device *pdev, *dev = _dev->device; sd_device *pdev;
unsigned long bitmask_ev[NBITS(EV_MAX)]; unsigned long bitmask_ev[NBITS(EV_MAX)];
unsigned long bitmask_abs[NBITS(ABS_MAX)]; unsigned long bitmask_abs[NBITS(ABS_MAX)];
unsigned long bitmask_key[NBITS(KEY_MAX)]; unsigned long bitmask_key[NBITS(KEY_MAX)];

View file

@ -183,13 +183,12 @@ static int open_device(const char *devnode) {
return fd; 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[1024];
unsigned release_count = 0; unsigned release_count = 0;
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
const char *node, *key, *value; const char *node, *key, *value;
int has_abs = -1, r; int has_abs = -1, r;
sd_device *dev = _dev->device;
r = sd_device_get_devname(dev, &node); r = sd_device_get_devname(dev, &node);
if (r < 0) { if (r < 0) {

View 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); 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; int i;
if (!ctx) if (!ctx)

View file

@ -805,12 +805,11 @@ static int ieee_oui(sd_device *dev, struct netnames *names, bool test) {
return 0; 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"; const char *s, *p, *devtype, *prefix = "en";
struct netnames names = {}; struct netnames names = {};
unsigned long i; unsigned long i;
int r; int r;
sd_device *dev = _dev->device;
/* handle only ARPHRD_ETHER, ARPHRD_SLIP and ARPHRD_INFINIBAND devices */ /* handle only ARPHRD_ETHER, ARPHRD_SLIP and ARPHRD_INFINIBAND devices */
r = sd_device_get_sysattr_value(dev, "type", &s); r = sd_device_get_sysattr_value(dev, "type", &s);

View file

@ -8,12 +8,11 @@
static link_config_ctx *ctx = NULL; 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; _cleanup_free_ char *driver = NULL;
const char *name = NULL; const char *name = NULL;
link_config *link; link_config *link;
int r; int r;
sd_device *dev = _dev->device;
if (argc > 1) { if (argc > 1) {
log_error("This program takes no arguments."); log_error("This program takes no arguments.");

View file

@ -519,13 +519,12 @@ static sd_device *handle_ap(sd_device *parent, char **path) {
return skip_subsystem(parent, "ap"); 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; sd_device *parent;
_cleanup_free_ char *path = NULL; _cleanup_free_ char *path = NULL;
bool supported_transport = false; bool supported_transport = false;
bool supported_parent = false; bool supported_parent = false;
const char *subsystem; const char *subsystem;
sd_device *dev = _dev->device;
assert(dev); assert(dev);

View file

@ -15,12 +15,11 @@
#include "log.h" #include "log.h"
#include "udev-builtin.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; int r;
const char *path = NULL, *seat; const char *path = NULL, *seat;
bool changed_acl = false; bool changed_acl = false;
uid_t uid; uid_t uid;
sd_device *dev = _dev->device;
umask(0022); umask(0022);

View 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 * 6.) If the device supplies a serial number, this number
* is concatenated with the identification with an underscore '_'. * 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[64] = "";
char vendor_str_enc[256]; char vendor_str_enc[256];
const char *vendor_id; 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; const char *syspath, *sysname, *devtype, *interface_syspath;
int r; int r;
sd_device *dev = _dev->device;
assert(dev); assert(dev);

View file

@ -5,6 +5,7 @@
#include <string.h> #include <string.h>
#include "device-private.h" #include "device-private.h"
#include "libudev-device-internal.h"
#include "string-util.h" #include "string-util.h"
#include "strv.h" #include "strv.h"
#include "udev-builtin.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 */ /* we need '0' here to reset the internal state */
optind = 0; 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) { int udev_builtin_add_property(sd_device *dev, bool test, const char *key, const char *val) {

View file

@ -3,8 +3,9 @@
#include <stdbool.h> #include <stdbool.h>
#include "sd-device.h"
#include "libudev.h" #include "libudev.h"
#include "libudev-device-internal.h"
enum udev_builtin_cmd { enum udev_builtin_cmd {
#if HAVE_BLKID #if HAVE_BLKID
@ -29,7 +30,7 @@ enum udev_builtin_cmd {
struct udev_builtin { struct udev_builtin {
const char *name; 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; const char *help;
int (*init)(void); int (*init)(void);
void (*exit)(void); void (*exit)(void);