diff options
| author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-19 22:03:06 +0000 |
|---|---|---|
| committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-19 22:03:06 +0000 |
| commit | 74e66317f395b68ea2d6f7006ec97ea0dd651090 (patch) | |
| tree | c244a24fb16b372f155129656d6c14e2fccae775 /coreutils | |
| parent | c89a142e47f056a0f5dfc73bbbec3252ccbeefb0 (diff) | |
| download | busybox-w32-74e66317f395b68ea2d6f7006ec97ea0dd651090.tar.gz busybox-w32-74e66317f395b68ea2d6f7006ec97ea0dd651090.tar.bz2 busybox-w32-74e66317f395b68ea2d6f7006ec97ea0dd651090.zip | |
ls: stop doing time() for each file in "ls -l"
ls: use fully-buffered stdout (can it be problematic
on VERY slow/hanging NFS mounts?)
git-svn-id: svn://busybox.net/trunk/busybox@17393 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/ls.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index ff0831dac..067e463ee 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
| @@ -537,6 +537,12 @@ static struct dnode **list_dir(const char *path) | |||
| 537 | } | 537 | } |
| 538 | 538 | ||
| 539 | 539 | ||
| 540 | #if ENABLE_FEATURE_LS_TIMESTAMPS | ||
| 541 | /* Do time() just once. Saves one syscall per file for "ls -l" */ | ||
| 542 | /* Initialized in main() */ | ||
| 543 | static time_t current_time_t; | ||
| 544 | #endif | ||
| 545 | |||
| 540 | static int list_single(struct dnode *dn) | 546 | static int list_single(struct dnode *dn) |
| 541 | { | 547 | { |
| 542 | int i, column = 0; | 548 | int i, column = 0; |
| @@ -611,7 +617,8 @@ static int list_single(struct dnode *dn) | |||
| 611 | break; | 617 | break; |
| 612 | case LIST_DATE_TIME: | 618 | case LIST_DATE_TIME: |
| 613 | if ((all_fmt & LIST_FULLTIME) == 0) { | 619 | if ((all_fmt & LIST_FULLTIME) == 0) { |
| 614 | age = time(NULL) - ttime; | 620 | /* current_time_t ~== time(NULL) */ |
| 621 | age = current_time_t - ttime; | ||
| 615 | printf("%6.6s ", filetime + 4); | 622 | printf("%6.6s ", filetime + 4); |
| 616 | if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) { | 623 | if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) { |
| 617 | /* hh:mm if less than 6 months old */ | 624 | /* hh:mm if less than 6 months old */ |
| @@ -785,6 +792,12 @@ int ls_main(int argc, char **argv) | |||
| 785 | USE_FEATURE_AUTOWIDTH(char *terminal_width_str = NULL;) | 792 | USE_FEATURE_AUTOWIDTH(char *terminal_width_str = NULL;) |
| 786 | USE_FEATURE_LS_COLOR(char *color_opt;) | 793 | USE_FEATURE_LS_COLOR(char *color_opt;) |
| 787 | 794 | ||
| 795 | setvbuf(stdout, bb_common_bufsiz1, _IOFBF, BUFSIZ); | ||
| 796 | |||
| 797 | #if ENABLE_FEATURE_LS_TIMESTAMPS | ||
| 798 | time(¤t_time_t); | ||
| 799 | #endif | ||
| 800 | |||
| 788 | all_fmt = LIST_SHORT | | 801 | all_fmt = LIST_SHORT | |
| 789 | (ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD)); | 802 | (ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD)); |
| 790 | 803 | ||
