public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] Consolidate open without cancellation
@ 2022-03-16 17:59 Adhemerval Zanella
0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2022-03-16 17:59 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b83490d5427012fc671884007d656c0032928f13
commit b83490d5427012fc671884007d656c0032928f13
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Mar 7 14:00:28 2022 -0300
Consolidate open without cancellation
To use only __openat64_nocancel.
Diff:
---
catgets/open_catalog.c | 4 +-
csu/check_fds.c | 2 +-
gmon/gmon.c | 7 ++--
iconv/gconv_cache.c | 2 +-
intl/loadmsgcat.c | 2 +-
io/Versions | 2 +-
libio/fileops.c | 4 +-
locale/loadarchive.c | 6 +--
locale/loadlocale.c | 4 +-
login/utmp_file.c | 6 +--
misc/daemon.c | 2 +-
nss/nss_db/db-open.c | 2 +-
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/closefrom_fallback.c | 8 ++--
sysdeps/unix/sysv/linux/fchmodat.c | 4 +-
sysdeps/unix/sysv/linux/fips-private.h | 2 +-
sysdeps/unix/sysv/linux/gethostid.c | 4 +-
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 4 +-
sysdeps/unix/sysv/linux/malloc-sysdep.h | 4 +-
sysdeps/unix/sysv/linux/not-cancel.h | 15 ++-----
sysdeps/unix/sysv/linux/open64_nocancel.c | 48 ----------------------
sysdeps/unix/sysv/linux/open_nocancel.c | 46 ---------------------
sysdeps/unix/sysv/linux/openat64_nocancel.c | 5 ---
sysdeps/unix/sysv/linux/openat_nocancel.c | 43 -------------------
sysdeps/unix/sysv/linux/opendir.c | 4 +-
.../unix/sysv/linux/powerpc/get_timebase_freq.c | 2 +-
sysdeps/unix/sysv/linux/spawni.c | 8 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
29 files changed, 48 insertions(+), 199 deletions(-)
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 48c2a4b983..7301b0812b 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -49,7 +49,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_nocancel (cat_name, O_RDONLY);
+ fd = __open64_nocancel (cat_name, O_RDONLY);
else
{
const char *run_nlspath = nlspath;
@@ -177,7 +177,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (bufact != 0)
{
- fd = __open_nocancel (buf, O_RDONLY);
+ fd = __open64_nocancel (buf, O_RDONLY);
if (fd >= 0)
break;
}
diff --git a/csu/check_fds.c b/csu/check_fds.c
index 4016a4a1c3..7e597dc76c 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -60,7 +60,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_nocancel (name, mode, 0);
+ int nullfd = __open64_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 dee64803ad..4af4e8cb29 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -362,13 +362,14 @@ write_gmon (void)
size_t len = strlen (env);
char buf[len + 20];
__snprintf (buf, sizeof (buf), "%s.%u", env, __getpid ());
- fd = __open_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666);
+ fd = __open64_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ 0666);
}
if (fd == -1)
{
- fd = __open_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
- 0666);
+ fd = __open64_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ 0666);
if (fd < 0)
{
char buf[300];
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index c772856d1f..22860c2133 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -57,7 +57,7 @@ __gconv_load_cache (void)
return -1;
/* See whether the cache file exists. */
- fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY, 0);
+ fd = __open64_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 98d5f53232..03fde79ec2 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_nocancel (name, flags)
+# define open(name, flags) __open64_nocancel (name, flags)
# define close(fd) __close_nocancel_nostatus (fd)
# define read(fd, buf, n) __read_nocancel (fd, buf, n)
# define mmap(addr, len, prot, flags, fd, offset) \
diff --git a/io/Versions b/io/Versions
index 4e19540885..2e92f504d1 100644
--- a/io/Versions
+++ b/io/Versions
@@ -143,7 +143,7 @@ libc {
GLIBC_PRIVATE {
__libc_fcntl64;
__fcntl_nocancel;
- __open64_nocancel;
+ __openat64_nocancel;
__write_nocancel;
__file_is_unchanged;
__file_change_detection_for_stat;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..737863e2d1 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -182,8 +182,8 @@ _IO_file_open (FILE *fp, const char *filename, int posix_mode, int prot,
{
int fdesc;
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
- fdesc = __open_nocancel (filename,
- posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
+ fdesc = __open64_nocancel (filename,
+ posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
fdesc = __open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
if (fdesc < 0)
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index e7c797bc70..52ce694cdf 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -202,7 +202,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
archmapped = &headmap;
/* The archive has never been opened. */
- fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open64_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd < 0)
/* Cannot open the archive, for whatever reason. */
return NULL;
@@ -397,8 +397,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (fd == -1)
{
struct __stat64_t64 st;
- fd = __open_nocancel (archfname,
- O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open64_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 b8cd1aa441..110205661e 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -174,7 +174,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
file->decided = 1;
file->data = NULL;
- fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC);
+ fd = __open64_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)
"/SYS_", 5), _nl_category_names_get (category),
_nl_category_name_sizes[category] + 1);
- fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC);
+ fd = __open64_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 6c3467d5d9..f686ea7511 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -141,7 +141,7 @@ __libc_setutent (void)
file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
file_writable = false;
- file_fd = __open_nocancel
+ file_fd = __open64_nocancel
(file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (file_fd == -1)
return 0;
@@ -353,7 +353,7 @@ __libc_pututline (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_nocancel
+ int new_fd = __open64_nocancel
(file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC);
if (new_fd == -1)
return NULL;
@@ -463,7 +463,7 @@ __libc_updwtmp (const char *file, const struct utmp *utmp)
int fd;
/* Open WTMP file. */
- fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE);
+ fd = __open64_nocancel (file, O_WRONLY | O_LARGEFILE);
if (fd < 0)
return -1;
diff --git a/misc/daemon.c b/misc/daemon.c
index 0e688f4d74..53b2625b8d 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_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
+ if ((fd = __open64_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
&& (__builtin_expect (__fstat64 (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 6abfba35e7..4552d76777 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_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ int fd = __open64_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1)
{
struct nss_db_header header;
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index ca953804d0..bf9d77b149 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -351,8 +351,7 @@ ifeq ($(subdir),io)
sysdep_routines += xstatconv internal_statvfs \
sync_file_range fallocate fallocate64 \
close_nocancel fcntl_nocancel \
- open_nocancel open64_nocancel \
- openat_nocancel openat64_nocancel \
+ openat64_nocancel \
read_nocancel pread64_nocancel \
write_nocancel statx_cp stat_t64_cp
diff --git a/sysdeps/unix/sysv/linux/closefrom_fallback.c b/sysdeps/unix/sysv/linux/closefrom_fallback.c
index 60101aa3ba..5a0311136c 100644
--- a/sysdeps/unix/sysv/linux/closefrom_fallback.c
+++ b/sysdeps/unix/sysv/linux/closefrom_fallback.c
@@ -32,8 +32,8 @@ __closefrom_fallback (int from, _Bool dirfd_fallback)
{
bool ret = false;
- int dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
- 0);
+ int dirfd = __open64_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
+ 0);
if (dirfd == -1)
{
/* The closefrom should work even when process can't open new files. */
@@ -47,8 +47,8 @@ __closefrom_fallback (int from, _Bool dirfd_fallback)
break;
}
- dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
- 0);
+ dirfd = __open64_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
+ 0);
if (dirfd == -1)
return false;
}
diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c
index 7aa073bf3c..61bfe0aa58 100644
--- a/sysdeps/unix/sysv/linux/fchmodat.c
+++ b/sysdeps/unix/sysv/linux/fchmodat.c
@@ -39,8 +39,8 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
However, we can create an O_PATH descriptor and change that
via /proc (which does not resolve symbolic links). */
- int pathfd = __openat_nocancel (fd, file,
- O_PATH | O_NOFOLLOW | O_CLOEXEC);
+ int pathfd = __openat64_nocancel (fd, file,
+ O_PATH | O_NOFOLLOW | O_CLOEXEC);
if (pathfd < 0)
/* This may report errors such as ENFILE and EMFILE. The
caller can treat them as temporary if necessary. */
diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h
index b734126bc0..a6997f6624 100644
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -42,7 +42,7 @@ fips_enabled_p (void)
if (checked == FIPS_UNTESTED)
{
- int fd = __open_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
if (fd != -1)
{
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index fa0001b63e..4b742a0764 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -48,7 +48,7 @@ sethostid (long int id)
}
/* Open file for writing. Everybody is allowed to read this file. */
- fd = __open_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+ fd = __open64_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
if (fd < 0)
return -1;
@@ -77,7 +77,7 @@ gethostid (void)
int fd;
/* First try to get the ID from a former invocation of sethostid. */
- fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
+ fd = __open64_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
if (fd >= 0)
{
ssize_t n = __read_nocancel (fd, &id, sizeof (id));
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 290628f5aa..d204ba55d5 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -35,7 +35,7 @@ int
attribute_hidden
__getlogin_r_loginuid (char *name, size_t namesize)
{
- int fd = __open_nocancel ("/proc/self/loginuid", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/self/loginuid", O_RDONLY);
if (fd == -1)
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 0c65d0e268..d0924c311d 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -117,7 +117,7 @@ get_nproc_stat (void)
int result = 0;
const int flags = O_RDONLY | O_CLOEXEC;
- int fd = __open_nocancel ("/proc/stat", flags);
+ int fd = __open64_nocancel ("/proc/stat", flags);
if (fd != -1)
{
char *l;
@@ -146,7 +146,7 @@ get_nprocs_cpu_online (void)
const int flags = O_RDONLY | O_CLOEXEC;
/* This file contains comma-separated ranges. */
- int fd = __open_nocancel ("/sys/devices/system/cpu/online", flags);
+ int fd = __open64_nocancel ("/sys/devices/system/cpu/online", flags);
char *l;
int result = 0;
if (fd != -1)
diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h
index 5145cf4366..a5e3877b93 100644
--- a/sysdeps/unix/sysv/linux/malloc-sysdep.h
+++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h
@@ -42,8 +42,8 @@ check_may_shrink_heap (void)
if (__builtin_expect (may_shrink_heap == 0, 1))
{
- int fd = __open_nocancel ("/proc/sys/vm/overcommit_memory",
- O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel ("/proc/sys/vm/overcommit_memory",
+ O_RDONLY | O_CLOEXEC);
if (fd >= 0)
{
char val;
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 75b9e0ee1e..6c0491bde3 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -27,15 +27,6 @@
#include <sys/wait.h>
#include <time.h>
-/* Non cancellable open syscall. */
-__typeof (open) __open_nocancel;
-
-/* Non cancellable open syscall (LFS version). */
-__typeof (open64) __open64_nocancel;
-
-/* Non cancellable openat syscall. */
-__typeof (openat) __openat_nocancel;
-
/* Non cacellable openat syscall (LFS version). */
__typeof (openat64) __openat64_nocancel;
@@ -51,6 +42,9 @@ __typeof (__write) __write_nocancel;
/* Uncancelable close. */
__typeof (__close) __close_nocancel;
+#define __open64_nocancel(args...) \
+ __openat64_nocancel (AT_FDCWD, args)
+
/* Non cancellable close syscall that does not also set errno in case of
failure. */
static inline void
@@ -71,9 +65,6 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
__typeof (__fcntl) __fcntl64_nocancel;
#if IS_IN (libc) || IS_IN (rtld)
-hidden_proto (__open_nocancel)
-hidden_proto (__open64_nocancel)
-hidden_proto (__openat_nocancel)
hidden_proto (__openat64_nocancel)
hidden_proto (__read_nocancel)
hidden_proto (__pread64_nocancel)
diff --git a/sysdeps/unix/sysv/linux/open64_nocancel.c b/sysdeps/unix/sysv/linux/open64_nocancel.c
deleted file mode 100644
index 099bdc9e40..0000000000
--- a/sysdeps/unix/sysv/linux/open64_nocancel.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Linux open syscall implementation, LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <not-cancel.h>
-
-int
-__open64_nocancel (const char *file, int oflag, ...)
-{
- int mode = 0;
-
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, int);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE,
- mode);
-}
-
-hidden_def (__open64_nocancel)
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-strong_alias (__open64_nocancel, __open_nocancel)
-hidden_def (__open_nocancel)
-#endif
diff --git a/sysdeps/unix/sysv/linux/open_nocancel.c b/sysdeps/unix/sysv/linux/open_nocancel.c
deleted file mode 100644
index 3ba5fd2433..0000000000
--- a/sysdeps/unix/sysv/linux/open_nocancel.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Linux open syscall implementation, non-LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sysdep-cancel.h>
-#include <not-cancel.h>
-
-#ifndef __OFF_T_MATCHES_OFF64_T
-
-int
-__open_nocancel (const char *file, int oflag, ...)
-{
- int mode = 0;
-
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, int);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag, mode);
-}
-hidden_def (__open_nocancel)
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c
index 9606ea3741..0a92ffb2c4 100644
--- a/sysdeps/unix/sysv/linux/openat64_nocancel.c
+++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c
@@ -38,8 +38,3 @@ __openat64_nocancel (int fd, const char *file, int oflag, ...)
mode);
}
hidden_def (__openat64_nocancel)
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-strong_alias (__openat64_nocancel, __openat_nocancel)
-hidden_def (__openat_nocancel)
-#endif
diff --git a/sysdeps/unix/sysv/linux/openat_nocancel.c b/sysdeps/unix/sysv/linux/openat_nocancel.c
deleted file mode 100644
index aeb7051030..0000000000
--- a/sysdeps/unix/sysv/linux/openat_nocancel.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Linux openat syscall implementation, non-LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sysdep-cancel.h>
-#include <not-cancel.h>
-
-#ifndef __OFF_T_MATCHES_OFF64_T
-
-int
-__openat_nocancel (int fd, const char *file, int oflag, ...)
-{
- mode_t mode = 0;
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, mode_t);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, fd, file, oflag, mode);
-}
-hidden_def (__openat_nocancel)
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/opendir.c b/sysdeps/unix/sysv/linux/opendir.c
index 9e81d00630..b2b6c86e5c 100644
--- a/sysdeps/unix/sysv/linux/opendir.c
+++ b/sysdeps/unix/sysv/linux/opendir.c
@@ -71,7 +71,7 @@ __opendirat (int dfd, const char *name)
if (__glibc_unlikely (invalid_name (name)))
return NULL;
- return opendir_tail (__openat_nocancel (dfd, name, opendir_oflags));
+ return opendir_tail (__openat64_nocancel (dfd, name, opendir_oflags));
}
#endif
@@ -83,7 +83,7 @@ __opendir (const char *name)
if (__glibc_unlikely (invalid_name (name)))
return NULL;
- return opendir_tail (__open_nocancel (name, opendir_oflags));
+ return opendir_tail (__open64_nocancel (name, opendir_oflags));
}
weak_alias (__opendir, opendir)
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
index 759d70eb74..bf3d683730 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
@@ -32,7 +32,7 @@ get_timebase_freq_fallback (void)
contains at least one line like:
timebase : 33333333
We search for this line and convert the number into an integer. */
- int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/cpuinfo", O_RDONLY);
if (__glibc_unlikely (fd == -1))
return result;
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index d703485e3f..57dc4fb5de 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -209,10 +209,10 @@ __spawni_child (void *arguments)
paths (like /dev/watchdog). */
__close_nocancel (action->action.open_action.fd);
- int ret = __open_nocancel (action->action.open_action.path,
- action->action.
- open_action.oflag | O_LARGEFILE,
- action->action.open_action.mode);
+ int ret = __open64_nocancel (action->action.open_action.path,
+ action->action.
+ open_action.oflag | O_LARGEFILE,
+ action->action.open_action.mode);
if (ret == -1)
goto fail;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 4afc00c8d0..28a8a7ebaa 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -96,7 +96,7 @@ __sysconf (int name)
if (procfname != NULL)
{
- int fd = __open_nocancel (procfname, O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel (procfname, O_RDONLY | O_CLOEXEC);
if (fd != -1)
{
/* This is more than enough, the file contains a single integer. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/azanella/clang] Consolidate open without cancellation
@ 2022-03-15 18:36 Adhemerval Zanella
0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2022-03-15 18:36 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b83490d5427012fc671884007d656c0032928f13
commit b83490d5427012fc671884007d656c0032928f13
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Mar 7 14:00:28 2022 -0300
Consolidate open without cancellation
To use only __openat64_nocancel.
Diff:
---
catgets/open_catalog.c | 4 +-
csu/check_fds.c | 2 +-
gmon/gmon.c | 7 ++--
iconv/gconv_cache.c | 2 +-
intl/loadmsgcat.c | 2 +-
io/Versions | 2 +-
libio/fileops.c | 4 +-
locale/loadarchive.c | 6 +--
locale/loadlocale.c | 4 +-
login/utmp_file.c | 6 +--
misc/daemon.c | 2 +-
nss/nss_db/db-open.c | 2 +-
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/closefrom_fallback.c | 8 ++--
sysdeps/unix/sysv/linux/fchmodat.c | 4 +-
sysdeps/unix/sysv/linux/fips-private.h | 2 +-
sysdeps/unix/sysv/linux/gethostid.c | 4 +-
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 4 +-
sysdeps/unix/sysv/linux/malloc-sysdep.h | 4 +-
sysdeps/unix/sysv/linux/not-cancel.h | 15 ++-----
sysdeps/unix/sysv/linux/open64_nocancel.c | 48 ----------------------
sysdeps/unix/sysv/linux/open_nocancel.c | 46 ---------------------
sysdeps/unix/sysv/linux/openat64_nocancel.c | 5 ---
sysdeps/unix/sysv/linux/openat_nocancel.c | 43 -------------------
sysdeps/unix/sysv/linux/opendir.c | 4 +-
.../unix/sysv/linux/powerpc/get_timebase_freq.c | 2 +-
sysdeps/unix/sysv/linux/spawni.c | 8 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
29 files changed, 48 insertions(+), 199 deletions(-)
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 48c2a4b983..7301b0812b 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -49,7 +49,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_nocancel (cat_name, O_RDONLY);
+ fd = __open64_nocancel (cat_name, O_RDONLY);
else
{
const char *run_nlspath = nlspath;
@@ -177,7 +177,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (bufact != 0)
{
- fd = __open_nocancel (buf, O_RDONLY);
+ fd = __open64_nocancel (buf, O_RDONLY);
if (fd >= 0)
break;
}
diff --git a/csu/check_fds.c b/csu/check_fds.c
index 4016a4a1c3..7e597dc76c 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -60,7 +60,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_nocancel (name, mode, 0);
+ int nullfd = __open64_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 dee64803ad..4af4e8cb29 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -362,13 +362,14 @@ write_gmon (void)
size_t len = strlen (env);
char buf[len + 20];
__snprintf (buf, sizeof (buf), "%s.%u", env, __getpid ());
- fd = __open_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666);
+ fd = __open64_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ 0666);
}
if (fd == -1)
{
- fd = __open_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
- 0666);
+ fd = __open64_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ 0666);
if (fd < 0)
{
char buf[300];
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index c772856d1f..22860c2133 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -57,7 +57,7 @@ __gconv_load_cache (void)
return -1;
/* See whether the cache file exists. */
- fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY, 0);
+ fd = __open64_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 98d5f53232..03fde79ec2 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_nocancel (name, flags)
+# define open(name, flags) __open64_nocancel (name, flags)
# define close(fd) __close_nocancel_nostatus (fd)
# define read(fd, buf, n) __read_nocancel (fd, buf, n)
# define mmap(addr, len, prot, flags, fd, offset) \
diff --git a/io/Versions b/io/Versions
index 4e19540885..2e92f504d1 100644
--- a/io/Versions
+++ b/io/Versions
@@ -143,7 +143,7 @@ libc {
GLIBC_PRIVATE {
__libc_fcntl64;
__fcntl_nocancel;
- __open64_nocancel;
+ __openat64_nocancel;
__write_nocancel;
__file_is_unchanged;
__file_change_detection_for_stat;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..737863e2d1 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -182,8 +182,8 @@ _IO_file_open (FILE *fp, const char *filename, int posix_mode, int prot,
{
int fdesc;
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
- fdesc = __open_nocancel (filename,
- posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
+ fdesc = __open64_nocancel (filename,
+ posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
fdesc = __open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
if (fdesc < 0)
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index e7c797bc70..52ce694cdf 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -202,7 +202,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
archmapped = &headmap;
/* The archive has never been opened. */
- fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open64_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd < 0)
/* Cannot open the archive, for whatever reason. */
return NULL;
@@ -397,8 +397,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (fd == -1)
{
struct __stat64_t64 st;
- fd = __open_nocancel (archfname,
- O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open64_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 b8cd1aa441..110205661e 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -174,7 +174,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
file->decided = 1;
file->data = NULL;
- fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC);
+ fd = __open64_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)
"/SYS_", 5), _nl_category_names_get (category),
_nl_category_name_sizes[category] + 1);
- fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC);
+ fd = __open64_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 6c3467d5d9..f686ea7511 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -141,7 +141,7 @@ __libc_setutent (void)
file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
file_writable = false;
- file_fd = __open_nocancel
+ file_fd = __open64_nocancel
(file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (file_fd == -1)
return 0;
@@ -353,7 +353,7 @@ __libc_pututline (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_nocancel
+ int new_fd = __open64_nocancel
(file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC);
if (new_fd == -1)
return NULL;
@@ -463,7 +463,7 @@ __libc_updwtmp (const char *file, const struct utmp *utmp)
int fd;
/* Open WTMP file. */
- fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE);
+ fd = __open64_nocancel (file, O_WRONLY | O_LARGEFILE);
if (fd < 0)
return -1;
diff --git a/misc/daemon.c b/misc/daemon.c
index 0e688f4d74..53b2625b8d 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_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
+ if ((fd = __open64_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
&& (__builtin_expect (__fstat64 (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 6abfba35e7..4552d76777 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_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ int fd = __open64_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1)
{
struct nss_db_header header;
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index ca953804d0..bf9d77b149 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -351,8 +351,7 @@ ifeq ($(subdir),io)
sysdep_routines += xstatconv internal_statvfs \
sync_file_range fallocate fallocate64 \
close_nocancel fcntl_nocancel \
- open_nocancel open64_nocancel \
- openat_nocancel openat64_nocancel \
+ openat64_nocancel \
read_nocancel pread64_nocancel \
write_nocancel statx_cp stat_t64_cp
diff --git a/sysdeps/unix/sysv/linux/closefrom_fallback.c b/sysdeps/unix/sysv/linux/closefrom_fallback.c
index 60101aa3ba..5a0311136c 100644
--- a/sysdeps/unix/sysv/linux/closefrom_fallback.c
+++ b/sysdeps/unix/sysv/linux/closefrom_fallback.c
@@ -32,8 +32,8 @@ __closefrom_fallback (int from, _Bool dirfd_fallback)
{
bool ret = false;
- int dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
- 0);
+ int dirfd = __open64_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
+ 0);
if (dirfd == -1)
{
/* The closefrom should work even when process can't open new files. */
@@ -47,8 +47,8 @@ __closefrom_fallback (int from, _Bool dirfd_fallback)
break;
}
- dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
- 0);
+ dirfd = __open64_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
+ 0);
if (dirfd == -1)
return false;
}
diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c
index 7aa073bf3c..61bfe0aa58 100644
--- a/sysdeps/unix/sysv/linux/fchmodat.c
+++ b/sysdeps/unix/sysv/linux/fchmodat.c
@@ -39,8 +39,8 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
However, we can create an O_PATH descriptor and change that
via /proc (which does not resolve symbolic links). */
- int pathfd = __openat_nocancel (fd, file,
- O_PATH | O_NOFOLLOW | O_CLOEXEC);
+ int pathfd = __openat64_nocancel (fd, file,
+ O_PATH | O_NOFOLLOW | O_CLOEXEC);
if (pathfd < 0)
/* This may report errors such as ENFILE and EMFILE. The
caller can treat them as temporary if necessary. */
diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h
index b734126bc0..a6997f6624 100644
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -42,7 +42,7 @@ fips_enabled_p (void)
if (checked == FIPS_UNTESTED)
{
- int fd = __open_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
if (fd != -1)
{
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index fa0001b63e..4b742a0764 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -48,7 +48,7 @@ sethostid (long int id)
}
/* Open file for writing. Everybody is allowed to read this file. */
- fd = __open_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+ fd = __open64_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
if (fd < 0)
return -1;
@@ -77,7 +77,7 @@ gethostid (void)
int fd;
/* First try to get the ID from a former invocation of sethostid. */
- fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
+ fd = __open64_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
if (fd >= 0)
{
ssize_t n = __read_nocancel (fd, &id, sizeof (id));
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 290628f5aa..d204ba55d5 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -35,7 +35,7 @@ int
attribute_hidden
__getlogin_r_loginuid (char *name, size_t namesize)
{
- int fd = __open_nocancel ("/proc/self/loginuid", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/self/loginuid", O_RDONLY);
if (fd == -1)
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 0c65d0e268..d0924c311d 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -117,7 +117,7 @@ get_nproc_stat (void)
int result = 0;
const int flags = O_RDONLY | O_CLOEXEC;
- int fd = __open_nocancel ("/proc/stat", flags);
+ int fd = __open64_nocancel ("/proc/stat", flags);
if (fd != -1)
{
char *l;
@@ -146,7 +146,7 @@ get_nprocs_cpu_online (void)
const int flags = O_RDONLY | O_CLOEXEC;
/* This file contains comma-separated ranges. */
- int fd = __open_nocancel ("/sys/devices/system/cpu/online", flags);
+ int fd = __open64_nocancel ("/sys/devices/system/cpu/online", flags);
char *l;
int result = 0;
if (fd != -1)
diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h
index 5145cf4366..a5e3877b93 100644
--- a/sysdeps/unix/sysv/linux/malloc-sysdep.h
+++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h
@@ -42,8 +42,8 @@ check_may_shrink_heap (void)
if (__builtin_expect (may_shrink_heap == 0, 1))
{
- int fd = __open_nocancel ("/proc/sys/vm/overcommit_memory",
- O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel ("/proc/sys/vm/overcommit_memory",
+ O_RDONLY | O_CLOEXEC);
if (fd >= 0)
{
char val;
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 75b9e0ee1e..6c0491bde3 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -27,15 +27,6 @@
#include <sys/wait.h>
#include <time.h>
-/* Non cancellable open syscall. */
-__typeof (open) __open_nocancel;
-
-/* Non cancellable open syscall (LFS version). */
-__typeof (open64) __open64_nocancel;
-
-/* Non cancellable openat syscall. */
-__typeof (openat) __openat_nocancel;
-
/* Non cacellable openat syscall (LFS version). */
__typeof (openat64) __openat64_nocancel;
@@ -51,6 +42,9 @@ __typeof (__write) __write_nocancel;
/* Uncancelable close. */
__typeof (__close) __close_nocancel;
+#define __open64_nocancel(args...) \
+ __openat64_nocancel (AT_FDCWD, args)
+
/* Non cancellable close syscall that does not also set errno in case of
failure. */
static inline void
@@ -71,9 +65,6 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
__typeof (__fcntl) __fcntl64_nocancel;
#if IS_IN (libc) || IS_IN (rtld)
-hidden_proto (__open_nocancel)
-hidden_proto (__open64_nocancel)
-hidden_proto (__openat_nocancel)
hidden_proto (__openat64_nocancel)
hidden_proto (__read_nocancel)
hidden_proto (__pread64_nocancel)
diff --git a/sysdeps/unix/sysv/linux/open64_nocancel.c b/sysdeps/unix/sysv/linux/open64_nocancel.c
deleted file mode 100644
index 099bdc9e40..0000000000
--- a/sysdeps/unix/sysv/linux/open64_nocancel.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Linux open syscall implementation, LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <not-cancel.h>
-
-int
-__open64_nocancel (const char *file, int oflag, ...)
-{
- int mode = 0;
-
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, int);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE,
- mode);
-}
-
-hidden_def (__open64_nocancel)
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-strong_alias (__open64_nocancel, __open_nocancel)
-hidden_def (__open_nocancel)
-#endif
diff --git a/sysdeps/unix/sysv/linux/open_nocancel.c b/sysdeps/unix/sysv/linux/open_nocancel.c
deleted file mode 100644
index 3ba5fd2433..0000000000
--- a/sysdeps/unix/sysv/linux/open_nocancel.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Linux open syscall implementation, non-LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sysdep-cancel.h>
-#include <not-cancel.h>
-
-#ifndef __OFF_T_MATCHES_OFF64_T
-
-int
-__open_nocancel (const char *file, int oflag, ...)
-{
- int mode = 0;
-
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, int);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag, mode);
-}
-hidden_def (__open_nocancel)
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c
index 9606ea3741..0a92ffb2c4 100644
--- a/sysdeps/unix/sysv/linux/openat64_nocancel.c
+++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c
@@ -38,8 +38,3 @@ __openat64_nocancel (int fd, const char *file, int oflag, ...)
mode);
}
hidden_def (__openat64_nocancel)
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-strong_alias (__openat64_nocancel, __openat_nocancel)
-hidden_def (__openat_nocancel)
-#endif
diff --git a/sysdeps/unix/sysv/linux/openat_nocancel.c b/sysdeps/unix/sysv/linux/openat_nocancel.c
deleted file mode 100644
index aeb7051030..0000000000
--- a/sysdeps/unix/sysv/linux/openat_nocancel.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Linux openat syscall implementation, non-LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sysdep-cancel.h>
-#include <not-cancel.h>
-
-#ifndef __OFF_T_MATCHES_OFF64_T
-
-int
-__openat_nocancel (int fd, const char *file, int oflag, ...)
-{
- mode_t mode = 0;
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, mode_t);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, fd, file, oflag, mode);
-}
-hidden_def (__openat_nocancel)
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/opendir.c b/sysdeps/unix/sysv/linux/opendir.c
index 9e81d00630..b2b6c86e5c 100644
--- a/sysdeps/unix/sysv/linux/opendir.c
+++ b/sysdeps/unix/sysv/linux/opendir.c
@@ -71,7 +71,7 @@ __opendirat (int dfd, const char *name)
if (__glibc_unlikely (invalid_name (name)))
return NULL;
- return opendir_tail (__openat_nocancel (dfd, name, opendir_oflags));
+ return opendir_tail (__openat64_nocancel (dfd, name, opendir_oflags));
}
#endif
@@ -83,7 +83,7 @@ __opendir (const char *name)
if (__glibc_unlikely (invalid_name (name)))
return NULL;
- return opendir_tail (__open_nocancel (name, opendir_oflags));
+ return opendir_tail (__open64_nocancel (name, opendir_oflags));
}
weak_alias (__opendir, opendir)
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
index 759d70eb74..bf3d683730 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
@@ -32,7 +32,7 @@ get_timebase_freq_fallback (void)
contains at least one line like:
timebase : 33333333
We search for this line and convert the number into an integer. */
- int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/cpuinfo", O_RDONLY);
if (__glibc_unlikely (fd == -1))
return result;
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index d703485e3f..57dc4fb5de 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -209,10 +209,10 @@ __spawni_child (void *arguments)
paths (like /dev/watchdog). */
__close_nocancel (action->action.open_action.fd);
- int ret = __open_nocancel (action->action.open_action.path,
- action->action.
- open_action.oflag | O_LARGEFILE,
- action->action.open_action.mode);
+ int ret = __open64_nocancel (action->action.open_action.path,
+ action->action.
+ open_action.oflag | O_LARGEFILE,
+ action->action.open_action.mode);
if (ret == -1)
goto fail;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 4afc00c8d0..28a8a7ebaa 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -96,7 +96,7 @@ __sysconf (int name)
if (procfname != NULL)
{
- int fd = __open_nocancel (procfname, O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel (procfname, O_RDONLY | O_CLOEXEC);
if (fd != -1)
{
/* This is more than enough, the file contains a single integer. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/azanella/clang] Consolidate open without cancellation
@ 2022-03-11 17:20 Adhemerval Zanella
0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2022-03-11 17:20 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0989c7823a9a66dde3aa9269985eafd4a4149448
commit 0989c7823a9a66dde3aa9269985eafd4a4149448
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Mar 7 14:00:28 2022 -0300
Consolidate open without cancellation
To use only __openat64_nocancel.
Diff:
---
catgets/open_catalog.c | 4 +-
csu/check_fds.c | 2 +-
gmon/gmon.c | 7 ++--
iconv/gconv_cache.c | 2 +-
intl/loadmsgcat.c | 2 +-
io/Versions | 2 +-
libio/fileops.c | 4 +-
locale/loadarchive.c | 6 +--
locale/loadlocale.c | 4 +-
login/utmp_file.c | 6 +--
misc/daemon.c | 2 +-
nss/nss_db/db-open.c | 2 +-
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/closefrom_fallback.c | 8 ++--
sysdeps/unix/sysv/linux/fchmodat.c | 4 +-
sysdeps/unix/sysv/linux/fips-private.h | 2 +-
sysdeps/unix/sysv/linux/gethostid.c | 4 +-
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 4 +-
sysdeps/unix/sysv/linux/malloc-sysdep.h | 4 +-
sysdeps/unix/sysv/linux/not-cancel.h | 15 ++-----
sysdeps/unix/sysv/linux/open64_nocancel.c | 48 ----------------------
sysdeps/unix/sysv/linux/open_nocancel.c | 46 ---------------------
sysdeps/unix/sysv/linux/openat64_nocancel.c | 5 ---
sysdeps/unix/sysv/linux/openat_nocancel.c | 43 -------------------
sysdeps/unix/sysv/linux/opendir.c | 4 +-
.../unix/sysv/linux/powerpc/get_timebase_freq.c | 2 +-
sysdeps/unix/sysv/linux/spawni.c | 8 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
29 files changed, 48 insertions(+), 199 deletions(-)
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 48c2a4b983..7301b0812b 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -49,7 +49,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_nocancel (cat_name, O_RDONLY);
+ fd = __open64_nocancel (cat_name, O_RDONLY);
else
{
const char *run_nlspath = nlspath;
@@ -177,7 +177,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (bufact != 0)
{
- fd = __open_nocancel (buf, O_RDONLY);
+ fd = __open64_nocancel (buf, O_RDONLY);
if (fd >= 0)
break;
}
diff --git a/csu/check_fds.c b/csu/check_fds.c
index 4016a4a1c3..7e597dc76c 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -60,7 +60,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_nocancel (name, mode, 0);
+ int nullfd = __open64_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 dee64803ad..4af4e8cb29 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -362,13 +362,14 @@ write_gmon (void)
size_t len = strlen (env);
char buf[len + 20];
__snprintf (buf, sizeof (buf), "%s.%u", env, __getpid ());
- fd = __open_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666);
+ fd = __open64_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ 0666);
}
if (fd == -1)
{
- fd = __open_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
- 0666);
+ fd = __open64_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ 0666);
if (fd < 0)
{
char buf[300];
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index c772856d1f..22860c2133 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -57,7 +57,7 @@ __gconv_load_cache (void)
return -1;
/* See whether the cache file exists. */
- fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY, 0);
+ fd = __open64_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 98d5f53232..03fde79ec2 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_nocancel (name, flags)
+# define open(name, flags) __open64_nocancel (name, flags)
# define close(fd) __close_nocancel_nostatus (fd)
# define read(fd, buf, n) __read_nocancel (fd, buf, n)
# define mmap(addr, len, prot, flags, fd, offset) \
diff --git a/io/Versions b/io/Versions
index 4e19540885..2e92f504d1 100644
--- a/io/Versions
+++ b/io/Versions
@@ -143,7 +143,7 @@ libc {
GLIBC_PRIVATE {
__libc_fcntl64;
__fcntl_nocancel;
- __open64_nocancel;
+ __openat64_nocancel;
__write_nocancel;
__file_is_unchanged;
__file_change_detection_for_stat;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..737863e2d1 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -182,8 +182,8 @@ _IO_file_open (FILE *fp, const char *filename, int posix_mode, int prot,
{
int fdesc;
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
- fdesc = __open_nocancel (filename,
- posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
+ fdesc = __open64_nocancel (filename,
+ posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
fdesc = __open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
if (fdesc < 0)
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index e7c797bc70..52ce694cdf 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -202,7 +202,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
archmapped = &headmap;
/* The archive has never been opened. */
- fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open64_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd < 0)
/* Cannot open the archive, for whatever reason. */
return NULL;
@@ -397,8 +397,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (fd == -1)
{
struct __stat64_t64 st;
- fd = __open_nocancel (archfname,
- O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open64_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 b8cd1aa441..110205661e 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -174,7 +174,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
file->decided = 1;
file->data = NULL;
- fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC);
+ fd = __open64_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)
"/SYS_", 5), _nl_category_names_get (category),
_nl_category_name_sizes[category] + 1);
- fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC);
+ fd = __open64_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 6c3467d5d9..f686ea7511 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -141,7 +141,7 @@ __libc_setutent (void)
file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
file_writable = false;
- file_fd = __open_nocancel
+ file_fd = __open64_nocancel
(file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (file_fd == -1)
return 0;
@@ -353,7 +353,7 @@ __libc_pututline (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_nocancel
+ int new_fd = __open64_nocancel
(file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC);
if (new_fd == -1)
return NULL;
@@ -463,7 +463,7 @@ __libc_updwtmp (const char *file, const struct utmp *utmp)
int fd;
/* Open WTMP file. */
- fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE);
+ fd = __open64_nocancel (file, O_WRONLY | O_LARGEFILE);
if (fd < 0)
return -1;
diff --git a/misc/daemon.c b/misc/daemon.c
index 0e688f4d74..53b2625b8d 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_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
+ if ((fd = __open64_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
&& (__builtin_expect (__fstat64 (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 6abfba35e7..4552d76777 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_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ int fd = __open64_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1)
{
struct nss_db_header header;
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index ca953804d0..bf9d77b149 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -351,8 +351,7 @@ ifeq ($(subdir),io)
sysdep_routines += xstatconv internal_statvfs \
sync_file_range fallocate fallocate64 \
close_nocancel fcntl_nocancel \
- open_nocancel open64_nocancel \
- openat_nocancel openat64_nocancel \
+ openat64_nocancel \
read_nocancel pread64_nocancel \
write_nocancel statx_cp stat_t64_cp
diff --git a/sysdeps/unix/sysv/linux/closefrom_fallback.c b/sysdeps/unix/sysv/linux/closefrom_fallback.c
index 60101aa3ba..5a0311136c 100644
--- a/sysdeps/unix/sysv/linux/closefrom_fallback.c
+++ b/sysdeps/unix/sysv/linux/closefrom_fallback.c
@@ -32,8 +32,8 @@ __closefrom_fallback (int from, _Bool dirfd_fallback)
{
bool ret = false;
- int dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
- 0);
+ int dirfd = __open64_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
+ 0);
if (dirfd == -1)
{
/* The closefrom should work even when process can't open new files. */
@@ -47,8 +47,8 @@ __closefrom_fallback (int from, _Bool dirfd_fallback)
break;
}
- dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
- 0);
+ dirfd = __open64_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
+ 0);
if (dirfd == -1)
return false;
}
diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c
index 7aa073bf3c..61bfe0aa58 100644
--- a/sysdeps/unix/sysv/linux/fchmodat.c
+++ b/sysdeps/unix/sysv/linux/fchmodat.c
@@ -39,8 +39,8 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
However, we can create an O_PATH descriptor and change that
via /proc (which does not resolve symbolic links). */
- int pathfd = __openat_nocancel (fd, file,
- O_PATH | O_NOFOLLOW | O_CLOEXEC);
+ int pathfd = __openat64_nocancel (fd, file,
+ O_PATH | O_NOFOLLOW | O_CLOEXEC);
if (pathfd < 0)
/* This may report errors such as ENFILE and EMFILE. The
caller can treat them as temporary if necessary. */
diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h
index b734126bc0..a6997f6624 100644
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -42,7 +42,7 @@ fips_enabled_p (void)
if (checked == FIPS_UNTESTED)
{
- int fd = __open_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
if (fd != -1)
{
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index fa0001b63e..4b742a0764 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -48,7 +48,7 @@ sethostid (long int id)
}
/* Open file for writing. Everybody is allowed to read this file. */
- fd = __open_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+ fd = __open64_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
if (fd < 0)
return -1;
@@ -77,7 +77,7 @@ gethostid (void)
int fd;
/* First try to get the ID from a former invocation of sethostid. */
- fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
+ fd = __open64_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
if (fd >= 0)
{
ssize_t n = __read_nocancel (fd, &id, sizeof (id));
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 290628f5aa..d204ba55d5 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -35,7 +35,7 @@ int
attribute_hidden
__getlogin_r_loginuid (char *name, size_t namesize)
{
- int fd = __open_nocancel ("/proc/self/loginuid", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/self/loginuid", O_RDONLY);
if (fd == -1)
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 0c65d0e268..d0924c311d 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -117,7 +117,7 @@ get_nproc_stat (void)
int result = 0;
const int flags = O_RDONLY | O_CLOEXEC;
- int fd = __open_nocancel ("/proc/stat", flags);
+ int fd = __open64_nocancel ("/proc/stat", flags);
if (fd != -1)
{
char *l;
@@ -146,7 +146,7 @@ get_nprocs_cpu_online (void)
const int flags = O_RDONLY | O_CLOEXEC;
/* This file contains comma-separated ranges. */
- int fd = __open_nocancel ("/sys/devices/system/cpu/online", flags);
+ int fd = __open64_nocancel ("/sys/devices/system/cpu/online", flags);
char *l;
int result = 0;
if (fd != -1)
diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h
index 5145cf4366..a5e3877b93 100644
--- a/sysdeps/unix/sysv/linux/malloc-sysdep.h
+++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h
@@ -42,8 +42,8 @@ check_may_shrink_heap (void)
if (__builtin_expect (may_shrink_heap == 0, 1))
{
- int fd = __open_nocancel ("/proc/sys/vm/overcommit_memory",
- O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel ("/proc/sys/vm/overcommit_memory",
+ O_RDONLY | O_CLOEXEC);
if (fd >= 0)
{
char val;
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 75b9e0ee1e..6c0491bde3 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -27,15 +27,6 @@
#include <sys/wait.h>
#include <time.h>
-/* Non cancellable open syscall. */
-__typeof (open) __open_nocancel;
-
-/* Non cancellable open syscall (LFS version). */
-__typeof (open64) __open64_nocancel;
-
-/* Non cancellable openat syscall. */
-__typeof (openat) __openat_nocancel;
-
/* Non cacellable openat syscall (LFS version). */
__typeof (openat64) __openat64_nocancel;
@@ -51,6 +42,9 @@ __typeof (__write) __write_nocancel;
/* Uncancelable close. */
__typeof (__close) __close_nocancel;
+#define __open64_nocancel(args...) \
+ __openat64_nocancel (AT_FDCWD, args)
+
/* Non cancellable close syscall that does not also set errno in case of
failure. */
static inline void
@@ -71,9 +65,6 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
__typeof (__fcntl) __fcntl64_nocancel;
#if IS_IN (libc) || IS_IN (rtld)
-hidden_proto (__open_nocancel)
-hidden_proto (__open64_nocancel)
-hidden_proto (__openat_nocancel)
hidden_proto (__openat64_nocancel)
hidden_proto (__read_nocancel)
hidden_proto (__pread64_nocancel)
diff --git a/sysdeps/unix/sysv/linux/open64_nocancel.c b/sysdeps/unix/sysv/linux/open64_nocancel.c
deleted file mode 100644
index 099bdc9e40..0000000000
--- a/sysdeps/unix/sysv/linux/open64_nocancel.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Linux open syscall implementation, LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <not-cancel.h>
-
-int
-__open64_nocancel (const char *file, int oflag, ...)
-{
- int mode = 0;
-
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, int);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE,
- mode);
-}
-
-hidden_def (__open64_nocancel)
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-strong_alias (__open64_nocancel, __open_nocancel)
-hidden_def (__open_nocancel)
-#endif
diff --git a/sysdeps/unix/sysv/linux/open_nocancel.c b/sysdeps/unix/sysv/linux/open_nocancel.c
deleted file mode 100644
index 3ba5fd2433..0000000000
--- a/sysdeps/unix/sysv/linux/open_nocancel.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Linux open syscall implementation, non-LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sysdep-cancel.h>
-#include <not-cancel.h>
-
-#ifndef __OFF_T_MATCHES_OFF64_T
-
-int
-__open_nocancel (const char *file, int oflag, ...)
-{
- int mode = 0;
-
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, int);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag, mode);
-}
-hidden_def (__open_nocancel)
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c
index 9606ea3741..0a92ffb2c4 100644
--- a/sysdeps/unix/sysv/linux/openat64_nocancel.c
+++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c
@@ -38,8 +38,3 @@ __openat64_nocancel (int fd, const char *file, int oflag, ...)
mode);
}
hidden_def (__openat64_nocancel)
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-strong_alias (__openat64_nocancel, __openat_nocancel)
-hidden_def (__openat_nocancel)
-#endif
diff --git a/sysdeps/unix/sysv/linux/openat_nocancel.c b/sysdeps/unix/sysv/linux/openat_nocancel.c
deleted file mode 100644
index aeb7051030..0000000000
--- a/sysdeps/unix/sysv/linux/openat_nocancel.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Linux openat syscall implementation, non-LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sysdep-cancel.h>
-#include <not-cancel.h>
-
-#ifndef __OFF_T_MATCHES_OFF64_T
-
-int
-__openat_nocancel (int fd, const char *file, int oflag, ...)
-{
- mode_t mode = 0;
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, mode_t);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, fd, file, oflag, mode);
-}
-hidden_def (__openat_nocancel)
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/opendir.c b/sysdeps/unix/sysv/linux/opendir.c
index 9e81d00630..b2b6c86e5c 100644
--- a/sysdeps/unix/sysv/linux/opendir.c
+++ b/sysdeps/unix/sysv/linux/opendir.c
@@ -71,7 +71,7 @@ __opendirat (int dfd, const char *name)
if (__glibc_unlikely (invalid_name (name)))
return NULL;
- return opendir_tail (__openat_nocancel (dfd, name, opendir_oflags));
+ return opendir_tail (__openat64_nocancel (dfd, name, opendir_oflags));
}
#endif
@@ -83,7 +83,7 @@ __opendir (const char *name)
if (__glibc_unlikely (invalid_name (name)))
return NULL;
- return opendir_tail (__open_nocancel (name, opendir_oflags));
+ return opendir_tail (__open64_nocancel (name, opendir_oflags));
}
weak_alias (__opendir, opendir)
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
index 759d70eb74..bf3d683730 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
@@ -32,7 +32,7 @@ get_timebase_freq_fallback (void)
contains at least one line like:
timebase : 33333333
We search for this line and convert the number into an integer. */
- int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/cpuinfo", O_RDONLY);
if (__glibc_unlikely (fd == -1))
return result;
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index d703485e3f..57dc4fb5de 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -209,10 +209,10 @@ __spawni_child (void *arguments)
paths (like /dev/watchdog). */
__close_nocancel (action->action.open_action.fd);
- int ret = __open_nocancel (action->action.open_action.path,
- action->action.
- open_action.oflag | O_LARGEFILE,
- action->action.open_action.mode);
+ int ret = __open64_nocancel (action->action.open_action.path,
+ action->action.
+ open_action.oflag | O_LARGEFILE,
+ action->action.open_action.mode);
if (ret == -1)
goto fail;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 4afc00c8d0..28a8a7ebaa 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -96,7 +96,7 @@ __sysconf (int name)
if (procfname != NULL)
{
- int fd = __open_nocancel (procfname, O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel (procfname, O_RDONLY | O_CLOEXEC);
if (fd != -1)
{
/* This is more than enough, the file contains a single integer. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/azanella/clang] Consolidate open without cancellation
@ 2022-03-08 18:57 Adhemerval Zanella
0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2022-03-08 18:57 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9ba66dc6b66bbf4ded050a89a50f51a7a9157965
commit 9ba66dc6b66bbf4ded050a89a50f51a7a9157965
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Mar 7 14:00:28 2022 -0300
Consolidate open without cancellation
To use only __openat64_nocancel.
Diff:
---
catgets/open_catalog.c | 4 +-
csu/check_fds.c | 2 +-
gmon/gmon.c | 7 ++--
iconv/gconv_cache.c | 2 +-
intl/loadmsgcat.c | 2 +-
io/Versions | 2 +-
libio/fileops.c | 4 +-
locale/loadarchive.c | 6 +--
locale/loadlocale.c | 4 +-
login/utmp_file.c | 6 +--
misc/daemon.c | 2 +-
nss/nss_db/db-open.c | 2 +-
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/closefrom_fallback.c | 8 ++--
sysdeps/unix/sysv/linux/fchmodat.c | 4 +-
sysdeps/unix/sysv/linux/fips-private.h | 2 +-
sysdeps/unix/sysv/linux/gethostid.c | 4 +-
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 4 +-
sysdeps/unix/sysv/linux/malloc-sysdep.h | 4 +-
sysdeps/unix/sysv/linux/not-cancel.h | 15 ++-----
sysdeps/unix/sysv/linux/open64_nocancel.c | 48 ----------------------
sysdeps/unix/sysv/linux/open_nocancel.c | 46 ---------------------
sysdeps/unix/sysv/linux/openat64_nocancel.c | 5 ---
sysdeps/unix/sysv/linux/openat_nocancel.c | 43 -------------------
sysdeps/unix/sysv/linux/opendir.c | 4 +-
.../unix/sysv/linux/powerpc/get_timebase_freq.c | 2 +-
sysdeps/unix/sysv/linux/spawni.c | 8 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
29 files changed, 48 insertions(+), 199 deletions(-)
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 48c2a4b983..7301b0812b 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -49,7 +49,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_nocancel (cat_name, O_RDONLY);
+ fd = __open64_nocancel (cat_name, O_RDONLY);
else
{
const char *run_nlspath = nlspath;
@@ -177,7 +177,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (bufact != 0)
{
- fd = __open_nocancel (buf, O_RDONLY);
+ fd = __open64_nocancel (buf, O_RDONLY);
if (fd >= 0)
break;
}
diff --git a/csu/check_fds.c b/csu/check_fds.c
index 4016a4a1c3..7e597dc76c 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -60,7 +60,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_nocancel (name, mode, 0);
+ int nullfd = __open64_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 dee64803ad..4af4e8cb29 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -362,13 +362,14 @@ write_gmon (void)
size_t len = strlen (env);
char buf[len + 20];
__snprintf (buf, sizeof (buf), "%s.%u", env, __getpid ());
- fd = __open_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666);
+ fd = __open64_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ 0666);
}
if (fd == -1)
{
- fd = __open_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
- 0666);
+ fd = __open64_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ 0666);
if (fd < 0)
{
char buf[300];
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index c772856d1f..22860c2133 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -57,7 +57,7 @@ __gconv_load_cache (void)
return -1;
/* See whether the cache file exists. */
- fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY, 0);
+ fd = __open64_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 98d5f53232..03fde79ec2 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_nocancel (name, flags)
+# define open(name, flags) __open64_nocancel (name, flags)
# define close(fd) __close_nocancel_nostatus (fd)
# define read(fd, buf, n) __read_nocancel (fd, buf, n)
# define mmap(addr, len, prot, flags, fd, offset) \
diff --git a/io/Versions b/io/Versions
index 4e19540885..2e92f504d1 100644
--- a/io/Versions
+++ b/io/Versions
@@ -143,7 +143,7 @@ libc {
GLIBC_PRIVATE {
__libc_fcntl64;
__fcntl_nocancel;
- __open64_nocancel;
+ __openat64_nocancel;
__write_nocancel;
__file_is_unchanged;
__file_change_detection_for_stat;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..737863e2d1 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -182,8 +182,8 @@ _IO_file_open (FILE *fp, const char *filename, int posix_mode, int prot,
{
int fdesc;
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
- fdesc = __open_nocancel (filename,
- posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
+ fdesc = __open64_nocancel (filename,
+ posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
fdesc = __open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
if (fdesc < 0)
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index e7c797bc70..52ce694cdf 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -202,7 +202,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
archmapped = &headmap;
/* The archive has never been opened. */
- fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open64_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd < 0)
/* Cannot open the archive, for whatever reason. */
return NULL;
@@ -397,8 +397,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (fd == -1)
{
struct __stat64_t64 st;
- fd = __open_nocancel (archfname,
- O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open64_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 b8cd1aa441..110205661e 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -174,7 +174,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
file->decided = 1;
file->data = NULL;
- fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC);
+ fd = __open64_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)
"/SYS_", 5), _nl_category_names_get (category),
_nl_category_name_sizes[category] + 1);
- fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC);
+ fd = __open64_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 6c3467d5d9..f686ea7511 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -141,7 +141,7 @@ __libc_setutent (void)
file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
file_writable = false;
- file_fd = __open_nocancel
+ file_fd = __open64_nocancel
(file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (file_fd == -1)
return 0;
@@ -353,7 +353,7 @@ __libc_pututline (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_nocancel
+ int new_fd = __open64_nocancel
(file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC);
if (new_fd == -1)
return NULL;
@@ -463,7 +463,7 @@ __libc_updwtmp (const char *file, const struct utmp *utmp)
int fd;
/* Open WTMP file. */
- fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE);
+ fd = __open64_nocancel (file, O_WRONLY | O_LARGEFILE);
if (fd < 0)
return -1;
diff --git a/misc/daemon.c b/misc/daemon.c
index 0e688f4d74..53b2625b8d 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_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
+ if ((fd = __open64_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
&& (__builtin_expect (__fstat64 (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 6abfba35e7..4552d76777 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_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ int fd = __open64_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1)
{
struct nss_db_header header;
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index ca953804d0..bf9d77b149 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -351,8 +351,7 @@ ifeq ($(subdir),io)
sysdep_routines += xstatconv internal_statvfs \
sync_file_range fallocate fallocate64 \
close_nocancel fcntl_nocancel \
- open_nocancel open64_nocancel \
- openat_nocancel openat64_nocancel \
+ openat64_nocancel \
read_nocancel pread64_nocancel \
write_nocancel statx_cp stat_t64_cp
diff --git a/sysdeps/unix/sysv/linux/closefrom_fallback.c b/sysdeps/unix/sysv/linux/closefrom_fallback.c
index 60101aa3ba..5a0311136c 100644
--- a/sysdeps/unix/sysv/linux/closefrom_fallback.c
+++ b/sysdeps/unix/sysv/linux/closefrom_fallback.c
@@ -32,8 +32,8 @@ __closefrom_fallback (int from, _Bool dirfd_fallback)
{
bool ret = false;
- int dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
- 0);
+ int dirfd = __open64_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
+ 0);
if (dirfd == -1)
{
/* The closefrom should work even when process can't open new files. */
@@ -47,8 +47,8 @@ __closefrom_fallback (int from, _Bool dirfd_fallback)
break;
}
- dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
- 0);
+ dirfd = __open64_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY,
+ 0);
if (dirfd == -1)
return false;
}
diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c
index 7aa073bf3c..61bfe0aa58 100644
--- a/sysdeps/unix/sysv/linux/fchmodat.c
+++ b/sysdeps/unix/sysv/linux/fchmodat.c
@@ -39,8 +39,8 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
However, we can create an O_PATH descriptor and change that
via /proc (which does not resolve symbolic links). */
- int pathfd = __openat_nocancel (fd, file,
- O_PATH | O_NOFOLLOW | O_CLOEXEC);
+ int pathfd = __openat64_nocancel (fd, file,
+ O_PATH | O_NOFOLLOW | O_CLOEXEC);
if (pathfd < 0)
/* This may report errors such as ENFILE and EMFILE. The
caller can treat them as temporary if necessary. */
diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h
index b734126bc0..a6997f6624 100644
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -42,7 +42,7 @@ fips_enabled_p (void)
if (checked == FIPS_UNTESTED)
{
- int fd = __open_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
if (fd != -1)
{
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index fa0001b63e..4b742a0764 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -48,7 +48,7 @@ sethostid (long int id)
}
/* Open file for writing. Everybody is allowed to read this file. */
- fd = __open_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+ fd = __open64_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
if (fd < 0)
return -1;
@@ -77,7 +77,7 @@ gethostid (void)
int fd;
/* First try to get the ID from a former invocation of sethostid. */
- fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
+ fd = __open64_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
if (fd >= 0)
{
ssize_t n = __read_nocancel (fd, &id, sizeof (id));
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 290628f5aa..d204ba55d5 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -35,7 +35,7 @@ int
attribute_hidden
__getlogin_r_loginuid (char *name, size_t namesize)
{
- int fd = __open_nocancel ("/proc/self/loginuid", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/self/loginuid", O_RDONLY);
if (fd == -1)
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 0c65d0e268..d0924c311d 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -117,7 +117,7 @@ get_nproc_stat (void)
int result = 0;
const int flags = O_RDONLY | O_CLOEXEC;
- int fd = __open_nocancel ("/proc/stat", flags);
+ int fd = __open64_nocancel ("/proc/stat", flags);
if (fd != -1)
{
char *l;
@@ -146,7 +146,7 @@ get_nprocs_cpu_online (void)
const int flags = O_RDONLY | O_CLOEXEC;
/* This file contains comma-separated ranges. */
- int fd = __open_nocancel ("/sys/devices/system/cpu/online", flags);
+ int fd = __open64_nocancel ("/sys/devices/system/cpu/online", flags);
char *l;
int result = 0;
if (fd != -1)
diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h
index 5145cf4366..a5e3877b93 100644
--- a/sysdeps/unix/sysv/linux/malloc-sysdep.h
+++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h
@@ -42,8 +42,8 @@ check_may_shrink_heap (void)
if (__builtin_expect (may_shrink_heap == 0, 1))
{
- int fd = __open_nocancel ("/proc/sys/vm/overcommit_memory",
- O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel ("/proc/sys/vm/overcommit_memory",
+ O_RDONLY | O_CLOEXEC);
if (fd >= 0)
{
char val;
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 75b9e0ee1e..6c0491bde3 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -27,15 +27,6 @@
#include <sys/wait.h>
#include <time.h>
-/* Non cancellable open syscall. */
-__typeof (open) __open_nocancel;
-
-/* Non cancellable open syscall (LFS version). */
-__typeof (open64) __open64_nocancel;
-
-/* Non cancellable openat syscall. */
-__typeof (openat) __openat_nocancel;
-
/* Non cacellable openat syscall (LFS version). */
__typeof (openat64) __openat64_nocancel;
@@ -51,6 +42,9 @@ __typeof (__write) __write_nocancel;
/* Uncancelable close. */
__typeof (__close) __close_nocancel;
+#define __open64_nocancel(args...) \
+ __openat64_nocancel (AT_FDCWD, args)
+
/* Non cancellable close syscall that does not also set errno in case of
failure. */
static inline void
@@ -71,9 +65,6 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
__typeof (__fcntl) __fcntl64_nocancel;
#if IS_IN (libc) || IS_IN (rtld)
-hidden_proto (__open_nocancel)
-hidden_proto (__open64_nocancel)
-hidden_proto (__openat_nocancel)
hidden_proto (__openat64_nocancel)
hidden_proto (__read_nocancel)
hidden_proto (__pread64_nocancel)
diff --git a/sysdeps/unix/sysv/linux/open64_nocancel.c b/sysdeps/unix/sysv/linux/open64_nocancel.c
deleted file mode 100644
index 099bdc9e40..0000000000
--- a/sysdeps/unix/sysv/linux/open64_nocancel.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Linux open syscall implementation, LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <not-cancel.h>
-
-int
-__open64_nocancel (const char *file, int oflag, ...)
-{
- int mode = 0;
-
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, int);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE,
- mode);
-}
-
-hidden_def (__open64_nocancel)
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-strong_alias (__open64_nocancel, __open_nocancel)
-hidden_def (__open_nocancel)
-#endif
diff --git a/sysdeps/unix/sysv/linux/open_nocancel.c b/sysdeps/unix/sysv/linux/open_nocancel.c
deleted file mode 100644
index 3ba5fd2433..0000000000
--- a/sysdeps/unix/sysv/linux/open_nocancel.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Linux open syscall implementation, non-LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sysdep-cancel.h>
-#include <not-cancel.h>
-
-#ifndef __OFF_T_MATCHES_OFF64_T
-
-int
-__open_nocancel (const char *file, int oflag, ...)
-{
- int mode = 0;
-
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, int);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag, mode);
-}
-hidden_def (__open_nocancel)
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c
index 9606ea3741..0a92ffb2c4 100644
--- a/sysdeps/unix/sysv/linux/openat64_nocancel.c
+++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c
@@ -38,8 +38,3 @@ __openat64_nocancel (int fd, const char *file, int oflag, ...)
mode);
}
hidden_def (__openat64_nocancel)
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-strong_alias (__openat64_nocancel, __openat_nocancel)
-hidden_def (__openat_nocancel)
-#endif
diff --git a/sysdeps/unix/sysv/linux/openat_nocancel.c b/sysdeps/unix/sysv/linux/openat_nocancel.c
deleted file mode 100644
index aeb7051030..0000000000
--- a/sysdeps/unix/sysv/linux/openat_nocancel.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Linux openat syscall implementation, non-LFS, non-cancellable.
- Copyright (C) 2018-2022 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
- <https://www.gnu.org/licenses/>. */
-
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sysdep-cancel.h>
-#include <not-cancel.h>
-
-#ifndef __OFF_T_MATCHES_OFF64_T
-
-int
-__openat_nocancel (int fd, const char *file, int oflag, ...)
-{
- mode_t mode = 0;
- if (__OPEN_NEEDS_MODE (oflag))
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, mode_t);
- va_end (arg);
- }
-
- return INLINE_SYSCALL_CALL (openat, fd, file, oflag, mode);
-}
-hidden_def (__openat_nocancel)
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/opendir.c b/sysdeps/unix/sysv/linux/opendir.c
index 9e81d00630..b2b6c86e5c 100644
--- a/sysdeps/unix/sysv/linux/opendir.c
+++ b/sysdeps/unix/sysv/linux/opendir.c
@@ -71,7 +71,7 @@ __opendirat (int dfd, const char *name)
if (__glibc_unlikely (invalid_name (name)))
return NULL;
- return opendir_tail (__openat_nocancel (dfd, name, opendir_oflags));
+ return opendir_tail (__openat64_nocancel (dfd, name, opendir_oflags));
}
#endif
@@ -83,7 +83,7 @@ __opendir (const char *name)
if (__glibc_unlikely (invalid_name (name)))
return NULL;
- return opendir_tail (__open_nocancel (name, opendir_oflags));
+ return opendir_tail (__open64_nocancel (name, opendir_oflags));
}
weak_alias (__opendir, opendir)
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
index 759d70eb74..bf3d683730 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
@@ -32,7 +32,7 @@ get_timebase_freq_fallback (void)
contains at least one line like:
timebase : 33333333
We search for this line and convert the number into an integer. */
- int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY);
+ int fd = __open64_nocancel ("/proc/cpuinfo", O_RDONLY);
if (__glibc_unlikely (fd == -1))
return result;
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index d703485e3f..57dc4fb5de 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -209,10 +209,10 @@ __spawni_child (void *arguments)
paths (like /dev/watchdog). */
__close_nocancel (action->action.open_action.fd);
- int ret = __open_nocancel (action->action.open_action.path,
- action->action.
- open_action.oflag | O_LARGEFILE,
- action->action.open_action.mode);
+ int ret = __open64_nocancel (action->action.open_action.path,
+ action->action.
+ open_action.oflag | O_LARGEFILE,
+ action->action.open_action.mode);
if (ret == -1)
goto fail;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 4afc00c8d0..28a8a7ebaa 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -96,7 +96,7 @@ __sysconf (int name)
if (procfname != NULL)
{
- int fd = __open_nocancel (procfname, O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel (procfname, O_RDONLY | O_CLOEXEC);
if (fd != -1)
{
/* This is more than enough, the file contains a single integer. */
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-16 17:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 17:59 [glibc/azanella/clang] Consolidate open without cancellation Adhemerval Zanella
-- strict thread matches above, loose matches on Subject: below --
2022-03-15 18:36 Adhemerval Zanella
2022-03-11 17:20 Adhemerval Zanella
2022-03-08 18:57 Adhemerval Zanella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).