summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c57
1 files changed, 26 insertions, 31 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index f72a55c20a..a088df811f 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -5,7 +5,7 @@
#include <sys/statfs.h>
#include <unistd.h>
-#include "libudev.h"
+#include "sd-device.h"
#include "sd-id128.h"
#include "alloc-util.h"
@@ -30,7 +30,7 @@
#include "specifier.h"
#include "stat-util.h"
#include "string-util.h"
-#include "udev-util.h"
+#include "strv.h"
#include "unit-name.h"
#include "util.h"
#include "virt.h"
@@ -446,41 +446,36 @@ static int add_esp(DissectedPartition *p) {
#endif
static int open_parent(dev_t devnum, int *ret) {
- _cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
- _cleanup_(udev_unrefp) struct udev *udev = NULL;
+ _cleanup_(sd_device_unrefp) sd_device *d = NULL;
const char *name, *devtype, *node;
- struct udev_device *parent;
+ sd_device *parent;
dev_t pn;
- int fd;
+ int fd, r;
assert(ret);
- udev = udev_new();
- if (!udev)
- return log_oom();
-
- d = udev_device_new_from_devnum(udev, 'b', devnum);
- if (!d)
- return log_oom();
+ r = sd_device_new_from_devnum(&d, 'b', devnum);
+ if (r < 0)
+ return log_debug_errno(r, "Failed to open device: %m");
- name = udev_device_get_devnode(d);
- if (!name)
- name = udev_device_get_syspath(d);
- if (!name) {
- log_debug("Device %u:%u does not have a name, ignoring.", major(devnum), minor(devnum));
- goto not_found;
+ if (sd_device_get_devname(d, &name) < 0) {
+ r = sd_device_get_syspath(d, &name);
+ if (r < 0) {
+ log_debug_errno(r, "Device %u:%u does not have a name, ignoring: %m", major(devnum), minor(devnum));
+ goto not_found;
+ }
}
- parent = udev_device_get_parent(d);
- if (!parent) {
- log_debug("%s: not a partitioned device, ignoring.", name);
+ r = sd_device_get_parent(d, &parent);
+ if (r < 0) {
+ log_debug_errno(r, "%s: not a partitioned device, ignoring: %m", name);
goto not_found;
}
/* Does it have a devtype? */
- devtype = udev_device_get_devtype(parent);
- if (!devtype) {
- log_debug("%s: parent doesn't have a device type, ignoring.", name);
+ r = sd_device_get_devtype(parent, &devtype);
+ if (r < 0) {
+ log_debug_errno(r, "%s: parent doesn't have a device type, ignoring: %m", name);
goto not_found;
}
@@ -491,17 +486,17 @@ static int open_parent(dev_t devnum, int *ret) {
}
/* Does it have a device node? */
- node = udev_device_get_devnode(parent);
- if (!node) {
- log_debug("%s: parent device does not have device node, ignoring.", name);
+ r = sd_device_get_devname(parent, &node);
+ if (r < 0) {
+ log_debug_errno(r, "%s: parent device does not have device node, ignoring: %m", name);
goto not_found;
}
log_debug("%s: root device %s.", name, node);
- pn = udev_device_get_devnum(parent);
- if (major(pn) == 0) {
- log_debug("%s: parent device is not a proper block device, ignoring.", name);
+ r = sd_device_get_devnum(parent, &pn);
+ if (r < 0) {
+ log_debug_errno(r, "%s: parent device is not a proper block device, ignoring: %m", name);
goto not_found;
}