diff options
author | Matt Kraai <kraai@debian.org> | 2000-11-18 01:08:24 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-11-18 01:08:24 +0000 |
commit | e93abf9e6997f333c5add8f11b1542bbc2ccc844 (patch) | |
tree | e098fc2e336e90f53d71f6906ad456350785aafa | |
parent | 5022d0e55fbfc137f2ff1e95af53a6687ed01b0e (diff) | |
download | busybox-w32-e93abf9e6997f333c5add8f11b1542bbc2ccc844.tar.gz busybox-w32-e93abf9e6997f333c5add8f11b1542bbc2ccc844.tar.bz2 busybox-w32-e93abf9e6997f333c5add8f11b1542bbc2ccc844.zip |
Fixed user and group name listing.
-rw-r--r-- | coreutils/ls.c | 35 | ||||
-rw-r--r-- | ls.c | 35 |
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) | |||
531 | char *filetime; | 531 | char *filetime; |
532 | time_t ttime, age; | 532 | time_t ttime, age; |
533 | #endif | 533 | #endif |
534 | #if defined (BB_FEATURE_LS_FILETYPES) || defined (BB_FEATURE_LS_USERNAME) | 534 | #if defined (BB_FEATURE_LS_FILETYPES) |
535 | struct stat info; | 535 | struct stat info; |
536 | #endif | 536 | #endif |
537 | #ifdef BB_FEATURE_LS_FILETYPES | 537 | #ifdef BB_FEATURE_LS_FILETYPES |
@@ -574,28 +574,19 @@ int list_single(struct dnode *dn) | |||
574 | break; | 574 | break; |
575 | case LIST_ID_NAME: | 575 | case LIST_ID_NAME: |
576 | #ifdef BB_FEATURE_LS_USERNAME | 576 | #ifdef BB_FEATURE_LS_USERNAME |
577 | { | 577 | memset(scratch, 0, sizeof(scratch)); |
578 | memset(&info, 0, sizeof(struct stat)); | 578 | my_getpwuid(scratch, dn->dstat.st_uid); |
579 | memset(scratch, 0, sizeof(scratch)); | 579 | if (*scratch) |
580 | if (!stat(dn->fullname, &info)) { | 580 | fprintf(stdout, "%-8.8s ", scratch); |
581 | my_getpwuid(scratch, info.st_uid); | 581 | else |
582 | } | 582 | fprintf(stdout, "%-8d ", dn->dstat.st_uid); |
583 | if (*scratch) { | 583 | memset(scratch, 0, sizeof(scratch)); |
584 | fprintf(stdout, "%-8.8s ", scratch); | 584 | my_getgrgid(scratch, dn->dstat.st_gid); |
585 | } else { | 585 | if (*scratch) |
586 | fprintf(stdout, "%-8d ", dn->dstat.st_uid); | 586 | fprintf(stdout, "%-8.8s", scratch); |
587 | } | 587 | else |
588 | memset(scratch, 0, sizeof(scratch)); | 588 | fprintf(stdout, "%-8d", dn->dstat.st_gid); |
589 | if (info.st_ctime != 0) { | ||
590 | my_getgrgid(scratch, info.st_gid); | ||
591 | } | ||
592 | if (*scratch) { | ||
593 | fprintf(stdout, "%-8.8s", scratch); | ||
594 | } else { | ||
595 | fprintf(stdout, "%-8d", dn->dstat.st_gid); | ||
596 | } | ||
597 | column += 17; | 589 | column += 17; |
598 | } | ||
599 | break; | 590 | break; |
600 | #endif | 591 | #endif |
601 | case LIST_ID_NUMERIC: | 592 | case LIST_ID_NUMERIC: |
@@ -531,7 +531,7 @@ int list_single(struct dnode *dn) | |||
531 | char *filetime; | 531 | char *filetime; |
532 | time_t ttime, age; | 532 | time_t ttime, age; |
533 | #endif | 533 | #endif |
534 | #if defined (BB_FEATURE_LS_FILETYPES) || defined (BB_FEATURE_LS_USERNAME) | 534 | #if defined (BB_FEATURE_LS_FILETYPES) |
535 | struct stat info; | 535 | struct stat info; |
536 | #endif | 536 | #endif |
537 | #ifdef BB_FEATURE_LS_FILETYPES | 537 | #ifdef BB_FEATURE_LS_FILETYPES |
@@ -574,28 +574,19 @@ int list_single(struct dnode *dn) | |||
574 | break; | 574 | break; |
575 | case LIST_ID_NAME: | 575 | case LIST_ID_NAME: |
576 | #ifdef BB_FEATURE_LS_USERNAME | 576 | #ifdef BB_FEATURE_LS_USERNAME |
577 | { | 577 | memset(scratch, 0, sizeof(scratch)); |
578 | memset(&info, 0, sizeof(struct stat)); | 578 | my_getpwuid(scratch, dn->dstat.st_uid); |
579 | memset(scratch, 0, sizeof(scratch)); | 579 | if (*scratch) |
580 | if (!stat(dn->fullname, &info)) { | 580 | fprintf(stdout, "%-8.8s ", scratch); |
581 | my_getpwuid(scratch, info.st_uid); | 581 | else |
582 | } | 582 | fprintf(stdout, "%-8d ", dn->dstat.st_uid); |
583 | if (*scratch) { | 583 | memset(scratch, 0, sizeof(scratch)); |
584 | fprintf(stdout, "%-8.8s ", scratch); | 584 | my_getgrgid(scratch, dn->dstat.st_gid); |
585 | } else { | 585 | if (*scratch) |
586 | fprintf(stdout, "%-8d ", dn->dstat.st_uid); | 586 | fprintf(stdout, "%-8.8s", scratch); |
587 | } | 587 | else |
588 | memset(scratch, 0, sizeof(scratch)); | 588 | fprintf(stdout, "%-8d", dn->dstat.st_gid); |
589 | if (info.st_ctime != 0) { | ||
590 | my_getgrgid(scratch, info.st_gid); | ||
591 | } | ||
592 | if (*scratch) { | ||
593 | fprintf(stdout, "%-8.8s", scratch); | ||
594 | } else { | ||
595 | fprintf(stdout, "%-8d", dn->dstat.st_gid); | ||
596 | } | ||
597 | column += 17; | 589 | column += 17; |
598 | } | ||
599 | break; | 590 | break; |
600 | #endif | 591 | #endif |
601 | case LIST_ID_NUMERIC: | 592 | case LIST_ID_NUMERIC: |