1 /* Definition for struct stat.
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 #if !defined _SYS_STAT_H && !defined _FCNTL_H
20 # error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
21 #endif
22 
23 #ifndef _BITS_STRUCT_STAT_H
24 #define _BITS_STRUCT_STAT_H	1
25 
26 #include <sgidefs.h>
27 
28 #if _MIPS_SIM == _ABIO32
29 /* Structure describing file characteristics.  */
30 struct stat
31   {
32 # ifdef __USE_TIME_BITS64
33 #  include <bits/struct_stat_time64_helper.h>
34 # else
35     unsigned long int st_dev;
36     long int st_pad1[3];
37 #  ifndef __USE_FILE_OFFSET64
38     __ino_t st_ino;		/* File serial number.		*/
39 #  else
40     __ino64_t st_ino;		/* File serial number.		*/
41 #  endif
42     __mode_t st_mode;		/* File mode.  */
43     __nlink_t st_nlink;		/* Link count.  */
44     __uid_t st_uid;		/* User ID of the file's owner.	*/
45     __gid_t st_gid;		/* Group ID of the file's group.*/
46     unsigned long int st_rdev;	/* Device number, if device.  */
47 #  ifndef __USE_FILE_OFFSET64
48     long int st_pad2[2];
49     __off_t st_size;		/* Size of file, in bytes.  */
50     /* SVR4 added this extra long to allow for expansion of off_t.  */
51     long int st_pad3;
52 #  else
53     long int st_pad2[3];
54     __off64_t st_size;		/* Size of file, in bytes.  */
55 #  endif
56 #  ifdef __USE_XOPEN2K8
57     /* Nanosecond resolution timestamps are stored in a format
58        equivalent to 'struct timespec'.  This is the type used
59        whenever possible but the Unix namespace rules do not allow the
60        identifier 'timespec' to appear in the <sys/stat.h> header.
61        Therefore we have to handle the use of this header in strictly
62        standard-compliant sources special.  */
63     struct timespec st_atim;            /* Time of last access.  */
64     struct timespec st_mtim;            /* Time of last modification.  */
65     struct timespec st_ctim;            /* Time of last status change.  */
66 #   define st_atime st_atim.tv_sec        /* Backward compatibility.  */
67 #   define st_mtime st_mtim.tv_sec
68 #   define st_ctime st_ctim.tv_sec
69 #  else
70     __time_t st_atime;			/* Time of last access.  */
71     unsigned long int st_atimensec;	/* Nscecs of last access.  */
72     __time_t st_mtime;			/* Time of last modification.  */
73     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
74     __time_t st_ctime;			/* Time of last status change.  */
75     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
76 #  endif
77     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
78 #  ifndef __USE_FILE_OFFSET64
79     __blkcnt_t st_blocks;	/* Number of 512-byte blocks allocated.  */
80 #  else
81     long int st_pad4;
82     __blkcnt64_t st_blocks;	/* Number of 512-byte blocks allocated.  */
83 #  endif
84     long int st_pad5[14];
85 # endif /* __USE_TIME_BITS64  */
86   };
87 
88 # ifdef __USE_LARGEFILE64
89 struct stat64
90   {
91 #  ifdef __USE_TIME_BITS64
92 #   include <bits/struct_stat_time64_helper.h>
93 #  else
94     unsigned long int st_dev;
95     long int st_pad1[3];
96     __ino64_t st_ino;		/* File serial number.		*/
97     __mode_t st_mode;		/* File mode.  */
98     __nlink_t st_nlink;		/* Link count.  */
99     __uid_t st_uid;		/* User ID of the file's owner.	*/
100     __gid_t st_gid;		/* Group ID of the file's group.*/
101     unsigned long int st_rdev;	/* Device number, if device.  */
102     long int st_pad2[3];
103     __off64_t st_size;		/* Size of file, in bytes.  */
104 #   ifdef __USE_XOPEN2K8
105     /* Nanosecond resolution timestamps are stored in a format
106        equivalent to 'struct timespec'.  This is the type used
107        whenever possible but the Unix namespace rules do not allow the
108        identifier 'timespec' to appear in the <sys/stat.h> header.
109        Therefore we have to handle the use of this header in strictly
110        standard-compliant sources special.  */
111     struct timespec st_atim;            /* Time of last access.  */
112     struct timespec st_mtim;            /* Time of last modification.  */
113     struct timespec st_ctim;            /* Time of last status change.  */
114 #   else
115     __time_t st_atime;			/* Time of last access.  */
116     unsigned long int st_atimensec;	/* Nscecs of last access.  */
117     __time_t st_mtime;			/* Time of last modification.  */
118     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
119     __time_t st_ctime;			/* Time of last status change.  */
120     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
121 #   endif
122     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
123     long int st_pad3;
124     __blkcnt64_t st_blocks;	/* Number of 512-byte blocks allocated.  */
125     long int st_pad4[14];
126 #  endif /* __USE_TIME_BITS64  */
127   };
128 # endif /* __USE_LARGEFILE64  */
129 
130 #else /* _MIPS_SIM != _ABIO32  */
131 
132 struct stat
133   {
134     __dev_t st_dev;
135     int	st_pad1[3];		/* Reserved for st_dev expansion  */
136 # ifndef __USE_FILE_OFFSET64
137     __ino_t st_ino;
138 # else
139     __ino64_t st_ino;
140 # endif
141     __mode_t st_mode;
142     __nlink_t st_nlink;
143     __uid_t st_uid;
144     __gid_t st_gid;
145     __dev_t st_rdev;
146 # if !defined __USE_FILE_OFFSET64
147     unsigned int st_pad2[2];	/* Reserved for st_rdev expansion  */
148     __off_t st_size;
149     int st_pad3;
150 # else
151     unsigned int st_pad2[3];	/* Reserved for st_rdev expansion  */
152     __off64_t st_size;
153 # endif
154 # ifdef __USE_XOPEN2K8
155     /* Nanosecond resolution timestamps are stored in a format
156        equivalent to 'struct timespec'.  This is the type used
157        whenever possible but the Unix namespace rules do not allow the
158        identifier 'timespec' to appear in the <sys/stat.h> header.
159        Therefore we have to handle the use of this header in strictly
160        standard-compliant sources special.  */
161     struct timespec st_atim;            /* Time of last access.  */
162     struct timespec st_mtim;            /* Time of last modification.  */
163     struct timespec st_ctim;            /* Time of last status change.  */
164 #  define st_atime st_atim.tv_sec        /* Backward compatibility.  */
165 #  define st_mtime st_mtim.tv_sec
166 #  define st_ctime st_ctim.tv_sec
167 # else
168     __time_t st_atime;			/* Time of last access.  */
169     unsigned long int st_atimensec;	/* Nscecs of last access.  */
170     __time_t st_mtime;			/* Time of last modification.  */
171     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
172     __time_t st_ctime;			/* Time of last status change.  */
173     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
174 # endif
175     __blksize_t st_blksize;
176     unsigned int st_pad4;
177 # ifndef __USE_FILE_OFFSET64
178     __blkcnt_t st_blocks;
179 # else
180     __blkcnt64_t st_blocks;
181 # endif
182     int st_pad5[14];
183   };
184 
185 #ifdef __USE_LARGEFILE64
186 struct stat64
187   {
188     __dev_t st_dev;
189     unsigned int st_pad1[3];	/* Reserved for st_dev expansion  */
190     __ino64_t st_ino;
191     __mode_t st_mode;
192     __nlink_t st_nlink;
193     __uid_t st_uid;
194     __gid_t st_gid;
195     __dev_t st_rdev;
196     unsigned int st_pad2[3];	/* Reserved for st_rdev expansion  */
197     __off64_t st_size;
198 #  ifdef __USE_XOPEN2K8
199     /* Nanosecond resolution timestamps are stored in a format
200        equivalent to 'struct timespec'.  This is the type used
201        whenever possible but the Unix namespace rules do not allow the
202        identifier 'timespec' to appear in the <sys/stat.h> header.
203        Therefore we have to handle the use of this header in strictly
204        standard-compliant sources special.  */
205     struct timespec st_atim;            /* Time of last access.  */
206     struct timespec st_mtim;            /* Time of last modification.  */
207     struct timespec st_ctim;            /* Time of last status change.  */
208 #  else
209     __time_t st_atime;			/* Time of last access.  */
210     unsigned long int st_atimensec;	/* Nscecs of last access.  */
211     __time_t st_mtime;			/* Time of last modification.  */
212     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
213     __time_t st_ctime;			/* Time of last status change.  */
214     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
215 #  endif
216     __blksize_t st_blksize;
217     unsigned int st_pad3;
218     __blkcnt64_t st_blocks;
219     int st_pad4[14];
220 };
221 #endif
222 
223 #endif
224 
225 /* Tell code we have these members.  */
226 #define	_STATBUF_ST_BLKSIZE
227 #define	_STATBUF_ST_RDEV
228 
229 #endif /* _BITS_STRUCT_STAT_H  */
230