This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2 00/18] posix: glob fixes and refactor
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Fri, 11 Aug 2017 11:50:26 -0300
- Subject: [PATCH v2 00/18] posix: glob fixes and refactor
- Authentication-results: sourceware.org; auth=none
Changes from previous version [1]
- Add fix for BZ#10246.
- Incorporate review change for the dynamic implementation for
C strings.
- Reorganize patch order.
---
The set fixes some long standing glob issues (gnulib sync and dandling
symlinks), adjust its tests for libsupport, and refactor current
implementation to use a dynarray implementation for C strings.
To correct provide a C string analogous using dynarray I had to access
its private member directly, so I created a specialized implementation
(malloc/char_array-skeleton.c). It currently works similar to dynarray,
by including its header which defines static functions. If it is the
case, one could its function as an internal API. I added some
function only to manipulate mainly for the work to refactor glob.
The idea to refactor is mainly to remove the alloca and internal buffer
handling boilerplate usage. So it does not trace its possible stack
usage using 'alloca_used' variable, which is somewhat fragile (since
it just track glob usage itself). I used 256 bytes for default
string size (for initial stack allocation), but we can also tune it
if required. The GCC -fstack-usage on x86_64 for shared cases
shows:
glob.c:246:1:next_brace_sub 32 static
dynarray-skeleton.c:203:1:globnames_array_free 48 static
glob.c:1176:1:collated_compare 32 static
glob.c:1196:1:prefix_array 96 static
dynarray-skeleton.c:275:1:globnames_array_add__ 64 static
dynarray-skeleton.c:373:1:char_array_resize.part.3 64 static
char_array-skeleton.c:257:1:char_array_replace_str_pos 64 static
char_array-skeleton.c:195:1:char_array_crop 48 static
char_array-skeleton.c:231:1:char_array_append_str 64 static
char_array-skeleton.c:117:1:char_array_set_str_size 64 static
glob.c:271:1:get_home_directory 1200 static
glob.c:1264:1:glob_in_dir 1104 static
glob.c:352:1:glob 1216 static
I did not and will not take care of the non-unix code on glob.c (it
is probably broken after the glob refactor). In fact I would like
to cleanup this implementation even further to remove all code not
really used for GLIBC if gnulib developers want to not keep the
implementation at sync.
Adhemerval Zanella (17):
posix: Sync glob with gnulib [BZ #1062]
posix: Adjust glob tests to libsupport
posix: Consolidate glob implementation
posix: Allow glob to match dangling symlinks [BZ #866]
posix: Remove glob GET_LOGIN_NAME_MAX usage
posix: User LOGIN_NAME_MAX for all user names in glob
malloc: Add specialized dynarray for C strings
posix: Use char_array for internal glob dirname
posix: Remove alloca usage for GLOB_BRACE on glob
posix: Remove alloca usage on glob dirname
posix: Use dynarray for globname in glob
posix: Remove all alloca usage in glob
posix: Use char_array for home_dir in glob
posix: Add common function to get home directory
posix: More check for overflow allocation in glob
posix: Use enum for __glob_pattern_type result
posix: Fix glob with GLOB_NOCHECK returning modified patterns
(BZ#10246)
Florian Weimer (1):
posix: Rewrite to use struct scratch_buffer instead of extend_alloca
malloc/Makefile | 4 +-
malloc/Versions | 7 +
malloc/char_array-impl.c | 57 +
malloc/char_array-skeleton.c | 271 +++++
malloc/char_array.h | 53 +
malloc/dynarray.h | 9 +
malloc/dynarray_overflow_failure.c | 31 +
malloc/malloc-internal.h | 14 +
malloc/tst-char_array.c | 110 ++
posix/Makefile | 17 +-
posix/bug-glob1.c | 88 --
posix/bug-glob3.c | 45 -
posix/glob.c | 1194 ++++++++------------
posix/glob_internal.h | 65 ++
posix/glob_pattern_p.c | 29 +
posix/globfree.c | 37 +
posix/globfree64.c | 27 +
posix/globtest.c | 166 +--
posix/globtest.sh | 36 +
posix/tst-glob_basic.c | 43 +
posix/tst-glob_common.c | 103 ++
posix/{bug-glob2.c => tst-glob_memory.c} | 100 +-
posix/tst-glob_symlinks.c | 133 +++
posix/tst-gnuglob.c | 109 +-
sysdeps/gnu/glob64.c | 25 -
sysdeps/unix/sysv/linux/Makefile | 2 +-
sysdeps/unix/sysv/linux/alpha/Makefile | 4 -
sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} | 11 -
sysdeps/unix/sysv/linux/alpha/globfree.c | 36 +
sysdeps/unix/sysv/linux/arm/glob64.c | 1 -
sysdeps/unix/sysv/linux/glob.c | 23 +
sysdeps/unix/sysv/linux/glob64.c | 55 +
sysdeps/unix/sysv/linux/globfree.c | 23 +
sysdeps/unix/sysv/linux/globfree64.c | 0
sysdeps/unix/sysv/linux/i386/alphasort64.c | 2 +-
sysdeps/unix/sysv/linux/i386/getdents64.c | 2 +-
sysdeps/unix/sysv/linux/i386/readdir64.c | 2 +-
sysdeps/unix/sysv/linux/i386/readdir64_r.c | 2 +-
sysdeps/unix/sysv/linux/i386/versionsort64.c | 2 +-
sysdeps/unix/sysv/linux/m68k/glob64.c | 1 -
sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c | 1 -
sysdeps/unix/sysv/linux/{i386 => }/olddirent.h | 0
.../unix/sysv/linux/{i386/glob64.c => oldglob.c} | 51 +-
sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c | 1 -
sysdeps/unix/sysv/linux/s390/s390-32/glob64.c | 20 +
sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c | 2 +
sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c | 1 -
sysdeps/unix/sysv/linux/wordsize-64/glob64.c | 2 -
sysdeps/unix/sysv/linux/x86_64/x32/glob.c | 1 -
sysdeps/wordsize-64/glob.c | 8 -
sysdeps/wordsize-64/glob64.c | 1 -
51 files changed, 1786 insertions(+), 1241 deletions(-)
create mode 100644 malloc/char_array-impl.c
create mode 100644 malloc/char_array-skeleton.c
create mode 100644 malloc/char_array.h
create mode 100644 malloc/dynarray_overflow_failure.c
create mode 100644 malloc/tst-char_array.c
delete mode 100644 posix/bug-glob1.c
delete mode 100644 posix/bug-glob3.c
create mode 100644 posix/glob_internal.h
create mode 100644 posix/glob_pattern_p.c
create mode 100644 posix/globfree.c
create mode 100644 posix/globfree64.c
create mode 100644 posix/tst-glob_basic.c
create mode 100644 posix/tst-glob_common.c
rename posix/{bug-glob2.c => tst-glob_memory.c} (76%)
create mode 100644 posix/tst-glob_symlinks.c
delete mode 100644 sysdeps/gnu/glob64.c
rename sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} (78%)
create mode 100644 sysdeps/unix/sysv/linux/alpha/globfree.c
delete mode 100644 sysdeps/unix/sysv/linux/arm/glob64.c
create mode 100644 sysdeps/unix/sysv/linux/glob.c
create mode 100644 sysdeps/unix/sysv/linux/glob64.c
create mode 100644 sysdeps/unix/sysv/linux/globfree.c
create mode 100644 sysdeps/unix/sysv/linux/globfree64.c
delete mode 100644 sysdeps/unix/sysv/linux/m68k/glob64.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c
rename sysdeps/unix/sysv/linux/{i386 => }/olddirent.h (100%)
rename sysdeps/unix/sysv/linux/{i386/glob64.c => oldglob.c} (62%)
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c
create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/glob64.c
create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c
delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c
delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/glob64.c
delete mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/glob.c
delete mode 100644 sysdeps/wordsize-64/glob.c
delete mode 100644 sysdeps/wordsize-64/glob64.c
--
2.7.4