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