mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-27 03:41:23 +08:00
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.
This commit is contained in:
parent
1ccbb9258e
commit
85741f7eba
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
31
sysdeps/mach/hurd/fstat.c
Normal file
31
sysdeps/mach/hurd/fstat.c
Normal file
@ -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)
|
36
sysdeps/mach/hurd/fstat64.c
Normal file
36
sysdeps/mach/hurd/fstat64.c
Normal file
@ -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)
|
32
sysdeps/mach/hurd/fstatat.c
Normal file
32
sysdeps/mach/hurd/fstatat.c
Normal file
@ -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)
|
43
sysdeps/mach/hurd/fstatat64.c
Normal file
43
sysdeps/mach/hurd/fstatat64.c
Normal file
@ -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)
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
30
sysdeps/mach/hurd/lstat.c
Normal file
30
sysdeps/mach/hurd/lstat.c
Normal file
@ -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)
|
41
sysdeps/mach/hurd/lstat64.c
Normal file
41
sysdeps/mach/hurd/lstat64.c
Normal file
@ -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)
|
@ -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
|
||||
|
@ -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
|
||||
|
31
sysdeps/mach/hurd/mknod.c
Normal file
31
sysdeps/mach/hurd/mknod.c
Normal file
@ -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)
|
118
sysdeps/mach/hurd/mknodat.c
Normal file
118
sysdeps/mach/hurd/mknodat.c
Normal file
@ -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)
|
30
sysdeps/mach/hurd/stat.c
Normal file
30
sysdeps/mach/hurd/stat.c
Normal file
@ -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)
|
40
sysdeps/mach/hurd/stat64.c
Normal file
40
sysdeps/mach/hurd/stat64.c
Normal file
@ -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)
|
@ -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
|
@ -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
|
||||
|
@ -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;
|
||||
return __mknodat (fd, path, mode, *dev);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
compat_symbol (libc, __xmknodat_compat, __xmknodat, GLIBC_2_4);
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user