aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-07-03 11:11:24 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-08-17 16:50:35 -0300
commitc22845744cd931267e0d7cb2e2b35a0da9c9510a (patch)
tree2cd9c6059492a3bf24c28edc159d0cee1ae6943e
parentd4505b895f2aa577a6b974ab4bd0a1fd0db60ceb (diff)
downloadglibc-c22845744cd931267e0d7cb2e2b35a0da9c9510a.tar.xz
glibc-c22845744cd931267e0d7cb2e2b35a0da9c9510a.zip
Consolidate non cancellable open call
This patch consolidates all the non cancellable open calls to use the __open_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. To be consistent with the following non cancellable openat call, a new __open64_nocancel is also added (although not currently used). Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (open_not_cancel): Remove macro. (open_not_cancel_2): Likewise. (open_nocancel): New macro. (open64_nocancel): Likewise. * sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Remove macro. (open_not_cancel_2): Likewise. (__open_nocancel): New prototype. (__open64_nocancel): Likewise. * sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add __open_nocancel. * sysdeps/unix/sysv/linux/open.c (__open_nocancel): New function. * sysdeps/unix/sysv/linux/open64.c (__open64_nocancel): Likewise. * catgets/open_catalog.c (__open_catalog): Replace open_not_cancel{_2} with __open_nocancel. * csu/check_fds.c (check_one_fd): Likewise. * gmon/gmon.c (write_gmon): Likewise. * iconv/gconv_cache.c (__gconv_load_cached): Likewise. * intl/loadmsgcat.c (open): Likewise. * libio/fileops.c (_IO_file_open): Likewise. * locale/loadarchive.c (_nl_load_locale_from_archive): Likewise. * locale/loadlocale.c (_nl_load_locale): Likewise. * login/utmp_file.c (setutent_file): Likewise. * misc/daemon.c (daemon): Likewise. * nss/nss_db/db-open.c (internal_setent): Likewise. * sysdeps/mach/hurd/opendir.c (__opendirat): Likewise. * sysdeps/posix/libc_fatal.c (__libc_message): Likewise. * sysdeps/posix/opendir.c (tryopen_o_directory): Likewise. (__opendir): Likewise. * sysdeps/posix/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise. * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise. (gethostid): Likewise. * sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise. * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise. * sysdeps/unix/sysv/linux/grantpt.c (__close_all_fds): Likewise. * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise. * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock): Likewise. * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise. * sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap): Likewise. * sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c (__get_clockfreq): Likewise. * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np): Likewise. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np): Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.
-rw-r--r--ChangeLog55
-rw-r--r--catgets/open_catalog.c4
-rw-r--r--csu/check_fds.c2
-rw-r--r--gmon/gmon.c4
-rw-r--r--iconv/gconv_cache.c2
-rw-r--r--intl/loadmsgcat.c2
-rw-r--r--libio/fileops.c2
-rw-r--r--locale/loadarchive.c6
-rw-r--r--locale/loadlocale.c4
-rw-r--r--login/utmp_file.c6
-rw-r--r--misc/daemon.c2
-rw-r--r--nss/nss_db/db-open.c2
-rw-r--r--sysdeps/generic/not-cancel.h8
-rw-r--r--sysdeps/mach/hurd/opendir.c2
-rw-r--r--sysdeps/posix/libc_fatal.c2
-rw-r--r--sysdeps/posix/opendir.c4
-rw-r--r--sysdeps/posix/spawni.c2
-rw-r--r--sysdeps/unix/sysv/linux/Versions1
-rw-r--r--sysdeps/unix/sysv/linux/fips-private.h2
-rw-r--r--sysdeps/unix/sysv/linux/gethostid.c4
-rw-r--r--sysdeps/unix/sysv/linux/getloadavg.c2
-rw-r--r--sysdeps/unix/sysv/linux/getlogin_r.c2
-rw-r--r--sysdeps/unix/sysv/linux/getsysstats.c6
-rw-r--r--sysdeps/unix/sysv/linux/grantpt.c4
-rw-r--r--sysdeps/unix/sysv/linux/i386/smp.h2
-rw-r--r--sysdeps/unix/sysv/linux/ia64/has_cpuclock.c2
-rw-r--r--sysdeps/unix/sysv/linux/libc_fatal.c2
-rw-r--r--sysdeps/unix/sysv/linux/malloc-sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/not-cancel.h20
-rw-r--r--sysdeps/unix/sysv/linux/open.c21
-rw-r--r--sysdeps/unix/sysv/linux/open64.c38
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c2
-rw-r--r--sysdeps/unix/sysv/linux/pthread_getname.c2
-rw-r--r--sysdeps/unix/sysv/linux/pthread_setname.c2
-rw-r--r--sysdeps/unix/sysv/linux/spawni.c2
-rw-r--r--sysdeps/unix/sysv/linux/sysconf.c2
36 files changed, 164 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index 08207b1c4e..0c8183ca21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,58 @@
+2017-08-17 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+
+ * sysdeps/generic/not-cancel.h (open_not_cancel): Remove macro.
+ (open_not_cancel_2): Likewise.
+ (open_nocancel): New macro.
+ (open64_nocancel): Likewise.
+ * sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Remove macro.
+ (open_not_cancel_2): Likewise.
+ (__open_nocancel): New prototype.
+ (__open64_nocancel): Likewise.
+ * sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add
+ __open_nocancel.
+ * sysdeps/unix/sysv/linux/open.c (__open_nocancel): New function.
+ * sysdeps/unix/sysv/linux/open64.c (__open64_nocancel): Likewise.
+ * catgets/open_catalog.c (__open_catalog): Replace open_not_cancel{_2}
+ with __open_nocancel.
+ * csu/check_fds.c (check_one_fd): Likewise.
+ * gmon/gmon.c (write_gmon): Likewise.
+ * iconv/gconv_cache.c (__gconv_load_cached): Likewise.
+ * intl/loadmsgcat.c (open): Likewise.
+ * libio/fileops.c (_IO_file_open): Likewise.
+ * locale/loadarchive.c (_nl_load_locale_from_archive): Likewise.
+ * locale/loadlocale.c (_nl_load_locale): Likewise.
+ * login/utmp_file.c (setutent_file): Likewise.
+ * misc/daemon.c (daemon): Likewise.
+ * nss/nss_db/db-open.c (internal_setent): Likewise.
+ * sysdeps/mach/hurd/opendir.c (__opendirat): Likewise.
+ * sysdeps/posix/libc_fatal.c (__libc_message): Likewise.
+ * sysdeps/posix/opendir.c (tryopen_o_directory): Likewise.
+ (__opendir): Likewise.
+ * sysdeps/posix/spawni.c (__spawni_child): Likewise.
+ * sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise.
+ * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
+ (gethostid): Likewise.
+ * sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
+ * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
+ Likewise.
+ * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise.
+ * sysdeps/unix/sysv/linux/grantpt.c (__close_all_fds): Likewise.
+ * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
+ * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
+ Likewise.
+ * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps):
+ Likewise.
+ * sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
+ Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c (__get_clockfreq):
+ Likewise.
+ * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
+ Likewise.
+ * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
+ Likewise.
+ * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
+ * sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.
+
2017-08-17 Wilco Dijkstra <wdijkstr@arm.com>
* benchtests/bench-skeleton.c (main): Add support for
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index cbb305a3f7..4621b263e7 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -50,7 +50,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
char *buf = NULL;
if (strchr (cat_name, '/') != NULL || nlspath == NULL)
- fd = open_not_cancel_2 (cat_name, O_RDONLY);
+ fd = __open_nocancel (cat_name, O_RDONLY);
else
{
const char *run_nlspath = nlspath;
@@ -178,7 +178,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (bufact != 0)
{
- fd = open_not_cancel_2 (buf, O_RDONLY);
+ fd = __open_nocancel (buf, O_RDONLY);
if (fd >= 0)
break;
}
diff --git a/csu/check_fds.c b/csu/check_fds.c
index 062c879373..5bd6392307 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -61,7 +61,7 @@ check_one_fd (int fd, int mode)
/* Something is wrong with this descriptor, it's probably not
opened. Open /dev/null so that the SUID program we are
about to start does not accidentally use this descriptor. */
- int nullfd = open_not_cancel (name, mode, 0);
+ int nullfd = __open_nocancel (name, mode, 0);
/* We are very paranoid here. With all means we try to ensure
that we are actually opening the /dev/null device and nothing
diff --git a/gmon/gmon.c b/gmon/gmon.c
index f394a7870e..87c3c4e01b 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -342,12 +342,12 @@ write_gmon (void)
size_t len = strlen (env);
char buf[len + 20];
__snprintf (buf, sizeof (buf), "%s.%u", env, __getpid ());
- fd = open_not_cancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666);
+ fd = __open_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666);
}
if (fd == -1)
{
- fd = open_not_cancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ fd = __open_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
0666);
if (fd < 0)
{
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index 0cadea3638..f1dce291f5 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -59,7 +59,7 @@ __gconv_load_cache (void)
return -1;
/* See whether the cache file exists. */
- fd = open_not_cancel (GCONV_MODULES_CACHE, O_RDONLY, 0);
+ fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY, 0);
if (__builtin_expect (fd, 0) == -1)
/* Not available. */
return -1;
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index c2ff64e97f..adca419f07 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -445,7 +445,7 @@
/* Rename the non ISO C functions. This is required by the standard
because some ISO C functions will require linking with this object
file and the name space must not be polluted. */
-# define open(name, flags) open_not_cancel_2 (name, flags)
+# define open(name, flags) __open_nocancel (name, flags)
# define close(fd) close_not_cancel_no_status (fd)
# define read(fd, buf, n) read_not_cancel (fd, buf, n)
# define mmap(addr, len, prot, flags, fd, offset) \
diff --git a/libio/fileops.c b/libio/fileops.c
index c55e196dd8..67f3d72020 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -223,7 +223,7 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot,
int fdesc;
#ifdef _LIBC
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
- fdesc = open_not_cancel (filename,
+ fdesc = __open_nocancel (filename,
posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index e6e1a05d2e..7825a1c655 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -203,7 +203,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
archmapped = &headmap;
/* The archive has never been opened. */
- fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd < 0)
/* Cannot open the archive, for whatever reason. */
return NULL;
@@ -398,8 +398,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (fd == -1)
{
struct stat64 st;
- fd = open_not_cancel_2 (archfname,
- O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open_nocancel (archfname,
+ O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd == -1)
/* Cannot open the archive, for whatever reason. */
return NULL;
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index 162dd1a66f..7416bc300c 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -173,7 +173,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
file->decided = 1;
file->data = NULL;
- fd = open_not_cancel_2 (file->filename, O_RDONLY | O_CLOEXEC);
+ fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC);
if (__builtin_expect (fd, 0) < 0)
/* Cannot open the file. */
return;
@@ -201,7 +201,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
_nl_category_names.str + _nl_category_name_idxs[category],
_nl_category_name_sizes[category] + 1);
- fd = open_not_cancel_2 (newp, O_RDONLY | O_CLOEXEC);
+ fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC);
if (__builtin_expect (fd, 0) < 0)
return;
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 240e0e3c10..14071165e0 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -143,7 +143,7 @@ setutent_file (void)
file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
file_writable = false;
- file_fd = open_not_cancel_2
+ file_fd = __open_nocancel
(file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (file_fd == -1)
return 0;
@@ -374,7 +374,7 @@ pututline_file (const struct utmp *data)
/* We must make the file descriptor writable before going on. */
const char *file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
- int new_fd = open_not_cancel_2
+ int new_fd = __open_nocancel
(file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC);
if (new_fd == -1)
return NULL;
@@ -484,7 +484,7 @@ updwtmp_file (const char *file, const struct utmp *utmp)
int fd;
/* Open WTMP file. */
- fd = open_not_cancel_2 (file, O_WRONLY | O_LARGEFILE);
+ fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE);
if (fd < 0)
return -1;
diff --git a/misc/daemon.c b/misc/daemon.c
index 9d186b24bd..dd38f2b87f 100644
--- a/misc/daemon.c
+++ b/misc/daemon.c
@@ -63,7 +63,7 @@ daemon (int nochdir, int noclose)
if (!noclose) {
struct stat64 st;
- if ((fd = open_not_cancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
+ if ((fd = __open_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
&& (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0)
== 0)) {
if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0
diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c
index 1c58bd1c54..40a2540d95 100644
--- a/nss/nss_db/db-open.c
+++ b/nss/nss_db/db-open.c
@@ -36,7 +36,7 @@ internal_setent (const char *file, struct nss_db_map *mapping)
{
enum nss_status status = NSS_STATUS_UNAVAIL;
- int fd = open_not_cancel_2 (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ int fd = __open_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1)
{
struct nss_db_header header;
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 5eabd2b31a..a4f7b7bf05 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -18,10 +18,10 @@
<http://www.gnu.org/licenses/>. */
/* By default we have none. Map the name to the normal functions. */
-#define open_not_cancel(name, flags, mode) \
- __libc_open (name, flags, mode)
-#define open_not_cancel_2(name, flags) \
- __libc_open (name, flags)
+#define __open_nocancel(...) \
+ __open (__VA_ARGS__)
+#define __open64_nocancel(...) \
+ __open64 (__VA_ARGS__)
#define openat_not_cancel(fd, name, flags, mode) \
__openat (fd, name, flags, mode)
#define openat_not_cancel_3(fd, name, flags) \
diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c
index b3dab24da1..8db70b2842 100644
--- a/sysdeps/mach/hurd/opendir.c
+++ b/sysdeps/mach/hurd/opendir.c
@@ -84,7 +84,7 @@ __opendirat (int dfd, const char *name)
int fd;
#if IS_IN (rtld)
assert (dfd == AT_FDCWD);
- fd = open_not_cancel_2 (name, flags);
+ fd = __open_nocancel (name, flags);
#else
fd = openat_not_cancel_3 (dfd, name, flags);
#endif
diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c
index c9189194dd..fbb1beca50 100644
--- a/sysdeps/posix/libc_fatal.c
+++ b/