s[0] = '\0';
if (streq(name, "TYPE")) {
- udev_builtin_add_property(dev, test, "ID_FS_TYPE", value);
+ udev_builtin_add_property(dev->device, test, "ID_FS_TYPE", value);
} else if (streq(name, "USAGE")) {
- udev_builtin_add_property(dev, test, "ID_FS_USAGE", value);
+ udev_builtin_add_property(dev->device, test, "ID_FS_USAGE", value);
} else if (streq(name, "VERSION")) {
- udev_builtin_add_property(dev, test, "ID_FS_VERSION", value);
+ udev_builtin_add_property(dev->device, test, "ID_FS_VERSION", value);
} else if (streq(name, "UUID")) {
blkid_safe_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_UUID", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_UUID", s);
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_UUID_ENC", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_UUID_ENC", s);
} else if (streq(name, "UUID_SUB")) {
blkid_safe_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_UUID_SUB", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_UUID_SUB", s);
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_UUID_SUB_ENC", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_UUID_SUB_ENC", s);
} else if (streq(name, "LABEL")) {
blkid_safe_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_LABEL", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_LABEL", s);
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_LABEL_ENC", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_LABEL_ENC", s);
} else if (streq(name, "PTTYPE")) {
- udev_builtin_add_property(dev, test, "ID_PART_TABLE_TYPE", value);
+ udev_builtin_add_property(dev->device, test, "ID_PART_TABLE_TYPE", value);
} else if (streq(name, "PTUUID")) {
- udev_builtin_add_property(dev, test, "ID_PART_TABLE_UUID", value);
+ udev_builtin_add_property(dev->device, test, "ID_PART_TABLE_UUID", value);
} else if (streq(name, "PART_ENTRY_NAME")) {
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_PART_ENTRY_NAME", s);
+ udev_builtin_add_property(dev->device, test, "ID_PART_ENTRY_NAME", s);
} else if (streq(name, "PART_ENTRY_TYPE")) {
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_PART_ENTRY_TYPE", s);
+ udev_builtin_add_property(dev->device, test, "ID_PART_ENTRY_TYPE", s);
} else if (startswith(name, "PART_ENTRY_")) {
strscpyl(s, sizeof(s), "ID_", name, NULL);
- udev_builtin_add_property(dev, test, s, value);
+ udev_builtin_add_property(dev->device, test, s, value);
} else if (streq(name, "SYSTEM_ID")) {
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_SYSTEM_ID", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_SYSTEM_ID", s);
} else if (streq(name, "PUBLISHER_ID")) {
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_PUBLISHER_ID", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_PUBLISHER_ID", s);
} else if (streq(name, "APPLICATION_ID")) {
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_APPLICATION_ID", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_APPLICATION_ID", s);
} else if (streq(name, "BOOT_SYSTEM_ID")) {
blkid_encode_string(value, s, sizeof(s));
- udev_builtin_add_property(dev, test, "ID_FS_BOOT_SYSTEM_ID", s);
+ udev_builtin_add_property(dev->device, test, "ID_FS_BOOT_SYSTEM_ID", s);
}
}
/* We found the ESP on this disk, and also found a root
* partition, nice! Let's export its UUID */
if (found_esp && root_id)
- udev_builtin_add_property(dev, test, "ID_PART_GPT_AUTO_ROOT_UUID", root_id);
+ udev_builtin_add_property(dev->device, test, "ID_PART_GPT_AUTO_ROOT_UUID", root_id);
#endif
return 0;
/* Is this a partition that matches the root partition
* property we inherited from our parent? */
if (root_partition && streq(name, "PART_ENTRY_UUID") && streq(data, root_partition))
- udev_builtin_add_property(dev, test, "ID_PART_GPT_AUTO_ROOT", "1");
+ udev_builtin_add_property(dev->device, test, "ID_PART_GPT_AUTO_ROOT", "1");
}
if (is_gpt)
if (err < 0)
return EXIT_FAILURE;
- udev_builtin_add_property(dev, test, "ID_BTRFS_READY", one_zero(err == 0));
+ udev_builtin_add_property(dev->device, test, "ID_BTRFS_READY", one_zero(err == 0));
return EXIT_SUCCESS;
}
if (filter && fnmatch(filter, key, FNM_NOESCAPE) != 0)
continue;
- if (udev_builtin_add_property(dev, test, key, value) < 0)
+ if (udev_builtin_add_property(dev->device, test, key, value) < 0)
return -ENOMEM;
n++;
}
xsprintf(width, "%d", abs_size_mm(&xabsinfo));
xsprintf(height, "%d", abs_size_mm(&yabsinfo));
- udev_builtin_add_property(dev, test, "ID_INPUT_WIDTH_MM", width);
- udev_builtin_add_property(dev, test, "ID_INPUT_HEIGHT_MM", height);
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_WIDTH_MM", width);
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_HEIGHT_MM", height);
}
/*
is_accelerometer = true;
if (is_accelerometer) {
- udev_builtin_add_property(dev, test, "ID_INPUT_ACCELEROMETER", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_ACCELEROMETER", "1");
return true;
}
is_mouse = true;
if (is_pointing_stick)
- udev_builtin_add_property(dev, test, "ID_INPUT_POINTINGSTICK", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_POINTINGSTICK", "1");
if (is_mouse)
- udev_builtin_add_property(dev, test, "ID_INPUT_MOUSE", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_MOUSE", "1");
if (is_touchpad)
- udev_builtin_add_property(dev, test, "ID_INPUT_TOUCHPAD", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_TOUCHPAD", "1");
if (is_touchscreen)
- udev_builtin_add_property(dev, test, "ID_INPUT_TOUCHSCREEN", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_TOUCHSCREEN", "1");
if (is_joystick)
- udev_builtin_add_property(dev, test, "ID_INPUT_JOYSTICK", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_JOYSTICK", "1");
if (is_tablet)
- udev_builtin_add_property(dev, test, "ID_INPUT_TABLET", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_TABLET", "1");
return is_tablet || is_mouse || is_touchpad || is_touchscreen || is_joystick || is_pointing_stick;
}
}
if (found > 0) {
- udev_builtin_add_property(dev, test, "ID_INPUT_KEY", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_KEY", "1");
ret = true;
}
* those, consider it a full keyboard; do not test KEY_RESERVED, though */
mask = 0xFFFFFFFE;
if (FLAGS_SET(bitmask_key[0], mask)) {
- udev_builtin_add_property(dev, test, "ID_INPUT_KEYBOARD", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_KEYBOARD", "1");
ret = true;
}
if (pdev) {
/* Use this as a flag that input devices were detected, so that this
* program doesn't need to be called more than once per device */
- udev_builtin_add_property(dev, test, "ID_INPUT", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT", "1");
get_cap_mask(dev, pdev, "capabilities/ev", bitmask_ev, sizeof(bitmask_ev), test);
get_cap_mask(dev, pdev, "capabilities/abs", bitmask_abs, sizeof(bitmask_abs), test);
get_cap_mask(dev, pdev, "capabilities/rel", bitmask_rel, sizeof(bitmask_rel), test);
/* Some evdev nodes have only a scrollwheel */
if (!is_pointer && !is_key && test_bit(EV_REL, bitmask_ev) &&
(test_bit(REL_WHEEL, bitmask_rel) || test_bit(REL_HWHEEL, bitmask_rel)))
- udev_builtin_add_property(dev, test, "ID_INPUT_KEY", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_KEY", "1");
if (test_bit(EV_SW, bitmask_ev))
- udev_builtin_add_property(dev, test, "ID_INPUT_SWITCH", "1");
+ udev_builtin_add_property(dev->device, test, "ID_INPUT_SWITCH", "1");
}
xsprintf(str, "%sx%02x%02x%02x%02x%02x%02x", prefix,
names.mac[0], names.mac[1], names.mac[2],
names.mac[3], names.mac[4], names.mac[5]);
- udev_builtin_add_property(dev, test, "ID_NET_NAME_MAC", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_MAC", str);
ieee_oui(dev, &names, test);
}
char str[IFNAMSIZ];
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.ccw_busid))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_PATH", str);
goto out;
}
char str[IFNAMSIZ];
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.vio_slot))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_SLOT", str);
goto out;
}
char str[IFNAMSIZ];
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.platform_path))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_PATH", str);
goto out;
}
if (names.pci_onboard[0] &&
snprintf_ok(str, sizeof str, "%s%s", prefix, names.pci_onboard))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_ONBOARD", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_ONBOARD", str);
if (names.pci_onboard_label &&
snprintf_ok(str, sizeof str, "%s%s", prefix, names.pci_onboard_label))
- udev_builtin_add_property(dev, test, "ID_NET_LABEL_ONBOARD", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_LABEL_ONBOARD", str);
if (names.pci_path[0] &&
snprintf_ok(str, sizeof str, "%s%s", prefix, names.pci_path))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_PATH", str);
if (names.pci_slot[0] &&
snprintf_ok(str, sizeof str, "%s%s", prefix, names.pci_slot))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_SLOT", str);
goto out;
}
if (names.pci_path[0] &&
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.usb_ports))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_PATH", str);
if (names.pci_slot[0] &&
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_slot, names.usb_ports))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_SLOT", str);
goto out;
}
if (names.pci_path[0] &&
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.bcma_core))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_PATH", str);
if (names.pci_slot[0] &&
snprintf(str, sizeof str, "%s%s%s", prefix, names.pci_slot, names.bcma_core))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME_SLOT", str);
goto out;
}
out:
r = link_get_driver(ctx, dev->device, &driver);
if (r >= 0)
- udev_builtin_add_property(dev, test, "ID_NET_DRIVER", driver);
+ udev_builtin_add_property(dev->device, test, "ID_NET_DRIVER", driver);
r = link_config_get(ctx, dev->device, &link);
if (r < 0) {
if (r < 0)
log_warning_errno(r, "Could not apply link config to %s, ignoring: %m", udev_device_get_sysname(dev));
- udev_builtin_add_property(dev, test, "ID_NET_LINK_FILE", link->filename);
+ udev_builtin_add_property(dev->device, test, "ID_NET_LINK_FILE", link->filename);
if (name)
- udev_builtin_add_property(dev, test, "ID_NET_NAME", name);
+ udev_builtin_add_property(dev->device, test, "ID_NET_NAME", name);
return EXIT_SUCCESS;
}
i--;
tag[i] = '\0';
- udev_builtin_add_property(dev, test, "ID_PATH", path);
- udev_builtin_add_property(dev, test, "ID_PATH_TAG", tag);
+ udev_builtin_add_property(dev->device, test, "ID_PATH", path);
+ udev_builtin_add_property(dev->device, test, "ID_PATH_TAG", tag);
}
return EXIT_SUCCESS;
if (!isempty(instance_str))
strpcpyl(&s, l, "-", instance_str, NULL);
- udev_builtin_add_property(dev, test, "ID_VENDOR", vendor_str);
- udev_builtin_add_property(dev, test, "ID_VENDOR_ENC", vendor_str_enc);
- udev_builtin_add_property(dev, test, "ID_VENDOR_ID", vendor_id);
- udev_builtin_add_property(dev, test, "ID_MODEL", model_str);
- udev_builtin_add_property(dev, test, "ID_MODEL_ENC", model_str_enc);
- udev_builtin_add_property(dev, test, "ID_MODEL_ID", product_id);
- udev_builtin_add_property(dev, test, "ID_REVISION", revision_str);
- udev_builtin_add_property(dev, test, "ID_SERIAL", serial);
+ udev_builtin_add_property(dev->device, test, "ID_VENDOR", vendor_str);
+ udev_builtin_add_property(dev->device, test, "ID_VENDOR_ENC", vendor_str_enc);
+ udev_builtin_add_property(dev->device, test, "ID_VENDOR_ID", vendor_id);
+ udev_builtin_add_property(dev->device, test, "ID_MODEL", model_str);
+ udev_builtin_add_property(dev->device, test, "ID_MODEL_ENC", model_str_enc);
+ udev_builtin_add_property(dev->device, test, "ID_MODEL_ID", product_id);
+ udev_builtin_add_property(dev->device, test, "ID_REVISION", revision_str);
+ udev_builtin_add_property(dev->device, test, "ID_SERIAL", serial);
if (!isempty(serial_str))
- udev_builtin_add_property(dev, test, "ID_SERIAL_SHORT", serial_str);
+ udev_builtin_add_property(dev->device, test, "ID_SERIAL_SHORT", serial_str);
if (!isempty(type_str))
- udev_builtin_add_property(dev, test, "ID_TYPE", type_str);
+ udev_builtin_add_property(dev->device, test, "ID_TYPE", type_str);
if (!isempty(instance_str))
- udev_builtin_add_property(dev, test, "ID_INSTANCE", instance_str);
- udev_builtin_add_property(dev, test, "ID_BUS", "usb");
+ udev_builtin_add_property(dev->device, test, "ID_INSTANCE", instance_str);
+ udev_builtin_add_property(dev->device, test, "ID_BUS", "usb");
if (!isempty(packed_if_str))
- udev_builtin_add_property(dev, test, "ID_USB_INTERFACES", packed_if_str);
+ udev_builtin_add_property(dev->device, test, "ID_USB_INTERFACES", packed_if_str);
if (ifnum != NULL)
- udev_builtin_add_property(dev, test, "ID_USB_INTERFACE_NUM", ifnum);
+ udev_builtin_add_property(dev->device, test, "ID_USB_INTERFACE_NUM", ifnum);
if (driver != NULL)
- udev_builtin_add_property(dev, test, "ID_USB_DRIVER", driver);
+ udev_builtin_add_property(dev->device, test, "ID_USB_DRIVER", driver);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <string.h>
+#include "device-private.h"
#include "string-util.h"
+#include "strv.h"
#include "udev-builtin.h"
-#include "udev.h"
static bool initialized;
return builtins[cmd]->cmd(dev, strv_length(argv), argv, test);
}
-int udev_builtin_add_property(struct udev_device *dev, bool test, const char *key, const char *val) {
- udev_device_add_property(dev, key, val);
+int udev_builtin_add_property(sd_device *dev, bool test, const char *key, const char *val) {
+ int r;
+
+ r = device_add_property(dev, key, val);
+ if (r < 0)
+ return r;
if (test)
printf("%s=%s\n", key, val);
#include <stdbool.h>
#include "libudev.h"
+#include "libudev-device-internal.h"
enum udev_builtin_cmd {
#if HAVE_BLKID
int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const char *command, bool test);
void udev_builtin_list(void);
bool udev_builtin_validate(void);
-int udev_builtin_add_property(struct udev_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);
int udev_builtin_hwdb_lookup(struct udev_device *dev, const char *prefix, const char *modalias,
const char *filter, bool test);