]>
Commit | Line | Data |
---|---|---|
6073bae6 | 1 | /* Struct stat/stat64 to stat/stat64 conversion for Linux. |
2b778ceb | 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. |
6073bae6 AZ |
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 | ||
cb49c65b | 22 | static inline long int |
6073bae6 AZ |
23 | __cp_kstat_stat (const struct kernel_stat *kst, struct stat *st) |
24 | { | |
aa03f722 AZ |
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)) | |
cb49c65b | 28 | return -EOVERFLOW; |
aa03f722 | 29 | |
6073bae6 AZ |
30 | st->st_dev = kst->st_dev; |
31 | memset (&st->st_pad1, 0, sizeof (st->st_pad1)); | |
32 | st->st_ino = kst->st_ino; | |
6073bae6 AZ |
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; | |
6073bae6 AZ |
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; | |
6073bae6 AZ |
49 | memset (&st->st_pad5, 0, sizeof (st->st_pad5)); |
50 | ||
51 | return 0; | |
52 | } | |
53 | ||
cb49c65b | 54 | static inline void |
aa03f722 | 55 | __cp_kstat_stat64_t64 (const struct kernel_stat *kst, struct __stat64_t64 *st) |
6073bae6 AZ |
56 | { |
57 | st->st_dev = kst->st_dev; | |
6073bae6 AZ |
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; | |
6073bae6 AZ |
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; | |
6073bae6 | 73 | } |