summaryrefslogtreecommitdiffstats
path: root/src/udev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-08-12 14:47:56 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-08-12 14:48:13 +0200
commit829bb61fb828af17064b9bb8571f6d5dd85b5081 (patch)
tree2e36990c0f1a8abfe9115ac0c7f73c229e635740 /src/udev
parenttest: add more tests for sd_device_new_from_path() (diff)
downloadsystemd-829bb61fb828af17064b9bb8571f6d5dd85b5081.tar.xz
systemd-829bb61fb828af17064b9bb8571f6d5dd85b5081.zip
udev: use sd_device_new_from_path() and _new_child()
Follow-up for 65c2ad985a8debdf6d7d11fee5b466f280260f4b.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-builtin-net_id.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index ef1f398927..33fce6e140 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -604,9 +604,8 @@ static int names_platform(sd_device *dev, NetNames *names, bool test) {
}
static int dev_devicetree_onboard(sd_device *dev, NetNames *names) {
- const char *alias, *ofnode_path, *ofnode_syspath;
- _cleanup_free_ char *devicetree_syspath = NULL;
- _cleanup_(sd_device_unrefp) sd_device *aliases_dev = NULL, *ofnode_dev = NULL;
+ _cleanup_(sd_device_unrefp) sd_device *aliases_dev = NULL, *ofnode_dev = NULL, *devicetree_dev = NULL;
+ const char *alias, *ofnode_path, *ofnode_syspath, *devicetree_syspath;
sd_device *parent;
int r;
@@ -626,7 +625,12 @@ static int dev_devicetree_onboard(sd_device *dev, NetNames *names) {
if (r < 0)
return r;
- r = chase_symlinks("/proc/device-tree", NULL, 0, &devicetree_syspath, NULL);
+ /* /proc/device-tree should be a symlink to /sys/firmware/devicetree/base. */
+ r = sd_device_new_from_path(&devicetree_dev, "/proc/device-tree");
+ if (r < 0)
+ return r;
+
+ r = sd_device_get_syspath(devicetree_dev, &devicetree_syspath);
if (r < 0)
return r;
@@ -644,7 +648,7 @@ static int dev_devicetree_onboard(sd_device *dev, NetNames *names) {
ofnode_path--;
assert(path_is_absolute(ofnode_path));
- r = sd_device_new_from_syspath(&aliases_dev, strjoina(devicetree_syspath, "/aliases"));
+ r = sd_device_new_child(&aliases_dev, devicetree_dev, "aliases");
if (r < 0)
return r;