mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-29 08:11:08 +00:00
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.
This commit is contained in:
parent
67a78072e2
commit
4cafcd839f
@ -196,7 +196,8 @@ sysdep_routines += cthreads
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq (io, $(subdir))
|
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
|
pread64_nocancel write_nocancel pwrite64_nocancel
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ libc {
|
|||||||
GLIBC_PRIVATE {
|
GLIBC_PRIVATE {
|
||||||
# Functions shared with the dynamic linker
|
# Functions shared with the dynamic linker
|
||||||
__access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
|
__access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
|
||||||
|
__open_nocancel;
|
||||||
__read_nocancel; __pread64_nocancel;
|
__read_nocancel; __pread64_nocancel;
|
||||||
__write_nocancel;
|
__write_nocancel;
|
||||||
__libc_lock_self0; __getcwd;
|
__libc_lock_self0; __getcwd;
|
||||||
@ -54,6 +55,7 @@ ld {
|
|||||||
|
|
||||||
# functions that must be shared with libc
|
# functions that must be shared with libc
|
||||||
__access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
|
__access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
|
||||||
|
__open_nocancel;
|
||||||
__read_nocancel; __pread64_nocancel;
|
__read_nocancel; __pread64_nocancel;
|
||||||
__write_nocancel;
|
__write_nocancel;
|
||||||
__libc_lock_self0; __getcwd;
|
__libc_lock_self0; __getcwd;
|
||||||
|
@ -338,6 +338,7 @@ open_file (const char *file_name, int flags,
|
|||||||
|
|
||||||
check_no_hidden(__open);
|
check_no_hidden(__open);
|
||||||
check_no_hidden (__open64);
|
check_no_hidden (__open64);
|
||||||
|
check_no_hidden (__open_nocancel);
|
||||||
int weak_function
|
int weak_function
|
||||||
__open (const char *file_name, int mode, ...)
|
__open (const char *file_name, int mode, ...)
|
||||||
{
|
{
|
||||||
@ -349,6 +350,7 @@ __open (const char *file_name, int mode, ...)
|
|||||||
return (int)port;
|
return (int)port;
|
||||||
}
|
}
|
||||||
weak_alias (__open, __open64)
|
weak_alias (__open, __open64)
|
||||||
|
weak_alias (__open, __open_nocancel)
|
||||||
|
|
||||||
check_no_hidden(__close);
|
check_no_hidden(__close);
|
||||||
int weak_function
|
int weak_function
|
||||||
|
@ -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
|
# 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.
|
# of shared libraries. These need to be overriden by libc once loaded.
|
||||||
ld.so: __open ?
|
ld.so: __open ?
|
||||||
ld.so: __open64
|
ld.so: __open64 ?
|
||||||
|
ld.so: __open_nocancel
|
||||||
ld.so: __close
|
ld.so: __close
|
||||||
ld.so: __read ?
|
ld.so: __read ?
|
||||||
ld.so: __read_nocancel
|
ld.so: __read_nocancel
|
||||||
|
@ -29,19 +29,23 @@
|
|||||||
#include <hurd/fd.h>
|
#include <hurd/fd.h>
|
||||||
|
|
||||||
/* For now we have none. Map the name to the normal functions. */
|
/* 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) \
|
#define __close_nocancel(fd) \
|
||||||
__close (fd)
|
__close (fd)
|
||||||
|
|
||||||
void __close_nocancel_nostatus (int 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. */
|
/* Non cancellable read syscall. */
|
||||||
__typeof (__read) __read_nocancel;
|
__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__)
|
__fcntl64 (fd, cmd, __VA_ARGS__)
|
||||||
|
|
||||||
#if IS_IN (libc)
|
#if IS_IN (libc)
|
||||||
|
hidden_proto (__open_nocancel)
|
||||||
|
hidden_proto (__openat_nocancel)
|
||||||
hidden_proto (__read_nocancel)
|
hidden_proto (__read_nocancel)
|
||||||
hidden_proto (__pread64_nocancel)
|
hidden_proto (__pread64_nocancel)
|
||||||
hidden_proto (__write_nocancel)
|
hidden_proto (__write_nocancel)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
#include <hurd/fd.h>
|
#include <hurd/fd.h>
|
||||||
|
#include <sysdep-cancel.h>
|
||||||
|
|
||||||
/* Open FILE with access OFLAG. If O_CREAT or O_TMPFILE is in OFLAG,
|
/* Open FILE with access OFLAG. If O_CREAT or O_TMPFILE is in OFLAG,
|
||||||
a third argument is the file protection. */
|
a third argument is the file protection. */
|
||||||
@ -29,6 +30,7 @@ __libc_open (const char *file, int oflag, ...)
|
|||||||
{
|
{
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
io_t port;
|
io_t port;
|
||||||
|
int cancel_oldtype;
|
||||||
|
|
||||||
if (__OPEN_NEEDS_MODE (oflag))
|
if (__OPEN_NEEDS_MODE (oflag))
|
||||||
{
|
{
|
||||||
@ -40,7 +42,10 @@ __libc_open (const char *file, int oflag, ...)
|
|||||||
else
|
else
|
||||||
mode = 0;
|
mode = 0;
|
||||||
|
|
||||||
|
cancel_oldtype = LIBC_CANCEL_ASYNC();
|
||||||
port = __file_name_lookup (file, oflag, mode);
|
port = __file_name_lookup (file, oflag, mode);
|
||||||
|
LIBC_CANCEL_RESET (cancel_oldtype);
|
||||||
|
|
||||||
if (port == MACH_PORT_NULL)
|
if (port == MACH_PORT_NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
51
sysdeps/mach/hurd/open_nocancel.c
Normal file
51
sysdeps/mach/hurd/open_nocancel.c
Normal file
@ -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)
|
@ -24,6 +24,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
#include <hurd/fd.h>
|
#include <hurd/fd.h>
|
||||||
|
#include <sysdep-cancel.h>
|
||||||
|
|
||||||
/* Open FILE with access OFLAG. Interpret relative paths relative to
|
/* 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
|
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;
|
mode_t mode;
|
||||||
io_t port;
|
io_t port;
|
||||||
|
int cancel_oldtype;
|
||||||
|
|
||||||
if (__OPEN_NEEDS_MODE (oflag))
|
if (__OPEN_NEEDS_MODE (oflag))
|
||||||
{
|
{
|
||||||
@ -44,7 +46,10 @@ __openat (int fd, const char *file, int oflag, ...)
|
|||||||
else
|
else
|
||||||
mode = 0;
|
mode = 0;
|
||||||
|
|
||||||
|
cancel_oldtype = LIBC_CANCEL_ASYNC();
|
||||||
port = __file_name_lookup_at (fd, 0, file, oflag, mode);
|
port = __file_name_lookup_at (fd, 0, file, oflag, mode);
|
||||||
|
LIBC_CANCEL_RESET (cancel_oldtype);
|
||||||
|
|
||||||
if (port == MACH_PORT_NULL)
|
if (port == MACH_PORT_NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
55
sysdeps/mach/hurd/openat_nocancel.c
Normal file
55
sysdeps/mach/hurd/openat_nocancel.c
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user