about summary refs log tree commit diff
path: root/sysdeps/mach
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/Makefile3
-rw-r--r--sysdeps/mach/hurd/Versions2
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c2
-rw-r--r--sysdeps/mach/hurd/i386/localplt.data3
-rw-r--r--sysdeps/mach/hurd/not-cancel.h22
-rw-r--r--sysdeps/mach/hurd/open.c5
-rw-r--r--sysdeps/mach/hurd/open_nocancel.c51
-rw-r--r--sysdeps/mach/hurd/openat.c5
-rw-r--r--sysdeps/mach/hurd/openat_nocancel.c55
9 files changed, 138 insertions, 10 deletions
diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile
index edab284d11..a58e8c1c3d 100644
--- a/sysdeps/mach/hurd/Makefile
+++ b/sysdeps/mach/hurd/Makefile
@@ -196,7 +196,8 @@ sysdep_routines += cthreads
 endif
 
 ifeq (io, $(subdir))
-sysdep_routines += f_setlk close_nocancel_nostatus read_nocancel \
+sysdep_routines += f_setlk close_nocancel_nostatus \
+		   open_nocancel openat_nocancel read_nocancel \
 		   pread64_nocancel write_nocancel pwrite64_nocancel
 endif
 
diff --git a/sysdeps/mach/hurd/Versions b/sysdeps/mach/hurd/Versions
index e8b4aba776..67594d8c08 100644
--- a/sysdeps/mach/hurd/Versions
+++ b/sysdeps/mach/hurd/Versions
@@ -13,6 +13,7 @@ libc {
   GLIBC_PRIVATE {
     # Functions shared with the dynamic linker
     __access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
+    __open_nocancel;
     __read_nocancel; __pread64_nocancel;
     __write_nocancel;
     __libc_lock_self0; __getcwd;
@@ -54,6 +55,7 @@ ld {
 
     # functions that must be shared with libc
     __access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
+    __open_nocancel;
     __read_nocancel; __pread64_nocancel;
     __write_nocancel;
     __libc_lock_self0; __getcwd;
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index a4eab4c08e..8a87b9b0f2 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -338,6 +338,7 @@ open_file (const char *file_name, int flags,
 
 check_no_hidden(__open);
 check_no_hidden (__open64);
+check_no_hidden (__open_nocancel);
 int weak_function
 __open (const char *file_name, int mode, ...)
 {
@@ -349,6 +350,7 @@ __open (const char *file_name, int mode, ...)
     return (int)port;
 }
 weak_alias (__open, __open64)
+weak_alias (__open, __open_nocancel)
 
 check_no_hidden(__close);
 int weak_function
diff --git a/sysdeps/mach/hurd/i386/localplt.data b/sysdeps/mach/hurd/i386/localplt.data
index 66478dee7a..66e9c4f253 100644
--- a/sysdeps/mach/hurd/i386/localplt.data
+++ b/sysdeps/mach/hurd/i386/localplt.data
@@ -17,7 +17,8 @@ ld.so: _dl_catch_exception + REL R_386_GLOB_DAT
 # The dynamic linker has its own versions of basic functions for initial loading
 # of shared libraries.  These need to be overriden by libc once loaded.
 ld.so: __open ?
-ld.so: __open64
+ld.so: __open64 ?
+ld.so: __open_nocancel
 ld.so: __close
 ld.so: __read ?
 ld.so: __read_nocancel
diff --git a/sysdeps/mach/hurd/not-cancel.h b/sysdeps/mach/hurd/not-cancel.h
index 202dca8792..c627ec7bde 100644
--- a/sysdeps/mach/hurd/not-cancel.h
+++ b/sysdeps/mach/hurd/not-cancel.h
@@ -29,19 +29,23 @@
 #include <hurd/fd.h>
 
 /* For now we have none.  Map the name to the normal functions.  */
-#define __open_nocancel(...) \
-  __open (__VA_ARGS__)
-#define __open64_nocancel(...) \
-  __open64 (__VA_ARGS__)
-#define __openat_nocancel(...) \
-  __openat (__VA_ARGS__)
-#define __openat64_nocancel(...) \
-  __openat64 (__VA_ARGS__)
 #define __close_nocancel(fd) \
   __close (fd)
 
 void __close_nocancel_nostatus (int fd);
 
+/* Non cancellable open syscall.  */
+__typeof (__open) __open_nocancel;
+/* open64 is just the same as open for us.  */
+#define __open64_nocancel(...) \
+  __open_nocancel (__VA_ARGS__)
+
+/* Non cancellable openat syscall.  */
+__typeof (__openat) __openat_nocancel;
+/* open64 is just the same as open for us.  */
+#define __openat64_nocancel(...) \
+  __openat_nocancel (__VA_ARGS__)
+
 /* Non cancellable read syscall.  */
 __typeof (__read) __read_nocancel;
 
@@ -66,6 +70,8 @@ void __writev_nocancel_nostatus (int fd, const struct iovec *vector, int count);
   __fcntl64 (fd, cmd, __VA_ARGS__)
 
 #if IS_IN (libc)
+hidden_proto (__open_nocancel)
+hidden_proto (__openat_nocancel)
 hidden_proto (__read_nocancel)
 hidden_proto (__pread64_nocancel)
 hidden_proto (__write_nocancel)
diff --git a/sysdeps/mach/hurd/open.c b/sysdeps/mach/hurd/open.c
index ec74a83b0f..c2c4e284c2 100644
--- a/sysdeps/mach/hurd/open.c
+++ b/sysdeps/mach/hurd/open.c
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <hurd.h>
 #include <hurd/fd.h>
+#include <sysdep-cancel.h>
 
 /* Open FILE with access OFLAG.  If O_CREAT or O_TMPFILE is in OFLAG,
    a third argument is the file protection.  */
@@ -29,6 +30,7 @@ __libc_open (const char *file, int oflag, ...)
 {
   mode_t mode;
   io_t port;
+  int cancel_oldtype;
 
   if (__OPEN_NEEDS_MODE (oflag))
     {
@@ -40,7 +42,10 @@ __libc_open (const char *file, int oflag, ...)
   else
     mode = 0;
 
+  cancel_oldtype = LIBC_CANCEL_ASYNC();
   port = __file_name_lookup (file, oflag, mode);
+  LIBC_CANCEL_RESET (cancel_oldtype);
+
   if (port == MACH_PORT_NULL)
     return -1;
 
diff --git a/sysdeps/mach/hurd/open_nocancel.c b/sysdeps/mach/hurd/open_nocancel.c
new file mode 100644
index 0000000000..e180c25bc1
--- /dev/null
+++ b/sysdeps/mach/hurd/open_nocancel.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1992-2020 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 <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <not-cancel.h>
+
+/* Open FILE with access OFLAG.  If O_CREAT or O_TMPFILE is in OFLAG,
+   a third argument is the file protection.  */
+int
+__open_nocancel (const char *file, int oflag, ...)
+{
+  mode_t mode;
+  io_t port;
+
+  if (__OPEN_NEEDS_MODE (oflag))
+    {
+      va_list arg;
+      va_start (arg, oflag);
+      mode = va_arg (arg, mode_t);
+      va_end (arg);
+    }
+  else
+    mode = 0;
+
+  port = __file_name_lookup (file, oflag, mode);
+  if (port == MACH_PORT_NULL)
+    return -1;
+
+  return _hurd_intern_fd (port, oflag, 1);
+}
+
+libc_hidden_def (__open_nocancel)
diff --git a/sysdeps/mach/hurd/openat.c b/sysdeps/mach/hurd/openat.c
index 7e241cd36f..5842da05d7 100644
--- a/sysdeps/mach/hurd/openat.c
+++ b/sysdeps/mach/hurd/openat.c
@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 #include <hurd.h>
 #include <hurd/fd.h>
+#include <sysdep-cancel.h>
 
 /* Open FILE with access OFLAG.  Interpret relative paths relative to
    the directory associated with FD.  If O_CREAT or O_TMPFILE is in OFLAG, a
@@ -33,6 +34,7 @@ __openat (int fd, const char *file, int oflag, ...)
 {
   mode_t mode;
   io_t port;
+  int cancel_oldtype;
 
   if (__OPEN_NEEDS_MODE (oflag))
     {
@@ -44,7 +46,10 @@ __openat (int fd, const char *file, int oflag, ...)
   else
     mode = 0;
 
+  cancel_oldtype = LIBC_CANCEL_ASYNC();
   port = __file_name_lookup_at (fd, 0, file, oflag, mode);
+  LIBC_CANCEL_RESET (cancel_oldtype);
+
   if (port == MACH_PORT_NULL)
     return -1;
 
diff --git a/sysdeps/mach/hurd/openat_nocancel.c b/sysdeps/mach/hurd/openat_nocancel.c
new file mode 100644
index 0000000000..b6af799c04
--- /dev/null
+++ b/sysdeps/mach/hurd/openat_nocancel.c
@@ -0,0 +1,55 @@
+/* openat -- Open a file named relative to an open directory.  Hurd version.
+   Copyright (C) 2006-2020 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 <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <not-cancel.h>
+
+/* Open FILE with access OFLAG.  Interpret relative paths relative to
+   the directory associated with FD.  If O_CREAT or O_TMPFILE is in OFLAG, a
+   third argument is the file protection.  */
+int
+__openat_nocancel (int fd, const char *file, int oflag, ...)
+{
+  mode_t mode;
+  io_t port;
+
+  if (__OPEN_NEEDS_MODE (oflag))
+    {
+      va_list arg;
+      va_start (arg, oflag);
+      mode = va_arg (arg, mode_t);
+      va_end (arg);
+    }
+  else
+    mode = 0;
+
+  port = __file_name_lookup_at (fd, 0, file, oflag, mode);
+  if (port == MACH_PORT_NULL)
+    return -1;
+
+  return _hurd_intern_fd (port, oflag, 1);
+}
+
+libc_hidden_def (__openat_nocancel)