]>
Commit | Line | Data |
---|---|---|
d8927238 | 1 | /* Definition for struct stat. |
dff8da6b | 2 | Copyright (C) 2020-2024 Free Software Foundation, Inc. |
e2d69068 AS |
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 | |
3214b89b 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. | |
e2d69068 AS |
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 | |
3214b89b | 13 | Lesser General Public License for more details. |
e2d69068 | 14 | |
3214b89b | 15 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff | 16 | License along with the GNU C Library. If not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
e2d69068 | 18 | |
2f12146a | 19 | #if !defined _SYS_STAT_H && !defined _FCNTL_H |
d8927238 | 20 | # error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead." |
e2d69068 AS |
21 | #endif |
22 | ||
d8927238 AZ |
23 | #ifndef _BITS_STRUCT_STAT_H |
24 | #define _BITS_STRUCT_STAT_H 1 | |
25 | ||
26 | #include <bits/endian.h> | |
27 | #include <bits/wordsize.h> | |
fdefc0e1 | 28 | |
7a6ca82f AZ |
29 | #if defined __USE_FILE_OFFSET64 |
30 | # define __field64(type, type64, name) type64 name | |
31 | #elif __WORDSIZE == 64 || defined __INO_T_MATCHES_INO64_T | |
32 | # if defined __INO_T_MATCHES_INO64_T && !defined __OFF_T_MATCHES_OFF64_T | |
33 | # error "ino_t and off_t must both be the same type" | |
4e852133 | 34 | # endif |
7a6ca82f AZ |
35 | # define __field64(type, type64, name) type name |
36 | #elif __BYTE_ORDER == __LITTLE_ENDIAN | |
37 | # define __field64(type, type64, name) \ | |
38 | type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad | |
39 | #else | |
40 | # define __field64(type, type64, name) \ | |
41 | int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name | |
42 | #endif | |
e2d69068 | 43 | |
7a6ca82f AZ |
44 | struct stat |
45 | { | |
46 | __dev_t st_dev; /* Device. */ | |
47 | __field64(__ino_t, __ino64_t, st_ino); /* File serial number. */ | |
48 | __mode_t st_mode; /* File mode. */ | |
49 | __nlink_t st_nlink; /* Link count. */ | |
50 | __uid_t st_uid; /* User ID of the file's owner. */ | |
51 | __gid_t st_gid; /* Group ID of the file's group.*/ | |
52 | __dev_t st_rdev; /* Device number, if device. */ | |
53 | __dev_t __pad1; | |
54 | __field64(__off_t, __off64_t, st_size); /* Size of file, in bytes. */ | |
55 | __blksize_t st_blksize; /* Optimal block size for I/O. */ | |
56 | int __pad2; | |
57 | __field64(__blkcnt_t, __blkcnt64_t, st_blocks); /* 512-byte blocks */ | |
58 | #ifdef __USE_XOPEN2K8 | |
2bf8a54e AS |
59 | /* Nanosecond resolution timestamps are stored in a format |
60 | equivalent to 'struct timespec'. This is the type used | |
61 | whenever possible but the Unix namespace rules do not allow the | |
62 | identifier 'timespec' to appear in the <sys/stat.h> header. | |
63 | Therefore we have to handle the use of this header in strictly | |
64 | standard-compliant sources special. */ | |
65 | struct timespec st_atim; /* Time of last access. */ | |
66 | struct timespec st_mtim; /* Time of last modification. */ | |
67 | struct timespec st_ctim; /* Time of last status change. */ | |
7a6ca82f AZ |
68 | # define st_atime st_atim.tv_sec /* Backward compatibility. */ |
69 | # define st_mtime st_mtim.tv_sec | |
70 | # define st_ctime st_ctim.tv_sec | |
71 | #else | |
e2d69068 | 72 | __time_t st_atime; /* Time of last access. */ |
2bf8a54e | 73 | unsigned long int st_atimensec; /* Nscecs of last access. */ |
e2d69068 | 74 | __time_t st_mtime; /* Time of last modification. */ |
2bf8a54e | 75 | unsigned long int st_mtimensec; /* Nsecs of last modification. */ |
e2d69068 | 76 | __time_t st_ctime; /* Time of last status change. */ |
2bf8a54e | 77 | unsigned long int st_ctimensec; /* Nsecs of last status change. */ |
7a6ca82f AZ |
78 | #endif |
79 | int __glibc_reserved[2]; | |
e2d69068 AS |
80 | }; |
81 | ||
7a6ca82f AZ |
82 | #undef __field64 |
83 | ||
e2d69068 AS |
84 | #ifdef __USE_LARGEFILE64 |
85 | struct stat64 | |
86 | { | |
7a6ca82f AZ |
87 | __dev_t st_dev; /* Device. */ |
88 | __ino64_t st_ino; /* File serial number. */ | |
89 | __mode_t st_mode; /* File mode. */ | |
90 | __nlink_t st_nlink; /* Link count. */ | |
91 | __uid_t st_uid; /* User ID of the file's owner. */ | |
92 | __gid_t st_gid; /* Group ID of the file's group.*/ | |
93 | __dev_t st_rdev; /* Device number, if device. */ | |
94 | __dev_t __pad1; | |
95 | __off64_t st_size; /* Size of file, in bytes. */ | |
96 | __blksize_t st_blksize; /* Optimal block size for I/O. */ | |
97 | int __pad2; | |
98 | __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */ | |
99 | #ifdef __USE_XOPEN2K8 | |
2bf8a54e AS |
100 | /* Nanosecond resolution timestamps are stored in a format |
101 | equivalent to 'struct timespec'. This is the type used | |
102 | whenever possible but the Unix namespace rules do not allow the | |
103 | identifier 'timespec' to appear in the <sys/stat.h> header. | |
104 | Therefore we have to handle the use of this header in strictly | |
105 | standard-compliant sources special. */ | |
106 | struct timespec st_atim; /* Time of last access. */ | |
107 | struct timespec st_mtim; /* Time of last modification. */ | |
108 | struct timespec st_ctim; /* Time of last status change. */ | |
7a6ca82f | 109 | #else |
e2d69068 | 110 | __time_t st_atime; /* Time of last access. */ |
2bf8a54e | 111 | unsigned long int st_atimensec; /* Nscecs of last access. */ |
e2d69068 | 112 | __time_t st_mtime; /* Time of last modification. */ |
2bf8a54e | 113 | unsigned long int st_mtimensec; /* Nsecs of last modification. */ |
e2d69068 | 114 | __time_t st_ctime; /* Time of last status change. */ |
2bf8a54e | 115 | unsigned long int st_ctimensec; /* Nsecs of last status change. */ |
7a6ca82f AZ |
116 | #endif |
117 | int __glibc_reserved[2]; | |
e2d69068 AS |
118 | }; |
119 | #endif | |
120 | ||
121 | /* Tell code we have these members. */ | |
122 | #define _STATBUF_ST_BLKSIZE | |
123 | #define _STATBUF_ST_RDEV | |
66f558e1 UD |
124 | /* Nanosecond resolution time values are supported. */ |
125 | #define _STATBUF_ST_NSEC | |
e2d69068 | 126 | |
d8927238 | 127 | #endif /* _BITS_STRUCT_STAT_H */ |