xref: /f-stack/freebsd/sys/stat.h (revision 22ce4aff)
1a9643ea8Slogwang /*-
2*22ce4affSfengbojiang  * SPDX-License-Identifier: BSD-3-Clause
3*22ce4affSfengbojiang  *
4a9643ea8Slogwang  * Copyright (c) 1982, 1986, 1989, 1993
5a9643ea8Slogwang  *	The Regents of the University of California.  All rights reserved.
6a9643ea8Slogwang  * (c) UNIX System Laboratories, Inc.
7a9643ea8Slogwang  * All or some portions of this file are derived from material licensed
8a9643ea8Slogwang  * to the University of California by American Telephone and Telegraph
9a9643ea8Slogwang  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10a9643ea8Slogwang  * the permission of UNIX System Laboratories, Inc.
11a9643ea8Slogwang  *
12a9643ea8Slogwang  * Redistribution and use in source and binary forms, with or without
13a9643ea8Slogwang  * modification, are permitted provided that the following conditions
14a9643ea8Slogwang  * are met:
15a9643ea8Slogwang  * 1. Redistributions of source code must retain the above copyright
16a9643ea8Slogwang  *    notice, this list of conditions and the following disclaimer.
17a9643ea8Slogwang  * 2. Redistributions in binary form must reproduce the above copyright
18a9643ea8Slogwang  *    notice, this list of conditions and the following disclaimer in the
19a9643ea8Slogwang  *    documentation and/or other materials provided with the distribution.
20*22ce4affSfengbojiang  * 3. Neither the name of the University nor the names of its contributors
21a9643ea8Slogwang  *    may be used to endorse or promote products derived from this software
22a9643ea8Slogwang  *    without specific prior written permission.
23a9643ea8Slogwang  *
24a9643ea8Slogwang  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25a9643ea8Slogwang  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26a9643ea8Slogwang  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27a9643ea8Slogwang  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28a9643ea8Slogwang  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29a9643ea8Slogwang  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30a9643ea8Slogwang  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31a9643ea8Slogwang  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32a9643ea8Slogwang  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33a9643ea8Slogwang  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34a9643ea8Slogwang  * SUCH DAMAGE.
35a9643ea8Slogwang  *
36a9643ea8Slogwang  *	@(#)stat.h	8.12 (Berkeley) 6/16/95
37a9643ea8Slogwang  * $FreeBSD$
38a9643ea8Slogwang  */
39a9643ea8Slogwang 
40a9643ea8Slogwang #ifndef _SYS_STAT_H_
41a9643ea8Slogwang #define	_SYS_STAT_H_
42a9643ea8Slogwang 
43a9643ea8Slogwang #include <sys/cdefs.h>
44a9643ea8Slogwang #include <sys/_timespec.h>
45a9643ea8Slogwang #include <sys/_types.h>
46a9643ea8Slogwang 
47a9643ea8Slogwang #ifndef _BLKSIZE_T_DECLARED
48a9643ea8Slogwang typedef	__blksize_t	blksize_t;
49a9643ea8Slogwang #define	_BLKSIZE_T_DECLARED
50a9643ea8Slogwang #endif
51a9643ea8Slogwang 
52a9643ea8Slogwang #ifndef _BLKCNT_T_DECLARED
53a9643ea8Slogwang typedef	__blkcnt_t	blkcnt_t;
54a9643ea8Slogwang #define	_BLKCNT_T_DECLARED
55a9643ea8Slogwang #endif
56a9643ea8Slogwang 
57a9643ea8Slogwang #ifndef _DEV_T_DECLARED
58a9643ea8Slogwang typedef	__dev_t		dev_t;
59a9643ea8Slogwang #define	_DEV_T_DECLARED
60a9643ea8Slogwang #endif
61a9643ea8Slogwang 
62a9643ea8Slogwang #ifndef _FFLAGS_T_DECLARED
63a9643ea8Slogwang typedef	__fflags_t	fflags_t;
64a9643ea8Slogwang #define	_FFLAGS_T_DECLARED
65a9643ea8Slogwang #endif
66a9643ea8Slogwang 
67a9643ea8Slogwang #ifndef _GID_T_DECLARED
68a9643ea8Slogwang typedef	__gid_t		gid_t;
69a9643ea8Slogwang #define	_GID_T_DECLARED
70a9643ea8Slogwang #endif
71a9643ea8Slogwang 
72a9643ea8Slogwang #ifndef _INO_T_DECLARED
73a9643ea8Slogwang typedef	__ino_t		ino_t;
74a9643ea8Slogwang #define	_INO_T_DECLARED
75a9643ea8Slogwang #endif
76a9643ea8Slogwang 
77a9643ea8Slogwang #ifndef _MODE_T_DECLARED
78a9643ea8Slogwang typedef	__mode_t	mode_t;
79a9643ea8Slogwang #define	_MODE_T_DECLARED
80a9643ea8Slogwang #endif
81a9643ea8Slogwang 
82a9643ea8Slogwang #ifndef _NLINK_T_DECLARED
83a9643ea8Slogwang typedef	__nlink_t	nlink_t;
84a9643ea8Slogwang #define	_NLINK_T_DECLARED
85a9643ea8Slogwang #endif
86a9643ea8Slogwang 
87a9643ea8Slogwang #ifndef _OFF_T_DECLARED
88a9643ea8Slogwang typedef	__off_t		off_t;
89a9643ea8Slogwang #define	_OFF_T_DECLARED
90a9643ea8Slogwang #endif
91a9643ea8Slogwang 
92a9643ea8Slogwang #ifndef _UID_T_DECLARED
93a9643ea8Slogwang typedef	__uid_t		uid_t;
94a9643ea8Slogwang #define	_UID_T_DECLARED
95a9643ea8Slogwang #endif
96a9643ea8Slogwang 
97a9643ea8Slogwang #if !defined(_KERNEL) && __BSD_VISIBLE
98a9643ea8Slogwang /*
99a9643ea8Slogwang  * XXX We get miscellaneous namespace pollution with this.
100a9643ea8Slogwang  */
101a9643ea8Slogwang #include <sys/time.h>
102a9643ea8Slogwang #endif
103a9643ea8Slogwang 
104a9643ea8Slogwang #ifdef _KERNEL
105a9643ea8Slogwang struct ostat {
106a9643ea8Slogwang 	__uint16_t st_dev;		/* inode's device */
107*22ce4affSfengbojiang 	__uint32_t st_ino;		/* inode's number */
108a9643ea8Slogwang 	mode_t	  st_mode;		/* inode protection mode */
109*22ce4affSfengbojiang 	__uint16_t st_nlink;		/* number of hard links */
110a9643ea8Slogwang 	__uint16_t st_uid;		/* user ID of the file's owner */
111a9643ea8Slogwang 	__uint16_t st_gid;		/* group ID of the file's group */
112a9643ea8Slogwang 	__uint16_t st_rdev;		/* device type */
113a9643ea8Slogwang 	__int32_t st_size;		/* file size, in bytes */
114a9643ea8Slogwang 	struct	timespec st_atim;	/* time of last access */
115a9643ea8Slogwang 	struct	timespec st_mtim;	/* time of last data modification */
116a9643ea8Slogwang 	struct	timespec st_ctim;	/* time of last file status change */
117a9643ea8Slogwang 	__int32_t st_blksize;		/* optimal blocksize for I/O */
118a9643ea8Slogwang 	__int32_t st_blocks;		/* blocks allocated for file */
119a9643ea8Slogwang 	fflags_t  st_flags;		/* user defined flags for file */
120a9643ea8Slogwang 	__uint32_t st_gen;		/* file generation number */
121a9643ea8Slogwang };
122a9643ea8Slogwang #endif
123a9643ea8Slogwang 
124*22ce4affSfengbojiang #if defined(_WANT_FREEBSD11_STAT) || defined(_KERNEL)
125*22ce4affSfengbojiang struct freebsd11_stat {
126*22ce4affSfengbojiang 	__uint32_t st_dev;		/* inode's device */
127*22ce4affSfengbojiang 	__uint32_t st_ino;		/* inode's number */
128a9643ea8Slogwang 	mode_t	  st_mode;		/* inode protection mode */
129*22ce4affSfengbojiang 	__uint16_t st_nlink;		/* number of hard links */
130a9643ea8Slogwang 	uid_t	  st_uid;		/* user ID of the file's owner */
131a9643ea8Slogwang 	gid_t	  st_gid;		/* group ID of the file's group */
132*22ce4affSfengbojiang 	__uint32_t st_rdev;		/* device type */
133a9643ea8Slogwang 	struct	timespec st_atim;	/* time of last access */
134a9643ea8Slogwang 	struct	timespec st_mtim;	/* time of last data modification */
135a9643ea8Slogwang 	struct	timespec st_ctim;	/* time of last file status change */
136a9643ea8Slogwang 	off_t	  st_size;		/* file size, in bytes */
137a9643ea8Slogwang 	blkcnt_t st_blocks;		/* blocks allocated for file */
138a9643ea8Slogwang 	blksize_t st_blksize;		/* optimal blocksize for I/O */
139a9643ea8Slogwang 	fflags_t  st_flags;		/* user defined flags for file */
140a9643ea8Slogwang 	__uint32_t st_gen;		/* file generation number */
141a9643ea8Slogwang 	__int32_t st_lspare;
142a9643ea8Slogwang 	struct timespec st_birthtim;	/* time of file creation */
143a9643ea8Slogwang 	/*
144a9643ea8Slogwang 	 * Explicitly pad st_birthtim to 16 bytes so that the size of
145a9643ea8Slogwang 	 * struct stat is backwards compatible.  We use bitfields instead
146a9643ea8Slogwang 	 * of an array of chars so that this doesn't require a C99 compiler
147a9643ea8Slogwang 	 * to compile if the size of the padding is 0.  We use 2 bitfields
148a9643ea8Slogwang 	 * to cover up to 64 bits on 32-bit machines.  We assume that
149a9643ea8Slogwang 	 * CHAR_BIT is 8...
150a9643ea8Slogwang 	 */
151a9643ea8Slogwang 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
152a9643ea8Slogwang 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
153a9643ea8Slogwang };
154*22ce4affSfengbojiang #endif /* _WANT_FREEBSD11_STAT || _KERNEL */
155*22ce4affSfengbojiang 
156*22ce4affSfengbojiang #if defined(__i386__)
157*22ce4affSfengbojiang #define	__STAT_TIME_T_EXT	1
158*22ce4affSfengbojiang #endif
159*22ce4affSfengbojiang 
160*22ce4affSfengbojiang struct stat {
161*22ce4affSfengbojiang 	dev_t     st_dev;		/* inode's device */
162*22ce4affSfengbojiang 	ino_t	  st_ino;		/* inode's number */
163*22ce4affSfengbojiang 	nlink_t	  st_nlink;		/* number of hard links */
164*22ce4affSfengbojiang 	mode_t	  st_mode;		/* inode protection mode */
165*22ce4affSfengbojiang 	__int16_t st_padding0;
166*22ce4affSfengbojiang 	uid_t	  st_uid;		/* user ID of the file's owner */
167*22ce4affSfengbojiang 	gid_t	  st_gid;		/* group ID of the file's group */
168*22ce4affSfengbojiang 	__int32_t st_padding1;
169*22ce4affSfengbojiang 	dev_t     st_rdev;		/* device type */
170*22ce4affSfengbojiang #ifdef	__STAT_TIME_T_EXT
171*22ce4affSfengbojiang 	__int32_t st_atim_ext;
172*22ce4affSfengbojiang #endif
173*22ce4affSfengbojiang 	struct	timespec st_atim;	/* time of last access */
174*22ce4affSfengbojiang #ifdef	__STAT_TIME_T_EXT
175*22ce4affSfengbojiang 	__int32_t st_mtim_ext;
176*22ce4affSfengbojiang #endif
177*22ce4affSfengbojiang 	struct	timespec st_mtim;	/* time of last data modification */
178*22ce4affSfengbojiang #ifdef	__STAT_TIME_T_EXT
179*22ce4affSfengbojiang 	__int32_t st_ctim_ext;
180*22ce4affSfengbojiang #endif
181*22ce4affSfengbojiang 	struct	timespec st_ctim;	/* time of last file status change */
182*22ce4affSfengbojiang #ifdef	__STAT_TIME_T_EXT
183*22ce4affSfengbojiang 	__int32_t st_btim_ext;
184*22ce4affSfengbojiang #endif
185*22ce4affSfengbojiang 	struct	timespec st_birthtim;	/* time of file creation */
186*22ce4affSfengbojiang 	off_t	  st_size;		/* file size, in bytes */
187*22ce4affSfengbojiang 	blkcnt_t st_blocks;		/* blocks allocated for file */
188*22ce4affSfengbojiang 	blksize_t st_blksize;		/* optimal blocksize for I/O */
189*22ce4affSfengbojiang 	fflags_t  st_flags;		/* user defined flags for file */
190*22ce4affSfengbojiang 	__uint64_t st_gen;		/* file generation number */
191*22ce4affSfengbojiang 	__uint64_t st_spare[10];
192*22ce4affSfengbojiang };
193a9643ea8Slogwang 
194a9643ea8Slogwang #ifdef _KERNEL
195a9643ea8Slogwang struct nstat {
196*22ce4affSfengbojiang 	__uint32_t st_dev;		/* inode's device */
197*22ce4affSfengbojiang 	__uint32_t st_ino;		/* inode's number */
198a9643ea8Slogwang 	__uint32_t st_mode;		/* inode protection mode */
199a9643ea8Slogwang 	__uint32_t st_nlink;		/* number of hard links */
200a9643ea8Slogwang 	uid_t	  st_uid;		/* user ID of the file's owner */
201a9643ea8Slogwang 	gid_t	  st_gid;		/* group ID of the file's group */
202*22ce4affSfengbojiang 	__uint32_t st_rdev;		/* device type */
203a9643ea8Slogwang 	struct	timespec st_atim;	/* time of last access */
204a9643ea8Slogwang 	struct	timespec st_mtim;	/* time of last data modification */
205a9643ea8Slogwang 	struct	timespec st_ctim;	/* time of last file status change */
206a9643ea8Slogwang 	off_t	  st_size;		/* file size, in bytes */
207a9643ea8Slogwang 	blkcnt_t st_blocks;		/* blocks allocated for file */
208a9643ea8Slogwang 	blksize_t st_blksize;		/* optimal blocksize for I/O */
209a9643ea8Slogwang 	fflags_t  st_flags;		/* user defined flags for file */
210a9643ea8Slogwang 	__uint32_t st_gen;		/* file generation number */
211a9643ea8Slogwang 	struct timespec st_birthtim;	/* time of file creation */
212a9643ea8Slogwang 	/*
213*22ce4affSfengbojiang 	 * See comment in the definition of struct freebsd11_stat
214*22ce4affSfengbojiang 	 * above about the following padding.
215a9643ea8Slogwang 	 */
216a9643ea8Slogwang 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
217a9643ea8Slogwang 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
218a9643ea8Slogwang };
219a9643ea8Slogwang #endif
220a9643ea8Slogwang 
221a9643ea8Slogwang #ifndef _KERNEL
222a9643ea8Slogwang #define	st_atime		st_atim.tv_sec
223a9643ea8Slogwang #define	st_mtime		st_mtim.tv_sec
224a9643ea8Slogwang #define	st_ctime		st_ctim.tv_sec
225a9643ea8Slogwang #if __BSD_VISIBLE
226a9643ea8Slogwang #define	st_birthtime		st_birthtim.tv_sec
227*22ce4affSfengbojiang #define	st_atimensec		st_atim.tv_nsec
228*22ce4affSfengbojiang #define	st_mtimensec		st_mtim.tv_nsec
229*22ce4affSfengbojiang #define	st_ctimensec		st_ctim.tv_nsec
230*22ce4affSfengbojiang #define	st_birthtimensec	st_birthtim.tv_nsec
231a9643ea8Slogwang #endif
232a9643ea8Slogwang 
233a9643ea8Slogwang /* For compatibility. */
234a9643ea8Slogwang #if __BSD_VISIBLE
235a9643ea8Slogwang #define	st_atimespec		st_atim
236a9643ea8Slogwang #define	st_mtimespec		st_mtim
237a9643ea8Slogwang #define	st_ctimespec		st_ctim
238a9643ea8Slogwang #define	st_birthtimespec	st_birthtim
239a9643ea8Slogwang #endif
240a9643ea8Slogwang #endif /* !_KERNEL */
241a9643ea8Slogwang 
242a9643ea8Slogwang #define	S_ISUID	0004000			/* set user id on execution */
243a9643ea8Slogwang #define	S_ISGID	0002000			/* set group id on execution */
244a9643ea8Slogwang #if __BSD_VISIBLE
245a9643ea8Slogwang #define	S_ISTXT	0001000			/* sticky bit */
246a9643ea8Slogwang #endif
247a9643ea8Slogwang 
248a9643ea8Slogwang #define	S_IRWXU	0000700			/* RWX mask for owner */
249a9643ea8Slogwang #define	S_IRUSR	0000400			/* R for owner */
250a9643ea8Slogwang #define	S_IWUSR	0000200			/* W for owner */
251a9643ea8Slogwang #define	S_IXUSR	0000100			/* X for owner */
252a9643ea8Slogwang 
253a9643ea8Slogwang #if __BSD_VISIBLE
254a9643ea8Slogwang #define	S_IREAD		S_IRUSR
255a9643ea8Slogwang #define	S_IWRITE	S_IWUSR
256a9643ea8Slogwang #define	S_IEXEC		S_IXUSR
257a9643ea8Slogwang #endif
258a9643ea8Slogwang 
259a9643ea8Slogwang #define	S_IRWXG	0000070			/* RWX mask for group */
260a9643ea8Slogwang #define	S_IRGRP	0000040			/* R for group */
261a9643ea8Slogwang #define	S_IWGRP	0000020			/* W for group */
262a9643ea8Slogwang #define	S_IXGRP	0000010			/* X for group */
263a9643ea8Slogwang 
264a9643ea8Slogwang #define	S_IRWXO	0000007			/* RWX mask for other */
265a9643ea8Slogwang #define	S_IROTH	0000004			/* R for other */
266a9643ea8Slogwang #define	S_IWOTH	0000002			/* W for other */
267a9643ea8Slogwang #define	S_IXOTH	0000001			/* X for other */
268a9643ea8Slogwang 
269a9643ea8Slogwang #if __XSI_VISIBLE
270a9643ea8Slogwang #define	S_IFMT	 0170000		/* type of file mask */
271a9643ea8Slogwang #define	S_IFIFO	 0010000		/* named pipe (fifo) */
272a9643ea8Slogwang #define	S_IFCHR	 0020000		/* character special */
273a9643ea8Slogwang #define	S_IFDIR	 0040000		/* directory */
274a9643ea8Slogwang #define	S_IFBLK	 0060000		/* block special */
275a9643ea8Slogwang #define	S_IFREG	 0100000		/* regular */
276a9643ea8Slogwang #define	S_IFLNK	 0120000		/* symbolic link */
277a9643ea8Slogwang #define	S_IFSOCK 0140000		/* socket */
278a9643ea8Slogwang #define	S_ISVTX	 0001000		/* save swapped text even after use */
279a9643ea8Slogwang #endif
280a9643ea8Slogwang #if __BSD_VISIBLE
281a9643ea8Slogwang #define	S_IFWHT  0160000		/* whiteout */
282a9643ea8Slogwang #endif
283a9643ea8Slogwang 
284a9643ea8Slogwang #define	S_ISDIR(m)	(((m) & 0170000) == 0040000)	/* directory */
285a9643ea8Slogwang #define	S_ISCHR(m)	(((m) & 0170000) == 0020000)	/* char special */
286a9643ea8Slogwang #define	S_ISBLK(m)	(((m) & 0170000) == 0060000)	/* block special */
287a9643ea8Slogwang #define	S_ISREG(m)	(((m) & 0170000) == 0100000)	/* regular file */
288a9643ea8Slogwang #define	S_ISFIFO(m)	(((m) & 0170000) == 0010000)	/* fifo or socket */
289a9643ea8Slogwang #if __POSIX_VISIBLE >= 200112
290a9643ea8Slogwang #define	S_ISLNK(m)	(((m) & 0170000) == 0120000)	/* symbolic link */
291a9643ea8Slogwang #define	S_ISSOCK(m)	(((m) & 0170000) == 0140000)	/* socket */
292a9643ea8Slogwang #endif
293a9643ea8Slogwang #if __BSD_VISIBLE
294a9643ea8Slogwang #define	S_ISWHT(m)	(((m) & 0170000) == 0160000)	/* whiteout */
295a9643ea8Slogwang #endif
296a9643ea8Slogwang 
297a9643ea8Slogwang #if __BSD_VISIBLE
298a9643ea8Slogwang #define	ACCESSPERMS	(S_IRWXU|S_IRWXG|S_IRWXO)	/* 0777 */
299a9643ea8Slogwang 							/* 7777 */
300a9643ea8Slogwang #define	ALLPERMS	(S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
301a9643ea8Slogwang 							/* 0666 */
302a9643ea8Slogwang #define	DEFFILEMODE	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
303a9643ea8Slogwang 
304a9643ea8Slogwang #define S_BLKSIZE	512		/* block size used in the stat struct */
305a9643ea8Slogwang 
306a9643ea8Slogwang /*
307a9643ea8Slogwang  * Definitions of flags stored in file flags word.
308a9643ea8Slogwang  *
309a9643ea8Slogwang  * Super-user and owner changeable flags.
310a9643ea8Slogwang  */
311a9643ea8Slogwang #define	UF_SETTABLE	0x0000ffff	/* mask of owner changeable flags */
312a9643ea8Slogwang #define	UF_NODUMP	0x00000001	/* do not dump file */
313a9643ea8Slogwang #define	UF_IMMUTABLE	0x00000002	/* file may not be changed */
314a9643ea8Slogwang #define	UF_APPEND	0x00000004	/* writes to file may only append */
315a9643ea8Slogwang #define	UF_OPAQUE	0x00000008	/* directory is opaque wrt. union */
316a9643ea8Slogwang #define	UF_NOUNLINK	0x00000010	/* file may not be removed or renamed */
317a9643ea8Slogwang /*
318a9643ea8Slogwang  * These two bits are defined in MacOS X.  They are not currently used in
319a9643ea8Slogwang  * FreeBSD.
320a9643ea8Slogwang  */
321a9643ea8Slogwang #if 0
322a9643ea8Slogwang #define	UF_COMPRESSED	0x00000020	/* file is compressed */
323a9643ea8Slogwang #define	UF_TRACKED	0x00000040	/* renames and deletes are tracked */
324a9643ea8Slogwang #endif
325a9643ea8Slogwang 
326a9643ea8Slogwang #define	UF_SYSTEM	0x00000080	/* Windows system file bit */
327a9643ea8Slogwang #define	UF_SPARSE	0x00000100	/* sparse file */
328a9643ea8Slogwang #define	UF_OFFLINE	0x00000200	/* file is offline */
329a9643ea8Slogwang #define	UF_REPARSE	0x00000400	/* Windows reparse point file bit */
330a9643ea8Slogwang #define	UF_ARCHIVE	0x00000800	/* file needs to be archived */
331a9643ea8Slogwang #define	UF_READONLY	0x00001000	/* Windows readonly file bit */
332a9643ea8Slogwang /* This is the same as the MacOS X definition of UF_HIDDEN. */
333a9643ea8Slogwang #define	UF_HIDDEN	0x00008000	/* file is hidden */
334a9643ea8Slogwang 
335a9643ea8Slogwang /*
336a9643ea8Slogwang  * Super-user changeable flags.
337a9643ea8Slogwang  */
338a9643ea8Slogwang #define	SF_SETTABLE	0xffff0000	/* mask of superuser changeable flags */
339a9643ea8Slogwang #define	SF_ARCHIVED	0x00010000	/* file is archived */
340a9643ea8Slogwang #define	SF_IMMUTABLE	0x00020000	/* file may not be changed */
341a9643ea8Slogwang #define	SF_APPEND	0x00040000	/* writes to file may only append */
342a9643ea8Slogwang #define	SF_NOUNLINK	0x00100000	/* file may not be removed or renamed */
343a9643ea8Slogwang #define	SF_SNAPSHOT	0x00200000	/* snapshot inode */
344a9643ea8Slogwang 
345a9643ea8Slogwang #ifdef _KERNEL
346a9643ea8Slogwang /*
347a9643ea8Slogwang  * Shorthand abbreviations of above.
348a9643ea8Slogwang  */
349a9643ea8Slogwang #define	OPAQUE		(UF_OPAQUE)
350a9643ea8Slogwang #define	APPEND		(UF_APPEND | SF_APPEND)
351a9643ea8Slogwang #define	IMMUTABLE	(UF_IMMUTABLE | SF_IMMUTABLE)
352a9643ea8Slogwang #define	NOUNLINK	(UF_NOUNLINK | SF_NOUNLINK)
353a9643ea8Slogwang #endif
354a9643ea8Slogwang 
355a9643ea8Slogwang #endif /* __BSD_VISIBLE */
356a9643ea8Slogwang 
357a9643ea8Slogwang #if __POSIX_VISIBLE >= 200809
358a9643ea8Slogwang #define	UTIME_NOW	-1
359a9643ea8Slogwang #define	UTIME_OMIT	-2
360a9643ea8Slogwang #endif
361a9643ea8Slogwang 
362a9643ea8Slogwang #ifndef _KERNEL
363a9643ea8Slogwang __BEGIN_DECLS
364a9643ea8Slogwang #if __BSD_VISIBLE
365a9643ea8Slogwang int	chflags(const char *, unsigned long);
366a9643ea8Slogwang int	chflagsat(int, const char *, unsigned long, int);
367a9643ea8Slogwang #endif
368a9643ea8Slogwang int	chmod(const char *, mode_t);
369a9643ea8Slogwang #if __BSD_VISIBLE
370a9643ea8Slogwang int	fchflags(int, unsigned long);
371a9643ea8Slogwang #endif
372a9643ea8Slogwang #if __POSIX_VISIBLE >= 200112
373a9643ea8Slogwang int	fchmod(int, mode_t);
374a9643ea8Slogwang #endif
375a9643ea8Slogwang #if __POSIX_VISIBLE >= 200809
376a9643ea8Slogwang int	fchmodat(int, const char *, mode_t, int);
377a9643ea8Slogwang int	futimens(int fd, const struct timespec times[2]);
378a9643ea8Slogwang int	utimensat(int fd, const char *path, const struct timespec times[2],
379a9643ea8Slogwang 		int flag);
380a9643ea8Slogwang #endif
381a9643ea8Slogwang int	fstat(int, struct stat *);
382a9643ea8Slogwang #if __BSD_VISIBLE
383a9643ea8Slogwang int	lchflags(const char *, unsigned long);
384a9643ea8Slogwang int	lchmod(const char *, mode_t);
385a9643ea8Slogwang #endif
386a9643ea8Slogwang #if __POSIX_VISIBLE >= 200112
387a9643ea8Slogwang int	lstat(const char * __restrict, struct stat * __restrict);
388a9643ea8Slogwang #endif
389a9643ea8Slogwang int	mkdir(const char *, mode_t);
390a9643ea8Slogwang int	mkfifo(const char *, mode_t);
391a9643ea8Slogwang #if !defined(_MKNOD_DECLARED) && __XSI_VISIBLE
392a9643ea8Slogwang int	mknod(const char *, mode_t, dev_t);
393a9643ea8Slogwang #define	_MKNOD_DECLARED
394a9643ea8Slogwang #endif
395a9643ea8Slogwang int	stat(const char * __restrict, struct stat * __restrict);
396a9643ea8Slogwang mode_t	umask(mode_t);
397a9643ea8Slogwang #if __POSIX_VISIBLE >= 200809
398a9643ea8Slogwang int	fstatat(int, const char *, struct stat *, int);
399a9643ea8Slogwang int	mkdirat(int, const char *, mode_t);
400a9643ea8Slogwang int	mkfifoat(int, const char *, mode_t);
401a9643ea8Slogwang #endif
402a9643ea8Slogwang #if __XSI_VISIBLE >= 700
403a9643ea8Slogwang int	mknodat(int, const char *, mode_t, dev_t);
404a9643ea8Slogwang #endif
405a9643ea8Slogwang __END_DECLS
406a9643ea8Slogwang #endif /* !_KERNEL */
407a9643ea8Slogwang 
408a9643ea8Slogwang #endif /* !_SYS_STAT_H_ */
409