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 struct stat
27   {
28     __dev_t st_dev;		/* Device.  */
29     __ino_t st_ino;		/* File serial number.	*/
30     __nlink_t st_nlink;		/* Link count.  */
31     __mode_t st_mode;		/* File mode.  */
32     __uid_t st_uid;		/* User ID of the file's owner.	*/
33     __gid_t st_gid;		/* Group ID of the file's group.*/
34     int __glibc_reserved0;
35     __dev_t st_rdev;		/* Device number, if device.  */
36     __off_t st_size;		/* Size of file, in bytes.  */
37 #ifdef __USE_XOPEN2K8
38     /* Nanosecond resolution timestamps are stored in a format
39        equivalent to 'struct timespec'.  This is the type used
40        whenever possible but the Unix namespace rules do not allow the
41        identifier 'timespec' to appear in the <sys/stat.h> header.
42        Therefore we have to handle the use of this header in strictly
43        standard-compliant sources special.  */
44     struct timespec st_atim;		/* Time of last access.  */
45     struct timespec st_mtim;		/* Time of last modification.  */
46     struct timespec st_ctim;		/* Time of last status change.  */
47 # define st_atime st_atim.tv_sec	/* Backward compatibility.  */
48 # define st_mtime st_mtim.tv_sec
49 # define st_ctime st_ctim.tv_sec
50 #else
51     __time_t st_atime;			/* Time of last access.  */
52     unsigned long int st_atimensec;	/* Nscecs of last access.  */
53     __time_t st_mtime;			/* Time of last modification.  */
54     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
55     __time_t st_ctime;			/* Time of last status change.  */
56     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
57 #endif
58     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
59     __blkcnt_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
60     long int __glibc_reserved[3];
61   };
62 
63 #ifdef __USE_LARGEFILE64
64 /* Note stat64 is the same shape as stat.  */
65 struct stat64
66   {
67     __dev_t st_dev;		/* Device.  */
68     __ino64_t st_ino;		/* File serial number.  */
69     __nlink_t st_nlink;		/* Link count.  */
70     __mode_t st_mode;		/* File mode.  */
71     __uid_t st_uid;		/* User ID of the file's owner.	*/
72     __gid_t st_gid;		/* Group ID of the file's group.*/
73     int __glibc_reserved0;
74     __dev_t st_rdev;		/* Device number, if device.  */
75     __off_t st_size;		/* Size of file, in bytes.  */
76 #ifdef __USE_XOPEN2K8
77     /* Nanosecond resolution timestamps are stored in a format
78        equivalent to 'struct timespec'.  This is the type used
79        whenever possible but the Unix namespace rules do not allow the
80        identifier 'timespec' to appear in the <sys/stat.h> header.
81        Therefore we have to handle the use of this header in strictly
82        standard-compliant sources special.  */
83     struct timespec st_atim;		/* Time of last access.  */
84     struct timespec st_mtim;		/* Time of last modification.  */
85     struct timespec st_ctim;		/* Time of last status change.  */
86 # define st_atime st_atim.tv_sec	/* Backward compatibility.  */
87 # define st_mtime st_mtim.tv_sec
88 # define st_ctime st_ctim.tv_sec
89 #else
90     __time_t st_atime;			/* Time of last access.  */
91     unsigned long int st_atimensec;	/* Nscecs of last access.  */
92     __time_t st_mtime;			/* Time of last modification.  */
93     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
94     __time_t st_ctime;			/* Time of last status change.  */
95     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
96 #endif
97     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
98     __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
99     long int __glibc_reserved[3];
100   };
101 #endif
102 
103 /* Tell code we have these members.  */
104 #define	_STATBUF_ST_BLKSIZE
105 #define _STATBUF_ST_RDEV
106 /* Nanosecond resolution time values are supported.  */
107 #define _STATBUF_ST_NSEC
108 
109 
110 #endif /* _BITS_STRUCT_STAT_H  */
111