xref: /illumos-gate/usr/src/uts/common/sys/stat.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
28*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
29*7c478bd9Sstevel@tonic-gate /*	All Rights Reserved	*/
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_STAT_H
32*7c478bd9Sstevel@tonic-gate #define	_SYS_STAT_H
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /*
44*7c478bd9Sstevel@tonic-gate  * The implementation specific header <sys/time_impl.h> includes a
45*7c478bd9Sstevel@tonic-gate  * definition for timestruc_t needed by the stat structure.  However,
46*7c478bd9Sstevel@tonic-gate  * including either <time.h>, which includes <sys/time_impl.h>, or
47*7c478bd9Sstevel@tonic-gate  * including <sys/time_impl.h> directly will break both X/Open and
48*7c478bd9Sstevel@tonic-gate  * POSIX namespace. Preceeding tag, structure, and structure member
49*7c478bd9Sstevel@tonic-gate  * names with underscores eliminates the namespace breakage and at the
50*7c478bd9Sstevel@tonic-gate  * same time, with unique type names, eliminates the possibility of
51*7c478bd9Sstevel@tonic-gate  * timespec_t or timestruct_t naming conflicts that could otherwise
52*7c478bd9Sstevel@tonic-gate  * result based on the order of inclusion of <sys/stat.h> and
53*7c478bd9Sstevel@tonic-gate  * <sys/time.h>.  The header <sys/time_std_impl.h> contains the
54*7c478bd9Sstevel@tonic-gate  * standards namespace safe versions of these definitions.
55*7c478bd9Sstevel@tonic-gate  */
56*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
57*7c478bd9Sstevel@tonic-gate #include <sys/time_impl.h>
58*7c478bd9Sstevel@tonic-gate #else
59*7c478bd9Sstevel@tonic-gate #include <sys/time_std_impl.h>
60*7c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate #define	_ST_FSTYPSZ 16		/* array size for file system type name */
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate /*
65*7c478bd9Sstevel@tonic-gate  * stat structure, used by stat(2) and fstat(2)
66*7c478bd9Sstevel@tonic-gate  */
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate 	/* Expanded stat structure */
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate #if defined(_LP64)
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate struct stat {
75*7c478bd9Sstevel@tonic-gate 	dev_t		st_dev;
76*7c478bd9Sstevel@tonic-gate 	ino_t		st_ino;
77*7c478bd9Sstevel@tonic-gate 	mode_t		st_mode;
78*7c478bd9Sstevel@tonic-gate 	nlink_t		st_nlink;
79*7c478bd9Sstevel@tonic-gate 	uid_t		st_uid;
80*7c478bd9Sstevel@tonic-gate 	gid_t		st_gid;
81*7c478bd9Sstevel@tonic-gate 	dev_t		st_rdev;
82*7c478bd9Sstevel@tonic-gate 	off_t		st_size;
83*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_atim;
84*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_mtim;
85*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_ctim;
86*7c478bd9Sstevel@tonic-gate 	blksize_t	st_blksize;
87*7c478bd9Sstevel@tonic-gate 	blkcnt_t	st_blocks;
88*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
89*7c478bd9Sstevel@tonic-gate };
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate struct stat64 {
92*7c478bd9Sstevel@tonic-gate 	dev_t		st_dev;
93*7c478bd9Sstevel@tonic-gate 	ino_t		st_ino;
94*7c478bd9Sstevel@tonic-gate 	mode_t		st_mode;
95*7c478bd9Sstevel@tonic-gate 	nlink_t		st_nlink;
96*7c478bd9Sstevel@tonic-gate 	uid_t		st_uid;
97*7c478bd9Sstevel@tonic-gate 	gid_t		st_gid;
98*7c478bd9Sstevel@tonic-gate 	dev_t		st_rdev;
99*7c478bd9Sstevel@tonic-gate 	off_t		st_size;
100*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_atim;
101*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_mtim;
102*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_ctim;
103*7c478bd9Sstevel@tonic-gate 	blksize_t	st_blksize;
104*7c478bd9Sstevel@tonic-gate 	blkcnt_t	st_blocks;
105*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
106*7c478bd9Sstevel@tonic-gate };
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate #else	/* _LP64 */
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate struct	stat {
111*7c478bd9Sstevel@tonic-gate 	dev_t		st_dev;
112*7c478bd9Sstevel@tonic-gate 	long		st_pad1[3];	/* reserve for dev expansion, */
113*7c478bd9Sstevel@tonic-gate 					/* sysid definition */
114*7c478bd9Sstevel@tonic-gate 	ino_t		st_ino;
115*7c478bd9Sstevel@tonic-gate 	mode_t		st_mode;
116*7c478bd9Sstevel@tonic-gate 	nlink_t		st_nlink;
117*7c478bd9Sstevel@tonic-gate 	uid_t		st_uid;
118*7c478bd9Sstevel@tonic-gate 	gid_t		st_gid;
119*7c478bd9Sstevel@tonic-gate 	dev_t		st_rdev;
120*7c478bd9Sstevel@tonic-gate 	long		st_pad2[2];
121*7c478bd9Sstevel@tonic-gate 	off_t		st_size;
122*7c478bd9Sstevel@tonic-gate 	long		st_pad3;	/* pad for future off_t expansion */
123*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_atim;
124*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_mtim;
125*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_ctim;
126*7c478bd9Sstevel@tonic-gate 	blksize_t	st_blksize;
127*7c478bd9Sstevel@tonic-gate 	blkcnt_t	st_blocks;
128*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
129*7c478bd9Sstevel@tonic-gate 	long		st_pad4[8];	/* expansion area */
130*7c478bd9Sstevel@tonic-gate };
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate struct  stat64 {
133*7c478bd9Sstevel@tonic-gate 	dev_t		st_dev;
134*7c478bd9Sstevel@tonic-gate 	long		st_pad1[3];	/* reserve for dev expansion, */
135*7c478bd9Sstevel@tonic-gate 				/* sysid definition */
136*7c478bd9Sstevel@tonic-gate 	ino64_t		st_ino;
137*7c478bd9Sstevel@tonic-gate 	mode_t		st_mode;
138*7c478bd9Sstevel@tonic-gate 	nlink_t		st_nlink;
139*7c478bd9Sstevel@tonic-gate 	uid_t		st_uid;
140*7c478bd9Sstevel@tonic-gate 	gid_t		st_gid;
141*7c478bd9Sstevel@tonic-gate 	dev_t		st_rdev;
142*7c478bd9Sstevel@tonic-gate 	long		st_pad2[2];
143*7c478bd9Sstevel@tonic-gate 	off64_t		st_size;	/* large file support */
144*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_atim;
145*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_mtim;
146*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_ctim;
147*7c478bd9Sstevel@tonic-gate 	blksize_t	st_blksize;
148*7c478bd9Sstevel@tonic-gate 	blkcnt64_t	st_blocks;	/* large file support */
149*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
150*7c478bd9Sstevel@tonic-gate 	long		st_pad4[8];	/* expansion area */
151*7c478bd9Sstevel@tonic-gate };
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate #endif	/* _LP64 */
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #else /* !defined(_KERNEL) */
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate /*
158*7c478bd9Sstevel@tonic-gate  * large file compilation environment setup
159*7c478bd9Sstevel@tonic-gate  */
160*7c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
161*7c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
162*7c478bd9Sstevel@tonic-gate #pragma redefine_extname	fstat	fstat64
163*7c478bd9Sstevel@tonic-gate #pragma redefine_extname	stat	stat64
164*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
165*7c478bd9Sstevel@tonic-gate 	defined(_ATFILE_SOURCE)
166*7c478bd9Sstevel@tonic-gate #pragma	redefine_extname	fstatat	fstatat64
167*7c478bd9Sstevel@tonic-gate #endif /* defined (_ATFILE_SOURCE) */
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
170*7c478bd9Sstevel@tonic-gate #pragma	redefine_extname	lstat	lstat64
171*7c478bd9Sstevel@tonic-gate #endif
172*7c478bd9Sstevel@tonic-gate #else	/* __PRAGMA_REDEFINE_EXTNAME */
173*7c478bd9Sstevel@tonic-gate #define	fstat	fstat64
174*7c478bd9Sstevel@tonic-gate #define	stat	stat64
175*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
176*7c478bd9Sstevel@tonic-gate 	defined(_ATFILE_SOURCE)
177*7c478bd9Sstevel@tonic-gate #define	fstatat	fstatat64
178*7c478bd9Sstevel@tonic-gate #endif /* defined (_ATFILE_SOURCE) */
179*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
180*7c478bd9Sstevel@tonic-gate #define	lstat	lstat64
181*7c478bd9Sstevel@tonic-gate #endif
182*7c478bd9Sstevel@tonic-gate #endif	/* __PRAGMA_REDEFINE_EXTNAME */
183*7c478bd9Sstevel@tonic-gate #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate /*
186*7c478bd9Sstevel@tonic-gate  * In the LP64 compilation environment, map large file interfaces
187*7c478bd9Sstevel@tonic-gate  * back to native versions where possible.
188*7c478bd9Sstevel@tonic-gate  */
189*7c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
190*7c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
191*7c478bd9Sstevel@tonic-gate #pragma	redefine_extname	fstat64	fstat
192*7c478bd9Sstevel@tonic-gate #pragma	redefine_extname	stat64	stat
193*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
194*7c478bd9Sstevel@tonic-gate 	defined(_ATFILE_SOURCE)
195*7c478bd9Sstevel@tonic-gate #pragma	redefine_extname	fstatat64 fstatat
196*7c478bd9Sstevel@tonic-gate #endif /* defined (_ATFILE_SOURCE) */
197*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
198*7c478bd9Sstevel@tonic-gate #pragma	redefine_extname	lstat64	lstat
199*7c478bd9Sstevel@tonic-gate #endif
200*7c478bd9Sstevel@tonic-gate #else	/* __PRAGMA_REDEFINE_EXTNAME */
201*7c478bd9Sstevel@tonic-gate #define	fstat64	fstat
202*7c478bd9Sstevel@tonic-gate #define	stat64	stat
203*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
204*7c478bd9Sstevel@tonic-gate 	defined(_ATFILE_SOURCE)
205*7c478bd9Sstevel@tonic-gate #define	fstatat64	fstatat
206*7c478bd9Sstevel@tonic-gate #endif /* defined (_ATFILE_SOURCE) */
207*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
208*7c478bd9Sstevel@tonic-gate #define	lstat64	lstat
209*7c478bd9Sstevel@tonic-gate #endif
210*7c478bd9Sstevel@tonic-gate #endif	/* __PRAGMA_REDEFINE_EXTNAME */
211*7c478bd9Sstevel@tonic-gate #endif	/* _LP64 && _LARGEFILE64_SOURCE */
212*7c478bd9Sstevel@tonic-gate 
213*7c478bd9Sstevel@tonic-gate /*
214*7c478bd9Sstevel@tonic-gate  * User level stat structure definitions.
215*7c478bd9Sstevel@tonic-gate  */
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate #if defined(_LP64)
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate struct stat {
220*7c478bd9Sstevel@tonic-gate 	dev_t		st_dev;
221*7c478bd9Sstevel@tonic-gate 	ino_t		st_ino;
222*7c478bd9Sstevel@tonic-gate 	mode_t		st_mode;
223*7c478bd9Sstevel@tonic-gate 	nlink_t		st_nlink;
224*7c478bd9Sstevel@tonic-gate 	uid_t		st_uid;
225*7c478bd9Sstevel@tonic-gate 	gid_t		st_gid;
226*7c478bd9Sstevel@tonic-gate 	dev_t		st_rdev;
227*7c478bd9Sstevel@tonic-gate 	off_t		st_size;
228*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
229*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_atim;
230*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_mtim;
231*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_ctim;
232*7c478bd9Sstevel@tonic-gate #else
233*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_atim;
234*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_mtim;
235*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_ctim;
236*7c478bd9Sstevel@tonic-gate #endif
237*7c478bd9Sstevel@tonic-gate 	blksize_t	st_blksize;
238*7c478bd9Sstevel@tonic-gate 	blkcnt_t	st_blocks;
239*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
240*7c478bd9Sstevel@tonic-gate };
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate #else	/* _LP64 */
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate struct	stat {
245*7c478bd9Sstevel@tonic-gate 	dev_t		st_dev;
246*7c478bd9Sstevel@tonic-gate 	long		st_pad1[3];	/* reserved for network id */
247*7c478bd9Sstevel@tonic-gate 	ino_t		st_ino;
248*7c478bd9Sstevel@tonic-gate 	mode_t		st_mode;
249*7c478bd9Sstevel@tonic-gate 	nlink_t		st_nlink;
250*7c478bd9Sstevel@tonic-gate 	uid_t		st_uid;
251*7c478bd9Sstevel@tonic-gate 	gid_t		st_gid;
252*7c478bd9Sstevel@tonic-gate 	dev_t		st_rdev;
253*7c478bd9Sstevel@tonic-gate 	long		st_pad2[2];
254*7c478bd9Sstevel@tonic-gate 	off_t		st_size;
255*7c478bd9Sstevel@tonic-gate #if _FILE_OFFSET_BITS != 64
256*7c478bd9Sstevel@tonic-gate 	long		st_pad3;	/* future off_t expansion */
257*7c478bd9Sstevel@tonic-gate #endif
258*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
259*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_atim;
260*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_mtim;
261*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_ctim;
262*7c478bd9Sstevel@tonic-gate #else
263*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_atim;
264*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_mtim;
265*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_ctim;
266*7c478bd9Sstevel@tonic-gate #endif
267*7c478bd9Sstevel@tonic-gate 	blksize_t	st_blksize;
268*7c478bd9Sstevel@tonic-gate 	blkcnt_t	st_blocks;
269*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
270*7c478bd9Sstevel@tonic-gate 	long		st_pad4[8];	/* expansion area */
271*7c478bd9Sstevel@tonic-gate };
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate #endif	/* _LP64 */
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate /* transitional large file interface version */
276*7c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
277*7c478bd9Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
278*7c478bd9Sstevel@tonic-gate #if defined(_LP64)
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate struct stat64 {
281*7c478bd9Sstevel@tonic-gate 	dev_t		st_dev;
282*7c478bd9Sstevel@tonic-gate 	ino_t		st_ino;
283*7c478bd9Sstevel@tonic-gate 	mode_t		st_mode;
284*7c478bd9Sstevel@tonic-gate 	nlink_t		st_nlink;
285*7c478bd9Sstevel@tonic-gate 	uid_t		st_uid;
286*7c478bd9Sstevel@tonic-gate 	gid_t		st_gid;
287*7c478bd9Sstevel@tonic-gate 	dev_t		st_rdev;
288*7c478bd9Sstevel@tonic-gate 	off_t		st_size;
289*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
290*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_atim;
291*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_mtim;
292*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_ctim;
293*7c478bd9Sstevel@tonic-gate #else
294*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_atim;
295*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_mtim;
296*7c478bd9Sstevel@tonic-gate 	_timestruc_t	st_ctim;
297*7c478bd9Sstevel@tonic-gate #endif
298*7c478bd9Sstevel@tonic-gate 	blksize_t	st_blksize;
299*7c478bd9Sstevel@tonic-gate 	blkcnt_t	st_blocks;
300*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
301*7c478bd9Sstevel@tonic-gate };
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate #else	/* _LP64 */
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate struct	stat64 {
306*7c478bd9Sstevel@tonic-gate 	dev_t		st_dev;
307*7c478bd9Sstevel@tonic-gate 	long		st_pad1[3];	/* reserved for network id */
308*7c478bd9Sstevel@tonic-gate 	ino64_t		st_ino;
309*7c478bd9Sstevel@tonic-gate 	mode_t		st_mode;
310*7c478bd9Sstevel@tonic-gate 	nlink_t		st_nlink;
311*7c478bd9Sstevel@tonic-gate 	uid_t		st_uid;
312*7c478bd9Sstevel@tonic-gate 	gid_t		st_gid;
313*7c478bd9Sstevel@tonic-gate 	dev_t		st_rdev;
314*7c478bd9Sstevel@tonic-gate 	long		st_pad2[2];
315*7c478bd9Sstevel@tonic-gate 	off64_t		st_size;
316*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
317*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_atim;
318*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_mtim;
319*7c478bd9Sstevel@tonic-gate 	timestruc_t	st_ctim;
320*7c478bd9Sstevel@tonic-gate #else
321*7c478bd9Sstevel@tonic-gate 	_timestruc_t    st_atim;
322*7c478bd9Sstevel@tonic-gate 	_timestruc_t    st_mtim;
323*7c478bd9Sstevel@tonic-gate 	_timestruc_t    st_ctim;
324*7c478bd9Sstevel@tonic-gate #endif
325*7c478bd9Sstevel@tonic-gate 	blksize_t	st_blksize;
326*7c478bd9Sstevel@tonic-gate 	blkcnt64_t	st_blocks;
327*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
328*7c478bd9Sstevel@tonic-gate 	long		st_pad4[8];	/* expansion area */
329*7c478bd9Sstevel@tonic-gate };
330*7c478bd9Sstevel@tonic-gate 
331*7c478bd9Sstevel@tonic-gate #endif	/* _LP64 */
332*7c478bd9Sstevel@tonic-gate #endif
333*7c478bd9Sstevel@tonic-gate 
334*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
335*7c478bd9Sstevel@tonic-gate #define	st_atime	st_atim.tv_sec
336*7c478bd9Sstevel@tonic-gate #define	st_mtime	st_mtim.tv_sec
337*7c478bd9Sstevel@tonic-gate #define	st_ctime	st_ctim.tv_sec
338*7c478bd9Sstevel@tonic-gate #else
339*7c478bd9Sstevel@tonic-gate #define	st_atime	st_atim.__tv_sec
340*7c478bd9Sstevel@tonic-gate #define	st_mtime	st_mtim.__tv_sec
341*7c478bd9Sstevel@tonic-gate #define	st_ctime	st_ctim.__tv_sec
342*7c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate #endif /* end defined(_KERNEL) */
345*7c478bd9Sstevel@tonic-gate 
346*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
347*7c478bd9Sstevel@tonic-gate 
348*7c478bd9Sstevel@tonic-gate /*
349*7c478bd9Sstevel@tonic-gate  * Kernel's view of user ILP32 stat and stat64 structures
350*7c478bd9Sstevel@tonic-gate  */
351*7c478bd9Sstevel@tonic-gate 
352*7c478bd9Sstevel@tonic-gate struct stat32 {
353*7c478bd9Sstevel@tonic-gate 	dev32_t		st_dev;
354*7c478bd9Sstevel@tonic-gate 	int32_t		st_pad1[3];
355*7c478bd9Sstevel@tonic-gate 	ino32_t		st_ino;
356*7c478bd9Sstevel@tonic-gate 	mode32_t	st_mode;
357*7c478bd9Sstevel@tonic-gate 	nlink32_t	st_nlink;
358*7c478bd9Sstevel@tonic-gate 	uid32_t		st_uid;
359*7c478bd9Sstevel@tonic-gate 	gid32_t		st_gid;
360*7c478bd9Sstevel@tonic-gate 	dev32_t		st_rdev;
361*7c478bd9Sstevel@tonic-gate 	int32_t		st_pad2[2];
362*7c478bd9Sstevel@tonic-gate 	off32_t		st_size;
363*7c478bd9Sstevel@tonic-gate 	int32_t		st_pad3;
364*7c478bd9Sstevel@tonic-gate 	timestruc32_t	st_atim;
365*7c478bd9Sstevel@tonic-gate 	timestruc32_t	st_mtim;
366*7c478bd9Sstevel@tonic-gate 	timestruc32_t	st_ctim;
367*7c478bd9Sstevel@tonic-gate 	int32_t		st_blksize;
368*7c478bd9Sstevel@tonic-gate 	blkcnt32_t	st_blocks;
369*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
370*7c478bd9Sstevel@tonic-gate 	int32_t		st_pad4[8];
371*7c478bd9Sstevel@tonic-gate };
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
374*7c478bd9Sstevel@tonic-gate #pragma pack(4)
375*7c478bd9Sstevel@tonic-gate #endif
376*7c478bd9Sstevel@tonic-gate 
377*7c478bd9Sstevel@tonic-gate struct stat64_32 {
378*7c478bd9Sstevel@tonic-gate 	dev32_t		st_dev;
379*7c478bd9Sstevel@tonic-gate 	int32_t		st_pad1[3];
380*7c478bd9Sstevel@tonic-gate 	ino64_t		st_ino;
381*7c478bd9Sstevel@tonic-gate 	mode32_t	st_mode;
382*7c478bd9Sstevel@tonic-gate 	nlink32_t	st_nlink;
383*7c478bd9Sstevel@tonic-gate 	uid32_t		st_uid;
384*7c478bd9Sstevel@tonic-gate 	gid32_t		st_gid;
385*7c478bd9Sstevel@tonic-gate 	dev32_t		st_rdev;
386*7c478bd9Sstevel@tonic-gate 	int32_t		st_pad2[2];
387*7c478bd9Sstevel@tonic-gate 	off64_t		st_size;
388*7c478bd9Sstevel@tonic-gate 	timestruc32_t	st_atim;
389*7c478bd9Sstevel@tonic-gate 	timestruc32_t	st_mtim;
390*7c478bd9Sstevel@tonic-gate 	timestruc32_t	st_ctim;
391*7c478bd9Sstevel@tonic-gate 	int32_t		st_blksize;
392*7c478bd9Sstevel@tonic-gate 	blkcnt64_t	st_blocks;
393*7c478bd9Sstevel@tonic-gate 	char		st_fstype[_ST_FSTYPSZ];
394*7c478bd9Sstevel@tonic-gate 	int32_t		st_pad4[8];
395*7c478bd9Sstevel@tonic-gate };
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
398*7c478bd9Sstevel@tonic-gate #pragma pack()
399*7c478bd9Sstevel@tonic-gate #endif
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
402*7c478bd9Sstevel@tonic-gate 
403*7c478bd9Sstevel@tonic-gate /* MODE MASKS */
404*7c478bd9Sstevel@tonic-gate 
405*7c478bd9Sstevel@tonic-gate /* de facto standard definitions */
406*7c478bd9Sstevel@tonic-gate 
407*7c478bd9Sstevel@tonic-gate #define	S_IFMT		0xF000	/* type of file */
408*7c478bd9Sstevel@tonic-gate #define	S_IAMB		0x1FF	/* access mode bits */
409*7c478bd9Sstevel@tonic-gate #define	S_IFIFO		0x1000	/* fifo */
410*7c478bd9Sstevel@tonic-gate #define	S_IFCHR		0x2000	/* character special */
411*7c478bd9Sstevel@tonic-gate #define	S_IFDIR		0x4000	/* directory */
412*7c478bd9Sstevel@tonic-gate /* XENIX definitions are not relevant to Solaris */
413*7c478bd9Sstevel@tonic-gate #define	S_IFNAM		0x5000  /* XENIX special named file */
414*7c478bd9Sstevel@tonic-gate #define	S_INSEM		0x1	/* XENIX semaphore subtype of IFNAM */
415*7c478bd9Sstevel@tonic-gate #define	S_INSHD		0x2	/* XENIX shared data subtype of IFNAM */
416*7c478bd9Sstevel@tonic-gate #define	S_IFBLK		0x6000	/* block special */
417*7c478bd9Sstevel@tonic-gate #define	S_IFREG		0x8000	/* regular */
418*7c478bd9Sstevel@tonic-gate #define	S_IFLNK		0xA000	/* symbolic link */
419*7c478bd9Sstevel@tonic-gate #define	S_IFSOCK	0xC000	/* socket */
420*7c478bd9Sstevel@tonic-gate #define	S_IFDOOR	0xD000	/* door */
421*7c478bd9Sstevel@tonic-gate #define	S_IFPORT	0xE000	/* event port */
422*7c478bd9Sstevel@tonic-gate #define	S_ISUID		0x800	/* set user id on execution */
423*7c478bd9Sstevel@tonic-gate #define	S_ISGID		0x400	/* set group id on execution */
424*7c478bd9Sstevel@tonic-gate #define	S_ISVTX		0x200	/* save swapped text even after use */
425*7c478bd9Sstevel@tonic-gate #define	S_IREAD		00400	/* read permission, owner */
426*7c478bd9Sstevel@tonic-gate #define	S_IWRITE	00200	/* write permission, owner */
427*7c478bd9Sstevel@tonic-gate #define	S_IEXEC		00100	/* execute/search permission, owner */
428*7c478bd9Sstevel@tonic-gate #define	S_ENFMT		S_ISGID	/* record locking enforcement flag */
429*7c478bd9Sstevel@tonic-gate 
430*7c478bd9Sstevel@tonic-gate /* the following macros are for POSIX conformance */
431*7c478bd9Sstevel@tonic-gate 
432*7c478bd9Sstevel@tonic-gate #define	S_IRWXU		00700	/* read, write, execute: owner */
433*7c478bd9Sstevel@tonic-gate #define	S_IRUSR		00400	/* read permission: owner */
434*7c478bd9Sstevel@tonic-gate #define	S_IWUSR		00200	/* write permission: owner */
435*7c478bd9Sstevel@tonic-gate #define	S_IXUSR		00100	/* execute permission: owner */
436*7c478bd9Sstevel@tonic-gate #define	S_IRWXG		00070	/* read, write, execute: group */
437*7c478bd9Sstevel@tonic-gate #define	S_IRGRP		00040	/* read permission: group */
438*7c478bd9Sstevel@tonic-gate #define	S_IWGRP		00020	/* write permission: group */
439*7c478bd9Sstevel@tonic-gate #define	S_IXGRP		00010	/* execute permission: group */
440*7c478bd9Sstevel@tonic-gate #define	S_IRWXO		00007	/* read, write, execute: other */
441*7c478bd9Sstevel@tonic-gate #define	S_IROTH		00004	/* read permission: other */
442*7c478bd9Sstevel@tonic-gate #define	S_IWOTH		00002	/* write permission: other */
443*7c478bd9Sstevel@tonic-gate #define	S_IXOTH		00001	/* execute permission: other */
444*7c478bd9Sstevel@tonic-gate 
445*7c478bd9Sstevel@tonic-gate 
446*7c478bd9Sstevel@tonic-gate #define	S_ISFIFO(mode)	(((mode)&0xF000) == 0x1000)
447*7c478bd9Sstevel@tonic-gate #define	S_ISCHR(mode)	(((mode)&0xF000) == 0x2000)
448*7c478bd9Sstevel@tonic-gate #define	S_ISDIR(mode)	(((mode)&0xF000) == 0x4000)
449*7c478bd9Sstevel@tonic-gate #define	S_ISBLK(mode)	(((mode)&0xF000) == 0x6000)
450*7c478bd9Sstevel@tonic-gate #define	S_ISREG(mode)	(((mode)&0xF000) == 0x8000)
451*7c478bd9Sstevel@tonic-gate #define	S_ISLNK(mode)	(((mode)&0xF000) == 0xa000)
452*7c478bd9Sstevel@tonic-gate #define	S_ISSOCK(mode)	(((mode)&0xF000) == 0xc000)
453*7c478bd9Sstevel@tonic-gate #define	S_ISDOOR(mode)	(((mode)&0xF000) == 0xd000)
454*7c478bd9Sstevel@tonic-gate #define	S_ISPORT(mode)	(((mode)&0xF000) == 0xe000)
455*7c478bd9Sstevel@tonic-gate 
456*7c478bd9Sstevel@tonic-gate /* POSIX.4 macros */
457*7c478bd9Sstevel@tonic-gate #define	S_TYPEISMQ(_buf)	(0)
458*7c478bd9Sstevel@tonic-gate #define	S_TYPEISSEM(_buf)	(0)
459*7c478bd9Sstevel@tonic-gate #define	S_TYPEISSHM(_buf)	(0)
460*7c478bd9Sstevel@tonic-gate 
461*7c478bd9Sstevel@tonic-gate #if defined(__i386) || (defined(__i386_COMPAT) && defined(_KERNEL))
462*7c478bd9Sstevel@tonic-gate 
463*7c478bd9Sstevel@tonic-gate /*
464*7c478bd9Sstevel@tonic-gate  * A version number is included in the x86 SVR4 stat and mknod interfaces
465*7c478bd9Sstevel@tonic-gate  * so that SVR4 binaries can be supported.  An LP64 kernel that supports
466*7c478bd9Sstevel@tonic-gate  * the i386 ABI need to be aware of this too.
467*7c478bd9Sstevel@tonic-gate  */
468*7c478bd9Sstevel@tonic-gate 
469*7c478bd9Sstevel@tonic-gate #define	_R3_MKNOD_VER	1	/* SVR3.0 mknod */
470*7c478bd9Sstevel@tonic-gate #define	_MKNOD_VER	2	/* current version of mknod */
471*7c478bd9Sstevel@tonic-gate #define	_R3_STAT_VER	1	/* SVR3.0 stat */
472*7c478bd9Sstevel@tonic-gate #define	_STAT_VER	2	/* current version of stat */
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate #endif	/* __i386 || (__i386_COMPAT && _KERNEL) */
475*7c478bd9Sstevel@tonic-gate 
476*7c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) || defined(_BOOT)
477*7c478bd9Sstevel@tonic-gate 
478*7c478bd9Sstevel@tonic-gate #if defined(__STDC__)
479*7c478bd9Sstevel@tonic-gate 
480*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
481*7c478bd9Sstevel@tonic-gate 	defined(_XPG4_2) || defined(__EXTENSIONS__)
482*7c478bd9Sstevel@tonic-gate extern int fchmod(int, mode_t);
483*7c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
484*7c478bd9Sstevel@tonic-gate 
485*7c478bd9Sstevel@tonic-gate extern int chmod(const char *, mode_t);
486*7c478bd9Sstevel@tonic-gate extern int mkdir(const char *, mode_t);
487*7c478bd9Sstevel@tonic-gate extern int mkfifo(const char *, mode_t);
488*7c478bd9Sstevel@tonic-gate extern mode_t umask(mode_t);
489*7c478bd9Sstevel@tonic-gate 
490*7c478bd9Sstevel@tonic-gate /* transitional large file interfaces */
491*7c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
492*7c478bd9Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
493*7c478bd9Sstevel@tonic-gate extern int fstat64(int, struct stat64 *);
494*7c478bd9Sstevel@tonic-gate extern int stat64(const char *_RESTRICT_KYWD, struct stat64 *_RESTRICT_KYWD);
495*7c478bd9Sstevel@tonic-gate extern int lstat64(const char *_RESTRICT_KYWD, struct stat64 *_RESTRICT_KYWD);
496*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
497*7c478bd9Sstevel@tonic-gate 	defined(_ATFILE_SOURCE)
498*7c478bd9Sstevel@tonic-gate extern int fstatat64(int, const char *, struct stat64 *, int);
499*7c478bd9Sstevel@tonic-gate #endif /* defined (_ATFILE_SOURCE) */
500*7c478bd9Sstevel@tonic-gate #endif
501*7c478bd9Sstevel@tonic-gate 
502*7c478bd9Sstevel@tonic-gate #else /* !__STDC__ */
503*7c478bd9Sstevel@tonic-gate 
504*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
505*7c478bd9Sstevel@tonic-gate 	defined(_XPG4_2) || defined(__EXTENSIONS__)
506*7c478bd9Sstevel@tonic-gate extern int fchmod();
507*7c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
508*7c478bd9Sstevel@tonic-gate 
509*7c478bd9Sstevel@tonic-gate extern int chmod();
510*7c478bd9Sstevel@tonic-gate extern int mkdir();
511*7c478bd9Sstevel@tonic-gate extern int mkfifo();
512*7c478bd9Sstevel@tonic-gate extern mode_t umask();
513*7c478bd9Sstevel@tonic-gate 
514*7c478bd9Sstevel@tonic-gate /* transitional large file interfaces */
515*7c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
516*7c478bd9Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
517*7c478bd9Sstevel@tonic-gate extern int fstat64();
518*7c478bd9Sstevel@tonic-gate extern int stat64();
519*7c478bd9Sstevel@tonic-gate extern int lstat64();
520*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
521*7c478bd9Sstevel@tonic-gate 	defined(_ATFILE_SOURCE)
522*7c478bd9Sstevel@tonic-gate extern int fstatat64();
523*7c478bd9Sstevel@tonic-gate #endif /* defined (_ATFILE_SOURCE) */
524*7c478bd9Sstevel@tonic-gate #endif
525*7c478bd9Sstevel@tonic-gate 
526*7c478bd9Sstevel@tonic-gate #endif /* defined(__STDC__) */
527*7c478bd9Sstevel@tonic-gate 
528*7c478bd9Sstevel@tonic-gate #include <sys/stat_impl.h>
529*7c478bd9Sstevel@tonic-gate 
530*7c478bd9Sstevel@tonic-gate #endif /* !defined(_KERNEL) */
531*7c478bd9Sstevel@tonic-gate 
532*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
533*7c478bd9Sstevel@tonic-gate }
534*7c478bd9Sstevel@tonic-gate #endif
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_STAT_H */
537