[PATCH v5 2/2] io: Use gnulib fts implementation (BZ 22944, BZ 20331)
Collin Funk
collin.funk1@gmail.com
Sun Apr 12 02:45:23 GMT 2026
Collin Funk <collin.funk1@gmail.com> writes:
> Here is a Gnulib patch which avoids the stat and preserves the old glibc
> behavior:
>
> diff --git a/lib/fts.c b/lib/fts.c
> index c61e8d89d8..fb42f243a0 100644
> --- a/lib/fts.c
> +++ b/lib/fts.c
> @@ -1035,6 +1035,22 @@ check_for_dir:
> if (! enter_dir (sp, p))
> return NULL;
> }
> +
> + if (p->fts_info == FTS_NSOK)
> + {
> + if (S_ISREG (p->fts_statp->st_mode))
> + p->fts_info = FTS_F;
> + else if (S_ISDIR (p->fts_statp->st_mode))
> + {
> + if (! ISDOT (p->fts_name))
> + p->fts_info = FTS_D;
> + else
> + {
> + p->fts_info = (p->fts_level == FTS_ROOTLEVEL
> + ? FTS_D : FTS_DOT);
> + }
> + }
> + }
> return p;
> }
> cd_dot_dot:
Actually ignore this...
Having ent->fts_info set to FTS_F or FTS_D would imply that
ent->fts_statp is valid, which it isn't. Therefore, this would cause
more breakage. :)
I guess we will have to version the symbols.
Collin
More information about the Libc-alpha
mailing list