1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 02:21:44 +03:00

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);
}
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' },

View 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;
}

View 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;

View 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)];

View 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) {

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);
}
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)

View 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);

View 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.");

View 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);

View File

@ -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);

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
* 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);

View 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) {

View 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);