From: Yu Watanabe Date: Sun, 18 Sep 2022 22:08:13 +0000 (+0900) Subject: sd-device: use fstatat() X-Git-Tag: v252-rc1~142^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=65c0f14bc16b925f936de39aafa2b2698ee080b5;p=thirdparty%2Fsystemd.git sd-device: use fstatat() No functional changes, just refactoring. --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index f2556ca4bcf..f5f36694028 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1901,7 +1901,7 @@ static int device_sysattrs_read_all_internal(sd_device *device, const char *subd return -errno; FOREACH_DIRENT_ALL(de, dir, return -errno) { - _cleanup_free_ char *path = NULL, *p = NULL; + _cleanup_free_ char *p = NULL; struct stat statbuf; if (dot_or_dot_dot(de->d_name)) @@ -1926,11 +1926,7 @@ static int device_sysattrs_read_all_internal(sd_device *device, const char *subd continue; } - path = path_join(syspath, p ?: de->d_name); - if (!path) - return -ENOMEM; - - if (lstat(path, &statbuf) != 0) + if (fstatat(dirfd(dir), de->d_name, &statbuf, AT_SYMLINK_NOFOLLOW) < 0) continue; if ((statbuf.st_mode & (S_IRUSR | S_IWUSR)) == 0)