The content of this branch was automatically imported from Fedora ELN with the following as its source: https://src.fedoraproject.org/rpms/sysfsutils#29b04909ce55c4620f2a3ac76c5a6559f6bf3a0a
44 lines
1.1 KiB
Diff
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
|
|
|