]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: use sd_device_new_from_path() and _new_child() 24285/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 12 Aug 2022 12:47:56 +0000 (21:47 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 12 Aug 2022 12:48:13 +0000 (21:48 +0900)
Follow-up for 65c2ad985a8debdf6d7d11fee5b466f280260f4b.

src/udev/udev-builtin-net_id.c

index ef1f398927c7c57939ec483abb6eb4b1ccdd3df2..33fce6e140613fabd172c166b81adb3535acce3d 100644 (file)
@@ -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;