aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-11-18 01:08:24 +0000
committerMatt Kraai <kraai@debian.org>2000-11-18 01:08:24 +0000
commite93abf9e6997f333c5add8f11b1542bbc2ccc844 (patch)
treee098fc2e336e90f53d71f6906ad456350785aafa
parent5022d0e55fbfc137f2ff1e95af53a6687ed01b0e (diff)
downloadbusybox-e93abf9e6997f333c5add8f11b1542bbc2ccc844.tar.gz
Fixed user and group name listing.
-rw-r--r--coreutils/ls.c35
-rw-r--r--ls.c35
2 files changed, 26 insertions, 44 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 004c2a773..b1fbe3b2a 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -531,7 +531,7 @@ int list_single(struct dnode *dn)
char *filetime;
time_t ttime, age;
#endif
-#if defined (BB_FEATURE_LS_FILETYPES) || defined (BB_FEATURE_LS_USERNAME)
+#if defined (BB_FEATURE_LS_FILETYPES)
struct stat info;
#endif
#ifdef BB_FEATURE_LS_FILETYPES
@@ -574,28 +574,19 @@ int list_single(struct dnode *dn)
break;
case LIST_ID_NAME:
#ifdef BB_FEATURE_LS_USERNAME
- {
- memset(&info, 0, sizeof(struct stat));
- memset(scratch, 0, sizeof(scratch));
- if (!stat(dn->fullname, &info)) {
- my_getpwuid(scratch, info.st_uid);
- }
- if (*scratch) {
- fprintf(stdout, "%-8.8s ", scratch);
- } else {
- fprintf(stdout, "%-8d ", dn->dstat.st_uid);
- }
- memset(scratch, 0, sizeof(scratch));
- if (info.st_ctime != 0) {
- my_getgrgid(scratch, info.st_gid);
- }
- if (*scratch) {
- fprintf(stdout, "%-8.8s", scratch);
- } else {
- fprintf(stdout, "%-8d", dn->dstat.st_gid);
- }
+ memset(scratch, 0, sizeof(scratch));
+ my_getpwuid(scratch, dn->dstat.st_uid);
+ if (*scratch)
+ fprintf(stdout, "%-8.8s ", scratch);
+ else
+ fprintf(stdout, "%-8d ", dn->dstat.st_uid);
+ memset(scratch, 0, sizeof(scratch));
+ my_getgrgid(scratch, dn->dstat.st_gid);
+ if (*scratch)
+ fprintf(stdout, "%-8.8s", scratch);
+ else
+ fprintf(stdout, "%-8d", dn->dstat.st_gid);
column += 17;
- }
break;
#endif
case LIST_ID_NUMERIC:
diff --git a/ls.c b/ls.c
index 004c2a773..b1fbe3b2a 100644
--- a/ls.c
+++ b/ls.c
@@ -531,7 +531,7 @@ int list_single(struct dnode *dn)
char *filetime;
time_t ttime, age;
#endif
-#if defined (BB_FEATURE_LS_FILETYPES) || defined (BB_FEATURE_LS_USERNAME)
+#if defined (BB_FEATURE_LS_FILETYPES)
struct stat info;
#endif
#ifdef BB_FEATURE_LS_FILETYPES
@@ -574,28 +574,19 @@ int list_single(struct dnode *dn)
break;
case LIST_ID_NAME:
#ifdef BB_FEATURE_LS_USERNAME
- {
- memset(&info, 0, sizeof(struct stat));
- memset(scratch, 0, sizeof(scratch));
- if (!stat(dn->fullname, &info)) {
- my_getpwuid(scratch, info.st_uid);
- }
- if (*scratch) {
- fprintf(stdout, "%-8.8s ", scratch);
- } else {
- fprintf(stdout, "%-8d ", dn->dstat.st_uid);
- }
- memset(scratch, 0, sizeof(scratch));
- if (info.st_ctime != 0) {
- my_getgrgid(scratch, info.st_gid);
- }
- if (*scratch) {
- fprintf(stdout, "%-8.8s", scratch);
- } else {
- fprintf(stdout, "%-8d", dn->dstat.st_gid);
- }
+ memset(scratch, 0, sizeof(scratch));
+ my_getpwuid(scratch, dn->dstat.st_uid);
+ if (*scratch)
+ fprintf(stdout, "%-8.8s ", scratch);
+ else
+ fprintf(stdout, "%-8d ", dn->dstat.st_uid);
+ memset(scratch, 0, sizeof(scratch));
+ my_getgrgid(scratch, dn->dstat.st_gid);
+ if (*scratch)
+ fprintf(stdout, "%-8.8s", scratch);
+ else
+ fprintf(stdout, "%-8d", dn->dstat.st_gid);
column += 17;
- }
break;
#endif
case LIST_ID_NUMERIC: