diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-19 07:08:59 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-19 19:42:36 +0900 |
commit | 62ccd11d38ccd2959c7ab2674890fb44bde5943b (patch) | |
tree | f53926d6102cc53aba0986dbb044c010b59d22f5 /src/libsystemd/sd-device | |
parent | db3049b6f0af4643b2678ad58ffdb93ab736ceaf (diff) | |
download | systemd-62ccd11d38ccd2959c7ab2674890fb44bde5943b.tar.gz |
sd-device: use device_opendir()
Diffstat (limited to 'src/libsystemd/sd-device')
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 7a5403be6f..7e3d5eeae1 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1867,33 +1867,19 @@ _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 */ if (errno != ENOENT) { |