diff options
author | Jim Meyering <jim@meyering.net> | 2002-12-01 08:57:26 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-12-01 08:57:26 +0000 |
commit | 4966d758f2b1e17478afeb52da4d436f40767e04 (patch) | |
tree | d99c7cac646bf8e56c0fe76c39ddf5ef90cb1600 /src | |
parent | 7274f62b83e3f3c6024be07432f475193efae0aa (diff) | |
download | coreutils-4966d758f2b1e17478afeb52da4d436f40767e04.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ls.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -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)) { |