return blkid_do_safeprobe(pr);
}
-static int builtin_blkid(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_blkid(sd_device *dev, sd_netlink **rtnl, 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;
#include "udev-builtin.h"
#include "util.h"
-static int builtin_btrfs(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_btrfs(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
struct btrfs_ioctl_vol_args args = {};
_cleanup_close_ int fd = -1;
int r;
return r;
}
-static int builtin_hwdb(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_hwdb(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
static const struct option options[] = {
{ "filter", required_argument, NULL, 'f' },
{ "device", required_argument, NULL, 'd' },
return found;
}
-static int builtin_input_id(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_input_id(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
sd_device *pdev;
unsigned long bitmask_ev[NBITS(EV_MAX)];
unsigned long bitmask_abs[NBITS(ABS_MAX)];
return 0;
}
-static int builtin_keyboard(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_keyboard(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
unsigned release[1024];
unsigned release_count = 0;
_cleanup_close_ int fd = -1;
log_internalv(priority, 0, file, line, fn, format, args);
}
-static int builtin_kmod(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_kmod(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
if (!ctx)
return 0;
return 0;
}
-static int builtin_net_id(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_net_id(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
const char *s, *p, *devtype, *prefix = "en";
struct netnames names = {};
unsigned long i;
static LinkConfigContext *ctx = NULL;
-static int builtin_net_setup_link(sd_device *dev, int argc, char **argv, bool test) {
+static int builtin_net_setup_link(sd_device *dev, sd_netlink **rtnl, int argc, char **argv, bool test) {
_cleanup_free_ char *driver = NULL;
const char *name = NULL;
LinkConfig *link;
return skip_subsystem(parent, "ap");
}
-static int builtin_path_id(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_path_id(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
sd_device *parent;
_cleanup_free_ char *path = NULL;
_cleanup_free_ char *compat_path = NULL;
#include "log.h"
#include "udev-builtin.h"
-static int builtin_uaccess(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_uaccess(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
const char *path = NULL, *seat;
bool changed_acl = false;
uid_t uid;
* 6.) If the device supplies a serial number, this number
* is concatenated with the identification with an underscore '_'.
*/
-static int builtin_usb_id(sd_device *dev, int argc, char *argv[], bool test) {
+static int builtin_usb_id(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test) {
char vendor_str[64] = "";
char vendor_str_enc[256];
const char *vendor_id;
return _UDEV_BUILTIN_INVALID;
}
-int udev_builtin_run(sd_device *dev, UdevBuiltinCommand cmd, const char *command, bool test) {
+int udev_builtin_run(sd_device *dev, sd_netlink **rtnl, UdevBuiltinCommand cmd, const char *command, bool test) {
_cleanup_strv_free_ char **argv = NULL;
int r;
/* 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, rtnl, strv_length(argv), argv, test);
}
int udev_builtin_add_property(sd_device *dev, bool test, const char *key, const char *val) {
#include <stdbool.h>
#include "sd-device.h"
+#include "sd-netlink.h"
typedef enum {
#if HAVE_BLKID
typedef struct UdevBuiltin {
const char *name;
- int (*cmd)(sd_device *dev, int argc, char *argv[], bool test);
+ int (*cmd)(sd_device *dev, sd_netlink **rtnl, int argc, char *argv[], bool test);
const char *help;
int (*init)(void);
void (*exit)(void);
UdevBuiltinCommand udev_builtin_lookup(const char *command);
const char *udev_builtin_name(UdevBuiltinCommand cmd);
bool udev_builtin_run_once(UdevBuiltinCommand cmd);
-int udev_builtin_run(sd_device *dev, UdevBuiltinCommand cmd, const char *command, bool test);
+int udev_builtin_run(sd_device *dev, sd_netlink **rtnl, UdevBuiltinCommand cmd, const char *command, bool test);
void udev_builtin_list(void);
bool udev_builtin_validate(void);
int udev_builtin_add_property(sd_device *dev, bool test, const char *key, const char *val);
if (builtin_cmd != _UDEV_BUILTIN_INVALID) {
log_device_debug(event->dev, "Running built-in command \"%s\"", command);
- r = udev_builtin_run(event->dev, builtin_cmd, command, false);
+ r = udev_builtin_run(event->dev, &event->rtnl, builtin_cmd, command, false);
if (r < 0)
log_device_debug_errno(event->dev, r, "Failed to run built-in command \"%s\", ignoring: %m", command);
} else {
(void) udev_event_apply_format(event, token->value, buf, sizeof(buf), false);
log_rule_debug(dev, rules, "Importing properties from results of builtin command '%s'", buf);
- r = udev_builtin_run(dev, cmd, buf, false);
+ r = udev_builtin_run(dev, &event->rtnl, cmd, buf, false);
if (r < 0) {
/* remember failure */
log_rule_debug_errno(dev, rules, r, "Failed to run builtin '%s': %m", buf);
}
int builtin_main(int argc, char *argv[], void *userdata) {
+ _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
UdevBuiltinCommand cmd;
int r;
goto finish;
}
- r = udev_builtin_run(dev, cmd, arg_command, true);
+ r = udev_builtin_run(dev, &rtnl, cmd, arg_command, true);
if (r < 0)
log_debug_errno(r, "Builtin command '%s' fails: %m", arg_command);