#endif
#include "sd-bus.h"
+#include "sd-device.h"
#include "sd-journal.h"
#include "acl-util.h"
#include "bus-util.h"
#include "catalog.h"
#include "chattr-util.h"
+#include "device-private.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "strv.h"
#include "syslog-util.h"
#include "terminal-util.h"
-#include "udev-util.h"
-#include "udev.h"
#include "unit-name.h"
#include "user-util.h"
} BootId;
static int add_matches_for_device(sd_journal *j, const char *devpath) {
- _cleanup_(udev_unrefp) struct udev *udev = NULL;
- _cleanup_(udev_device_unrefp) struct udev_device *device = NULL;
- struct udev_device *d = NULL;
+ _cleanup_(sd_device_unrefp) sd_device *device = NULL;
+ sd_device *d = NULL;
struct stat st;
int r;
return -EINVAL;
}
- udev = udev_new();
- if (!udev)
- return log_oom();
-
if (stat(devpath, &st) < 0)
return log_error_errno(errno, "Couldn't stat file: %m");
- r = udev_device_new_from_stat_rdev(udev, &st, &device);
+ r = device_new_from_stat_rdev(&device, &st);
if (r < 0)
- return log_error_errno(r, "Failed to get udev device from devnum %u:%u: %m", major(st.st_rdev), minor(st.st_rdev));
+ return log_error_errno(r, "Failed to get device from devnum %u:%u: %m", major(st.st_rdev), minor(st.st_rdev));
- d = device;
- while (d) {
+ for (d = device; d; ) {
_cleanup_free_ char *match = NULL;
const char *subsys, *sysname, *devnode;
+ sd_device *parent;
- subsys = udev_device_get_subsystem(d);
- if (!subsys) {
- d = udev_device_get_parent(d);
- continue;
- }
+ r = sd_device_get_subsystem(d, &subsys);
+ if (r < 0)
+ goto get_parent;
- sysname = udev_device_get_sysname(d);
- if (!sysname) {
- d = udev_device_get_parent(d);
- continue;
- }
+ r = sd_device_get_sysname(d, &sysname);
+ if (r < 0)
+ goto get_parent;
match = strjoin("_KERNEL_DEVICE=+", subsys, ":", sysname);
if (!match)
if (r < 0)
return log_error_errno(r, "Failed to add match: %m");
- devnode = udev_device_get_devnode(d);
- if (devnode) {
+ if (sd_device_get_devname(d, &devnode) >= 0) {
_cleanup_free_ char *match1 = NULL;
r = stat(devnode, &st);
return log_error_errno(r, "Failed to add match: %m");
}
- d = udev_device_get_parent(d);
+get_parent:
+ if (sd_device_get_parent(d, &parent) < 0)
+ break;
+
+ d = parent;
}
r = add_match_this_boot(j, arg_machine);
#include <sys/socket.h>
#include <unistd.h>
-#include "libudev.h"
+#include "sd-device.h"
#include "sd-messages.h"
#include "alloc-util.h"
+#include "device-util.h"
#include "escape.h"
#include "fd-util.h"
#include "format-util.h"
}
if (kernel_device) {
- struct udev_device *ud;
+ _cleanup_(sd_device_unrefp) sd_device *d = NULL;
- ud = udev_device_new_from_device_id(s->udev, kernel_device);
- if (ud) {
+ if (sd_device_new_from_device_id(&d, kernel_device) >= 0) {
const char *g;
- struct udev_list_entry *ll;
char *b;
- g = udev_device_get_devnode(ud);
- if (g) {
+ if (sd_device_get_devname(d, &g) >= 0) {
b = strappend("_UDEV_DEVNODE=", g);
if (b) {
iovec[n++] = IOVEC_MAKE_STRING(b);
}
}
- g = udev_device_get_sysname(ud);
- if (g) {
+ if (sd_device_get_sysname(d, &g) >= 0) {
b = strappend("_UDEV_SYSNAME=", g);
if (b) {
iovec[n++] = IOVEC_MAKE_STRING(b);
}
j = 0;
- ll = udev_device_get_devlinks_list_entry(ud);
- udev_list_entry_foreach(ll, ll) {
+ FOREACH_DEVICE_DEVLINK(d, g) {
if (j > N_IOVEC_UDEV_FIELDS)
break;
- g = udev_list_entry_get_name(ll);
- if (g) {
- b = strappend("_UDEV_DEVLINK=", g);
- if (b) {
- iovec[n++] = IOVEC_MAKE_STRING(b);
- z++;
- }
+ b = strappend("_UDEV_DEVLINK=", g);
+ if (b) {
+ iovec[n++] = IOVEC_MAKE_STRING(b);
+ z++;
}
j++;
}
-
- udev_device_unref(ud);
}
}