diff options
| author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-11-11 22:47:13 +0000 |
|---|---|---|
| committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-11-11 23:56:56 +0000 |
| commit | 85741f7eba716db09f586bc94aaa9a6b5dc2347f (patch) | |
| tree | a54aedc2139d0ab78c7b7a4d55a5c4b08f06fb2c | |
| parent | 1ccbb9258eed0f667edf459a28ba23a805549b36 (diff) | |
| download | glibc-85741f7eba716db09f586bc94aaa9a6b5dc2347f.tar.xz glibc-85741f7eba716db09f586bc94aaa9a6b5dc2347f.zip | |
hurd: Move {,f,l}xstat{,at} and xmknod{at} to compat symbols
We do not actually need them, so we can move their implementations
into the standard {,f,l}stat{,at} variants and only keep compatibility
wrappers.
26 files changed, 510 insertions, 219 deletions
diff --git a/include/sys/stat.h b/include/sys/stat.h index 108cb0c9bf..b4c9344628 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -94,36 +94,5 @@ int __lxstat64 (int ver, const char *__filename, struct stat64 *__stat_buf); int __fxstatat64 (int ver, int __fildes, const char *__filename, struct stat64 *__stat_buf, int __flag); -# ifdef NO_RTLD_HIDDEN -/* These are still required for Hurd. */ -libc_hidden_proto (__fxstat); -libc_hidden_proto (__xstat); -libc_hidden_proto (__lxstat); -libc_hidden_proto (__fxstatat); -# if IS_IN (libc) -hidden_proto (__fxstat64); -hidden_proto (__xstat64); -hidden_proto (__lxstat64); -hidden_proto (__fxstatat64); -# endif -libc_hidden_proto (__xmknod) -libc_hidden_proto (__xmknodat) -# define stat(fname, buf) __xstat (_STAT_VER, fname, buf) -# define lstat(fname, buf) __lxstat (_STAT_VER, fname, buf) -# define __lstat(fname, buf) __lxstat (_STAT_VER, fname, buf) -# define lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf) -# define __lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf) -# define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf) -# define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf) -# define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf) -# define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf) -# define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf) -# define __fstat(fd, buf) __fxstat (_STAT_VER, fd, buf) -# define __fstatat(dfd, fname, buf, flag) \ - __fxstatat (_STAT_VER, dfd, fname, buf, flag) -# define __fstatat64(dfd, fname, buf, flag) \ - __fxstatat64 (_STAT_VER, dfd, fname, buf, flag) -# endif /* NO_RTLD_HIDDEN */ - #endif #endif diff --git a/sysdeps/mach/hurd/Versions b/sysdeps/mach/hurd/Versions index c456f472c4..89dabd0485 100644 --- a/sysdeps/mach/hurd/Versions +++ b/sysdeps/mach/hurd/Versions @@ -18,6 +18,7 @@ libc { __read_nocancel; __pread64_nocancel; __write_nocancel; __libc_lock_self0; __getcwd; + __stat64; _dl_init_first; __close_nocancel_nostatus; @@ -35,7 +36,7 @@ ld { # functions that must be shared with libc __close; __getpid; __mmap; __open; __read; __sbrk; __strtoul_internal; - __write; __writev; __xstat64; __fxstat64; + __write; __writev; _exit; _hurd_intr_rpc_mach_msg; abort; } @@ -61,5 +62,6 @@ ld { __read_nocancel; __pread64_nocancel; __write_nocancel; __libc_lock_self0; __getcwd; + __stat64; __fstat64; } } diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 6b32d41c76..370495710e 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -545,31 +545,27 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) return (void *) mapaddr; } -check_no_hidden(__fxstat64); +check_no_hidden(__fstat64); int weak_function -__fxstat64 (int vers, int fd, struct stat64 *buf) +__fstat64 (int fd, struct stat64 *buf) { error_t err; - assert (vers == _STAT_VER); - err = __io_stat ((mach_port_t) fd, buf); if (err) return __hurd_fail (err); return 0; } -libc_hidden_def (__fxstat64) +libc_hidden_def (__fstat64) -check_no_hidden(__xstat64); +check_no_hidden(__stat64); int weak_function -__xstat64 (int vers, const char *file, struct stat64 *buf) +__stat64 (const char *file, struct stat64 *buf) { error_t err; mach_port_t port; - assert (vers == _STAT_VER); - err = open_file (file, 0, &port, buf); if (err) return __hurd_fail (err); @@ -578,7 +574,7 @@ __xstat64 (int vers, const char *file, struct stat64 *buf) return 0; } -libc_hidden_def (__xstat64) +libc_hidden_def (__stat64) /* This function is called by the dynamic linker (rtld.c) to check whether debugging malloc is allowed even for SUID binaries. This diff --git a/sysdeps/mach/hurd/fstat.c b/sysdeps/mach/hurd/fstat.c new file mode 100644 index 0000000000..2f752e2289 --- /dev/null +++ b/sysdeps/mach/hurd/fstat.c @@ -0,0 +1,31 @@ +/* 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 <stddef.h> +#include <sys/stat.h> + +#include "statconv.c" + +/* Get information about the file descriptor FD in BUF. */ +int +__fstat (int fd, struct stat *buf) +{ + struct stat64 buf64; + return __fstat64 (fd, &buf64) ?: stat64_conv (buf, &buf64); +} +weak_alias (__fstat, fstat) diff --git a/sysdeps/mach/hurd/fstat64.c b/sysdeps/mach/hurd/fstat64.c new file mode 100644 index 0000000000..05c6c548ea --- /dev/null +++ b/sysdeps/mach/hurd/fstat64.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2000-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 <stddef.h> +#include <sys/stat.h> +#include <hurd.h> +#include <hurd/fd.h> + +/* Get information about the file descriptor FD in BUF. */ +int +__fstat64 (int fd, struct stat64 *buf) +{ + error_t err; + + if (err = HURD_DPORT_USE (fd, __io_stat (port, buf))) + return __hurd_dfail (fd, err); + + return 0; +} +hidden_def (__fstat64) +weak_alias (__fstat64, fstat64) diff --git a/sysdeps/mach/hurd/fstatat.c b/sysdeps/mach/hurd/fstatat.c new file mode 100644 index 0000000000..6b6aba22ee --- /dev/null +++ b/sysdeps/mach/hurd/fstatat.c @@ -0,0 +1,32 @@ +/* Get information about file named relative to 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 <stddef.h> +#include <sys/stat.h> + +#include "statconv.c" + +int +__fstatat (int fd, const char *filename, struct stat *buf, int flag) +{ + struct stat64 buf64; + return (__fstatat64 (fd, filename, &buf64, flag) + ?: stat64_conv (buf, &buf64)); +} +weak_alias (__fstatat, fstatat) diff --git a/sysdeps/mach/hurd/fstatat64.c b/sysdeps/mach/hurd/fstatat64.c new file mode 100644 index 0000000000..69ccaa4e21 --- /dev/null +++ b/sysdeps/mach/hurd/fstatat64.c @@ -0,0 +1,43 @@ +/* Get information about file named relative to 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 <stddef.h> +#include <sys/stat.h> +#include <hurd.h> +#include <hurd/fd.h> + +/* Get information about the file descriptor FD in BUF. */ +int +__fstatat64 (int fd, const char *filename, struct stat64 *buf, int flag) +{ + error_t err; + io_t port; + + port = __file_name_lookup_at (fd, flag, filename, 0, 0); + if (port == MACH_PORT_NULL) + return -1; + + err = __io_stat (port, buf); + __mach_port_deallocate (__mach_task_self (), port); + + return __hurd_fail (err); +} +libc_hidden_def (__fstatat64) +weak_alias (__fstatat64, fstatat64) diff --git a/sysdeps/mach/hurd/fxstat.c b/sysdeps/mach/hurd/fxstat.c index a403f5417f..3201bb8cf1 100644 --- a/sysdeps/mach/hurd/fxstat.c +++ b/sysdeps/mach/hurd/fxstat.c @@ -18,15 +18,20 @@ #include <errno.h> #include <stddef.h> #include <sys/stat.h> +#include <hurd.h> +#include <shlib-compat.h> -#include "xstatconv.c" +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33) /* Get information about the file descriptor FD in BUF. */ int __fxstat (int vers, int fd, struct stat *buf) { - struct stat64 buf64; - return __fxstat64 (vers, fd, &buf64) ?: xstat64_conv (buf, &buf64); + if (vers != _STAT_VER) + return __hurd_fail (EINVAL); + + return __fstat (fd, buf); } -hidden_def (__fxstat) weak_alias (__fxstat, _fxstat) + +#endif diff --git a/sysdeps/mach/hurd/fxstat64.c b/sysdeps/mach/hurd/fxstat64.c index 12bc808593..6b404b296c 100644 --- a/sysdeps/mach/hurd/fxstat64.c +++ b/sysdeps/mach/hurd/fxstat64.c @@ -15,28 +15,22 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ -#ifndef RTLD_STAT64 /* dl-fxstat64.c, but we don't want it. */ - #include <errno.h> #include <stddef.h> #include <sys/stat.h> #include <hurd.h> -#include <hurd/fd.h> +#include <shlib-compat.h> + +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33) /* Get information about the file descriptor FD in BUF. */ int __fxstat64 (int vers, int fd, struct stat64 *buf) { - error_t err; - if (vers != _STAT_VER) return __hurd_fail (EINVAL); - if (err = HURD_DPORT_USE (fd, __io_stat (port, buf))) - return __hurd_dfail (fd, err); - - return 0; + return __fstat64 (fd, buf); } -hidden_def (__fxstat64) #endif diff --git a/sysdeps/mach/hurd/fxstatat.c b/sysdeps/mach/hurd/fxstatat.c index 48ae4b49ad..b71ab9fad5 100644 --- a/sysdeps/mach/hurd/fxstatat.c +++ b/sysdeps/mach/hurd/fxstatat.c @@ -19,14 +19,18 @@ #include <errno.h> #include <stddef.h> #include <sys/stat.h> +#include <hurd.h> +#include <shlib-compat.h> -#include "xstatconv.c" +#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33) int __fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag) { - struct stat64 buf64; - return (__fxstatat64 (vers, fd, filename, &buf64, flag) - ?: xstat64_conv (buf, &buf64)); + if (vers != _STAT_VER) + return __hurd_fail (EINVAL); + + return __fstatat (fd, filename, buf, flag); } -libc_hidden_def (__fxstatat) + +#endif diff --git a/sysdeps/mach/hurd/fxstatat64.c b/sysdeps/mach/hurd/fxstatat64.c index 8d22ff7ed0..f0c171f64c 100644 --- a/sysdeps/mach/hurd/fxstatat64.c +++ b/sysdeps/mach/hurd/fxstatat64.c @@ -21,26 +21,19 @@ #include <stddef.h> #include <sys/stat.h> #include <hurd.h> -#include <hurd/fd.h> +#include <shlib-compat.h> + +#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33) /* Get information about the file descriptor FD in BUF. */ int __fxstatat64 (int vers, int fd, const char *filename, struct stat64 *buf, int flag) { - error_t err; - io_t port; - if (vers != _STAT_VER) return __hurd_fail (EINVAL); - port = __file_name_lookup_at (fd, flag, filename, 0, 0); - if (port == MACH_PORT_NULL) - return -1; - - err = __io_stat (port, buf); - __mach_port_deallocate (__mach_task_self (), port); - - return __hurd_fail (err); + return __fstatat64 (fd, filename, buf, flag); } -libc_hidden_def (__fxstatat64) + +#endif diff --git a/sysdeps/mach/hurd/i386/ld.abilist b/sysdeps/mach/hurd/i386/ld.abilist index 0eaea9f66d..751664bcda 100644 --- a/sysdeps/mach/hurd/i386/ld.abilist +++ b/sysdeps/mach/hurd/i386/ld.abilist @@ -1,6 +1,5 @@ GLIBC_2.2.6 __close F GLIBC_2.2.6 __errno_location F -GLIBC_2.2.6 __fxstat64 F GLIBC_2.2.6 __getpid F GLIBC_2.2.6 __libc_stack_end D 0x4 GLIBC_2.2.6 __mmap F @@ -11,7 +10,6 @@ GLIBC_2.2.6 __read F GLIBC_2.2.6 __sbrk F GLIBC_2.2.6 __write F GLIBC_2.2.6 __writev F -GLIBC_2.2.6 __xstat64 F GLIBC_2.2.6 _dl_mcount F GLIBC_2.2.6 _hurd_intr_rpc_mach_msg F GLIBC_2.2.6 _r_debug D 0x14 diff --git a/sysdeps/mach/hurd/i386/localplt.data b/sysdeps/mach/hurd/i386/localplt.data index abd8f31fac..94064ecbc5 100644 --- a/sysdeps/mach/hurd/i386/localplt.data +++ b/sysdeps/mach/hurd/i386/localplt.data @@ -30,8 +30,8 @@ ld.so: __write_nocancel ld.so: __writev ld.so: __libc_lseek64 ld.so: __mmap -ld.so: __fxstat64 -ld.so: __xstat64 +ld.so: __fstat64 +ld.so: __stat64 ld.so: __access ld.so: __access_noerrno ld.so: __getpid diff --git a/sysdeps/mach/hurd/lstat.c b/sysdeps/mach/hurd/lstat.c new file mode 100644 index 0000000000..88bc0e4914 --- /dev/null +++ b/sysdeps/mach/hurd/lstat.c @@ -0,0 +1,30 @@ +/* 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 <sys/stat.h> +#include <stddef.h> + +#include "statconv.c" + +int +__lstat (const char *file, struct stat *buf) +{ + struct stat64 buf64; + return __lstat64 (file, &buf64) ?: stat64_conv (buf, &buf64); +} +weak_alias (__lstat, lstat) diff --git a/sysdeps/mach/hurd/lstat64.c b/sysdeps/mach/hurd/lstat64.c new file mode 100644 index 0000000000..5380458f69 --- /dev/null +++ b/sysdeps/mach/hurd/lstat64.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2000-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 |
