]>
Commit | Line | Data |
---|---|---|
fd811dc6 | 1 | /* Convert between `struct stat' format, and `struct stat64' format. |
04277e02 | 2 | Copyright (C) 2000-2019 Free Software Foundation, Inc. |
fd811dc6 MK |
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 | |
41bdb6e2 AJ |
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. | |
fd811dc6 MK |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
fd811dc6 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
fd811dc6 | 18 | |
337738b7 | 19 | #include <errno.h> |
fd811dc6 MK |
20 | #include <sys/stat.h> |
21 | ||
337738b7 RM |
22 | static inline int |
23 | xstat64_conv (struct stat *buf, const struct stat64 *buf64) | |
fd811dc6 | 24 | { |
337738b7 RM |
25 | if (sizeof *buf == sizeof *buf64 |
26 | && sizeof buf->st_ino == sizeof buf64->st_ino | |
27 | && sizeof buf->st_size == sizeof buf64->st_size | |
28 | && sizeof buf->st_blocks == sizeof buf64->st_blocks) | |
29 | { | |
30 | *buf = *(struct stat *) buf64; | |
31 | return 0; | |
32 | } | |
33 | ||
34 | buf->st_fstype = buf64->st_fstype; | |
35 | buf->st_fsid = buf64->st_fsid; | |
36 | buf->st_ino = buf64->st_ino; | |
37 | buf->st_gen = buf64->st_gen; | |
38 | buf->st_rdev = buf64->st_rdev; | |
39 | buf->st_mode = buf64->st_mode; | |
40 | buf->st_nlink = buf64->st_nlink; | |
41 | buf->st_uid = buf64->st_uid; | |
42 | buf->st_gid = buf64->st_gid; | |
43 | buf->st_size = buf64->st_size; | |
8e41b99f TS |
44 | buf->st_atim = buf64->st_atim; |
45 | buf->st_mtim = buf64->st_mtim; | |
46 | buf->st_ctim = buf64->st_ctim; | |
337738b7 RM |
47 | buf->st_blksize = buf64->st_blksize; |
48 | buf->st_blocks = buf64->st_blocks; | |
49 | buf->st_author = buf64->st_author; | |
50 | buf->st_flags = buf64->st_flags; | |
51 | ||
52 | if ((sizeof buf->st_ino != sizeof buf64->st_ino | |
53 | && buf->st_ino != buf64->st_ino) | |
54 | || (sizeof buf->st_size != sizeof buf64->st_size | |
55 | && buf->st_size != buf64->st_size) | |
56 | || (sizeof buf->st_blocks != sizeof buf64->st_blocks | |
57 | && buf->st_blocks != buf64->st_blocks)) | |
58 | { | |
59 | __set_errno (EOVERFLOW); | |
60 | return -1; | |
61 | } | |
62 | ||
63 | return 0; | |
fd811dc6 | 64 | } |