bug-gnulib
[Top][All Lists]
Advanced

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

Re: [patch v2] glob: resolve DT_UNKNOWN via is_dir


From: Paul Eggert
Subject: Re: [patch v2] glob: resolve DT_UNKNOWN via is_dir
Date: Fri, 11 Mar 2022 16:37:54 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2

Thanks for looking into this; it's long been on my plate but I haven't had time to work on the proper solution, which is basically to rewrite glob from scratch (this should make it considerably faster).

As far as your patch goes:

Gnulib prefers spaces to tabs.

The code unnecessarily calls strlen (directory).

The patch mishandles a directory "/" and a file "x", as it stats "//x" but this may differ from "/x" on some systems.

For speed the code should prefer fstatat on d.name to stat on the full name. Too bad glob_t doesn't have a gl_fstatat entry, but we can use fstatat when GLOB_ALTDIRFUNC is not in use.

The patch goes through a loop calling alloca_account, which is not good: it'll waste the stack. Better to use a scratch buffer, as in other parts of glob.c.

The code should prefer mempcpy and memcpy to stpcpy and strcpy (as in the rest of glob.c). That way, the Gnulib glob module needn't depend on the stpcpy module (plus the code's more reliable if another thread stomps on our strings between strlen and strcpy :-).

I don't see how the patch fixes the case where readdir_result_type (d) returns DT_LNK; this might be a symlink to a directory.

Proposed pair of patches attached (I haven't installed these). The first is yours but with tabs turned to spaces and with ChangeLog equal to your log entry. The second contains my proposed improvements. I haven't tested except on the Gnulib test cases (which aren't much).

Of course performance will suffer with all these correctness patches, but that can wait until a rewrite.

Attachment: 0001-glob-resolve-DT_UNKNOWN-via-is_dir.patch
Description: Text Data

Attachment: 0002-glob-fix-symlink-and-issues-improve-speed.patch
Description: Text Data


reply via email to

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