sysfsutils/0003-use-stat-not-lstat.patch
Christopher Engelhard c1dfc3ce6e Use new upstream tarball, backport relevant upstream fixes up to commit b688c65
The new tarball hosted on GitHub is not identical to the original one, but
contains no functional differences

All of Fedora's patches to sysfsutils 2.1.0 have been merged upstream and will
be included in the next sysfsutils release. This commit incorporates all previous
patches. Additionally, it backports various fixes added upstream, that mainly
deal with compiler warnings when using moden compilers.
2020-08-17 18:34:42 +02:00

44 lines
1.1 KiB
Diff

From 88b1ba388e6908e1bca3ef1779325e5b9a688f9c Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Thu, 25 Jun 2020 10:04:40 -0700
Subject: [PATCH 3/8] Use stat() not lstat() to find link target.
The test was backwards? We are trying to find what the
link points at, not info about the link.
path_is_file() should call stat(), not lstat()
---
lib/sysfs_utils.c | 2 +-
test/test.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/sysfs_utils.c b/lib/sysfs_utils.c
index bd6f9c1..bddf722 100644
--- a/lib/sysfs_utils.c
+++ b/lib/sysfs_utils.c
@@ -292,7 +292,7 @@ int sysfs_path_is_file(const char *path)
errno = EINVAL;
return 1;
}
- if ((lstat(path, &astats)) != 0) {
+ if ((stat(path, &astats)) != 0) {
dprintf("stat() failed\n");
return 1;
}
diff --git a/test/test.c b/test/test.c
index ab2397d..41a470c 100644
--- a/test/test.c
+++ b/test/test.c
@@ -165,7 +165,7 @@ static int path_is_dir(const char *path)
{
struct stat astats;
- if ((lstat(path, &astats)) != 0)
+ if ((stat(path, &astats)) != 0)
goto direrr;
if (S_ISDIR(astats.st_mode))
--
2.28.0