bug-findutils
[Top][All Lists]
Advanced

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

[bug #54262] -printf %Y doesn't output N for broken links


From: Tavian Barnes
Subject: [bug #54262] -printf %Y doesn't output N for broken links
Date: Sat, 7 Jul 2018 15:26:07 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Follow-up Comment #1, bug #54262 (project findutils):

The code in print.c is

                /* If we would normally follow links, do not do so.
                 * If we would normally not follow links, do so.
                 */
                if ((following_links () ? optionp_stat : optionl_stat)
                    (state.rel_pathname, &sbuf) != 0)

which calls optionl_stat() in the default -P mode.  But optionl_stat() calls
fallback_stat() if the initial fstatat() fails, which does

  switch (errno)
    {
    case ENOENT:
    case ENOTDIR:
      if (options.debug_options & DebugStat)
        fprintf(stderr, "fallback_stat(): stat(%s) failed; falling back on
lstat()\n", name);
      return fstatat(state.cwd_dir_fd, name, p, AT_SYMLINK_NOFOLLOW);

which is probably wrong for %Y.  Also the print.c code should probably check
for ENOTDIR in addition to ENOENT.

Furthermore, the "if we would normally follow links, do not do so" comment,
and subsequent attempt to use optionp_stat() if following_links(), seems to
contradict the documentation which just says "(like %y), plus follow
symlinks".  But that whole block is guarded by

            if (S_ISLNK (stat_buf->st_mode))

which won't be true except for broken links if following_links().

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54262>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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