1 | /* Struct stat with 64-bit time 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 | #ifndef _BITS_STRUCT_STAT_TIME64_H |
20 | #define _BITS_STRUCT_STAT_TIME64_H 1 |
21 | |
22 | #if __TIMESIZE == 64 |
23 | # define __stat64_t64 stat64 |
24 | #else |
25 | # ifdef __USE_LARGEFILE64 |
26 | # include <endian.h> |
27 | |
28 | /* The definition should be equal to the 'struct __timespec64' internal |
29 | layout. */ |
30 | # if BYTE_ORDER == BIG_ENDIAN |
31 | # define __fieldts64(name) \ |
32 | __time64_t name; __int32_t :32; __int32_t name ## nsec |
33 | # else |
34 | # define __fieldts64(name) \ |
35 | __time64_t name; __int32_t name ## nsec; __int32_t :32 |
36 | # endif |
37 | |
38 | /* Workaround for the definition from struct_stat.h */ |
39 | # undef st_atime |
40 | # undef st_mtime |
41 | # undef st_ctime |
42 | |
43 | struct __stat64_t64 |
44 | { |
45 | __dev_t st_dev; /* Device. */ |
46 | __ino64_t st_ino; /* file serial number. */ |
47 | __mode_t st_mode; /* File mode. */ |
48 | __nlink_t st_nlink; /* Link count. */ |
49 | __uid_t st_uid; /* User ID of the file's owner. */ |
50 | __gid_t st_gid; /* Group ID of the file's group.*/ |
51 | __dev_t st_rdev; /* Device number, if device. */ |
52 | __off64_t st_size; /* Size of file, in bytes. */ |
53 | __blksize_t st_blksize; /* Optimal block size for I/O. */ |
54 | __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ |
55 | # ifdef __USE_XOPEN2K8 |
56 | /* Nanosecond resolution timestamps are stored in a format |
57 | equivalent to 'struct timespec'. This is the type used |
58 | whenever possible but the Unix namespace rules do not allow the |
59 | identifier 'timespec' to appear in the <sys/stat.h> header. |
60 | Therefore we have to handle the use of this header in strictly |
61 | standard-compliant sources special. */ |
62 | struct __timespec64 st_atim; /* Time of last access. */ |
63 | struct __timespec64 st_mtim; /* Time of last modification. */ |
64 | struct __timespec64 st_ctim; /* Time of last status change. */ |
65 | # define st_atime st_atim.tv_sec /* Backward compatibility. */ |
66 | # define st_mtime st_mtim.tv_sec |
67 | # define st_ctime st_ctim.tv_sec |
68 | # else |
69 | __fieldts64 (st_atime); |
70 | __fieldts64 (st_mtime); |
71 | __fieldts64 (st_ctime); |
72 | # endif /* __USE_XOPEN2K8 */ |
73 | }; |
74 | |
75 | # define _STATBUF_ST_BLKSIZE |
76 | # define _STATBUF_ST_RDEV |
77 | # define _STATBUF_ST_NSEC |
78 | |
79 | # undef __fieldts64 |
80 | |
81 | # endif /* __USE_LARGEFILE64 */ |
82 | |
83 | # endif /* __TIMESIZE == 64 */ |
84 | |
85 | #endif /* _BITS_STRUCT_STAT_TIME64_H */ |
86 | |