[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

in ls.c, should check errno after readdir

From: Mike Coleman
Subject: in ls.c, should check errno after readdir
Date: Wed, 21 Aug 2002 04:24:54 GMT

In ls.c, errno should be checked after a NULL result from readdir, to see if
there was an error.  It may be that in a "normal" posix system, no error can
happen here, but my NAS box (an EMC Celerra) is reporting EACCES here, so a
defensive check, rather than ignoring the error, would be helpful.

I suppose this applies to all readdir's.


  while ((next = readdir (reading)) != NULL)
    if (file_interesting (next))
        enum filetype type = unknown;

        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)
          type = next->d_type;
        total_blocks += gobble_file (next->d_name, type, 0, name);

  if (CLOSEDIR (reading))
      error (0, errno, "%s", quotearg_colon (name));
      exit_status = 1;
      /* Don't return; print whatever we got. */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]