diff options
Diffstat (limited to 'dirent')
-rw-r--r-- | dirent/Makefile | 10 | ||||
-rw-r--r-- | dirent/alphasort.c | 15 | ||||
-rw-r--r-- | dirent/alphasort64.c | 9 | ||||
-rw-r--r-- | dirent/closedir.c | 2 | ||||
-rw-r--r-- | dirent/dirent.h | 9 | ||||
-rw-r--r-- | dirent/dirfd.c | 6 | ||||
-rw-r--r-- | dirent/fdopendir.c | 2 | ||||
-rw-r--r-- | dirent/getdents.c | 2 | ||||
-rw-r--r-- | dirent/getdents64.c | 2 | ||||
-rw-r--r-- | dirent/list.c | 2 | ||||
-rw-r--r-- | dirent/opendir-tst1.c | 11 | ||||
-rw-r--r-- | dirent/opendir.c | 2 | ||||
-rw-r--r-- | dirent/readdir.c | 2 | ||||
-rw-r--r-- | dirent/readdir64.c | 2 | ||||
-rw-r--r-- | dirent/readdir64_r.c | 2 | ||||
-rw-r--r-- | dirent/readdir_r.c | 2 | ||||
-rw-r--r-- | dirent/rewinddir.c | 2 | ||||
-rw-r--r-- | dirent/scandir-cancel.c | 2 | ||||
-rw-r--r-- | dirent/scandir-tail-common.c | 103 | ||||
-rw-r--r-- | dirent/scandir-tail.c | 95 | ||||
-rw-r--r-- | dirent/scandir.c | 29 | ||||
-rw-r--r-- | dirent/scandir64-tail.c | 12 | ||||
-rw-r--r-- | dirent/scandir64.c | 25 | ||||
-rw-r--r-- | dirent/scandirat.c | 32 | ||||
-rw-r--r-- | dirent/scandirat64.c | 25 | ||||
-rw-r--r-- | dirent/seekdir.c | 2 | ||||
-rw-r--r-- | dirent/telldir.c | 2 | ||||
-rw-r--r-- | dirent/tst-fdopendir.c | 1 | ||||
-rw-r--r-- | dirent/tst-fdopendir2.c | 1 | ||||
-rw-r--r-- | dirent/tst-scandir.c | 4 | ||||
-rw-r--r-- | dirent/versionsort.c | 14 | ||||
-rw-r--r-- | dirent/versionsort64.c | 9 |
32 files changed, 208 insertions, 230 deletions
diff --git a/dirent/Makefile b/dirent/Makefile index 26bfb43985..25cd63a78d 100644 --- a/dirent/Makefile +++ b/dirent/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2016 Free Software Foundation, Inc. +# Copyright (C) 1991-2018 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -33,10 +33,10 @@ routines := opendir closedir readdir readdir_r rewinddir \ tests := list tst-seekdir opendir-tst1 bug-readdir1 tst-fdopendir \ tst-fdopendir2 tst-scandir tst-scandir64 -CFLAGS-scandir.c = $(uses-callbacks) -CFLAGS-scandir64.c = $(uses-callbacks) -CFLAGS-scandir-tail.c = $(uses-callbacks) -CFLAGS-scandir64-tail.c = $(uses-callbacks) +CFLAGS-scandir.c += $(uses-callbacks) +CFLAGS-scandir64.c += $(uses-callbacks) +CFLAGS-scandir-tail.c += $(uses-callbacks) +CFLAGS-scandir64-tail.c += $(uses-callbacks) include ../Rules diff --git a/dirent/alphasort.c b/dirent/alphasort.c index 8255e8d573..6b2a70770d 100644 --- a/dirent/alphasort.c +++ b/dirent/alphasort.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,23 +15,14 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -/* We need to avoid the header declaration of alphasort64, because - the types don't match alphasort and then the compiler will - complain about the mismatch when we do the alias below. */ -#define alphasort64 __renamed_alphasort64 - #include <dirent.h> -#undef alphasort64 - -#include <string.h> +#if !_DIRENT_MATCHES_DIRENT64 +# include <string.h> int alphasort (const struct dirent **a, const struct dirent **b) { return strcoll ((*a)->d_name, (*b)->d_name); } - -#ifdef _DIRENT_MATCHES_DIRENT64 -weak_alias (alphasort, alphasort64) #endif diff --git a/dirent/alphasort64.c b/dirent/alphasort64.c index 7247b589b9..b822333fca 100644 --- a/dirent/alphasort64.c +++ b/dirent/alphasort64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,16 +15,17 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#define alphasort __no_alphasort_decl #include <dirent.h> +#undef alphasort #include <string.h> -/* alphasort.c defines alphasort64 as an alias if _DIRENT_MATCHES_DIRENT64. */ -#ifndef _DIRENT_MATCHES_DIRENT64 - int alphasort64 (const struct dirent64 **a, const struct dirent64 **b) { return strcoll ((*a)->d_name, (*b)->d_name); } +#if _DIRENT_MATCHES_DIRENT64 +weak_alias (alphasort64, alphasort) #endif diff --git a/dirent/closedir.c b/dirent/closedir.c index 9d43588ad1..ac0126cdfa 100644 --- a/dirent/closedir.c +++ b/dirent/closedir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/dirent.h b/dirent/dirent.h index 9a4b6bf579..03018b235c 100644 --- a/dirent/dirent.h +++ b/dirent/dirent.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -183,14 +183,15 @@ extern struct dirent64 *readdir64 (DIR *__dirp) __nonnull ((1)); extern int readdir_r (DIR *__restrict __dirp, struct dirent *__restrict __entry, struct dirent **__restrict __result) - __nonnull ((1, 2, 3)); + __nonnull ((1, 2, 3)) __attribute_deprecated__; # else # ifdef __REDIRECT extern int __REDIRECT (readdir_r, (DIR *__restrict __dirp, struct dirent *__restrict __entry, struct dirent **__restrict __result), - readdir64_r) __nonnull ((1, 2, 3)); + readdir64_r) + __nonnull ((1, 2, 3)) __attribute_deprecated__; # else # define readdir_r readdir64_r # endif @@ -200,7 +201,7 @@ extern int __REDIRECT (readdir_r, extern int readdir64_r (DIR *__restrict __dirp, struct dirent64 *__restrict __entry, struct dirent64 **__restrict __result) - __nonnull ((1, 2, 3)); + __nonnull ((1, 2, 3)) __attribute_deprecated__; # endif #endif /* POSIX or misc */ diff --git a/dirent/dirfd.c b/dirent/dirfd.c index 4d3bb5b880..8e59cfa928 100644 --- a/dirent/dirfd.c +++ b/dirent/dirfd.c @@ -1,5 +1,5 @@ /* Return the file descriptor used by a DIR stream. Stub version. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,10 +21,12 @@ #include <errno.h> int -dirfd (DIR *dirp) +__dirfd (DIR *dirp) { __set_errno (ENOSYS); return -1; } +weak_alias (__dirfd, dirfd) stub_warning (dirfd) +libc_hidden_def (dirfd) diff --git a/dirent/fdopendir.c b/dirent/fdopendir.c index 9771ddd7a3..9f0c7cd50b 100644 --- a/dirent/fdopendir.c +++ b/dirent/fdopendir.c @@ -1,5 +1,5 @@ /* Open a directory stream from a file descriptor. Stub version. - Copyright (C) 2005-2016 Free Software Foundation, Inc. + Copyright (C) 2005-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/getdents.c b/dirent/getdents.c index 8386bb02bc..63da1c42f5 100644 --- a/dirent/getdents.c +++ b/dirent/getdents.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/getdents64.c b/dirent/getdents64.c index 2933400198..19361f363c 100644 --- a/dirent/getdents64.c +++ b/dirent/getdents64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/list.c b/dirent/list.c index 002430546d..803b85abf1 100644 --- a/dirent/list.c +++ b/dirent/list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/opendir-tst1.c b/dirent/opendir-tst1.c index e96a817398..81ce31774f 100644 --- a/dirent/opendir-tst1.c +++ b/dirent/opendir-tst1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -23,6 +23,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/stat.h> /* Name of the FIFO. */ char tmpname[] = "fifoXXXXXX"; @@ -58,7 +59,7 @@ real_test (void) static int -do_test (int argc, char *argv[]) +do_test (void) { int retval; @@ -89,8 +90,6 @@ do_cleanup (void) { remove (tmpname); } -#define CLEANUP_HANDLER do_cleanup () +#define CLEANUP_HANDLER do_cleanup - -/* Include the test skeleton. */ -#include <test-skeleton.c> +#include <support/test-driver.c> diff --git a/dirent/opendir.c b/dirent/opendir.c index 1fb3981036..b922ca63d8 100644 --- a/dirent/opendir.c +++ b/dirent/opendir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/readdir.c b/dirent/readdir.c index 9d1080550a..c053fd85fe 100644 --- a/dirent/readdir.c +++ b/dirent/readdir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/readdir64.c b/dirent/readdir64.c index f5167a45f2..daa6b86256 100644 --- a/dirent/readdir64.c +++ b/dirent/readdir64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/readdir64_r.c b/dirent/readdir64_r.c index 3c5f9db9fd..50b83bfe01 100644 --- a/dirent/readdir64_r.c +++ b/dirent/readdir64_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/readdir_r.c b/dirent/readdir_r.c index 646526337d..39339f9cf4 100644 --- a/dirent/readdir_r.c +++ b/dirent/readdir_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/rewinddir.c b/dirent/rewinddir.c index eaecb46f5e..30acd37909 100644 --- a/dirent/rewinddir.c +++ b/dirent/rewinddir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/scandir-cancel.c b/dirent/scandir-cancel.c index 929a58a454..65dee6e156 100644 --- a/dirent/scandir-cancel.c +++ b/dirent/scandir-cancel.c @@ -1,5 +1,5 @@ /* Cancellation handler used in scandir* implementations. - Copyright (C) 1992-2016 Free Software Foundation, Inc. + Copyright (C) 1992-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/scandir-tail-common.c b/dirent/scandir-tail-common.c new file mode 100644 index 0000000000..f89cf77b56 --- /dev/null +++ b/dirent/scandir-tail-common.c @@ -0,0 +1,103 @@ +/* Common implementation for scandir{at}. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <string.h> +#include <errno.h> + +int +SCANDIR_TAIL (DIR *dp, + DIRENT_TYPE ***namelist, + int (*select) (const DIRENT_TYPE *), + int (*cmp) (const DIRENT_TYPE **, const DIRENT_TYPE **)) +{ + if (dp == NULL) + return -1; + + int save = errno; + __set_errno (0); + + int result; + struct scandir_cancel_struct c = { .dp = dp }; + __libc_cleanup_push (&__scandir_cancel_handler, &c); + + DIRENT_TYPE **v = NULL; + size_t vsize = 0; + DIRENT_TYPE *d; + while ((d = READDIR (dp)) != NULL) + { + if (select != NULL) + { + int selected = (*select) (d); + + /* The SELECT function might have set errno to non-zero on + success. It was zero before and it needs to be again to + make the later tests work. */ + __set_errno (0); + + if (!selected) + continue; + } + + if (__glibc_unlikely (c.cnt == vsize)) + { + if (vsize == 0) + vsize = 10; + else + vsize *= 2; + DIRENT_TYPE **new = realloc (v, vsize * sizeof *v); + if (new == NULL) + break; + c.v = v = new; + } + + size_t dsize = &d->d_name[_D_ALLOC_NAMLEN (d)] - (char *) d; + DIRENT_TYPE *vnew = malloc (dsize); + if (vnew == NULL) + break; + v[c.cnt++] = (DIRENT_TYPE *) memcpy (vnew, d, dsize); + + /* Ignore errors from readdir, malloc or realloc. These functions + might have set errno to non-zero on success. It was zero before + and it needs to be again to make the latter tests work. */ + __set_errno (0); + } + + if (__glibc_likely (errno == 0)) + { + __closedir (dp); + + /* Sort the list if we have a comparison function to sort with. */ + if (cmp != NULL) + qsort (v, c.cnt, sizeof *v, (__compar_fn_t) cmp); + + *namelist = v; + result = c.cnt; + } + else + { + /* This frees everything and calls closedir. */ + __scandir_cancel_handler (&c); + result = -1; + } + + __libc_cleanup_pop (0); + + if (result >= 0) + __set_errno (save); + return result; +} diff --git a/dirent/scandir-tail.c b/dirent/scandir-tail.c index b72d9c7b6d..7395dc4a26 100644 --- a/dirent/scandir-tail.c +++ b/dirent/scandir-tail.c @@ -1,5 +1,5 @@ /* Logic guts of scandir*. - Copyright (C) 1992-2016 Free Software Foundation, Inc. + Copyright (C) 1992-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,94 +17,13 @@ <http://www.gnu.org/licenses/>. */ #include <dirent.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <libc-lock.h> -#ifndef SCANDIR_TAIL -# define SCANDIR_TAIL __scandir_tail -# define READDIR __readdir -# define DIRENT_TYPE struct dirent -#endif - -internal_function -int -SCANDIR_TAIL (DIR *dp, - DIRENT_TYPE ***namelist, - int (*select) (const DIRENT_TYPE *), - int (*cmp) (const DIRENT_TYPE **, const DIRENT_TYPE **)) -{ - if (dp == NULL) - return -1; - - int save = errno; - __set_errno (0); - - int result; - struct scandir_cancel_struct c = { .dp = dp }; - __libc_cleanup_push (&__scandir_cancel_handler, &c); - - DIRENT_TYPE **v = NULL; - size_t vsize = 0; - DIRENT_TYPE *d; - while ((d = READDIR (dp)) != NULL) - { - if (select != NULL) - { - int selected = (*select) (d); - - /* The SELECT function might have changed errno. It was - zero before and it need to be again to make the later - tests work. */ - __set_errno (0); +#if !_DIRENT_MATCHES_DIRENT64 - if (!selected) - continue; - } - else - __set_errno (0); +# define SCANDIR_TAIL __scandir_tail +# define READDIR __readdir +# define DIRENT_TYPE struct dirent - if (__glibc_unlikely (c.cnt == vsize)) - { - if (vsize == 0) - vsize = 10; - else - vsize *= 2; - DIRENT_TYPE **new = realloc (v, vsize * sizeof *v); - if (new == NULL) - break; - c.v = v = new; - } +# include <dirent/scandir-tail-common.c> - size_t dsize = &d->d_name[_D_ALLOC_NAMLEN (d)] - (char *) d; - DIRENT_TYPE *vnew = malloc (dsize); - if (vnew == NULL) - break; - v[c.cnt++] = (DIRENT_TYPE *) memcpy (vnew, d, dsize); - } - - if (__glibc_likely (errno == 0)) - { - __closedir (dp); - - /* Sort the list if we have a comparison function to sort with. */ - if (cmp != NULL) - qsort (v, c.cnt, sizeof *v, (__compar_fn_t) cmp); - - *namelist = v; - result = c.cnt; - } - else - { - /* This frees everything and calls closedir. */ - __scandir_cancel_handler (&c); - result = -1; - } - - __libc_cleanup_pop (0); - - if (result >= 0) - __set_errno (save); - return result; -} +#endif diff --git a/dirent/scandir.c b/dirent/scandir.c index a9b504c972..6d8352dc9c 100644 --- a/dirent/scandir.c +++ b/dirent/scandir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,31 +15,14 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -/* We need to avoid the header declaration of scandir64, because - the types don't match scandir and then the compiler will - complain about the mismatch when we do the alias below. */ -#define scandir64 __renamed_scandir64 - #include <dirent.h> -#undef scandir64 - -#ifndef SCANDIR -# define SCANDIR scandir -# define SCANDIR_TAIL __scandir_tail -# define DIRENT_TYPE struct dirent -#endif - - +#if !_DIRENT_MATCHES_DIRENT64 int -SCANDIR (const char *dir, - DIRENT_TYPE ***namelist, - int (*select) (const DIRENT_TYPE *), - int (*cmp) (const DIRENT_TYPE **, const DIRENT_TYPE **)) +scandir (const char *dir, struct dirent ***namelist, + int (*select) (const struct dirent *), + int (*cmp) (const struct dirent **, const struct dirent **)) { - return SCANDIR_TAIL (__opendir (dir), namelist, select, cmp); + return __scandir_tail (__opendir (dir), namelist, select, cmp); } - -#ifdef _DIRENT_MATCHES_DIRENT64 -weak_alias (scandir, scandir64) #endif diff --git a/dirent/scandir64-tail.c b/dirent/scandir64-tail.c index 05a259f6ad..4e873d47d6 100644 --- a/dirent/scandir64-tail.c +++ b/dirent/scandir64-tail.c @@ -1,5 +1,5 @@ /* Logic guts of scandir*64. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + Copyright (C) 2015-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,9 +18,7 @@ #include <dirent.h> -#ifndef _DIRENT_MATCHES_DIRENT64 -# define SCANDIR_TAIL __scandir64_tail -# define READDIR __readdir64 -# define DIRENT_TYPE struct dirent64 -# include <scandir-tail.c> -#endif +#define SCANDIR_TAIL __scandir64_tail +#define READDIR __readdir64 +#define DIRENT_TYPE struct dirent64 +#include <scandir-tail-common.c> diff --git a/dirent/scandir64.c b/dirent/scandir64.c index c64e454095..6bdd4628ad 100644 --- a/dirent/scandir64.c +++ b/dirent/scandir64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,15 +15,18 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#define scandir __no_scandir_decl #include <dirent.h> - -/* scandir.c defines scandir64 as an alias if _DIRENT_MATCHES_DIRENT64. */ -#ifndef _DIRENT_MATCHES_DIRENT64 - -# define SCANDIR scandir64 -# define SCANDIR_TAIL __scandir64_tail -# define DIRENT_TYPE struct dirent64 - -# include <dirent/scandir.c> - +#undef scandir + +int +scandir64 (const char *dir, struct dirent64 ***namelist, + int (*select) (const struct dirent64 *), + int (*cmp) (const struct dirent64 **, const struct dirent64 **)) +{ + return __scandir64_tail (__opendir (dir), namelist, select, cmp); +} + +#if _DIRENT_MATCHES_DIRENT64 +weak_alias (scandir64, scandir) #endif diff --git a/dirent/scandirat.c b/dirent/scandirat.c index ef3d6d85d5..8dad1e8a21 100644 --- a/dirent/scandirat.c +++ b/dirent/scandirat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,35 +15,15 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -/* We need to avoid the header declaration of scandir64, because - the types don't match scandir and then the compiler will - complain about the mismatch when we do the alias below. */ -#define scandirat64 __renamed_scandirat64 - #include <dirent.h> -#undef scandirat64 - -#ifndef SCANDIRAT -# define SCANDIRAT __scandirat -# define SCANDIR_TAIL __scandir_tail -# define DIRENT_TYPE struct dirent -# define SCANDIRAT_WEAK_ALIAS -#endif - +#if !_DIRENT_MATCHES_DIRENT64 int -SCANDIRAT (int dfd, const char *dir, - DIRENT_TYPE ***namelist, - int (*select) (const DIRENT_TYPE *), - int (*cmp) (const DIRENT_TYPE **, const DIRENT_TYPE **)) +__scandirat (int dfd, const char *dir, struct dirent ***namelist, + int (*select) (const struct dirent *), + int (*cmp) (const struct dirent **, const struct dirent **)) { - return SCANDIR_TAIL (__opendirat (dfd, dir), namelist, select, cmp); + return __scandir_tail (__opendirat (dfd, dir), namelist, select, cmp); } -libc_hidden_def (SCANDIRAT) -#ifdef SCANDIRAT_WEAK_ALIAS weak_alias (__scandirat, scandirat) #endif - -#ifdef _DIRENT_MATCHES_DIRENT64 -weak_alias (scandirat, scandirat64) -#endif diff --git a/dirent/scandirat64.c b/dirent/scandirat64.c index c7888849e3..7e5e209cdf 100644 --- a/dirent/scandirat64.c +++ b/dirent/scandirat64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,15 +15,18 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#define scandirat __no_scandirat_decl #include <dirent.h> - -/* scandirat.c defines scandirat64 as an alias if _DIRENT_MATCHES_DIRENT64. */ -#ifndef _DIRENT_MATCHES_DIRENT64 - -# define SCANDIRAT scandirat64 -# define SCANDIR_TAIL __scandir64_tail -# define DIRENT_TYPE struct dirent64 - -# include <scandirat.c> - +#undef scandirat + +int +scandirat64 (int dfd, const char *dir, struct dirent64 ***namelist, + int (*select) (const struct dirent64 *), + int (*cmp) (const struct dirent64 **, const struct dirent64 **)) +{ + return __scandir64_tail (__opendirat (dfd, dir), namelist, select, cmp); +} + +#if _DIRENT_MATCHES_DIRENT64 +weak_alias (scandirat64, scandirat) #endif diff --git a/dirent/seekdir.c b/dirent/seekdir.c index bf1d889c03..653a34e295 100644 --- a/dirent/seekdir.c +++ b/dirent/seekdir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/telldir.c b/dirent/telldir.c index 3802be7dd0..5f82b7fbe4 100644 --- a/dirent/telldir.c +++ b/dirent/telldir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/dirent/tst-fdopendir.c b/dirent/tst-fdopendir.c index 0780c19916..89bdca9086 100644 --- a/dirent/tst-fdopendir.c +++ b/dirent/tst-fdopendir.c @@ -5,6 +5,7 @@ #include <dirent.h> #include <stdbool.h> #include <string.h> +#include <sys/stat.h> #ifndef O_NOATIME # define O_NOATIME 0 diff --git a/dirent/tst-fdopendir2.c b/dirent/tst-fdopendir2.c index 3720809dc2..7709e4b3bc 100644 --- a/dirent/tst-fdopendir2.c +++ b/dirent/tst-fdopendir2.c @@ -1,6 +1,7 @@ #include <errno.h> #include <dirent.h> #include <stdio.h> +#include <stdlib.h> #include <unistd.h> diff --git a/dirent/tst-scandir.c b/dirent/tst-scandir.c index 4bce4a3488..5473242de4 100644 --- a/dirent/tst-scandir.c +++ b/dirent/tst-scandir.c @@ -1,5 +1,5 @@ /* Basic test for scandir function. - Copyright (C) 2015-2016 Free Software Foundation, Inc. + Copyright (C) 2015-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#include <stdbool.h> #include <dirent.h> #include <errno.h> #include <stdio.h> @@ -292,7 +293,6 @@ do_test (void) remove_file (scandir_test_dir, "aa"); remove_file (scandir_test_dir, "b"); remove_file (scandir_test_dir, "a"); - rmdir (scandir_test_dir); return 0; } diff --git a/dirent/versionsort.c b/dirent/versionsort.c index cde661b3b1..ca38c2dc03 100644 --- a/dirent/versionsort.c +++ b/dirent/versionsort.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,16 +15,10 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -/* We need to avoid the header declaration of versionsort64, because - the types don't match versionsort and then the compiler will - complain about the mismatch when we do the alias below. */ -#define versionsort64 __renamed_versionsort64 - #include <dirent.h> -#undef versionsort64 - -#include <string.h> +#if !_DIRENT_MATCHES_DIRENT64 +# include <string.h> int versionsort (const struct dirent **a, const struct dirent **b) @@ -32,6 +26,4 @@ versionsort (const struct dirent **a, const struct dirent **b) return __strverscmp ((*a)->d_name, (*b)->d_name); } -#ifdef _DIRENT_MATCHES_DIRENT64 -weak_alias (versionsort, versionsort64) #endif diff --git a/dirent/versionsort64.c b/dirent/versionsort64.c index 1c5047c625..8f47e609d0 100644 --- a/dirent/versionsort64.c +++ b/dirent/versionsort64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,16 +15,17 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#define versionsort __no_versionsort_decl #include <dirent.h> +#undef versionsort #include <string.h> -/* versionsort.c defines a versionsort64 alias if _DIRENT_MATCHES_DIRENT64. */ -#ifndef _DIRENT_MATCHES_DIRENT64 - int versionsort64 (const struct dirent64 **a, const struct dirent64 **b) { return __strverscmp ((*a)->d_name, (*b)->d_name); } +#if !_DIRENT_MATCHES_DIRENT64 +weak_alias (versionsort64, versionsort) #endif |