From 4966d758f2b1e17478afeb52da4d436f40767e04 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 1 Dec 2002 08:57:26 +0000 Subject: ls is now more efficient: it no longer needs to stat each directory entry on systems with valid dirent.d_type. (print_dir): Add DT_LNK and DT_REG. (main): Make --recursive set format_needs_type, not format_needs_stat. (gobble_file): Remove a FIXME comment, now that this is fixed. --- src/ls.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ls.c b/src/ls.c index 587fe4c63..118d70679 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1127,9 +1127,10 @@ main (int argc, char **argv) format_needs_stat = sort_type == sort_time || sort_type == sort_size || format == long_format || dereference == DEREF_ALWAYS - || recursive || print_block_size || print_inode; + || print_block_size || print_inode; format_needs_type = (format_needs_stat == 0 - && (print_with_color || indicator_style != none)); + && (recursive || print_with_color + || indicator_style != none)); if (dired && format == long_format) { @@ -2184,9 +2185,13 @@ print_dir (const char *name, const char *realname) enum filetype type = unknown; #if HAVE_STRUCT_DIRENT_D_TYPE - if (next->d_type == DT_DIR || next->d_type == DT_CHR - || next->d_type == DT_BLK || next->d_type == DT_SOCK - || next->d_type == DT_FIFO) + if (next->d_type == DT_BLK + || next->d_type == DT_CHR + || next->d_type == DT_DIR + || next->d_type == DT_FIFO + || next->d_type == DT_LNK + || next->d_type == DT_REG + || next->d_type == DT_SOCK) type = next->d_type; #endif total_blocks += gobble_file (next->d_name, type, 0, name); @@ -2318,10 +2323,6 @@ gobble_file (const char *name, enum filetype type, int explicit_arg, files[files_index].linkmode = 0; files[files_index].linkok = 0; - /* FIXME: this use of ls: `mkdir a; touch a/{b,c,d}; ls -R a' - shouldn't require that ls stat b, c, and d -- at least - not on systems with usable d_type. The problem is that - format_needs_stat is set, because of the -R. */ if (explicit_arg || format_needs_stat || (format_needs_type && type == unknown)) { -- cgit v1.2.3-70-g09d2