This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch roland/opendir updated. glibc-2.21-341-gd4045ef
- From: roland at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 13 May 2015 20:34:56 -0000
- Subject: GNU C Library master sources branch roland/opendir updated. glibc-2.21-341-gd4045ef
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, roland/opendir has been updated
via d4045ef0e22e4bf984aeecb15854a2a5dc7fb2ec (commit)
via 9e4ec74ffc9ea00e57a1b84acd60c1659457dd36 (commit)
via 953416737a805a67c18d254c39f5086bde590f6e (commit)
via d2ee815ad677bba720c4f0275c1d6065f5809e7a (commit)
via 83c10893259916152d277327fa37d8f70bb4d4c2 (commit)
via b88a18e10c9b18a74e2c2b26817189a5841cff12 (commit)
via d9efd775ba51916b58b899d8b1c8501105a830de (commit)
via 265a9b73baf3898cb89410eed71a6337762e37b1 (commit)
via a964c6e4f3dafb53a32693c89cdf13359c5f1564 (commit)
via 60ccaf7514b2a4b153a03302752f1afa340e66c0 (commit)
via 9f53d7ad577db870c4383b4378cd23131f516c42 (commit)
via 0f4840be2528b3e3f2ecea009ab08e753701e9be (commit)
via 7327b333e56926d7d79bb9e01b839d3618bf750f (commit)
via 8e65ea4dc05e32a2d461f9db8e570f2c0fcbecbc (commit)
via f13c2a8dff2329c6692a80176262ceaaf8a6f74e (commit)
via 34cb304e5a6df706e186d504b69af974bfc15a2f (commit)
via b13b96ca05a132a12dc5f3712b99e626670716bf (commit)
via e1b6cb04f5efff7fb7415c69511d3ab3c31c6e4a (commit)
from c4c977c6a294d8e0bcaf31059469aa683e0f00fe (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d4045ef0e22e4bf984aeecb15854a2a5dc7fb2ec
commit d4045ef0e22e4bf984aeecb15854a2a5dc7fb2ec
Author: Roland McGrath <roland@hack.frob.com>
Date: Wed May 13 13:34:33 2015 -0700
Refactor opendir.
diff --git a/ChangeLog b/ChangeLog
index 6d96ce2..051be5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2015-05-13 Roland McGrath <roland@hack.frob.com>
+ * sysdeps/posix/opendir.c: Include <stdbool.h>.
+ (invalid_name): New function, broken out of ...
+ (__opendirat): ... here. Call it.
+ (need_isdir_precheck): New function, broken out of ...
+ (__opendirat): ... here. Call it.
+ Use __fxstatat64, not __xstatat64.
+ (opendir_oflags): New function, broken out of ...
+ (__opendirat): ... here. Call it.
+ (opendir_tail): New function, broken out of ...
+ (__opendirat): ... here. Call it.
+ (__opendir): Call invalid_name, need_isdir_precheck, __xstat64, and
+ opendir_tail, rather than punting to __opendirat.
+ (__opendirat): Conditionalize function definition on [IS_IN (libc)].
+
* sysdeps/nacl/fdopendir.c: New file.
* dirent/scandir-tail.c: New file.
diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
index 451c56e..6509f5c 100644
--- a/sysdeps/posix/opendir.c
+++ b/sysdeps/posix/opendir.c
@@ -18,6 +18,7 @@
#include <assert.h>
#include <errno.h>
#include <limits.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <dirent.h>
@@ -81,83 +82,122 @@ tryopen_o_directory (void)
#endif
-DIR *
-internal_function
-__opendirat (int dfd, const char *name)
+static bool
+invalid_name (const char *name)
{
- struct stat64 statbuf;
- struct stat64 *statp = NULL;
-
- if (__builtin_expect (name[0], '\1') == '\0')
+ if (__glibc_unlikely (name[0] == '\0'))
{
/* POSIX.1-1990 says an empty name gets ENOENT;
but `open' might like it fine. */
__set_errno (ENOENT);
- return NULL;
+ return true;
}
+ return false;
+}
+
+static bool
+need_isdir_precheck (void)
+{
#ifdef O_DIRECTORY
/* Test whether O_DIRECTORY works. */
if (o_directory_works == 0)
tryopen_o_directory ();
/* We can skip the expensive `stat' call if O_DIRECTORY works. */
- if (o_directory_works < 0)
+ return o_directory_works > 0;
#endif
- {
- /* We first have to check whether the name is for a directory. We
- cannot do this after the open() call since the open/close operation
- performed on, say, a tape device might have undesirable effects. */
- if (__builtin_expect (__xstat64 (_STAT_VER, name, &statbuf), 0) < 0)
- return NULL;
- if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
- {
- __set_errno (ENOTDIR);
- return NULL;
- }
- }
+ return true;
+}
+
+static int
+opendir_oflags (void)
+{
int flags = O_RDONLY|O_NDELAY|EXTRA_FLAGS|O_LARGEFILE;
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
- int fd;
-#if IS_IN (rtld)
- assert (dfd == AT_FDCWD);
- fd = open_not_cancel_2 (name, flags);
-#else
- fd = openat_not_cancel_3 (dfd, name, flags);
-#endif
- if (__builtin_expect (fd, 0) < 0)
+ return flags;
+}
+
+
+static DIR *
+opendir_tail (int fd)
+{
+ if (__glibc_unlikely (fd < 0))
return NULL;
-#ifdef O_DIRECTORY
- if (o_directory_works <= 0)
-#endif
+ /* Now make sure this really is a directory and nothing changed since the
+ `stat' call. The S_ISDIR check is superfluous if O_DIRECTORY works,
+ but it's cheap and we need the stat call for st_blksize anyway. */
+ struct stat64 statbuf;
+ if (__glibc_unlikely (__fxstat64 (_STAT_VER, fd, &statbuf) < 0))
+ goto lose;
+ if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
{
- /* Now make sure this really is a directory and nothing changed since
- the `stat' call. */
- if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
- goto lose;
+ __set_errno (ENOTDIR);
+ lose:
+ close_not_cancel_no_status (fd);
+ return NULL;
+ }
+
+ return __alloc_dir (fd, true, 0, &statbuf);
+}
+
+
+#if IS_IN (libc)
+DIR *
+internal_function
+__opendirat (int dfd, const char *name)
+{
+ if (__glibc_unlikely (invalid_name (name)))
+ return NULL;
+
+ if (need_isdir_precheck ())
+ {
+ /* We first have to check whether the name is for a directory. We
+ cannot do this after the open() call since the open/close operation
+ performed on, say, a tape device might have undesirable effects. */
+ struct stat64 statbuf;
+ if (__glibc_unlikely (__fxstatat64 (_STAT_VER, dfd, name,
+ &statbuf, 0) < 0))
+ return NULL;
if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
{
__set_errno (ENOTDIR);
- lose:
- close_not_cancel_no_status (fd);
return NULL;
}
- statp = &statbuf;
}
- return __alloc_dir (fd, true, 0, statp);
+ return opendir_tail (openat_not_cancel_3 (dfd, name, opendir_oflags ()));
}
+#endif
/* Open a directory stream on NAME. */
DIR *
__opendir (const char *name)
{
- return __opendirat (AT_FDCWD, name);
+ if (__glibc_unlikely (invalid_name (name)))
+ return NULL;
+
+ if (need_isdir_precheck ())
+ {
+ /* We first have to check whether the name is for a directory. We
+ cannot do this after the open() call since the open/close operation
+ performed on, say, a tape device might have undesirable effects. */
+ struct stat64 statbuf;
+ if (__glibc_unlikely (__xstat64 (_STAT_VER, name, &statbuf) < 0))
+ return NULL;
+ if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
+ {
+ __set_errno (ENOTDIR);
+ return NULL;
+ }
+ }
+
+ return opendir_tail (open_not_cancel_2 (name, opendir_oflags ()));
}
weak_alias (__opendir, opendir)
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 167 +
NEWS | 9 +-
benchtests/Makefile | 13 +-
benchtests/bench-strcoll.c | 277 +
benchtests/strcoll-inputs/filelist#C | 1 +
benchtests/strcoll-inputs/filelist#en_US.UTF-8 |15248 +++++++++++++++++++++
benchtests/strcoll-inputs/lorem_ipsum#ar_SA.UTF-8 | 49 +
benchtests/strcoll-inputs/lorem_ipsum#cs_CZ.UTF-8 | 41 +
benchtests/strcoll-inputs/lorem_ipsum#da_DK.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#el_GR.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#en_GB.UTF-8 | 47 +
benchtests/strcoll-inputs/lorem_ipsum#en_US.UTF-8 | 43 +
benchtests/strcoll-inputs/lorem_ipsum#es_ES.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#fr_FR.UTF-8 | 47 +
benchtests/strcoll-inputs/lorem_ipsum#hi_IN.UTF-8 | 51 +
benchtests/strcoll-inputs/lorem_ipsum#hu_HU.UTF-8 | 47 +
benchtests/strcoll-inputs/lorem_ipsum#is_IS.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#it_IT.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#iw_IL.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#ja_JP.UTF-8 | 19 +
benchtests/strcoll-inputs/lorem_ipsum#pl_PL.UTF-8 | 47 +
benchtests/strcoll-inputs/lorem_ipsum#pt_PT.UTF-8 | 47 +
benchtests/strcoll-inputs/lorem_ipsum#ru_RU.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#sr_RS.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#sv_SE.UTF-8 | 43 +
benchtests/strcoll-inputs/lorem_ipsum#tr_TR.UTF-8 | 45 +
benchtests/strcoll-inputs/lorem_ipsum#vi_VN.UTF-8 | 47 +
benchtests/strcoll-inputs/lorem_ipsum#zh_CN.UTF-8 | 19 +
conform/linknamespace.pl | 3 +
dirent/Makefile | 7 +-
dirent/scandir-cancel.c | 31 +
dirent/scandir-tail.c | 110 +
dirent/scandir.c | 19 +-
dirent/scandir64-tail.c | 26 +
dirent/scandir64.c | 8 +-
dirent/scandirat.c | 125 +-
dirent/scandirat64.c | 9 +-
dirent/tst-scandir.c | 298 +
dirent/tst-scandir64.c | 2 +
gen-locales.mk | 20 +
include/dirent.h | 23 +-
locale/C-collate.c | 4 +-
locale/categories.def | 1 +
locale/langinfo.h | 1 +
locale/localeinfo.h | 8 +
locale/programs/ld-collate.c | 9 +
localedata/ChangeLog | 8 +
localedata/Makefile | 16 +-
localedata/gen-locale.sh | 2 +-
localedata/tst-strfmon1.c | 2 +-
nis/nss_compat/compat-grp.c | 6 +-
nis/nss_compat/compat-pwd.c | 6 +-
nis/nss_compat/compat-spwd.c | 16 +-
nss/nss_files/files-XXX.c | 109 +-
nss/nss_files/files-alias.c | 90 +-
nss/nss_files/files-hosts.c | 35 +-
posix/uname-values.h | 28 +
posix/uname.c | 7 +-
string/strcoll_l.c | 38 +-
sysdeps/aarch64/tls-macros.h | 2 +-
sysdeps/arm/nacl/uname-values.h | 20 +
sysdeps/mips/mips32/fpu/Makefile | 3 +
sysdeps/mips/mips32/fpu/fpu_control.c | 34 -
sysdeps/mips/mips32/fpu/fpucw-helpers.c | 34 +
sysdeps/nacl/fdopendir.c | 32 +
sysdeps/nacl/uname-values.h | 32 +
sysdeps/posix/opendir.c | 122 +-
sysdeps/unix/make-syscalls.sh | 2 +-
sysdeps/unix/sysv/linux/i386/scandir64.c | 16 +-
sysdeps/x86_64/multiarch/strcspn.S | 7 -
sysdeps/x86_64/multiarch/strspn.S | 6 -
wcsmbs/wcscoll_l.c | 1 +
72 files changed, 17596 insertions(+), 449 deletions(-)
create mode 100644 benchtests/bench-strcoll.c
create mode 120000 benchtests/strcoll-inputs/filelist#C
create mode 100644 benchtests/strcoll-inputs/filelist#en_US.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#ar_SA.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#cs_CZ.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#da_DK.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#el_GR.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#en_GB.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#en_US.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#es_ES.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#fr_FR.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#hi_IN.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#hu_HU.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#is_IS.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#it_IT.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#iw_IL.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#ja_JP.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#pl_PL.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#pt_PT.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#ru_RU.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#sr_RS.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#sv_SE.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#tr_TR.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#vi_VN.UTF-8
create mode 100644 benchtests/strcoll-inputs/lorem_ipsum#zh_CN.UTF-8
create mode 100644 dirent/scandir-cancel.c
create mode 100644 dirent/scandir-tail.c
create mode 100644 dirent/scandir64-tail.c
create mode 100644 dirent/tst-scandir.c
create mode 100644 dirent/tst-scandir64.c
create mode 100644 gen-locales.mk
create mode 100644 posix/uname-values.h
create mode 100644 sysdeps/arm/nacl/uname-values.h
create mode 100644 sysdeps/mips/mips32/fpu/Makefile
delete mode 100644 sysdeps/mips/mips32/fpu/fpu_control.c
create mode 100644 sysdeps/mips/mips32/fpu/fpucw-helpers.c
create mode 100644 sysdeps/nacl/fdopendir.c
create mode 100644 sysdeps/nacl/uname-values.h
hooks/post-receive
--
GNU C Library master sources