diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-06-28 14:27:36 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-06-28 15:11:23 +0000 |
commit | 4cafcd839f8c002c290ec96c64b6d85e87e270e8 (patch) | |
tree | c05a300192173a1d1f3c593534703aaf0a6c374b /sysdeps/mach/hurd/open_nocancel.c | |
parent | 67a78072e2891b8b16a7bfb20675844a5854cff1 (diff) | |
download | glibc-4cafcd839f8c002c290ec96c64b6d85e87e270e8.tar.gz glibc-4cafcd839f8c002c290ec96c64b6d85e87e270e8.tar.xz glibc-4cafcd839f8c002c290ec96c64b6d85e87e270e8.zip |
hurd: make open and openat cancellation points
and add _nocancel variants. * sysdeps/mach/hurd/Makefile [io] (sysdep_routines): Add open_nocancel openat_nocancel. * sysdeps/mach/hurd/Versions (libc.GLIBC_PRIVATE, ld.GLIBC_PRIVATE): Add __open_nocancel. * sysdeps/mach/hurd/dl-sysdep.c (__open_nocancel): Add alias, check it is not hidden. * sysdeps/mach/hurd/i386/localplt.data (__open_nocancel): Allow PLT. * sysdeps/mach/hurd/not-cancel.h (__open_nocancel, __openat_nocancel: Replace macros with declarations with hidden proto. (__open64_nocancel, __openat64_nocancel): Call __open_nocancel and __openat_nocancel instead of __open64 and __openat64. * sysdeps/mach/hurd/open.c: Include <sysdep-cancel.h> (__libc_open): Surround __file_name_lookup with enabling async cancel. * sysdeps/mach/hurd/openat.c: Likewise. * sysdeps/mach/hurd/open_nocancel.c, sysdeps/mach/hurd/openat_nocancel.c: New files.
Diffstat (limited to 'sysdeps/mach/hurd/open_nocancel.c')
-rw-r--r-- | sysdeps/mach/hurd/open_nocancel.c | 51 |
1 files changed, 51 insertions, 0 deletions
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) |