summaryrefslogtreecommitdiffstats
path: root/bin/ls
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-10-24 01:01:53 +0000
committerrwatson <rwatson@FreeBSD.org>2002-10-24 01:01:53 +0000
commit9201f501eae07c0b19f600c15685348b896e9edb (patch)
tree3841d7437afb1c196f0ecd0a855fb8fd24b8f750 /bin/ls
parent42f90ed7abf25bd99b0acdcd93c6e9f644e0b875 (diff)
downloadFreeBSD-src-9201f501eae07c0b19f600c15685348b896e9edb.zip
FreeBSD-src-9201f501eae07c0b19f600c15685348b896e9edb.tar.gz
Attempt improved use of fts results: use the correct path to the
object to retrieve label information on, rather than directly consuming the fts-provided paths (none of which are quite right). This is based on the similar readlink() code, and may contain the same bugs. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'bin/ls')
-rw-r--r--bin/ls/ls.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 6cacf4f..cddbb79 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/syslimits.h>
#include <sys/ioctl.h>
#include <sys/mac.h>
@@ -685,6 +686,7 @@ display(FTSENT *p, FTSENT *list, int options)
flen = 0;
labelstr = NULL;
if (f_label) {
+ char name[PATH_MAX + 1];
mac_t label;
int error;
@@ -696,12 +698,20 @@ display(FTSENT *p, FTSENT *list, int options)
goto label_out;
}
+ if (cur->fts_level == FTS_ROOTLEVEL)
+ snprintf(name, sizeof(name),
+ "%s", cur->fts_name);
+ else
+ snprintf(name, sizeof(name),
+ "%s/%s", cur->fts_parent->fts_accpath,
+ cur->fts_name);
+
if (options & FTS_LOGICAL)
- error = mac_get_file(
- cur->fts_path, label);
+ error = mac_get_file(name,
+ label);
else
- error = mac_get_link(
- cur->fts_name, label);
+ error = mac_get_link(name,
+ label);
if (error == -1) {
perror(cur->fts_name);
mac_free(label);
OpenPOWER on IntegriCloud