summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-12-02 20:55:02 +0000
committerJim Meyering <jim@meyering.net>2000-12-02 20:55:02 +0000
commite49511faef949ea27e266f11030351aed935dddc (patch)
tree02cbb37775629158e0807d0361185036926cbe3c /src
parente05c32a868b08fb59a4e54e9cffaccd4f5377521 (diff)
downloadcoreutils-e49511faef949ea27e266f11030351aed935dddc.tar.xz
(gobble_file): Do not fall back on lstat if stat
fails; POSIX.2 does not allow this. Invoke acl only on non-symlinks, and only if lstat or stat succeeds.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/ls.c b/src/ls.c
index 146b5aa5d..6fb10edf5 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1887,23 +1887,9 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
attach (path, dirname, name);
}
- if (trace_links)
- {
- val = stat (path, &files[files_index].stat);
- if (val < 0)
- {
- /* Perhaps a symbolically-linked to file doesn't exist; stat
- the link instead. */
- val = lstat (path, &files[files_index].stat);
- }
- }
- else
- {
- val = lstat (path, &files[files_index].stat);
-#if USE_ACL
- files[files_index].have_acl = (acl (path, GETACLCNT, 0, NULL) > 4);
-#endif
- }
+ val = (trace_links
+ ? stat (path, &files[files_index].stat)
+ : lstat (path, &files[files_index].stat));
if (val < 0)
{
@@ -1912,6 +1898,11 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
return 0;
}
+#if USE_ACL
+ if (! S_ISLNK (files[files_index].stat.st_mode))
+ files[files_index].have_acl = 4 < acl (path, GETACLCNT, 0, NULL);
+#endif
+
if (S_ISLNK (files[files_index].stat.st_mode)
&& (explicit_arg || format == long_format || check_symlink_color))
{