]>
Commit | Line | Data |
---|---|---|
6bbfc5c0 | 1 | /* Struct statx to stat/stat64 conversion for Linux. |
d614a753 | 2 | Copyright (C) 2018-2020 Free Software Foundation, Inc. |
6bbfc5c0 MH |
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 | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
6bbfc5c0 MH |
18 | |
19 | #include <stddef.h> | |
20 | #include <string.h> | |
21 | #include <sys/stat.h> | |
22 | ||
23 | #include <statx_cp.h> | |
24 | ||
25 | #if !defined(__NR_fstat64) || !defined(__NR_fstatat64) | |
26 | void | |
27 | __cp_stat64_statx (struct stat64 *to, struct statx *from) | |
28 | { | |
29 | memset (to, 0, sizeof (struct stat64)); | |
30 | to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8) | |
31 | | ((from->stx_dev_minor & ~0xff) << 12)); | |
32 | to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8) | |
33 | | ((from->stx_rdev_minor & ~0xff) << 12)); | |
34 | to->st_ino = from->stx_ino; | |
35 | to->st_mode = from->stx_mode; | |
36 | to->st_nlink = from->stx_nlink; | |
37 | to->st_uid = from->stx_uid; | |
38 | to->st_gid = from->stx_gid; | |
39 | to->st_atime = from->stx_atime.tv_sec; | |
40 | to->st_atim.tv_nsec = from->stx_atime.tv_nsec; | |
41 | to->st_mtime = from->stx_mtime.tv_sec; | |
42 | to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec; | |
43 | to->st_ctime = from->stx_ctime.tv_sec; | |
44 | to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec; | |
45 | to->st_size = from->stx_size; | |
46 | to->st_blocks = from->stx_blocks; | |
47 | to->st_blksize = from->stx_blksize; | |
48 | } | |
49 | #endif | |
aa03f722 AZ |
50 | |
51 | #if (__WORDSIZE == 32 \ | |
52 | && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) | |
53 | void | |
54 | __cp_stat64_t64_statx (struct __stat64_t64 *to, const struct statx *from) | |
55 | { | |
56 | /* Clear both pad and reserved fields. */ | |
57 | memset (to, 0, sizeof (*to)); | |
58 | ||
59 | to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8) | |
60 | | ((from->stx_dev_minor & ~0xff) << 12)); | |
61 | to->st_ino = from->stx_ino; | |
62 | to->st_mode = from->stx_mode; | |
63 | to->st_nlink = from->stx_nlink; | |
64 | to->st_uid = from->stx_uid; | |
65 | to->st_gid = from->stx_gid; | |
66 | to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8) | |
67 | | ((from->stx_rdev_minor & ~0xff) << 12)); | |
68 | to->st_size = from->stx_size; | |
69 | to->st_blksize = from->stx_blksize; | |
70 | to->st_blocks = from->stx_blocks; | |
71 | ||
72 | to->st_atime = from->stx_atime.tv_sec; | |
73 | to->st_atim.tv_nsec = from->stx_atime.tv_nsec; | |
74 | to->st_mtime = from->stx_mtime.tv_sec; | |
75 | to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec; | |
76 | to->st_ctime = from->stx_ctime.tv_sec; | |
77 | to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec; | |
78 | } | |
79 | #endif |