17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
53b862e9Roger A. Faulkner * Common Development and Distribution License (the "License").
63b862e9Roger A. Faulkner * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
213b862e9Roger A. Faulkner
227c478bdstevel@tonic-gate/*
23ba3594bGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24794f0adRoger A. Faulkner * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
277c478bdstevel@tonic-gate/*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
287c478bdstevel@tonic-gate/*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
297c478bdstevel@tonic-gate/*	All Rights Reserved	*/
307c478bdstevel@tonic-gate
317c478bdstevel@tonic-gate#ifndef _SYS_STAT_H
327c478bdstevel@tonic-gate#define	_SYS_STAT_H
337c478bdstevel@tonic-gate
347c478bdstevel@tonic-gate#include <sys/feature_tests.h>
357c478bdstevel@tonic-gate#include <sys/types.h>
367c478bdstevel@tonic-gate
377c478bdstevel@tonic-gate#ifdef	__cplusplus
387c478bdstevel@tonic-gateextern "C" {
397c478bdstevel@tonic-gate#endif
407c478bdstevel@tonic-gate
417c478bdstevel@tonic-gate/*
427c478bdstevel@tonic-gate * The implementation specific header <sys/time_impl.h> includes a
437c478bdstevel@tonic-gate * definition for timestruc_t needed by the stat structure.  However,
447c478bdstevel@tonic-gate * including either <time.h>, which includes <sys/time_impl.h>, or
457c478bdstevel@tonic-gate * including <sys/time_impl.h> directly will break both X/Open and
467c478bdstevel@tonic-gate * POSIX namespace. Preceeding tag, structure, and structure member
477c478bdstevel@tonic-gate * names with underscores eliminates the namespace breakage and at the
487c478bdstevel@tonic-gate * same time, with unique type names, eliminates the possibility of
497c478bdstevel@tonic-gate * timespec_t or timestruct_t naming conflicts that could otherwise
507c478bdstevel@tonic-gate * result based on the order of inclusion of <sys/stat.h> and
517c478bdstevel@tonic-gate * <sys/time.h>.  The header <sys/time_std_impl.h> contains the
527c478bdstevel@tonic-gate * standards namespace safe versions of these definitions.
537c478bdstevel@tonic-gate */
547c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
557c478bdstevel@tonic-gate#include <sys/time_impl.h>
567c478bdstevel@tonic-gate#else
577c478bdstevel@tonic-gate#include <sys/time_std_impl.h>
587c478bdstevel@tonic-gate#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
597c478bdstevel@tonic-gate
607c478bdstevel@tonic-gate#define	_ST_FSTYPSZ 16		/* array size for file system type name */
617c478bdstevel@tonic-gate
627c478bdstevel@tonic-gate/*
637c478bdstevel@tonic-gate * stat structure, used by stat(2) and fstat(2)
647c478bdstevel@tonic-gate */
657c478bdstevel@tonic-gate
667c478bdstevel@tonic-gate#if defined(_KERNEL)
677c478bdstevel@tonic-gate
687c478bdstevel@tonic-gate	/* Expanded stat structure */
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gate#if defined(_LP64)
717c478bdstevel@tonic-gate
727c478bdstevel@tonic-gatestruct stat {
737c478bdstevel@tonic-gate	dev_t		st_dev;
747c478bdstevel@tonic-gate	ino_t		st_ino;
757c478bdstevel@tonic-gate	mode_t		st_mode;
767c478bdstevel@tonic-gate	nlink_t		st_nlink;
777c478bdstevel@tonic-gate	uid_t		st_uid;
787c478bdstevel@tonic-gate	gid_t		st_gid;
797c478bdstevel@tonic-gate	dev_t		st_rdev;
807c478bdstevel@tonic-gate	off_t		st_size;
817c478bdstevel@tonic-gate	timestruc_t	st_atim;
827c478bdstevel@tonic-gate	timestruc_t	st_mtim;
837c478bdstevel@tonic-gate	timestruc_t	st_ctim;
847c478bdstevel@tonic-gate	blksize_t	st_blksize;
857c478bdstevel@tonic-gate	blkcnt_t	st_blocks;
867c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
877c478bdstevel@tonic-gate};
887c478bdstevel@tonic-gate
897c478bdstevel@tonic-gatestruct stat64 {
907c478bdstevel@tonic-gate	dev_t		st_dev;
917c478bdstevel@tonic-gate	ino_t		st_ino;
927c478bdstevel@tonic-gate	mode_t		st_mode;
937c478bdstevel@tonic-gate	nlink_t		st_nlink;
947c478bdstevel@tonic-gate	uid_t		st_uid;
957c478bdstevel@tonic-gate	gid_t		st_gid;
967c478bdstevel@tonic-gate	dev_t		st_rdev;
977c478bdstevel@tonic-gate	off_t		st_size;
987c478bdstevel@tonic-gate	timestruc_t	st_atim;
997c478bdstevel@tonic-gate	timestruc_t	st_mtim;
1007c478bdstevel@tonic-gate	timestruc_t	st_ctim;
1017c478bdstevel@tonic-gate	blksize_t	st_blksize;
1027c478bdstevel@tonic-gate	blkcnt_t	st_blocks;
1037c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
1047c478bdstevel@tonic-gate};
1057c478bdstevel@tonic-gate
1067c478bdstevel@tonic-gate#else	/* _LP64 */
1077c478bdstevel@tonic-gate
1087c478bdstevel@tonic-gatestruct	stat {
1097c478bdstevel@tonic-gate	dev_t		st_dev;
1107c478bdstevel@tonic-gate	long		st_pad1[3];	/* reserve for dev expansion, */
1117c478bdstevel@tonic-gate					/* sysid definition */
1127c478bdstevel@tonic-gate	ino_t		st_ino;
1137c478bdstevel@tonic-gate	mode_t		st_mode;
1147c478bdstevel@tonic-gate	nlink_t		st_nlink;
1157c478bdstevel@tonic-gate	uid_t		st_uid;
1167c478bdstevel@tonic-gate	gid_t		st_gid;
1177c478bdstevel@tonic-gate	dev_t		st_rdev;
1187c478bdstevel@tonic-gate	long		st_pad2[2];
1197c478bdstevel@tonic-gate	off_t		st_size;
1207c478bdstevel@tonic-gate	long		st_pad3;	/* pad for future off_t expansion */
1217c478bdstevel@tonic-gate	timestruc_t	st_atim;
1227c478bdstevel@tonic-gate	timestruc_t	st_mtim;
1237c478bdstevel@tonic-gate	timestruc_t	st_ctim;
1247c478bdstevel@tonic-gate	blksize_t	st_blksize;
1257c478bdstevel@tonic-gate	blkcnt_t	st_blocks;
1267c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
1277c478bdstevel@tonic-gate	long		st_pad4[8];	/* expansion area */
1287c478bdstevel@tonic-gate};
1297c478bdstevel@tonic-gate
1307c478bdstevel@tonic-gatestruct  stat64 {
1317c478bdstevel@tonic-gate	dev_t		st_dev;
1327c478bdstevel@tonic-gate	long		st_pad1[3];	/* reserve for dev expansion, */
1337c478bdstevel@tonic-gate				/* sysid definition */
1347c478bdstevel@tonic-gate	ino64_t		st_ino;
1357c478bdstevel@tonic-gate	mode_t		st_mode;
1367c478bdstevel@tonic-gate	nlink_t		st_nlink;
1377c478bdstevel@tonic-gate	uid_t		st_uid;
1387c478bdstevel@tonic-gate	gid_t		st_gid;
1397c478bdstevel@tonic-gate	dev_t		st_rdev;
1407c478bdstevel@tonic-gate	long		st_pad2[2];
1417c478bdstevel@tonic-gate	off64_t		st_size;	/* large file support */
1427c478bdstevel@tonic-gate	timestruc_t	st_atim;
1437c478bdstevel@tonic-gate	timestruc_t	st_mtim;
1447c478bdstevel@tonic-gate	timestruc_t	st_ctim;
1457c478bdstevel@tonic-gate	blksize_t	st_blksize;
1467c478bdstevel@tonic-gate	blkcnt64_t	st_blocks;	/* large file support */
1477c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
1487c478bdstevel@tonic-gate	long		st_pad4[8];	/* expansion area */
1497c478bdstevel@tonic-gate};
1507c478bdstevel@tonic-gate
1517c478bdstevel@tonic-gate#endif	/* _LP64 */
1527c478bdstevel@tonic-gate
1537c478bdstevel@tonic-gate#else /* !defined(_KERNEL) */
1547c478bdstevel@tonic-gate
1557c478bdstevel@tonic-gate/*
1567c478bdstevel@tonic-gate * large file compilation environment setup
1577c478bdstevel@tonic-gate */
1587c478bdstevel@tonic-gate#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
1597c478bdstevel@tonic-gate#ifdef	__PRAGMA_REDEFINE_EXTNAME
1607c478bdstevel@tonic-gate#pragma redefine_extname	fstat	fstat64
1617c478bdstevel@tonic-gate#pragma redefine_extname	stat	stat64
1627c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
1637c478bdstevel@tonic-gate	defined(_ATFILE_SOURCE)
1647c478bdstevel@tonic-gate#pragma	redefine_extname	fstatat	fstatat64
1657c478bdstevel@tonic-gate#endif /* defined (_ATFILE_SOURCE) */
1667c478bdstevel@tonic-gate
1677c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
1687c478bdstevel@tonic-gate#pragma	redefine_extname	lstat	lstat64
1697c478bdstevel@tonic-gate#endif
1707c478bdstevel@tonic-gate#else	/* __PRAGMA_REDEFINE_EXTNAME */
1717c478bdstevel@tonic-gate#define	fstat	fstat64
1727c478bdstevel@tonic-gate#define	stat	stat64
1737c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
1747c478bdstevel@tonic-gate	defined(_ATFILE_SOURCE)
1757c478bdstevel@tonic-gate#define	fstatat	fstatat64
1767c478bdstevel@tonic-gate#endif /* defined (_ATFILE_SOURCE) */
1777c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
1787c478bdstevel@tonic-gate#define	lstat	lstat64
1797c478bdstevel@tonic-gate#endif
1807c478bdstevel@tonic-gate#endif	/* __PRAGMA_REDEFINE_EXTNAME */
1817c478bdstevel@tonic-gate#endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
1827c478bdstevel@tonic-gate
1837c478bdstevel@tonic-gate/*
1847c478bdstevel@tonic-gate * In the LP64 compilation environment, map large file interfaces
1857c478bdstevel@tonic-gate * back to native versions where possible.
1867c478bdstevel@tonic-gate */
1877c478bdstevel@tonic-gate#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
1887c478bdstevel@tonic-gate#ifdef	__PRAGMA_REDEFINE_EXTNAME
1897c478bdstevel@tonic-gate#pragma	redefine_extname	fstat64	fstat
1907c478bdstevel@tonic-gate#pragma	redefine_extname	stat64	stat
1917c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
1927c478bdstevel@tonic-gate	defined(_ATFILE_SOURCE)
1937c478bdstevel@tonic-gate#pragma	redefine_extname	fstatat64 fstatat
1947c478bdstevel@tonic-gate#endif /* defined (_ATFILE_SOURCE) */
1957c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
1967c478bdstevel@tonic-gate#pragma	redefine_extname	lstat64	lstat
1977c478bdstevel@tonic-gate#endif
1987c478bdstevel@tonic-gate#else	/* __PRAGMA_REDEFINE_EXTNAME */
1997c478bdstevel@tonic-gate#define	fstat64	fstat
2007c478bdstevel@tonic-gate#define	stat64	stat
2017c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
2027c478bdstevel@tonic-gate	defined(_ATFILE_SOURCE)
2037c478bdstevel@tonic-gate#define	fstatat64	fstatat
2047c478bdstevel@tonic-gate#endif /* defined (_ATFILE_SOURCE) */
2057c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
2067c478bdstevel@tonic-gate#define	lstat64	lstat
2077c478bdstevel@tonic-gate#endif
2087c478bdstevel@tonic-gate#endif	/* __PRAGMA_REDEFINE_EXTNAME */
2097c478bdstevel@tonic-gate#endif	/* _LP64 && _LARGEFILE64_SOURCE */
2107c478bdstevel@tonic-gate
2117c478bdstevel@tonic-gate/*
2127c478bdstevel@tonic-gate * User level stat structure definitions.
2137c478bdstevel@tonic-gate */
2147c478bdstevel@tonic-gate
2157c478bdstevel@tonic-gate#if defined(_LP64)
2167c478bdstevel@tonic-gate
2177c478bdstevel@tonic-gatestruct stat {
2187c478bdstevel@tonic-gate	dev_t		st_dev;
2197c478bdstevel@tonic-gate	ino_t		st_ino;
2207c478bdstevel@tonic-gate	mode_t		st_mode;
2217c478bdstevel@tonic-gate	nlink_t		st_nlink;
2227c478bdstevel@tonic-gate	uid_t		st_uid;
2237c478bdstevel@tonic-gate	gid_t		st_gid;
2247c478bdstevel@tonic-gate	dev_t		st_rdev;
2257c478bdstevel@tonic-gate	off_t		st_size;
2267c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
2277c478bdstevel@tonic-gate	timestruc_t	st_atim;
2287c478bdstevel@tonic-gate	timestruc_t	st_mtim;
2297c478bdstevel@tonic-gate	timestruc_t	st_ctim;
2307c478bdstevel@tonic-gate#else
2317c478bdstevel@tonic-gate	_timestruc_t	st_atim;
2327c478bdstevel@tonic-gate	_timestruc_t	st_mtim;
2337c478bdstevel@tonic-gate	_timestruc_t	st_ctim;
2347c478bdstevel@tonic-gate#endif
2357c478bdstevel@tonic-gate	blksize_t	st_blksize;
2367c478bdstevel@tonic-gate	blkcnt_t	st_blocks;
2377c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
2387c478bdstevel@tonic-gate};
2397c478bdstevel@tonic-gate
2407c478bdstevel@tonic-gate#else	/* _LP64 */
2417c478bdstevel@tonic-gate
2427c478bdstevel@tonic-gatestruct	stat {
2437c478bdstevel@tonic-gate	dev_t		st_dev;
2447c478bdstevel@tonic-gate	long		st_pad1[3];	/* reserved for network id */
2457c478bdstevel@tonic-gate	ino_t		st_ino;
2467c478bdstevel@tonic-gate	mode_t		st_mode;
2477c478bdstevel@tonic-gate	nlink_t		st_nlink;
2487c478bdstevel@tonic-gate	uid_t		st_uid;
2497c478bdstevel@tonic-gate	gid_t		st_gid;
2507c478bdstevel@tonic-gate	dev_t		st_rdev;
2517c478bdstevel@tonic-gate	long		st_pad2[2];
2527c478bdstevel@tonic-gate	off_t		st_size;
2537c478bdstevel@tonic-gate#if _FILE_OFFSET_BITS != 64
2547c478bdstevel@tonic-gate	long		st_pad3;	/* future off_t expansion */
2557c478bdstevel@tonic-gate#endif
2567c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
2577c478bdstevel@tonic-gate	timestruc_t	st_atim;
2587c478bdstevel@tonic-gate	timestruc_t	st_mtim;
2597c478bdstevel@tonic-gate	timestruc_t	st_ctim;
2607c478bdstevel@tonic-gate#else
2617c478bdstevel@tonic-gate	_timestruc_t	st_atim;
2627c478bdstevel@tonic-gate	_timestruc_t	st_mtim;
2637c478bdstevel@tonic-gate	_timestruc_t	st_ctim;
2647c478bdstevel@tonic-gate#endif
2657c478bdstevel@tonic-gate	blksize_t	st_blksize;
2667c478bdstevel@tonic-gate	blkcnt_t	st_blocks;
2677c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
2687c478bdstevel@tonic-gate	long		st_pad4[8];	/* expansion area */
2697c478bdstevel@tonic-gate};
2707c478bdstevel@tonic-gate
2717c478bdstevel@tonic-gate#endif	/* _LP64 */
2727c478bdstevel@tonic-gate
2737c478bdstevel@tonic-gate/* transitional large file interface version */
2747c478bdstevel@tonic-gate#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
2757c478bdstevel@tonic-gate	    !defined(__PRAGMA_REDEFINE_EXTNAME))
2767c478bdstevel@tonic-gate#if defined(_LP64)
2777c478bdstevel@tonic-gate
2787c478bdstevel@tonic-gatestruct stat64 {
2797c478bdstevel@tonic-gate	dev_t		st_dev;
2807c478bdstevel@tonic-gate	ino_t		st_ino;
2817c478bdstevel@tonic-gate	mode_t		st_mode;
2827c478bdstevel@tonic-gate	nlink_t		st_nlink;
2837c478bdstevel@tonic-gate	uid_t		st_uid;
2847c478bdstevel@tonic-gate	gid_t		st_gid;
2857c478bdstevel@tonic-gate	dev_t		st_rdev;
2867c478bdstevel@tonic-gate	off_t		st_size;
2877c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
2887c478bdstevel@tonic-gate	timestruc_t	st_atim;
2897c478bdstevel@tonic-gate	timestruc_t	st_mtim;
2907c478bdstevel@tonic-gate	timestruc_t	st_ctim;
2917c478bdstevel@tonic-gate#else
2927c478bdstevel@tonic-gate	_timestruc_t	st_atim;
2937c478bdstevel@tonic-gate	_timestruc_t	st_mtim;
2947c478bdstevel@tonic-gate	_timestruc_t	st_ctim;
2957c478bdstevel@tonic-gate#endif
2967c478bdstevel@tonic-gate	blksize_t	st_blksize;
2977c478bdstevel@tonic-gate	blkcnt_t	st_blocks;
2987c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
2997c478bdstevel@tonic-gate};
3007c478bdstevel@tonic-gate
3017c478bdstevel@tonic-gate#else	/* _LP64 */
3027c478bdstevel@tonic-gate
3037c478bdstevel@tonic-gatestruct	stat64 {
3047c478bdstevel@tonic-gate	dev_t		st_dev;
3057c478bdstevel@tonic-gate	long		st_pad1[3];	/* reserved for network id */
3067c478bdstevel@tonic-gate	ino64_t		st_ino;
3077c478bdstevel@tonic-gate	mode_t		st_mode;
3087c478bdstevel@tonic-gate	nlink_t		st_nlink;
3097c478bdstevel@tonic-gate	uid_t		st_uid;
3107c478bdstevel@tonic-gate	gid_t		st_gid;
3117c478bdstevel@tonic-gate	dev_t		st_rdev;
3127c478bdstevel@tonic-gate	long		st_pad2[2];
3137c478bdstevel@tonic-gate	off64_t		st_size;
3147c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3157c478bdstevel@tonic-gate	timestruc_t	st_atim;
3167c478bdstevel@tonic-gate	timestruc_t	st_mtim;
3177c478bdstevel@tonic-gate	timestruc_t	st_ctim;
3187c478bdstevel@tonic-gate#else
3197c478bdstevel@tonic-gate	_timestruc_t    st_atim;
3207c478bdstevel@tonic-gate	_timestruc_t    st_mtim;
3217c478bdstevel@tonic-gate	_timestruc_t    st_ctim;
3227c478bdstevel@tonic-gate#endif
3237c478bdstevel@tonic-gate	blksize_t	st_blksize;
3247c478bdstevel@tonic-gate	blkcnt64_t	st_blocks;
3257c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
3267c478bdstevel@tonic-gate	long		st_pad4[8];	/* expansion area */
3277c478bdstevel@tonic-gate};
3287c478bdstevel@tonic-gate
3297c478bdstevel@tonic-gate#endif	/* _LP64 */
3307c478bdstevel@tonic-gate#endif
3317c478bdstevel@tonic-gate
3327c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3337c478bdstevel@tonic-gate#define	st_atime	st_atim.tv_sec
3347c478bdstevel@tonic-gate#define	st_mtime	st_mtim.tv_sec
3357c478bdstevel@tonic-gate#define	st_ctime	st_ctim.tv_sec
3367c478bdstevel@tonic-gate#else
3377c478bdstevel@tonic-gate#define	st_atime	st_atim.__tv_sec
3387c478bdstevel@tonic-gate#define	st_mtime	st_mtim.__tv_sec
3397c478bdstevel@tonic-gate#define	st_ctime	st_ctim.__tv_sec
3407c478bdstevel@tonic-gate#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
3417c478bdstevel@tonic-gate
3427c478bdstevel@tonic-gate#endif /* end defined(_KERNEL) */
3437c478bdstevel@tonic-gate
3447c478bdstevel@tonic-gate#if defined(_SYSCALL32)
3457c478bdstevel@tonic-gate
3467c478bdstevel@tonic-gate/*
3477c478bdstevel@tonic-gate * Kernel's view of user ILP32 stat and stat64 structures
3487c478bdstevel@tonic-gate */
3497c478bdstevel@tonic-gate
3507c478bdstevel@tonic-gatestruct stat32 {
3517c478bdstevel@tonic-gate	dev32_t		st_dev;
3527c478bdstevel@tonic-gate	int32_t		st_pad1[3];
3537c478bdstevel@tonic-gate	ino32_t		st_ino;
3547c478bdstevel@tonic-gate	mode32_t	st_mode;
3557c478bdstevel@tonic-gate	nlink32_t	st_nlink;
3567c478bdstevel@tonic-gate	uid32_t		st_uid;
3577c478bdstevel@tonic-gate	gid32_t		st_gid;
3587c478bdstevel@tonic-gate	dev32_t		st_rdev;
3597c478bdstevel@tonic-gate	int32_t		st_pad2[2];
3607c478bdstevel@tonic-gate	off32_t		st_size;
3617c478bdstevel@tonic-gate	int32_t		st_pad3;
3627c478bdstevel@tonic-gate	timestruc32_t	st_atim;
3637c478bdstevel@tonic-gate	timestruc32_t	st_mtim;
3647c478bdstevel@tonic-gate	timestruc32_t	st_ctim;
3657c478bdstevel@tonic-gate	int32_t		st_blksize;
3667c478bdstevel@tonic-gate	blkcnt32_t	st_blocks;
3677c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
3687c478bdstevel@tonic-gate	int32_t		st_pad4[8];
3697c478bdstevel@tonic-gate};
3707c478bdstevel@tonic-gate
3717c478bdstevel@tonic-gate#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
3727c478bdstevel@tonic-gate#pragma pack(4)
3737c478bdstevel@tonic-gate#endif
3747c478bdstevel@tonic-gate
3757c478bdstevel@tonic-gatestruct stat64_32 {
3767c478bdstevel@tonic-gate	dev32_t		st_dev;
3777c478bdstevel@tonic-gate	int32_t		st_pad1[3];
3787c478bdstevel@tonic-gate	ino64_t		st_ino;
3797c478bdstevel@tonic-gate	mode32_t	st_mode;
3807c478bdstevel@tonic-gate	nlink32_t	st_nlink;
3817c478bdstevel@tonic-gate	uid32_t		st_uid;
3827c478bdstevel@tonic-gate	gid32_t		st_gid;
3837c478bdstevel@tonic-gate	dev32_t		st_rdev;
3847c478bdstevel@tonic-gate	int32_t		st_pad2[2];
3857c478bdstevel@tonic-gate	off64_t		st_size;
3867c478bdstevel@tonic-gate	timestruc32_t	st_atim;
3877c478bdstevel@tonic-gate	timestruc32_t	st_mtim;
3887c478bdstevel@tonic-gate	timestruc32_t	st_ctim;
3897c478bdstevel@tonic-gate	int32_t		st_blksize;
3907c478bdstevel@tonic-gate	blkcnt64_t	st_blocks;
3917c478bdstevel@tonic-gate	char		st_fstype[_ST_FSTYPSZ];
3927c478bdstevel@tonic-gate	int32_t		st_pad4[8];
3937c478bdstevel@tonic-gate};
3947c478bdstevel@tonic-gate
3957c478bdstevel@tonic-gate#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
3967c478bdstevel@tonic-gate#pragma pack()
3977c478bdstevel@tonic-gate#endif
3987c478bdstevel@tonic-gate
3997c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
4007c478bdstevel@tonic-gate
4017c478bdstevel@tonic-gate/* MODE MASKS */
4027c478bdstevel@tonic-gate
4037c478bdstevel@tonic-gate/* de facto standard definitions */
4047c478bdstevel@tonic-gate
4057c478bdstevel@tonic-gate#define	S_IFMT		0xF000	/* type of file */
4067c478bdstevel@tonic-gate#define	S_IAMB		0x1FF	/* access mode bits */
4077c478bdstevel@tonic-gate#define	S_IFIFO		0x1000	/* fifo */
4087c478bdstevel@tonic-gate#define	S_IFCHR		0x2000	/* character special */
4097c478bdstevel@tonic-gate#define	S_IFDIR		0x4000	/* directory */
4107c478bdstevel@tonic-gate/* XENIX definitions are not relevant to Solaris */
4117c478bdstevel@tonic-gate#define	S_IFNAM		0x5000  /* XENIX special named file */
4127c478bdstevel@tonic-gate#define	S_INSEM		0x1	/* XENIX semaphore subtype of IFNAM */
4137c478bdstevel@tonic-gate#define	S_INSHD		0x2	/* XENIX shared data subtype of IFNAM */
4147c478bdstevel@tonic-gate#define	S_IFBLK		0x6000	/* block special */
4157c478bdstevel@tonic-gate#define	S_IFREG		0x8000	/* regular */
4167c478bdstevel@tonic-gate#define	S_IFLNK		0xA000	/* symbolic link */
4177c478bdstevel@tonic-gate#define	S_IFSOCK	0xC000	/* socket */
4187c478bdstevel@tonic-gate#define	S_IFDOOR	0xD000	/* door */
4197c478bdstevel@tonic-gate#define	S_IFPORT	0xE000	/* event port */
4207c478bdstevel@tonic-gate#define	S_ISUID		0x800	/* set user id on execution */
4217c478bdstevel@tonic-gate#define	S_ISGID		0x400	/* set group id on execution */
4227c478bdstevel@tonic-gate#define	S_ISVTX		0x200	/* save swapped text even after use */
4237c478bdstevel@tonic-gate#define	S_IREAD		00400	/* read permission, owner */
4247c478bdstevel@tonic-gate#define	S_IWRITE	00200	/* write permission, owner */
4257c478bdstevel@tonic-gate#define	S_IEXEC		00100	/* execute/search permission, owner */
4267c478bdstevel@tonic-gate#define	S_ENFMT		S_ISGID	/* record locking enforcement flag */
4277c478bdstevel@tonic-gate
4287c478bdstevel@tonic-gate/* the following macros are for POSIX conformance */
4297c478bdstevel@tonic-gate
4307c478bdstevel@tonic-gate#define	S_IRWXU		00700	/* read, write, execute: owner */
4317c478bdstevel@tonic-gate#define	S_IRUSR		00400	/* read permission: owner */
4327c478bdstevel@tonic-gate#define	S_IWUSR		00200	/* write permission: owner */
4337c478bdstevel@tonic-gate#define	S_IXUSR		00100	/* execute permission: owner */
4347c478bdstevel@tonic-gate#define	S_IRWXG		00070	/* read, write, execute: group */
4357c478bdstevel@tonic-gate#define	S_IRGRP		00040	/* read permission: group */
4367c478bdstevel@tonic-gate#define	S_IWGRP		00020	/* write permission: group */
4377c478bdstevel@tonic-gate#define	S_IXGRP		00010	/* execute permission: group */
4387c478bdstevel@tonic-gate#define	S_IRWXO		00007	/* read, write, execute: other */
4397c478bdstevel@tonic-gate#define	S_IROTH		00004	/* read permission: other */
4407c478bdstevel@tonic-gate#define	S_IWOTH		00002	/* write permission: other */
4417c478bdstevel@tonic-gate#define	S_IXOTH		00001	/* execute permission: other */
4427c478bdstevel@tonic-gate
4437c478bdstevel@tonic-gate
4447c478bdstevel@tonic-gate#define	S_ISFIFO(mode)	(((mode)&0xF000) == 0x1000)
4457c478bdstevel@tonic-gate#define	S_ISCHR(mode)	(((mode)&0xF000) == 0x2000)
4467c478bdstevel@tonic-gate#define	S_ISDIR(mode)	(((mode)&0xF000) == 0x4000)
4477c478bdstevel@tonic-gate#define	S_ISBLK(mode)	(((mode)&0xF000) == 0x6000)
4487c478bdstevel@tonic-gate#define	S_ISREG(mode)	(((mode)&0xF000) == 0x8000)
4497c478bdstevel@tonic-gate#define	S_ISLNK(mode)	(((mode)&0xF000) == 0xa000)
4507c478bdstevel@tonic-gate#define	S_ISSOCK(mode)	(((mode)&0xF000) == 0xc000)
4517c478bdstevel@tonic-gate#define	S_ISDOOR(mode)	(((mode)&0xF000) == 0xd000)
4527c478bdstevel@tonic-gate#define	S_ISPORT(mode)	(((mode)&0xF000) == 0xe000)
4537c478bdstevel@tonic-gate
4547c478bdstevel@tonic-gate/* POSIX.4 macros */
4557c478bdstevel@tonic-gate#define	S_TYPEISMQ(_buf)	(0)
4567c478bdstevel@tonic-gate#define	S_TYPEISSEM(_buf)	(0)
4577c478bdstevel@tonic-gate#define	S_TYPEISSHM(_buf)	(0)
4587c478bdstevel@tonic-gate
4597c478bdstevel@tonic-gate#if defined(__i386) || (defined(__i386_COMPAT) && defined(_KERNEL))
4607c478bdstevel@tonic-gate
4617c478bdstevel@tonic-gate/*
4627c478bdstevel@tonic-gate * A version number is included in the x86 SVR4 stat and mknod interfaces
4637c478bdstevel@tonic-gate * so that SVR4 binaries can be supported.  An LP64 kernel that supports
4647c478bdstevel@tonic-gate * the i386 ABI need to be aware of this too.
4657c478bdstevel@tonic-gate */
4667c478bdstevel@tonic-gate
4677c478bdstevel@tonic-gate#define	_R3_MKNOD_VER	1	/* SVR3.0 mknod */
4687c478bdstevel@tonic-gate#define	_MKNOD_VER	2	/* current version of mknod */
4697c478bdstevel@tonic-gate#define	_R3_STAT_VER	1	/* SVR3.0 stat */
4707c478bdstevel@tonic-gate#define	_STAT_VER	2	/* current version of stat */
4717c478bdstevel@tonic-gate
4727c478bdstevel@tonic-gate#endif	/* __i386 || (__i386_COMPAT && _KERNEL) */
4737c478bdstevel@tonic-gate
4743b862e9Roger A. Faulkner#if defined(__EXTENSIONS__) || \
4753b862e9Roger A. Faulkner	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
4763b862e9Roger A. Faulkner	/* || defined(_XPG7) */
4773b862e9Roger A. Faulkner/* for use with futimens() and utimensat() */
4783b862e9Roger A. Faulkner#define	UTIME_NOW	-1L
4793b862e9Roger A. Faulkner#define	UTIME_OMIT	-2L
4803b862e9Roger A. Faulkner#endif	/* defined(__EXTENSIONS__) ... */
4813b862e9Roger A. Faulkner
4827c478bdstevel@tonic-gate#if !defined(_KERNEL) || defined(_BOOT)
4837c478bdstevel@tonic-gate
4847c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
4857c478bdstevel@tonic-gate	defined(_XPG4_2) || defined(__EXTENSIONS__)
4867c478bdstevel@tonic-gateextern int fchmod(int, mode_t);
4877c478bdstevel@tonic-gate#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
4887c478bdstevel@tonic-gate
4897c478bdstevel@tonic-gateextern int chmod(const char *, mode_t);
4907c478bdstevel@tonic-gateextern int mkdir(const char *, mode_t);
4917c478bdstevel@tonic-gateextern int mkfifo(const char *, mode_t);
4927c478bdstevel@tonic-gateextern mode_t umask(mode_t);
4937c478bdstevel@tonic-gate
4947c478bdstevel@tonic-gate/* transitional large file interfaces */
4957c478bdstevel@tonic-gate#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
4967c478bdstevel@tonic-gate	    !defined(__PRAGMA_REDEFINE_EXTNAME))
4977c478bdstevel@tonic-gateextern int fstat64(int, struct stat64 *);
4987c478bdstevel@tonic-gateextern int stat64(const char *_RESTRICT_KYWD, struct stat64 *_RESTRICT_KYWD);
4997c478bdstevel@tonic-gateextern int lstat64(const char *_RESTRICT_KYWD, struct stat64 *_RESTRICT_KYWD);
5007c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
5017c478bdstevel@tonic-gate	defined(_ATFILE_SOURCE)
5027c478bdstevel@tonic-gateextern int fstatat64(int, const char *, struct stat64 *, int);
5037c478bdstevel@tonic-gate#endif /* defined (_ATFILE_SOURCE) */
5047c478bdstevel@tonic-gate#endif
5057c478bdstevel@tonic-gate
506794f0adRoger A. Faulkner#if defined(__EXTENSIONS__) || defined(_ATFILE_SOURCE) || \
5073b862e9Roger A. Faulkner	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
5083b862e9Roger A. Faulkner	/* || defined(_XPG7) */
509794f0adRoger A. Faulknerextern int mkdirat(int, const char *, mode_t);
510794f0adRoger A. Faulknerextern int mkfifoat(int, const char *, mode_t);
511794f0adRoger A. Faulknerextern int mknodat(int, const char *, mode_t, dev_t);
512794f0adRoger A. Faulknerextern int fchmodat(int, const char *, mode_t, int);
5133b862e9Roger A. Faulknerextern int futimens(int, const struct timespec[2]);
5143b862e9Roger A. Faulknerextern int utimensat(int, const char *, const struct timespec[2], int);
5153b862e9Roger A. Faulkner#endif	/* defined(__EXTENSIONS__) ... */
5163b862e9Roger A. Faulkner
5177c478bdstevel@tonic-gate#include <sys/stat_impl.h>
5187c478bdstevel@tonic-gate
5197c478bdstevel@tonic-gate#endif /* !defined(_KERNEL) */
5207c478bdstevel@tonic-gate
5217c478bdstevel@tonic-gate#ifdef	__cplusplus
5227c478bdstevel@tonic-gate}
5237c478bdstevel@tonic-gate#endif
5247c478bdstevel@tonic-gate
5257c478bdstevel@tonic-gate#endif	/* _SYS_STAT_H */
526