| author | |
| committer | |
| log | 3dcd3612dca6f649a1e05f558c5d6ed462d2e4a4 |
| tree | c2bc2094cb11bfb86190c5b641c784e7caca6190 |
| parent | 19ca2415f26b07b399a60fd17a4cf85f290da0fd |
Upstream, some of the nonshared functions moved to be different for hurd
and for linux. Since our glibc is linux-only we update to use the
linux-specific files.
This fixes std lib tests for x86_64 when linking glibc.38 files changed, 1383 insertions(+), 305 deletions(-)
lib/libc/glibc/io/fstat.c deleted-33| ... | ... | @@ -1,33 +0,0 @@ |
| 1 | /* Copyright (C) 1996-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/stat.h> | |
| 19 | #include <errno.h> | |
| 20 | #include <fcntl.h> | |
| 21 | ||
| 22 | int | |
| 23 | __fstat (int fd, struct stat *buf) | |
| 24 | { | |
| 25 | if (fd < 0) | |
| 26 | { | |
| 27 | __set_errno (EBADF); | |
| 28 | return -1; | |
| 29 | } | |
| 30 | return __fstatat (fd, "", buf, AT_EMPTY_PATH); | |
| 31 | } | |
| 32 | ||
| 33 | weak_alias (__fstat, fstat) |
lib/libc/glibc/io/fstat64.c deleted-33| ... | ... | @@ -1,33 +0,0 @@ |
| 1 | /* Copyright (C) 1996-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/stat.h> | |
| 19 | #include <errno.h> | |
| 20 | #include <fcntl.h> | |
| 21 | ||
| 22 | int | |
| 23 | __fstat64 (int fd, struct stat64 *buf) | |
| 24 | { | |
| 25 | if (fd < 0) | |
| 26 | { | |
| 27 | __set_errno (EBADF); | |
| 28 | return -1; | |
| 29 | } | |
| 30 | return __fstatat64 (fd, "", buf, AT_EMPTY_PATH); | |
| 31 | } | |
| 32 | hidden_def (__fstat64) | |
| 33 | weak_alias (__fstat64, fstat64) |
lib/libc/glibc/io/fstatat.c deleted-42| ... | ... | @@ -1,42 +0,0 @@ |
| 1 | /* Copyright (C) 2005-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/stat.h> | |
| 19 | #include <errno.h> | |
| 20 | #include <fcntl.h> | |
| 21 | ||
| 22 | int | |
| 23 | __fstatat (int fd, const char *file, struct stat *buf, int flag) | |
| 24 | { | |
| 25 | if (fd < 0 && fd != AT_FDCWD) | |
| 26 | { | |
| 27 | __set_errno (EBADF); | |
| 28 | return -1; | |
| 29 | } | |
| 30 | if (buf == 0 || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) | |
| 31 | { | |
| 32 | __set_errno (EINVAL); | |
| 33 | return -1; | |
| 34 | } | |
| 35 | ||
| 36 | __set_errno (ENOSYS); | |
| 37 | return -1; | |
| 38 | } | |
| 39 | ||
| 40 | weak_alias (__fstatat, fstatat) | |
| 41 | ||
| 42 | stub_warning (fstatat) |
lib/libc/glibc/io/fstatat64.c deleted-42| ... | ... | @@ -1,42 +0,0 @@ |
| 1 | /* Copyright (C) 2005-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/stat.h> | |
| 19 | #include <errno.h> | |
| 20 | #include <fcntl.h> | |
| 21 | ||
| 22 | int | |
| 23 | __fstatat64 (int fd, const char *file, struct stat64 *buf, int flag) | |
| 24 | { | |
| 25 | if (fd < 0 && fd != AT_FDCWD) | |
| 26 | { | |
| 27 | __set_errno (EBADF); | |
| 28 | return -1; | |
| 29 | } | |
| 30 | if (buf == 0 || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) | |
| 31 | { | |
| 32 | __set_errno (EINVAL); | |
| 33 | return -1; | |
| 34 | } | |
| 35 | ||
| 36 | __set_errno (ENOSYS); | |
| 37 | return -1; | |
| 38 | } | |
| 39 | hidden_def (__fstatat64) | |
| 40 | weak_alias (__fstatat64, fstatat64) | |
| 41 | ||
| 42 | stub_warning (fstatat64) |
lib/libc/glibc/io/lstat.c deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | /* Copyright (C) 1996-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/stat.h> | |
| 19 | #include <fcntl.h> | |
| 20 | ||
| 21 | int | |
| 22 | __lstat (const char *file, struct stat *buf) | |
| 23 | { | |
| 24 | return __fstatat (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW); | |
| 25 | } | |
| 26 | ||
| 27 | weak_alias (__lstat, lstat) |
lib/libc/glibc/io/lstat64.c deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | /* Copyright (C) 1996-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/stat.h> | |
| 19 | #include <fcntl.h> | |
| 20 | ||
| 21 | int | |
| 22 | __lstat64 (const char *file, struct stat64 *buf) | |
| 23 | { | |
| 24 | return __fstatat64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW); | |
| 25 | } | |
| 26 | hidden_def (__lstat64) | |
| 27 | weak_alias (__lstat64, lstat64) |
lib/libc/glibc/io/mknodat.c deleted-31| ... | ... | @@ -1,31 +0,0 @@ |
| 1 | /* Copyright (C) 1995-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/types.h> | |
| 19 | #include <sys/stat.h> | |
| 20 | #include <errno.h> | |
| 21 | ||
| 22 | int | |
| 23 | __mknodat (int fd, const char *path, mode_t mode, dev_t dev) | |
| 24 | { | |
| 25 | __set_errno (ENOSYS); | |
| 26 | return -1; | |
| 27 | } | |
| 28 | libc_hidden_def (__mknodat) | |
| 29 | weak_alias (__mknodat, mknodat) | |
| 30 | ||
| 31 | stub_warning (mknodat) |
lib/libc/glibc/io/stat.c deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | /* Copyright (C) 1996-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/stat.h> | |
| 19 | #include <fcntl.h> | |
| 20 | ||
| 21 | int | |
| 22 | __stat (const char *file, struct stat *buf) | |
| 23 | { | |
| 24 | return __fstatat (AT_FDCWD, file, buf, 0); | |
| 25 | } | |
| 26 | ||
| 27 | weak_alias (__stat, stat) |
lib/libc/glibc/io/stat64.c deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | /* Copyright (C) 1996-2021 Free Software Foundation, Inc. | |
| 2 | This file is part of the GNU C Library. | |
| 3 | ||
| 4 | The GNU C Library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | The GNU C Library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with the GNU C Library; if not, see | |
| 16 | <https://www.gnu.org/licenses/>. */ | |
| 17 | ||
| 18 | #include <sys/stat.h> | |
| 19 | #include <fcntl.h> | |
| 20 | ||
| 21 | int | |
| 22 | __stat64 (const char *file, struct stat64 *buf) | |
| 23 | { | |
| 24 | return __fstatat64 (AT_FDCWD, file, buf, 0); | |
| 25 | } | |
| 26 | hidden_def (__stat64) | |
| 27 | weak_alias (__stat64, stat64) |
lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/kernel_stat.h created+91| ... | ... | @@ -0,0 +1,91 @@ |
| 1 | /* Definition of `struct stat' used in the kernel. */ | |
| 2 | struct kernel_stat | |
| 3 | { | |
| 4 | unsigned int st_dev; | |
| 5 | unsigned int st_ino; | |
| 6 | unsigned int st_mode; | |
| 7 | unsigned int st_nlink; | |
| 8 | unsigned int st_uid; | |
| 9 | unsigned int st_gid; | |
| 10 | unsigned int st_rdev; | |
| 11 | long int st_size; | |
| 12 | unsigned long int st_atime_sec; | |
| 13 | unsigned long int st_mtime_sec; | |
| 14 | unsigned long int st_ctime_sec; | |
| 15 | unsigned int st_blksize; | |
| 16 | int st_blocks; | |
| 17 | unsigned int st_flags; | |
| 18 | unsigned int st_gen; | |
| 19 | }; | |
| 20 | ||
| 21 | /* Definition of `struct stat64' used in the kernel. */ | |
| 22 | struct kernel_stat64 | |
| 23 | { | |
| 24 | unsigned long st_dev; | |
| 25 | unsigned long st_ino; | |
| 26 | unsigned long st_rdev; | |
| 27 | long st_size; | |
| 28 | unsigned long st_blocks; | |
| 29 | ||
| 30 | unsigned int st_mode; | |
| 31 | unsigned int st_uid; | |
| 32 | unsigned int st_gid; | |
| 33 | unsigned int st_blksize; | |
| 34 | unsigned int st_nlink; | |
| 35 | unsigned int __pad0; | |
| 36 | ||
| 37 | unsigned long st_atime_sec; | |
| 38 | unsigned long st_atimensec; | |
| 39 | unsigned long st_mtime_sec; | |
| 40 | unsigned long st_mtimensec; | |
| 41 | unsigned long st_ctime_sec; | |
| 42 | unsigned long st_ctimensec; | |
| 43 | long __glibc_reserved[3]; | |
| 44 | }; | |
| 45 | ||
| 46 | /* Definition of `struct stat' used by glibc 2.0. */ | |
| 47 | struct glibc2_stat | |
| 48 | { | |
| 49 | __dev_t st_dev; | |
| 50 | __ino_t st_ino; | |
| 51 | __mode_t st_mode; | |
| 52 | __nlink_t st_nlink; | |
| 53 | __uid_t st_uid; | |
| 54 | __gid_t st_gid; | |
| 55 | __dev_t st_rdev; | |
| 56 | __off_t st_size; | |
| 57 | __time_t st_atime_sec; | |
| 58 | __time_t st_mtime_sec; | |
| 59 | __time_t st_ctime_sec; | |
| 60 | unsigned int st_blksize; | |
| 61 | int st_blocks; | |
| 62 | unsigned int st_flags; | |
| 63 | unsigned int st_gen; | |
| 64 | }; | |
| 65 | ||
| 66 | /* Definition of `struct stat' used by glibc 2.1. */ | |
| 67 | struct glibc21_stat | |
| 68 | { | |
| 69 | __dev_t st_dev; | |
| 70 | __ino64_t st_ino; | |
| 71 | __mode_t st_mode; | |
| 72 | __nlink_t st_nlink; | |
| 73 | __uid_t st_uid; | |
| 74 | __gid_t st_gid; | |
| 75 | __dev_t st_rdev; | |
| 76 | __off_t st_size; | |
| 77 | __time_t st_atime_sec; | |
| 78 | __time_t st_mtime_sec; | |
| 79 | __time_t st_ctime_sec; | |
| 80 | __blkcnt64_t st_blocks; | |
| 81 | __blksize_t st_blksize; | |
| 82 | unsigned int st_flags; | |
| 83 | unsigned int st_gen; | |
| 84 | int __pad3; | |
| 85 | long __glibc_reserved[4]; | |
| 86 | }; | |
| 87 | ||
| 88 | #define STAT_IS_KERNEL_STAT 0 | |
| 89 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 90 | #define XSTAT_IS_XSTAT64 1 | |
| 91 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/arm/kernel_stat.h created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | /* Definition of `struct stat' used in the kernel.. */ | |
| 2 | struct kernel_stat | |
| 3 | { | |
| 4 | unsigned short int st_dev; | |
| 5 | unsigned short int __pad1; | |
| 6 | #define _HAVE___PAD1 | |
| 7 | unsigned long int st_ino; | |
| 8 | unsigned short int st_mode; | |
| 9 | unsigned short int st_nlink; | |
| 10 | unsigned short int st_uid; | |
| 11 | unsigned short int st_gid; | |
| 12 | unsigned short int st_rdev; | |
| 13 | unsigned short int __pad2; | |
| 14 | #define _HAVE___PAD2 | |
| 15 | unsigned long int st_size; | |
| 16 | unsigned long int st_blksize; | |
| 17 | unsigned long int st_blocks; | |
| 18 | struct timespec st_atim; | |
| 19 | struct timespec st_mtim; | |
| 20 | struct timespec st_ctim; | |
| 21 | unsigned long int __glibc_reserved4; | |
| 22 | #define _HAVE___UNUSED4 | |
| 23 | unsigned long int __glibc_reserved5; | |
| 24 | #define _HAVE___UNUSED5 | |
| 25 | }; | |
| 26 | ||
| 27 | #define _HAVE_STAT___UNUSED4 | |
| 28 | #define _HAVE_STAT___UNUSED5 | |
| 29 | #define _HAVE_STAT___PAD1 | |
| 30 | #define _HAVE_STAT___PAD2 | |
| 31 | #define _HAVE_STAT_NSEC | |
| 32 | #define _HAVE_STAT64___PAD1 | |
| 33 | #define _HAVE_STAT64___PAD2 | |
| 34 | #define _HAVE_STAT64___ST_INO | |
| 35 | #define _HAVE_STAT64_NSEC | |
| 36 | ||
| 37 | #define STAT_IS_KERNEL_STAT 0 | |
| 38 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 39 | #define XSTAT_IS_XSTAT64 0 | |
| 40 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/csky/kernel_stat.h created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | /* Internal definitions for stat functions. Linux/csky. | |
| 2 | Copyright (C) 2011-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library. If not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #define STAT_IS_KERNEL_STAT 1 | |
| 20 | #define XSTAT_IS_XSTAT64 0 | |
| 21 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/fstat.c created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | /* Get file status. Linux version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #include <sys/stat.h> | |
| 20 | #include <kernel_stat.h> | |
| 21 | #include <fcntl.h> | |
| 22 | #include <errno.h> | |
| 23 | ||
| 24 | #if !XSTAT_IS_XSTAT64 | |
| 25 | int | |
| 26 | __fstat (int fd, struct stat *buf) | |
| 27 | { | |
| 28 | if (fd < 0) | |
| 29 | { | |
| 30 | __set_errno (EBADF); | |
| 31 | return -1; | |
| 32 | } | |
| 33 | return __fstatat (fd, "", buf, AT_EMPTY_PATH); | |
| 34 | } | |
| 35 | ||
| 36 | weak_alias (__fstat, fstat) | |
| 37 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/fstat64.c created+64| ... | ... | @@ -0,0 +1,64 @@ |
| 1 | /* Get file status. Linux version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #define __fstat __redirect___fstat | |
| 20 | #define fstat __redirect_fstat | |
| 21 | #include <sys/stat.h> | |
| 22 | #include <fcntl.h> | |
| 23 | #include <kernel_stat.h> | |
| 24 | #include <stat_t64_cp.h> | |
| 25 | #include <errno.h> | |
| 26 | ||
| 27 | int | |
| 28 | __fstat64_time64 (int fd, struct __stat64_t64 *buf) | |
| 29 | { | |
| 30 | if (fd < 0) | |
| 31 | { | |
| 32 | __set_errno (EBADF); | |
| 33 | return -1; | |
| 34 | } | |
| 35 | return __fstatat64_time64 (fd, "", buf, AT_EMPTY_PATH); | |
| 36 | } | |
| 37 | #if __TIMESIZE != 64 | |
| 38 | hidden_def (__fstat64_time64) | |
| 39 | ||
| 40 | int | |
| 41 | __fstat64 (int fd, struct stat64 *buf) | |
| 42 | { | |
| 43 | if (fd < 0) | |
| 44 | { | |
| 45 | __set_errno (EBADF); | |
| 46 | return -1; | |
| 47 | } | |
| 48 | ||
| 49 | struct __stat64_t64 st_t64; | |
| 50 | return __fstat64_time64 (fd, &st_t64) | |
| 51 | 	 ?: __cp_stat64_t64_stat64 (&st_t64, buf); | |
| 52 | } | |
| 53 | #endif | |
| 54 | ||
| 55 | #undef __fstat | |
| 56 | #undef fstat | |
| 57 | ||
| 58 | hidden_def (__fstat64) | |
| 59 | weak_alias (__fstat64, fstat64) | |
| 60 | ||
| 61 | #if XSTAT_IS_XSTAT64 | |
| 62 | strong_alias (__fstat64, __fstat) | |
| 63 | weak_alias (__fstat64, fstat) | |
| 64 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/fstatat.c created+62| ... | ... | @@ -0,0 +1,62 @@ |
| 1 | /* Get file status. Linux version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #include <sys/stat.h> | |
| 20 | #include <kernel_stat.h> | |
| 21 | #include <sysdep.h> | |
| 22 | ||
| 23 | #if !XSTAT_IS_XSTAT64 | |
| 24 | # include <kstat_cp.h> | |
| 25 | ||
| 26 | int | |
| 27 | __fstatat (int fd, const char *file, struct stat *buf, int flag) | |
| 28 | { | |
| 29 | struct __stat64_t64 st64; | |
| 30 | int r = __fstatat64_time64 (fd, file, &st64, flag); | |
| 31 | if (r == 0) | |
| 32 | { | |
| 33 | if (! in_ino_t_range (st64.st_ino) | |
| 34 | 	 || ! in_off_t_range (st64.st_size) | |
| 35 | 	 || ! in_blkcnt_t_range (st64.st_blocks) | |
| 36 | 	 || ! in_time_t_range (st64.st_atim.tv_sec) | |
| 37 | 	 || ! in_time_t_range (st64.st_mtim.tv_sec) | |
| 38 | 	 || ! in_time_t_range (st64.st_ctim.tv_sec)) | |
| 39 | 	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); | |
| 40 | ||
| 41 | /* Clear internal pad and reserved fields. */ | |
| 42 | memset (buf, 0, sizeof (*buf)); | |
| 43 | ||
| 44 | buf->st_dev = st64.st_dev; | |
| 45 | buf->st_ino = st64.st_ino; | |
| 46 | buf->st_mode = st64.st_mode; | |
| 47 | buf->st_nlink = st64.st_nlink; | |
| 48 | buf->st_uid = st64.st_uid; | |
| 49 | buf->st_gid = st64.st_gid; | |
| 50 | buf->st_rdev = st64.st_rdev; | |
| 51 | buf->st_size = st64.st_size; | |
| 52 | buf->st_blksize = st64.st_blksize; | |
| 53 | buf->st_blocks = st64.st_blocks; | |
| 54 | buf->st_atim = valid_timespec64_to_timespec (st64.st_atim); | |
| 55 | buf->st_mtim = valid_timespec64_to_timespec (st64.st_mtim); | |
| 56 | buf->st_ctim = valid_timespec64_to_timespec (st64.st_ctim); | |
| 57 | } | |
| 58 | return r; | |
| 59 | } | |
| 60 | ||
| 61 | weak_alias (__fstatat, fstatat) | |
| 62 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/fstatat64.c created+188| ... | ... | @@ -0,0 +1,188 @@ |
| 1 | /* Get file status. Linux version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #define __fstatat __redirect___fstatat | |
| 20 | #define fstatat __redirect_fstatat | |
| 21 | #include <sys/stat.h> | |
| 22 | #include <fcntl.h> | |
| 23 | #include <string.h> | |
| 24 | #include <kernel_stat.h> | |
| 25 | #include <sysdep.h> | |
| 26 | #include <time.h> | |
| 27 | #include <kstat_cp.h> | |
| 28 | #include <stat_t64_cp.h> | |
| 29 | #include <sys/sysmacros.h> | |
| 30 | ||
| 31 | #if __TIMESIZE == 64 \ | |
| 32 | && (__WORDSIZE == 32 \ | |
| 33 | && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) | |
| 34 | /* Sanity check to avoid newer 32-bit ABI to support non-LFS calls. */ | |
| 35 | _Static_assert (sizeof (__off_t) == sizeof (__off64_t), | |
| 36 | "__blkcnt_t and __blkcnt64_t must match"); | |
| 37 | _Static_assert (sizeof (__ino_t) == sizeof (__ino64_t), | |
| 38 | "__blkcnt_t and __blkcnt64_t must match"); | |
| 39 | _Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t), | |
| 40 | "__blkcnt_t and __blkcnt64_t must match"); | |
| 41 | #endif | |
| 42 | ||
| 43 | static inline int | |
| 44 | fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf, | |
| 45 | 			int flag) | |
| 46 | { | |
| 47 | /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32. Also | |
| 48 | 64-bit time_t support is done through statx syscall. */ | |
| 49 | struct statx tmp; | |
| 50 | int r = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag, | |
| 51 | 				 STATX_BASIC_STATS, &tmp); | |
| 52 | if (r != 0) | |
| 53 | return r; | |
| 54 | ||
| 55 | *buf = (struct __stat64_t64) { | |
| 56 | .st_dev = __gnu_dev_makedev (tmp.stx_dev_major, tmp.stx_dev_minor), | |
| 57 | .st_rdev = __gnu_dev_makedev (tmp.stx_rdev_major, tmp.stx_rdev_minor), | |
| 58 | .st_ino = tmp.stx_ino, | |
| 59 | .st_mode = tmp.stx_mode, | |
| 60 | .st_nlink = tmp.stx_nlink, | |
| 61 | .st_uid = tmp.stx_uid, | |
| 62 | .st_gid = tmp.stx_gid, | |
| 63 | .st_atime = tmp.stx_atime.tv_sec, | |
| 64 | .st_atim.tv_nsec = tmp.stx_atime.tv_nsec, | |
| 65 | .st_mtime = tmp.stx_mtime.tv_sec, | |
| 66 | .st_mtim.tv_nsec = tmp.stx_mtime.tv_nsec, | |
| 67 | .st_ctime = tmp.stx_ctime.tv_sec, | |
| 68 | .st_ctim.tv_nsec = tmp.stx_ctime.tv_nsec, | |
| 69 | .st_size = tmp.stx_size, | |
| 70 | .st_blocks = tmp.stx_blocks, | |
| 71 | .st_blksize = tmp.stx_blksize, | |
| 72 | }; | |
| 73 | ||
| 74 | return r; | |
| 75 | } | |
| 76 | ||
| 77 | static inline int | |
| 78 | fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf, | |
| 79 | 		 int flag) | |
| 80 | { | |
| 81 | int r; | |
| 82 | ||
| 83 | #if XSTAT_IS_XSTAT64 | |
| 84 | # ifdef __NR_newfstatat | |
| 85 | /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, riscv64, and | |
| 86 | x86_64. */ | |
| 87 | r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, buf, flag); | |
| 88 | # elif defined __NR_fstatat64 | |
| 89 | # if STAT64_IS_KERNEL_STAT64 | |
| 90 | /* 64-bit kABI outlier, e.g. alpha */ | |
| 91 | r = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, buf, flag); | |
| 92 | # else | |
| 93 | /* 64-bit kABI outlier, e.g. sparc64. */ | |
| 94 | struct kernel_stat64 kst64; | |
| 95 | r = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, &kst64, flag); | |
| 96 | if (r == 0) | |
| 97 | __cp_stat64_kstat64 (buf, &kst64); | |
| 98 | # endif | |
| 99 | # endif | |
| 100 | #else | |
| 101 | # ifdef __NR_fstatat64 | |
| 102 | /* All kABIs with non-LFS support and with old 32-bit time_t support | |
| 103 | e.g. arm, csky, i386, hppa, m68k, microblaze, nios2, sh, powerpc32, | |
| 104 | and sparc32. */ | |
| 105 | struct stat64 st64; | |
| 106 | r = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, &st64, flag); | |
| 107 | if (r == 0) | |
| 108 | { | |
| 109 | /* Clear both pad and reserved fields. */ | |
| 110 | memset (buf, 0, sizeof (*buf)); | |
| 111 | ||
| 112 | buf->st_dev = st64.st_dev, | |
| 113 | buf->st_ino = st64.st_ino; | |
| 114 | buf->st_mode = st64.st_mode; | |
| 115 | buf->st_nlink = st64.st_nlink; | |
| 116 | buf->st_uid = st64.st_uid; | |
| 117 | buf->st_gid = st64.st_gid; | |
| 118 | buf->st_rdev = st64.st_rdev; | |
| 119 | buf->st_size = st64.st_size; | |
| 120 | buf->st_blksize = st64.st_blksize; | |
| 121 | buf->st_blocks = st64.st_blocks; | |
| 122 | buf->st_atim = valid_timespec_to_timespec64 (st64.st_atim); | |
| 123 | buf->st_mtim = valid_timespec_to_timespec64 (st64.st_mtim); | |
| 124 | buf->st_ctim = valid_timespec_to_timespec64 (st64.st_ctim); | |
| 125 | } | |
| 126 | # else | |
| 127 | /* 64-bit kabi outlier, e.g. mips64 and mips64-n32. */ | |
| 128 | struct kernel_stat kst; | |
| 129 | r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag); | |
| 130 | if (r == 0) | |
| 131 | __cp_kstat_stat64_t64 (&kst, buf); | |
| 132 | # endif | |
| 133 | #endif | |
| 134 | ||
| 135 | return r; | |
| 136 | } | |
| 137 | ||
| 138 | #if (__WORDSIZE == 32 \ | |
| 139 | && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) \ | |
| 140 | || defined STAT_HAS_TIME32 | |
| 141 | # define FSTATAT_USE_STATX 1 | |
| 142 | #else | |
| 143 | # define FSTATAT_USE_STATX 0 | |
| 144 | #endif | |
| 145 | ||
| 146 | int | |
| 147 | __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf, | |
| 148 | 		 int flag) | |
| 149 | { | |
| 150 | int r; | |
| 151 | ||
| 152 | #if FSTATAT_USE_STATX | |
| 153 | r = fstatat64_time64_statx (fd, file, buf, flag); | |
| 154 | # ifndef __ASSUME_STATX | |
| 155 | if (r == -ENOSYS) | |
| 156 | r = fstatat64_time64_stat (fd, file, buf, flag); | |
| 157 | # endif | |
| 158 | #else | |
| 159 | r = fstatat64_time64_stat (fd, file, buf, flag); | |
| 160 | #endif | |
| 161 | ||
| 162 | return INTERNAL_SYSCALL_ERROR_P (r) | |
| 163 | 	 ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r) | |
| 164 | 	 : 0; | |
| 165 | } | |
| 166 | #if __TIMESIZE != 64 | |
| 167 | hidden_def (__fstatat64_time64) | |
| 168 | ||
| 169 | int | |
| 170 | __fstatat64 (int fd, const char *file, struct stat64 *buf, int flags) | |
| 171 | { | |
| 172 | struct __stat64_t64 st_t64; | |
| 173 | return __fstatat64_time64 (fd, file, &st_t64, flags) | |
| 174 | 	 ?: __cp_stat64_t64_stat64 (&st_t64, buf); | |
| 175 | } | |
| 176 | #endif | |
| 177 | ||
| 178 | #undef __fstatat | |
| 179 | #undef fstatat | |
| 180 | ||
| 181 | hidden_def (__fstatat64) | |
| 182 | weak_alias (__fstatat64, fstatat64) | |
| 183 | ||
| 184 | #if XSTAT_IS_XSTAT64 | |
| 185 | strong_alias (__fstatat64, __fstatat) | |
| 186 | weak_alias (__fstatat64, fstatat) | |
| 187 | strong_alias (__fstatat64, __GI___fstatat); | |
| 188 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/kernel_stat.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | /* definition of "struct stat" from the kernel */ | |
| 2 | struct kernel_stat { | |
| 3 | 	unsigned long	st_dev;		/* dev_t is 32 bits on parisc */ | |
| 4 | 	unsigned long	st_ino;		/* 32 bits */ | |
| 5 | 	unsigned short	st_mode;	/* 16 bits */ | |
| 6 | 	unsigned short	st_nlink;	/* 16 bits */ | |
| 7 | 	unsigned short	st_reserved1;	/* old st_uid */ | |
| 8 | 	unsigned short	st_reserved2;	/* old st_gid */ | |
| 9 | 	unsigned long	st_rdev; | |
| 10 | 	unsigned long st_size; | |
| 11 | 	struct timespec st_atim; | |
| 12 | 	struct timespec st_mtim; | |
| 13 | 	struct timespec st_ctim; | |
| 14 | 	long		st_blksize; | |
| 15 | 	long		st_blocks; | |
| 16 | 	unsigned long	__glibc_reserved1;	/* ACL stuff */ | |
| 17 | 	unsigned long	__glibc_reserved2;	/* network */ | |
| 18 | 	unsigned long	__glibc_reserved3;	/* network */ | |
| 19 | 	unsigned long	__glibc_reserved4;	/* cnodes */ | |
| 20 | 	unsigned short	__glibc_reserved5;	/* netsite */ | |
| 21 | 	short		st_fstype; | |
| 22 | 	unsigned long	st_realdev; | |
| 23 | 	unsigned short	st_basemode; | |
| 24 | 	unsigned short	st_spareshort; | |
| 25 | 	unsigned long	st_uid; | |
| 26 | 	unsigned long st_gid; | |
| 27 | 	unsigned long	st_spare4[3]; | |
| 28 | }; | |
| 29 | ||
| 30 | #define _HAVE_STAT_NSEC | |
| 31 | #define _HAVE_STAT64_NSEC | |
| 32 | ||
| 33 | #define STAT_IS_KERNEL_STAT 0 | |
| 34 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 35 | #define XSTAT_IS_XSTAT64 0 | |
| 36 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/i386/kernel_stat.h created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | /* Definition of `struct stat' used in the kernel.. */ | |
| 2 | struct kernel_stat | |
| 3 | { | |
| 4 | unsigned short int st_dev; | |
| 5 | unsigned short int __pad1; | |
| 6 | #define _HAVE___PAD1 | |
| 7 | unsigned long int st_ino; | |
| 8 | unsigned short int st_mode; | |
| 9 | unsigned short int st_nlink; | |
| 10 | unsigned short int st_uid; | |
| 11 | unsigned short int st_gid; | |
| 12 | unsigned short int st_rdev; | |
| 13 | unsigned short int __pad2; | |
| 14 | #define _HAVE___PAD2 | |
| 15 | unsigned long int st_size; | |
| 16 | unsigned long int st_blksize; | |
| 17 | unsigned long int st_blocks; | |
| 18 | struct timespec st_atim; | |
| 19 | struct timespec st_mtim; | |
| 20 | struct timespec st_ctim; | |
| 21 | unsigned long int __glibc_reserved4; | |
| 22 | #define _HAVE___UNUSED4 | |
| 23 | unsigned long int __glibc_reserved5; | |
| 24 | #define _HAVE___UNUSED5 | |
| 25 | }; | |
| 26 | ||
| 27 | #define _HAVE_STAT___UNUSED4 | |
| 28 | #define _HAVE_STAT___UNUSED5 | |
| 29 | #define _HAVE_STAT___PAD1 | |
| 30 | #define _HAVE_STAT___PAD2 | |
| 31 | #define _HAVE_STAT_NSEC | |
| 32 | #define _HAVE_STAT64___PAD1 | |
| 33 | #define _HAVE_STAT64___PAD2 | |
| 34 | #define _HAVE_STAT64___ST_INO | |
| 35 | #define _HAVE_STAT64_NSEC | |
| 36 | ||
| 37 | #define STAT_IS_KERNEL_STAT 0 | |
| 38 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 39 | #define XSTAT_IS_XSTAT64 0 | |
| 40 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/kernel_stat.h created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | /* Internal definitions for stat functions. | |
| 2 | Copyright (C) 2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | /* The default Linux ABI assumes only LFS support. */ | |
| 20 | #define XSTAT_IS_XSTAT64 1 | |
| 21 | #define STATFS_IS_STATFS64 __STATFS_MATCHES_STATFS64 | |
| 22 | #define STAT_IS_KERNEL_STAT 1 |
lib/libc/glibc/sysdeps/unix/sysv/linux/kstat_cp.h created+2| ... | ... | @@ -0,0 +1,2 @@ |
| 1 | /* Empty, it is overridden by an architecture which might require copy to or | |
| 2 | from a kernel_stat stat struct to glibc export stat{64}. */ |
lib/libc/glibc/sysdeps/unix/sysv/linux/lstat.c created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | /* Get file status. Linux version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #include <sys/stat.h> | |
| 20 | #include <fcntl.h> | |
| 21 | #include <kernel_stat.h> | |
| 22 | ||
| 23 | #if !XSTAT_IS_XSTAT64 | |
| 24 | int | |
| 25 | __lstat (const char *file, struct stat *buf) | |
| 26 | { | |
| 27 | return __fstatat (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW); | |
| 28 | } | |
| 29 | ||
| 30 | weak_alias (__lstat, lstat) | |
| 31 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/lstat64.c created+51| ... | ... | @@ -0,0 +1,51 @@ |
| 1 | /* Get file status. | |
| 2 | Copyright (C) 1996-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #define __lstat __redirect___lstat | |
| 20 | #define lstat __redirect_lstat | |
| 21 | #include <sys/stat.h> | |
| 22 | #include <fcntl.h> | |
| 23 | #include <kernel_stat.h> | |
| 24 | #include <stat_t64_cp.h> | |
| 25 | ||
| 26 | int | |
| 27 | __lstat64_time64 (const char *file, struct __stat64_t64 *buf) | |
| 28 | { | |
| 29 | return __fstatat64_time64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW); | |
| 30 | } | |
| 31 | #if __TIMESIZE != 64 | |
| 32 | hidden_def (__lstat64_time64) | |
| 33 | ||
| 34 | int | |
| 35 | __lstat64 (const char *file, struct stat64 *buf) | |
| 36 | { | |
| 37 | struct __stat64_t64 st_t64; | |
| 38 | return __lstat64_time64 (file, &st_t64) | |
| 39 | 	 ?: __cp_stat64_t64_stat64 (&st_t64, buf); | |
| 40 | } | |
| 41 | #endif | |
| 42 | hidden_def (__lstat64) | |
| 43 | weak_alias (__lstat64, lstat64) | |
| 44 | ||
| 45 | #undef __lstat | |
| 46 | #undef lstat | |
| 47 | ||
| 48 | #if XSTAT_IS_XSTAT64 | |
| 49 | strong_alias (__lstat64, __lstat) | |
| 50 | weak_alias (__lstat64, lstat) | |
| 51 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/m68k/kernel_stat.h created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | /* Definition of `struct stat' used in the kernel.. */ | |
| 2 | struct kernel_stat | |
| 3 | { | |
| 4 | unsigned short int st_dev; | |
| 5 | unsigned short int __pad1; | |
| 6 | #define _HAVE___PAD1 | |
| 7 | unsigned long int st_ino; | |
| 8 | unsigned short int st_mode; | |
| 9 | unsigned short int st_nlink; | |
| 10 | unsigned short int st_uid; | |
| 11 | unsigned short int st_gid; | |
| 12 | unsigned short int st_rdev; | |
| 13 | unsigned short int __pad2; | |
| 14 | #define _HAVE___PAD2 | |
| 15 | unsigned long int st_size; | |
| 16 | unsigned long int st_blksize; | |
| 17 | unsigned long int st_blocks; | |
| 18 | struct timespec st_atim; | |
| 19 | struct timespec st_mtim; | |
| 20 | struct timespec st_ctim; | |
| 21 | unsigned long int __glibc_reserved4; | |
| 22 | #define _HAVE___UNUSED4 | |
| 23 | unsigned long int __glibc_reserved5; | |
| 24 | #define _HAVE___UNUSED5 | |
| 25 | }; | |
| 26 | ||
| 27 | #define _HAVE_STAT___UNUSED4 | |
| 28 | #define _HAVE_STAT___UNUSED5 | |
| 29 | #define _HAVE_STAT___PAD1 | |
| 30 | #define _HAVE_STAT___PAD2 | |
| 31 | #define _HAVE_STAT_NSEC | |
| 32 | #define _HAVE_STAT64___PAD1 | |
| 33 | #define _HAVE_STAT64___PAD2 | |
| 34 | #define _HAVE_STAT64___ST_INO | |
| 35 | #define _HAVE_STAT64_NSEC | |
| 36 | ||
| 37 | #define STAT_IS_KERNEL_STAT 0 | |
| 38 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 39 | #define XSTAT_IS_XSTAT64 0 | |
| 40 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h created+54| ... | ... | @@ -0,0 +1,54 @@ |
| 1 | /* Definition of `struct stat' used in the kernel | |
| 2 | Copyright (C) 2013-2021 Free Software Foundation, Inc. | |
| 3 | ||
| 4 | This file is part of the GNU C Library. | |
| 5 | ||
| 6 | The GNU C Library is free software; you can redistribute it and/or | |
| 7 | modify it under the terms of the GNU Lesser General Public License as | |
| 8 | published by the Free Software Foundation; either version 2.1 of the | |
| 9 | License, or (at your option) any later version. | |
| 10 | ||
| 11 | The GNU C Library is distributed in the hope that it will be useful, | |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | Lesser General Public License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public | |
| 17 | License along with the GNU C Library; if not, see | |
| 18 | <https://www.gnu.org/licenses/>. */ | |
| 19 | ||
| 20 | struct kernel_stat | |
| 21 | { | |
| 22 | unsigned long st_dev; /* Device. */ | |
| 23 | unsigned long st_ino; /* File serial number. */ | |
| 24 | unsigned int st_mode; /* File mode. */ | |
| 25 | unsigned int st_nlink; /* Link count. */ | |
| 26 | unsigned int st_uid; /* User ID of the file's owner. */ | |
| 27 | unsigned int st_gid; /* Group ID of the file's group. */ | |
| 28 | unsigned long st_rdev; /* Device number, if device. */ | |
| 29 | unsigned long __pad2; | |
| 30 | #define _HAVE_STAT___PAD2 | |
| 31 | #define _HAVE_STAT64___PAD2 | |
| 32 | long st_size; /* Size of file, in bytes. */ | |
| 33 | int st_blksize; /* Optimal block size for I/O. */ | |
| 34 | int __pad3; | |
| 35 | #define _HAVE_STAT___PAD3 | |
| 36 | #define _HAVE_STAT64___PAD3 | |
| 37 | long st_blocks; /* Number 512-byte blocks allocated. */ | |
| 38 | struct timespec st_atim; | |
| 39 | struct timespec st_mtim; | |
| 40 | struct timespec st_ctim; | |
| 41 | #define _HAVE_STAT_NSEC | |
| 42 | #define _HAVE_STAT64_NSEC | |
| 43 | unsigned int __glibc_reserved4; | |
| 44 | #define _HAVE_STAT___UNUSED4 | |
| 45 | #define _HAVE_STAT64___UNUSED4 | |
| 46 | unsigned int __glibc_reserved5; | |
| 47 | #define _HAVE_STAT___UNUSED5 | |
| 48 | #define _HAVE_STAT64___UNUSED5 | |
| 49 | }; | |
| 50 | ||
| 51 | #define STAT_IS_KERNEL_STAT 0 | |
| 52 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 53 | #define XSTAT_IS_XSTAT64 0 | |
| 54 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/mips/kernel_stat.h created+75| ... | ... | @@ -0,0 +1,75 @@ |
| 1 | #ifndef _KERNEL_STAT_H | |
| 2 | #define _KERNEL_STAT_H | |
| 3 | ||
| 4 | #include <sgidefs.h> | |
| 5 | /* As tempting as it is to define XSTAT_IS_XSTAT64 for n64, the | |
| 6 | userland data structures are not identical, because of different | |
| 7 | padding. */ | |
| 8 | /* Definition of `struct stat' used in the kernel. */ | |
| 9 | #if _MIPS_SIM != _ABIO32 | |
| 10 | struct kernel_stat | |
| 11 | { | |
| 12 | unsigned int st_dev; | |
| 13 | unsigned int __pad1[3]; | |
| 14 | unsigned long long st_ino; | |
| 15 | unsigned int st_mode; | |
| 16 | unsigned int st_nlink; | |
| 17 | int st_uid; | |
| 18 | int st_gid; | |
| 19 | unsigned int st_rdev; | |
| 20 | unsigned int __pad2[3]; | |
| 21 | long long st_size; | |
| 22 | unsigned int st_atime_sec; | |
| 23 | unsigned int st_atime_nsec; | |
| 24 | unsigned int st_mtime_sec; | |
| 25 | unsigned int st_mtime_nsec; | |
| 26 | unsigned int st_ctime_sec; | |
| 27 | unsigned int st_ctime_nsec; | |
| 28 | unsigned int st_blksize; | |
| 29 | unsigned int __pad3; | |
| 30 | unsigned long long st_blocks; | |
| 31 | }; | |
| 32 | #else | |
| 33 | struct kernel_stat | |
| 34 | { | |
| 35 | unsigned long int st_dev; | |
| 36 | long int __pad1[3];			/* Reserved for network id */ | |
| 37 | unsigned long int st_ino; | |
| 38 | unsigned long int st_mode; | |
| 39 | unsigned long int st_nlink; | |
| 40 | long int st_uid; | |
| 41 | long int st_gid; | |
| 42 | unsigned long int st_rdev; | |
| 43 | long int __pad2[2]; | |
| 44 | long int st_size; | |
| 45 | long int __pad3; | |
| 46 | unsigned int st_atime_sec; | |
| 47 | unsigned int st_atime_nsec; | |
| 48 | unsigned int st_mtime_sec; | |
| 49 | unsigned int st_mtime_nsec; | |
| 50 | unsigned int st_ctime_sec; | |
| 51 | unsigned int st_ctime_nsec; | |
| 52 | long int st_blksize; | |
| 53 | long int st_blocks; | |
| 54 | char st_fstype[16];			/* Filesystem type name, unsupported */ | |
| 55 | long st_pad4[8]; | |
| 56 | /* Linux specific fields */ | |
| 57 | unsigned int st_flags; | |
| 58 | unsigned int st_gen; | |
| 59 | }; | |
| 60 | #endif | |
| 61 | ||
| 62 | #define STAT_IS_KERNEL_STAT 0 | |
| 63 | #define STAT64_IS_KERNEL_STAT64 0 | |
| 64 | #define XSTAT_IS_XSTAT64 0 | |
| 65 | #if _MIPS_SIM == _ABI64 | |
| 66 | # define STATFS_IS_STATFS64 1 | |
| 67 | #else | |
| 68 | # define STATFS_IS_STATFS64 0 | |
| 69 | #endif | |
| 70 | /* MIPS64 has unsigned 32 bit timestamps fields, so use statx as well. */ | |
| 71 | #if _MIPS_SIM == _ABI64 | |
| 72 | # define STAT_HAS_TIME32 | |
| 73 | #endif | |
| 74 | ||
| 75 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h created+73| ... | ... | @@ -0,0 +1,73 @@ |
| 1 | /* Struct stat/stat64 to stat/stat64 conversion for Linux. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library. If not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #include <sys/stat.h> | |
| 20 | #include <kernel_stat.h> | |
| 21 | ||
| 22 | static inline long int | |
| 23 | __cp_kstat_stat (const struct kernel_stat *kst, struct stat *st) | |
| 24 | { | |
| 25 | if (! in_ino_t_range (kst->st_ino) | |
| 26 | || ! in_off_t_range (kst->st_size) | |
| 27 | || ! in_blkcnt_t_range (kst->st_blocks)) | |
| 28 | return -EOVERFLOW; | |
| 29 | ||
| 30 | st->st_dev = kst->st_dev; | |
| 31 | memset (&st->st_pad1, 0, sizeof (st->st_pad1)); | |
| 32 | st->st_ino = kst->st_ino; | |
| 33 | st->st_mode = kst->st_mode; | |
| 34 | st->st_nlink = kst->st_nlink; | |
| 35 | st->st_uid = kst->st_uid; | |
| 36 | st->st_gid = kst->st_gid; | |
| 37 | st->st_rdev = kst->st_rdev; | |
| 38 | memset (&st->st_pad2, 0, sizeof (st->st_pad2)); | |
| 39 | st->st_size = kst->st_size; | |
| 40 | st->st_pad3 = 0; | |
| 41 | st->st_atim.tv_sec = kst->st_atime_sec; | |
| 42 | st->st_atim.tv_nsec = kst->st_atime_nsec; | |
| 43 | st->st_mtim.tv_sec = kst->st_mtime_sec; | |
| 44 | st->st_mtim.tv_nsec = kst->st_mtime_nsec; | |
| 45 | st->st_ctim.tv_sec = kst->st_ctime_sec; | |
| 46 | st->st_ctim.tv_nsec = kst->st_ctime_nsec; | |
| 47 | st->st_blksize = kst->st_blksize; | |
| 48 | st->st_blocks = kst->st_blocks; | |
| 49 | memset (&st->st_pad5, 0, sizeof (st->st_pad5)); | |
| 50 | ||
| 51 | return 0; | |
| 52 | } | |
| 53 | ||
| 54 | static inline void | |
| 55 | __cp_kstat_stat64_t64 (const struct kernel_stat *kst, struct __stat64_t64 *st) | |
| 56 | { | |
| 57 | st->st_dev = kst->st_dev; | |
| 58 | st->st_ino = kst->st_ino; | |
| 59 | st->st_mode = kst->st_mode; | |
| 60 | st->st_nlink = kst->st_nlink; | |
| 61 | st->st_uid = kst->st_uid; | |
| 62 | st->st_gid = kst->st_gid; | |
| 63 | st->st_rdev = kst->st_rdev; | |
| 64 | st->st_size = kst->st_size; | |
| 65 | st->st_blksize = kst->st_blksize; | |
| 66 | st->st_blocks = kst->st_blocks; | |
| 67 | st->st_atim.tv_sec = kst->st_atime_sec; | |
| 68 | st->st_atim.tv_nsec = kst->st_atime_nsec; | |
| 69 | st->st_mtim.tv_sec = kst->st_mtime_sec; | |
| 70 | st->st_mtim.tv_nsec = kst->st_mtime_nsec; | |
| 71 | st->st_ctim.tv_sec = kst->st_ctime_sec; | |
| 72 | st->st_ctim.tv_nsec = kst->st_ctime_nsec; | |
| 73 | } |
lib/libc/glibc/sysdeps/unix/sysv/linux/mknodat.c created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | /* Create a special or ordinary file. Linux version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #include <sys/types.h> | |
| 20 | #include <sys/stat.h> | |
| 21 | #include <errno.h> | |
| 22 | #include <sysdep.h> | |
| 23 | ||
| 24 | int | |
| 25 | __mknodat (int fd, const char *path, mode_t mode, dev_t dev) | |
| 26 | { | |
| 27 | /* The user-exported dev_t is 64-bit while the kernel interface is | |
| 28 | 32-bit. */ | |
| 29 | unsigned int k_dev = dev; | |
| 30 | if (k_dev != dev) | |
| 31 | return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); | |
| 32 | ||
| 33 | return INLINE_SYSCALL_CALL (mknodat, fd, path, mode, k_dev); | |
| 34 | } | |
| 35 | libc_hidden_def (__mknodat) | |
| 36 | weak_alias (__mknodat, mknodat) |
lib/libc/glibc/sysdeps/unix/sysv/linux/nios2/kernel_stat.h created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | /* Internal definitions for stat functions. Linux/nios2. | |
| 2 | Copyright (C) 2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. | |
| 5 | ||
| 6 | The GNU C Library is free software; you can redistribute it and/or | |
| 7 | modify it under the terms of the GNU Lesser General Public | |
| 8 | License as published by the Free Software Foundation; either | |
| 9 | version 2.1 of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | The GNU C Library is distributed in the hope that it will be useful, | |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | Lesser General Public License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public | |
| 17 | License along with the GNU C Library. If not, see | |
| 18 | <https://www.gnu.org/licenses/>. */ | |
| 19 | ||
| 20 | #define STAT_IS_KERNEL_STAT 1 | |
| 21 | #define XSTAT_IS_XSTAT64 0 | |
| 22 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h created+53| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | /* Definition of `struct stat' used in the kernel. | |
| 2 | Copyright (C) 1997-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | struct kernel_stat | |
| 20 | { | |
| 21 | unsigned int st_dev; | |
| 22 | unsigned int st_ino; | |
| 23 | unsigned int st_mode; | |
| 24 | unsigned short st_nlink; | |
| 25 | unsigned int st_uid; | |
| 26 | unsigned int st_gid; | |
| 27 | unsigned int st_rdev; | |
| 28 | unsigned long int st_size; | |
| 29 | unsigned long int st_blksize; | |
| 30 | unsigned long int st_blocks; | |
| 31 | struct timespec st_atim; | |
| 32 | struct timespec st_mtim; | |
| 33 | struct timespec st_ctim; | |
| 34 | unsigned long int __glibc_reserved4; | |
| 35 | #define _HAVE___UNUSED4 | |
| 36 | unsigned long int __glibc_reserved5; | |
| 37 | #define _HAVE___UNUSED5 | |
| 38 | }; | |
| 39 | ||
| 40 | #define _HAVE_STAT___UNUSED4 | |
| 41 | #define _HAVE_STAT___UNUSED5 | |
| 42 | #define _HAVE_STAT___PAD1 | |
| 43 | #define _HAVE_STAT___PAD2 | |
| 44 | #define _HAVE_STAT_NSEC | |
| 45 | #define _HAVE_STAT64___UNUSED4 | |
| 46 | #define _HAVE_STAT64___UNUSED5 | |
| 47 | #define _HAVE_STAT64___PAD2 | |
| 48 | #define _HAVE_STAT64_NSEC | |
| 49 | ||
| 50 | #define STAT_IS_KERNEL_STAT 0 | |
| 51 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 52 | #define XSTAT_IS_XSTAT64 0 | |
| 53 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | /* Definition of `struct stat' used in the kernel.. */ | |
| 2 | struct kernel_stat | |
| 3 | { | |
| 4 | unsigned short int st_dev; | |
| 5 | unsigned short int __pad1; | |
| 6 | #define _HAVE___PAD1 | |
| 7 | unsigned long int st_ino; | |
| 8 | unsigned short int st_mode; | |
| 9 | unsigned short int st_nlink; | |
| 10 | unsigned short int st_uid; | |
| 11 | unsigned short int st_gid; | |
| 12 | unsigned short int st_rdev; | |
| 13 | unsigned short int __pad2; | |
| 14 | #define _HAVE___PAD2 | |
| 15 | unsigned long int st_size; | |
| 16 | unsigned long int st_blksize; | |
| 17 | unsigned long int st_blocks; | |
| 18 | struct timespec st_atim; | |
| 19 | struct timespec st_mtim; | |
| 20 | struct timespec st_ctim; | |
| 21 | unsigned long int __glibc_reserved4; | |
| 22 | #define _HAVE___UNUSED4 | |
| 23 | unsigned long int __glibc_reserved5; | |
| 24 | #define _HAVE___UNUSED5 | |
| 25 | }; | |
| 26 | ||
| 27 | #define _HAVE_STAT___UNUSED4 | |
| 28 | #define _HAVE_STAT___UNUSED5 | |
| 29 | #define _HAVE_STAT___PAD1 | |
| 30 | #define _HAVE_STAT___PAD2 | |
| 31 | #define _HAVE_STAT_NSEC | |
| 32 | #define _HAVE_STAT64___PAD1 | |
| 33 | #define _HAVE_STAT64___PAD2 | |
| 34 | #define _HAVE_STAT64___ST_INO | |
| 35 | #define _HAVE_STAT64_NSEC | |
| 36 | ||
| 37 | #define STAT_IS_KERNEL_STAT 0 | |
| 38 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 39 | #define XSTAT_IS_XSTAT64 0 | |
| 40 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/sh/kernel_stat.h created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | /* Definition of `struct stat' used in the kernel.. */ | |
| 2 | struct kernel_stat | |
| 3 | { | |
| 4 | unsigned short int st_dev; | |
| 5 | unsigned short int __pad1; | |
| 6 | #define _HAVE___PAD1 | |
| 7 | unsigned long int st_ino; | |
| 8 | unsigned short int st_mode; | |
| 9 | unsigned short int st_nlink; | |
| 10 | unsigned short int st_uid; | |
| 11 | unsigned short int st_gid; | |
| 12 | unsigned short int st_rdev; | |
| 13 | unsigned short int __pad2; | |
| 14 | #define _HAVE___PAD2 | |
| 15 | unsigned long int st_size; | |
| 16 | unsigned long int st_blksize; | |
| 17 | unsigned long int st_blocks; | |
| 18 | struct timespec st_atim; | |
| 19 | struct timespec st_mtim; | |
| 20 | struct timespec st_ctim; | |
| 21 | unsigned long int __glibc_reserved4; | |
| 22 | #define _HAVE___UNUSED4 | |
| 23 | unsigned long int __glibc_reserved5; | |
| 24 | #define _HAVE___UNUSED5 | |
| 25 | }; | |
| 26 | ||
| 27 | #define _HAVE_STAT___UNUSED4 | |
| 28 | #define _HAVE_STAT___UNUSED5 | |
| 29 | #define _HAVE_STAT___PAD1 | |
| 30 | #define _HAVE_STAT___PAD2 | |
| 31 | #define _HAVE_STAT_NSEC | |
| 32 | #define _HAVE_STAT64___PAD1 | |
| 33 | #define _HAVE_STAT64___PAD2 | |
| 34 | #define _HAVE_STAT64___ST_INO | |
| 35 | #define _HAVE_STAT64_NSEC | |
| 36 | ||
| 37 | #define STAT_IS_KERNEL_STAT 0 | |
| 38 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 39 | #define XSTAT_IS_XSTAT64 0 | |
| 40 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | /* Definition of `struct stat' used in the kernel */ | |
| 2 | struct kernel_stat | |
| 3 | { | |
| 4 | unsigned short int st_dev; | |
| 5 | unsigned long int st_ino; | |
| 6 | unsigned short int st_mode; | |
| 7 | short int st_nlink; | |
| 8 | unsigned short int st_uid; | |
| 9 | unsigned short int st_gid; | |
| 10 | unsigned short int st_rdev; | |
| 11 | long int st_size; | |
| 12 | struct timespec st_atim; | |
| 13 | struct timespec st_mtim; | |
| 14 | struct timespec st_ctim; | |
| 15 | long int st_blksize; | |
| 16 | long int st_blocks; | |
| 17 | unsigned long int __glibc_reserved4; | |
| 18 | unsigned long int __glibc_reserved5; | |
| 19 | }; | |
| 20 | ||
| 21 | #define _HAVE___UNUSED4 | |
| 22 | #define _HAVE___UNUSED5 | |
| 23 | ||
| 24 | #define _HAVE_STAT___UNUSED4 | |
| 25 | #define _HAVE_STAT___UNUSED5 | |
| 26 | #define _HAVE_STAT___PAD1 | |
| 27 | #define _HAVE_STAT___PAD2 | |
| 28 | #define _HAVE_STAT64___UNUSED4 | |
| 29 | #define _HAVE_STAT64___UNUSED5 | |
| 30 | #define _HAVE_STAT64___PAD2 | |
| 31 | #define _HAVE_STAT_NSEC | |
| 32 | #define _HAVE_STAT64_NSEC | |
| 33 | ||
| 34 | #define STAT_IS_KERNEL_STAT 0 | |
| 35 | #define STAT64_IS_KERNEL_STAT64 1 | |
| 36 | #define XSTAT_IS_XSTAT64 0 | |
| 37 | #define STATFS_IS_STATFS64 0 |
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h created+58| ... | ... | @@ -0,0 +1,58 @@ |
| 1 | #ifndef _KERNEL_STAT_H | |
| 2 | #define _KERNEL_STAT_H | |
| 3 | ||
| 4 | /* Definition of `struct stat' used in the kernel */ | |
| 5 | struct kernel_stat | |
| 6 | { | |
| 7 | unsigned int st_dev; | |
| 8 | unsigned long int st_ino; | |
| 9 | unsigned int st_mode; | |
| 10 | short int st_nlink; | |
| 11 | unsigned int st_uid; | |
| 12 | unsigned int st_gid; | |
| 13 | unsigned int st_rdev; | |
| 14 | long int st_size; | |
| 15 | long int st_atime_sec; | |
| 16 | long int st_mtime_sec; | |
| 17 | long int st_ctime_sec; | |
| 18 | long int st_blksize; | |
| 19 | long int st_blocks; | |
| 20 | unsigned long int __glibc_reserved1; | |
| 21 | unsigned long int __glibc_reserved2; | |
| 22 | }; | |
| 23 | ||
| 24 | /* Definition of `struct stat64' used in the kernel. */ | |
| 25 | struct kernel_stat64 | |
| 26 | { | |
| 27 | unsigned long int st_dev; | |
| 28 | unsigned long int st_ino; | |
| 29 | unsigned long int st_nlink; | |
| 30 | ||
| 31 | unsigned int st_mode; | |
| 32 | unsigned int st_uid; | |
| 33 | unsigned int st_gid; | |
| 34 | unsigned int __pad0; | |
| 35 | ||
| 36 | unsigned long int st_rdev; | |
| 37 | long int st_size; | |
| 38 | long int st_blksize; | |
| 39 | long int st_blocks; | |
| 40 | ||
| 41 | unsigned long int st_atime_sec; | |
| 42 | unsigned long int st_atime_nsec; | |
| 43 | unsigned long int st_mtime_sec; | |
| 44 | unsigned long int st_mtime_nsec; | |
| 45 | unsigned long int st_ctime_sec; | |
| 46 | unsigned long int st_ctime_nsec; | |
| 47 | long int __glibc_reserved[3]; | |
| 48 | }; | |
| 49 | ||
| 50 | #define STAT_IS_KERNEL_STAT 0 | |
| 51 | #define STAT64_IS_KERNEL_STAT64 0 | |
| 52 | #define XSTAT_IS_XSTAT64 1 | |
| 53 | #ifdef __arch64__ | |
| 54 | # define STATFS_IS_STATFS64 1 | |
| 55 | #else | |
| 56 | # define STATFS_IS_STATFS64 0 | |
| 57 | #endif | |
| 58 | #endif /* _KERNEL_STAT_H */ |
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h created+44| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | /* Struct kernel_stat64 to stat64. Linux/SPARC version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library. If not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #include <errno.h> | |
| 20 | ||
| 21 | static inline void | |
| 22 | __cp_stat64_kstat64 (struct stat64 *st64, const struct kernel_stat64 *kst64) | |
| 23 | { | |
| 24 | st64->st_dev = kst64->st_dev; | |
| 25 | st64->__pad1 = 0; | |
| 26 | st64->st_ino = kst64->st_ino; | |
| 27 | st64->st_mode = kst64->st_mode; | |
| 28 | st64->st_nlink = kst64->st_nlink; | |
| 29 | st64->st_uid = kst64->st_uid; | |
| 30 | st64->st_gid = kst64->st_gid; | |
| 31 | st64->st_rdev = kst64->st_rdev; | |
| 32 | st64->__pad2 = 0; | |
| 33 | st64->st_size = kst64->st_size; | |
| 34 | st64->st_blksize = kst64->st_blksize; | |
| 35 | st64->st_blocks = kst64->st_blocks; | |
| 36 | st64->st_atim.tv_sec = kst64->st_atime_sec; | |
| 37 | st64->st_atim.tv_nsec = kst64->st_atime_nsec; | |
| 38 | st64->st_mtim.tv_sec = kst64->st_mtime_sec; | |
| 39 | st64->st_mtim.tv_nsec = kst64->st_mtime_nsec; | |
| 40 | st64->st_ctim.tv_sec = kst64->st_ctime_sec; | |
| 41 | st64->st_ctim.tv_nsec = kst64->st_ctime_nsec; | |
| 42 | st64->__glibc_reserved4 = 0; | |
| 43 | st64->__glibc_reserved5 = 0; | |
| 44 | } |
lib/libc/glibc/sysdeps/unix/sysv/linux/stat.c created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | /* Get file status. Linux version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #include <sys/stat.h> | |
| 20 | #include <fcntl.h> | |
| 21 | #include <kernel_stat.h> | |
| 22 | ||
| 23 | #if !XSTAT_IS_XSTAT64 | |
| 24 | int | |
| 25 | __stat (const char *file, struct stat *buf) | |
| 26 | { | |
| 27 | return __fstatat (AT_FDCWD, file, buf, 0); | |
| 28 | } | |
| 29 | ||
| 30 | weak_alias (__stat, stat) | |
| 31 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/stat64.c created+52| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | /* Get file status. Linux version. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library; if not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #define __stat __redirect___stat | |
| 20 | #define stat __redirect_stat | |
| 21 | #include <sys/stat.h> | |
| 22 | #include <fcntl.h> | |
| 23 | #include <kernel_stat.h> | |
| 24 | #include <stat_t64_cp.h> | |
| 25 | ||
| 26 | int | |
| 27 | __stat64_time64 (const char *file, struct __stat64_t64 *buf) | |
| 28 | { | |
| 29 | return __fstatat64_time64 (AT_FDCWD, file, buf, 0); | |
| 30 | } | |
| 31 | #if __TIMESIZE != 64 | |
| 32 | hidden_def (__stat64_time64) | |
| 33 | ||
| 34 | int | |
| 35 | __stat64 (const char *file, struct stat64 *buf) | |
| 36 | { | |
| 37 | struct __stat64_t64 st_t64; | |
| 38 | return __stat64_time64 (file, &st_t64) | |
| 39 | 	 ?: __cp_stat64_t64_stat64 (&st_t64, buf); | |
| 40 | } | |
| 41 | #endif | |
| 42 | ||
| 43 | #undef __stat | |
| 44 | #undef stat | |
| 45 | ||
| 46 | hidden_def (__stat64) | |
| 47 | weak_alias (__stat64, stat64) | |
| 48 | ||
| 49 | #if XSTAT_IS_XSTAT64 | |
| 50 | strong_alias (__stat64, __stat) | |
| 51 | weak_alias (__stat64, stat) | |
| 52 | #endif |
lib/libc/glibc/sysdeps/unix/sysv/linux/stat_t64_cp.h created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | /* Copy to/from struct stat with and without 64-bit time_t support. | |
| 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. | |
| 3 | This file is part of the GNU C Library. | |
| 4 | ||
| 5 | The GNU C Library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | ||
| 10 | The GNU C Library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with the GNU C Library. If not, see | |
| 17 | <https://www.gnu.org/licenses/>. */ | |
| 18 | ||
| 19 | #include <sys/stat.h> | |
| 20 | ||
| 21 | #if __TIMESIZE != 64 | |
| 22 | extern int __cp_stat64_t64_stat64 (const struct __stat64_t64 *st64_t64, | |
| 23 | 				 struct stat64 *st64) | |
| 24 | attribute_hidden; | |
| 25 | #endif |
src/glibc.zig+18-16| ... | ... | @@ -269,23 +269,25 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 269 | 269 | return comp.build_crt_file("Scrt1", .Obj, &[_]Compilation.CSourceFile{ start_os, abi_note_o }); |
| 270 | 270 | }, |
| 271 | 271 | .libc_nonshared_a => { |
| 272 | const s = path.sep_str; | |
| 273 | const linux_prefix = lib_libc_glibc ++ | |
| 274 | "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s; | |
| 272 | 275 | const deps = [_][]const u8{ |
| 273 | lib_libc_glibc ++ "stdlib" ++ path.sep_str ++ "atexit.c", | |
| 274 | lib_libc_glibc ++ "stdlib" ++ path.sep_str ++ "at_quick_exit.c", | |
| 275 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "stat.c", | |
| 276 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "fstat.c", | |
| 277 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "lstat.c", | |
| 278 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "stat64.c", | |
| 279 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "fstat64.c", | |
| 280 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "lstat64.c", | |
| 281 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "fstatat.c", | |
| 282 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "fstatat64.c", | |
| 283 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "mknod.c", | |
| 284 | lib_libc_glibc ++ "io" ++ path.sep_str ++ "mknodat.c", | |
| 285 | lib_libc_glibc ++ "sysdeps" ++ path.sep_str ++ "pthread" ++ path.sep_str ++ | |
| 286 | "pthread_atfork.c", | |
| 287 | lib_libc_glibc ++ "debug" ++ path.sep_str ++ "stack_chk_fail_local.c", | |
| 288 | lib_libc_glibc ++ "csu" ++ path.sep_str ++ "errno.c", | |
| 276 | lib_libc_glibc ++ "stdlib" ++ s ++ "atexit.c", | |
| 277 | lib_libc_glibc ++ "stdlib" ++ s ++ "at_quick_exit.c", | |
| 278 | linux_prefix ++ "stat.c", | |
| 279 | linux_prefix ++ "fstat.c", | |
| 280 | linux_prefix ++ "lstat.c", | |
| 281 | linux_prefix ++ "stat64.c", | |
| 282 | linux_prefix ++ "fstat64.c", | |
| 283 | linux_prefix ++ "lstat64.c", | |
| 284 | linux_prefix ++ "fstatat.c", | |
| 285 | linux_prefix ++ "fstatat64.c", | |
| 286 | linux_prefix ++ "mknodat.c", | |
| 287 | lib_libc_glibc ++ "io" ++ s ++ "mknod.c", | |
| 288 | lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread" ++ s ++ "pthread_atfork.c", | |
| 289 | lib_libc_glibc ++ "debug" ++ s ++ "stack_chk_fail_local.c", | |
| 290 | lib_libc_glibc ++ "csu" ++ s ++ "errno.c", | |
| 289 | 291 | }; |
| 290 | 292 | |
| 291 | 293 | var c_source_files: [deps.len]Compilation.CSourceFile = undefined; |