From: Yu Watanabe Date: Sun, 18 Sep 2022 22:08:59 +0000 (+0900) Subject: sd-device: use device_opendir() X-Git-Tag: v252-rc1~142^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=62ccd11d38ccd2959c7ab2674890fb44bde5943b;p=thirdparty%2Fsystemd.git sd-device: use device_opendir() --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 7a5403be6fc..7e3d5eeae12 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1867,32 +1867,18 @@ _public_ const char *sd_device_get_property_next(sd_device *device, const char * } static int device_sysattrs_read_all_internal(sd_device *device, const char *subdir, Set **stack) { - _cleanup_free_ char *path_dir = NULL; _cleanup_closedir_ DIR *dir = NULL; - const char *syspath; int r; assert(device); assert(stack); - r = sd_device_get_syspath(device, &syspath); + r = device_opendir(device, subdir, &dir); + if (r == -ENOENT && subdir) + return 0; /* Maybe, this is a child device, and is already removed. */ if (r < 0) return r; - if (subdir) { - path_dir = path_join(syspath, subdir); - if (!path_dir) - return -ENOMEM; - } - - dir = opendir(path_dir ?: syspath); - if (!dir) { - if (errno == ENOENT && subdir) - return 0; /* Maybe, this is a child device, and is already removed. */ - - return -errno; - } - if (subdir) { if (faccessat(dirfd(dir), "uevent", F_OK, 0) >= 0) return 0; /* this is a child device, skipping */