1 | /* Convert between `struct stat' format, and `struct stat64' format. |
---|---|
2 | Copyright (C) 2000-2024 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 | #include <sys/stat.h> |
21 | #include <hurd.h> |
22 | |
23 | static inline int |
24 | stat64_conv (struct stat *buf, const struct stat64 *buf64) |
25 | { |
26 | if (sizeof *buf == sizeof *buf64 |
27 | && sizeof buf->st_ino == sizeof buf64->st_ino |
28 | && sizeof buf->st_size == sizeof buf64->st_size |
29 | && sizeof buf->st_blocks == sizeof buf64->st_blocks) |
30 | { |
31 | *buf = *(struct stat *) buf64; |
32 | return 0; |
33 | } |
34 | |
35 | buf->st_fstype = buf64->st_fstype; |
36 | buf->st_fsid = buf64->st_fsid; |
37 | buf->st_ino = buf64->st_ino; |
38 | buf->st_gen = buf64->st_gen; |
39 | buf->st_rdev = buf64->st_rdev; |
40 | buf->st_mode = buf64->st_mode; |
41 | buf->st_nlink = buf64->st_nlink; |
42 | buf->st_uid = buf64->st_uid; |
43 | buf->st_gid = buf64->st_gid; |
44 | buf->st_size = buf64->st_size; |
45 | buf->st_atim = buf64->st_atim; |
46 | buf->st_mtim = buf64->st_mtim; |
47 | buf->st_ctim = buf64->st_ctim; |
48 | buf->st_blksize = buf64->st_blksize; |
49 | buf->st_blocks = buf64->st_blocks; |
50 | buf->st_author = buf64->st_author; |
51 | buf->st_flags = buf64->st_flags; |
52 | |
53 | if ((sizeof buf->st_ino != sizeof buf64->st_ino |
54 | && buf->st_ino != buf64->st_ino) |
55 | || (sizeof buf->st_size != sizeof buf64->st_size |
56 | && buf->st_size != buf64->st_size) |
57 | || (sizeof buf->st_blocks != sizeof buf64->st_blocks |
58 | && buf->st_blocks != buf64->st_blocks)) |
59 | return __hurd_fail (EOVERFLOW); |
60 | |
61 | return 0; |
62 | } |
63 |