summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-11-11 22:47:13 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-11-11 23:56:56 +0000
commit85741f7eba716db09f586bc94aaa9a6b5dc2347f (patch)
treea54aedc2139d0ab78c7b7a4d55a5c4b08f06fb2c
parent1ccbb9258eed0f667edf459a28ba23a805549b36 (diff)
downloadglibc-85741f7eba716db09f586bc94aaa9a6b5dc2347f.tar.gz
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.
-rw-r--r--include/sys/stat.h31
-rw-r--r--sysdeps/mach/hurd/Versions4
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c16
-rw-r--r--sysdeps/mach/hurd/fstat.c31
-rw-r--r--sysdeps/mach/hurd/fstat64.c36
-rw-r--r--sysdeps/mach/hurd/fstatat.c32
-rw-r--r--sysdeps/mach/hurd/fstatat64.c43
-rw-r--r--sysdeps/mach/hurd/fxstat.c13
-rw-r--r--sysdeps/mach/hurd/fxstat64.c14
-rw-r--r--sysdeps/mach/hurd/fxstatat.c14
-rw-r--r--sysdeps/mach/hurd/fxstatat64.c19
-rw-r--r--sysdeps/mach/hurd/i386/ld.abilist2
-rw-r--r--sysdeps/mach/hurd/i386/localplt.data4
-rw-r--r--sysdeps/mach/hurd/lstat.c30
-rw-r--r--sysdeps/mach/hurd/lstat64.c41
-rw-r--r--sysdeps/mach/hurd/lxstat.c13
-rw-r--r--sysdeps/mach/hurd/lxstat64.c18
-rw-r--r--sysdeps/mach/hurd/mknod.c31
-rw-r--r--sysdeps/mach/hurd/mknodat.c118
-rw-r--r--sysdeps/mach/hurd/stat.c30
-rw-r--r--sysdeps/mach/hurd/stat64.c40
-rw-r--r--sysdeps/mach/hurd/statconv.c (renamed from sysdeps/mach/hurd/xstatconv.c)2
-rw-r--r--sysdeps/mach/hurd/xmknod.c16
-rw-r--r--sysdeps/mach/hurd/xmknodat.c100
-rw-r--r--sysdeps/mach/hurd/xstat.c13
-rw-r--r--sysdeps/mach/hurd/xstat64.c18
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
+ 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 <fcntl.h>
+#include <hurd.h>
+
+/* Get information about the file descriptor FD in BUF. */
+int
+__lstat64 (const char *file, struct stat64 *buf)
+{
+ error_t err;
+ file_t port;
+
+ port = __file_name_lookup (file, O_NOLINK, 0);
+ if (port == MACH_PORT_NULL)
+ return -1;
+ err = __io_stat (port, buf);
+ __mach_port_deallocate (__mach_task_self (), port);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+hidden_def (__lstat64)
+weak_alias (__lstat64, lstat64)
diff --git a/sysdeps/mach/hurd/lxstat.c b/sysdeps/mach/hurd/lxstat.c
index 382ece2d5c..ba40612f50 100644
--- a/sysdeps/mach/hurd/lxstat.c
+++ b/sysdeps/mach/hurd/lxstat.c
@@ -18,14 +18,19 @@
#include <errno.h>
#include <sys/stat.h>
#include <stddef.h>
+#include <hurd.h>
+#include <shlib-compat.h>
-#include "xstatconv.c"
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
int
__lxstat (int vers, const char *file, struct stat *buf)
{
- struct stat64 buf64;
- return __lxstat64 (vers, file, &buf64) ?: xstat64_conv (buf, &buf64);
+ if (vers != _STAT_VER)
+ return __hurd_fail (EINVAL);
+
+ return __lstat (file, buf);
}
-hidden_def (__lxstat)
weak_alias (__lxstat, _lxstat)
+
+#endif
diff --git a/sysdeps/mach/hurd/lxstat64.c b/sysdeps/mach/hurd/lxstat64.c
index 4c4532a86f..7059bceb11 100644
--- a/sysdeps/mach/hurd/lxstat64.c
+++ b/sysdeps/mach/hurd/lxstat64.c
@@ -20,24 +20,18 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <hurd.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
__lxstat64 (int vers, const char *file, struct stat64 *buf)
{
- error_t err;
- file_t port;
-
if (vers != _STAT_VER)
return __hurd_fail (EINVAL);
- port = __file_name_lookup (file, O_NOLINK, 0);
- if (port == MACH_PORT_NULL)
- return -1;
- err = __io_stat (port, buf);
- __mach_port_deallocate (__mach_task_self (), port);
- if (err)
- return __hurd_fail (err);
- return 0;
+ return __lstat64 (file, buf);
}
-hidden_def (__lxstat64)
+
+#endif
diff --git a/sysdeps/mach/hurd/mknod.c b/sysdeps/mach/hurd/mknod.c
new file mode 100644
index 0000000000..1b9c9db741
--- /dev/null
+++ b/sysdeps/mach/hurd/mknod.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991-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 <sys/stat.h>
+#include <fcntl.h>
+#include <shlib-compat.h>
+
+/* Create a device file named FILE_NAME, with permission and special bits MODE
+ and device number DEV (which can be constructed from major and minor
+ device numbers with the `makedev' macro above). */
+int
+__mknod (const char *file_name, mode_t mode, dev_t dev)
+{
+ return __mknodat (AT_FDCWD, file_name, mode, dev);
+}
+libc_hidden_def (__mknod)
+weak_alias (__mknod, mknod)
diff --git a/sysdeps/mach/hurd/mknodat.c b/sysdeps/mach/hurd/mknodat.c
new file mode 100644
index 0000000000..6f24904c8c
--- /dev/null
+++ b/sysdeps/mach/hurd/mknodat.c
@@ -0,0 +1,118 @@
+/* Create a device file relative to an open directory. Hurd version.
+ Copyright (C) 1991-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 <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/paths.h>
+#include <fcntl.h>
+#include <_itoa.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/sysmacros.h>
+#include <shlib-compat.h>
+
+/* Create a device file named PATH relative to FD, with permission and
+ special bits MODE and device number DEV (which can be constructed
+ from major and minor device numbers with the `makedev' macro
+ above). */
+int
+__mknodat (int fd, const char *path, mode_t mode, dev_t dev)
+{
+ error_t errnode, err;
+ file_t dir, node;
+ char *name;
+ char buf[100], *bp;
+ const char *translator;
+ size_t len;
+
+ if (S_ISCHR (mode))
+ {
+ translator = _HURD_CHRDEV;
+ len = sizeof (_HURD_CHRDEV);
+ }
+ else if (S_ISBLK (mode))
+ {
+ translator = _HURD_BLKDEV;
+ len = sizeof (_HURD_BLKDEV);
+ }
+ else if (S_ISFIFO (mode))
+ {
+ translator = _HURD_FIFO;
+ len = sizeof (_HURD_FIFO);
+ }
+ else if (S_ISREG (mode))
+ {
+ translator = NULL;
+ len = 0;
+ }
+ else
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (translator != NULL && ! S_ISFIFO (mode))
+ {
+ /* We set the translator to "ifmt\0major\0minor\0", where IFMT
+ depends on the S_IFMT bits of our MODE argument, and MAJOR and
+ MINOR are ASCII decimal (octal or hex would do as well)
+ representations of our arguments. Thus the convention is that
+ CHRDEV and BLKDEV translators are invoked with two non-switch
+ arguments, giving the major and minor device numbers in %i format. */
+
+ bp = buf + sizeof (buf);
+ *--bp = '\0';
+ bp = _itoa (__gnu_dev_minor (dev), bp, 10, 0);
+ *--bp = '\0';
+ bp = _itoa (__gnu_dev_major (dev), bp, 10, 0);
+ memcpy (bp - len, translator, len);
+ translator = bp - len;
+ len = buf + sizeof (buf) - translator;
+ }
+
+ dir = __file_name_split_at (fd, path, &name);
+ if (dir == MACH_PORT_NULL)
+ return -1;
+
+ /* Create a new, unlinked node in the target directory. */
+ errnode = err = __dir_mkfile (dir, O_WRITE, (mode & ~S_IFMT) & ~_hurd_umask, &node);
+
+ if (! err && translator != NULL)
+ /* Set the node's translator to make it a device. */
+ err = __file_set_translator (node,
+ FS_TRANS_EXCL | FS_TRANS_SET,
+ FS_TRANS_EXCL | FS_TRANS_SET, 0,
+ translator, len,
+ MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
+
+ if (! err)
+ /* Link the node, now a valid device, into the target directory. */
+ err = __dir_link (dir, node, name, 1);
+
+ __mach_port_deallocate (__mach_task_self (), dir);
+ if (! errnode)
+ __mach_port_deallocate (__mach_task_self (), node);
+
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+libc_hidden_def (__mknodat)
+weak_alias (__mknodat, mknodat)
diff --git a/sysdeps/mach/hurd/stat.c b/sysdeps/mach/hurd/stat.c
new file mode 100644
index 0000000000..1470316286
--- /dev/null
+++ b/sysdeps/mach/hurd/stat.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 "statconv.c"
+
+/* Get file information about FILE in BUF. */
+int
+__stat (const char *file, struct stat *buf)
+{
+ struct stat64 buf64;
+ return __stat64 (file, &buf64) ?: stat64_conv (buf, &buf64);
+}
+weak_alias (__stat, stat)
diff --git a/sysdeps/mach/hurd/stat64.c b/sysdeps/mach/hurd/stat64.c
new file mode 100644
index 0000000000..90fa704123
--- /dev/null
+++ b/sysdeps/mach/hurd/stat64.c
@@ -0,0 +1,40 @@
+/* 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>
+
+/* Get information about the file descriptor FD in BUF. */
+int
+__stat64 (const char *file, struct stat64 *buf)
+{
+ error_t err;
+ file_t port;
+
+ port = __file_name_lookup (file, 0, 0);
+ if (port == MACH_PORT_NULL)
+ return -1;
+ err = __io_stat (port, buf);
+ __mach_port_deallocate (__mach_task_self (), port);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+hidden_def (__stat64)
+weak_alias (__stat64, stat64)
diff --git a/sysdeps/mach/hurd/xstatconv.c b/sysdeps/mach/hurd/statconv.c
index 57455ed178..7600161589 100644
--- a/sysdeps/mach/hurd/xstatconv.c
+++ b/sysdeps/mach/hurd/statconv.c
@@ -20,7 +20,7 @@
#include <sys/stat.h>
static inline int
-xstat64_conv (struct stat *buf, const struct stat64 *buf64)
+stat64_conv (struct stat *buf, const struct stat64 *buf64)
{
if (sizeof *buf == sizeof *buf64
&& sizeof buf->st_ino == sizeof buf64->st_ino
diff --git a/sysdeps/mach/hurd/xmknod.c b/sysdeps/mach/hurd/xmknod.c
index a1b5af086d..b8705ac235 100644
--- a/sysdeps/mach/hurd/xmknod.c
+++ b/sysdeps/mach/hurd/xmknod.c
@@ -16,25 +16,21 @@
<https://www.gnu.org/licenses/>. */
#include <sys/stat.h>
+#include <errno.h>
#include <fcntl.h>
+#include <hurd.h>
#include <shlib-compat.h>
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
/* Create a device file named FILE_NAME, with permission and special bits MODE
and device number DEV (which can be constructed from major and minor
device numbers with the `makedev' macro above). */
int
__xmknod (int vers, const char *file_name, mode_t mode, dev_t *dev)
{
- return __xmknodat (vers, AT_FDCWD, file_name, mode, dev);
-}
-libc_hidden_def (__xmknod)
+ if (vers != _MKNOD_VER)
+ return __hurd_fail (EINVAL);
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
-int
-__xmknod_compat (int vers, const char *file_name, mode_t mode, dev_t *dev)
-{
- return __xmknod (vers, file_name, mode, dev);
+ return __mknodat (AT_FDCWD, file_name, mode, *dev);
}
-
-compat_symbol (libc, __xmknod_compat, __xmknod, GLIBC_2_0);
#endif
diff --git a/sysdeps/mach/hurd/xmknodat.c b/sysdeps/mach/hurd/xmknodat.c
index 90724694d5..069f8bed3a 100644
--- a/sysdeps/mach/hurd/xmknodat.c
+++ b/sysdeps/mach/hurd/xmknodat.c
@@ -16,18 +16,13 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
#include <sys/stat.h>
-#include <hurd.h>
-#include <hurd/fd.h>
-#include <hurd/paths.h>
+#include <errno.h>
#include <fcntl.h>
-#include <_itoa.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/sysmacros.h>
+#include <hurd.h>
#include <shlib-compat.h>
+#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
/* Create a device file named PATH relative to FD, with permission and
special bits MODE and device number DEV (which can be constructed
from major and minor device numbers with the `makedev' macro
@@ -35,96 +30,9 @@
int
__xmknodat (int vers, int fd, const char *path, mode_t mode, dev_t *dev)
{
- error_t errnode, err;
- file_t dir, node;
- char *name;
- char buf[100], *bp;
- const char *translator;
- size_t len;
-
if (vers != _MKNOD_VER)
return __hurd_fail (EINVAL);
- if (S_ISCHR (mode))
- {
- translator = _HURD_CHRDEV;
- len = sizeof (_HURD_CHRDEV);
- }
- else if (S_ISBLK (mode))
- {
- translator = _HURD_BLKDEV;
- len = sizeof (_HURD_BLKDEV);
- }
- else if (S_ISFIFO (mode))
- {
- translator = _HURD_FIFO;
- len = sizeof (_HURD_FIFO);
- }
- else if (S_ISREG (mode))
- {
- translator = NULL;
- len = 0;
- }
- else
- {
- errno = EINVAL;
- return -1;
- }
-
- if (translator != NULL && ! S_ISFIFO (mode))
- {
- /* We set the translator to "ifmt\0major\0minor\0", where IFMT
- depends on the S_IFMT bits of our MODE argument, and MAJOR and
- MINOR are ASCII decimal (octal or hex would do as well)
- representations of our arguments. Thus the convention is that
- CHRDEV and BLKDEV translators are invoked with two non-switch
- arguments, giving the major and minor device numbers in %i format. */
-
- bp = buf + sizeof (buf);
- *--bp = '\0';
- bp = _itoa (__gnu_dev_minor (*dev), bp, 10, 0);
- *--bp = '\0';
- bp = _itoa (__gnu_dev_major (*dev), bp, 10, 0);
- memcpy (bp - len, translator, len);
- translator = bp - len;
- len = buf + sizeof (buf) - translator;
- }
-
- dir = __file_name_split_at (fd, path, &name);
- if (dir == MACH_PORT_NULL)
- return -1;
-
- /* Create a new, unlinked node in the target directory. */
- errnode = err = __dir_mkfile (dir, O_WRITE, (mode & ~S_IFMT) & ~_hurd_umask, &node);
-
- if (! err && translator != NULL)
- /* Set the node's translator to make it a device. */
- err = __file_set_translator (node,
- FS_TRANS_EXCL | FS_TRANS_SET,
- FS_TRANS_EXCL | FS_TRANS_SET, 0,
- translator, len,
- MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
-
- if (! err)
- /* Link the node, now a valid device, into the target directory. */
- err = __dir_link (dir, node, name, 1);
-
- __mach_port_deallocate (__mach_task_self (), dir);
- if (! errnode)
- __mach_port_deallocate (__mach_task_self (), node);
-
- if (err)
- return __hurd_fail (err);
- return 0;
-}
-libc_hidden_def (__xmknodat)
-
-#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
-int
-__xmknodat_compat (int vers, int fd, const char *path, mode_t mode, dev_t *dev)
-{
- return __xmknodat (vers, fd, path, mode, dev);
+ return __mknodat (fd, path, mode, *dev);
}
-
-compat_symbol (libc, __xmknodat_compat, __xmknodat, GLIBC_2_4);
#endif
diff --git a/sysdeps/mach/hurd/xstat.c b/sysdeps/mach/hurd/xstat.c
index e7ab244cb8..8d56fe3c44 100644
--- a/sysdeps/mach/hurd/xstat.c
+++ b/sysdeps/mach/hurd/xstat.c
@@ -17,15 +17,20 @@
#include <errno.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 file information about FILE in BUF. */
int
__xstat (int vers, const char *file, struct stat *buf)
{
- struct stat64 buf64;
- return __xstat64 (vers, file, &buf64) ?: xstat64_conv (buf, &buf64);
+ if (vers != _STAT_VER)
+ return __hurd_fail (EINVAL);
+
+ return __stat (file, buf);
}
-hidden_def (__xstat)
weak_alias (__xstat, _xstat)
+
+#endif
diff --git a/sysdeps/mach/hurd/xstat64.c b/sysdeps/mach/hurd/xstat64.c
index c57017fbf7..26bf5e2c79 100644
--- a/sysdeps/mach/hurd/xstat64.c
+++ b/sysdeps/mach/hurd/xstat64.c
@@ -15,32 +15,22 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#ifndef RTLD_STAT64 /* dl-xstat64.c, but we don't want it. */
-
#include <errno.h>
#include <stddef.h>
#include <sys/stat.h>
#include <hurd.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
__xstat64 (int vers, const char *file, struct stat64 *buf)
{
- error_t err;
- file_t port;
-
if (vers != _STAT_VER)
return __hurd_fail (EINVAL);
- port = __file_name_lookup (file, 0, 0);
- if (port == MACH_PORT_NULL)
- return -1;
- err = __io_stat (port, buf);
- __mach_port_deallocate (__mach_task_self (), port);
- if (err)
- return __hurd_fail (err);
- return 0;
+ return __stat64 (file, buf);
}
-hidden_def (__xstat64)
#endif