xref: /titanic_41/usr/src/lib/libbc/inc/include/sys/stat.h (revision 5d54f3d8999eac1762fe0a8c7177d20f1f201fae)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	__SYS_STAT_H
28 #define	__SYS_STAT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * NOTE: changes to this file should also be made to xpg2include/sys/stat.h
34  */
35 
36 #include <sys/types.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 struct	stat {
43 	dev_t	st_dev;
44 	ino_t	st_ino;
45 	mode_t	st_mode;
46 	short	st_nlink;
47 	uid_t	st_uid;
48 	gid_t	st_gid;
49 	dev_t	st_rdev;
50 	off_t	st_size;
51 	time_t	st_atime;
52 	int	st_spare1;
53 	time_t	st_mtime;
54 	int	st_spare2;
55 	time_t	st_ctime;
56 	int	st_spare3;
57 	long	st_blksize;
58 	long	st_blocks;
59 	long	st_spare4[2];
60 };
61 
62 #define	_IFMT		0170000	/* type of file */
63 #define		_IFDIR	0040000	/* directory */
64 #define		_IFCHR	0020000	/* character special */
65 #define		_IFBLK	0060000	/* block special */
66 #define		_IFREG	0100000	/* regular */
67 #define		_IFLNK	0120000	/* symbolic link */
68 #define		_IFSOCK	0140000	/* socket */
69 #define		_IFIFO	0010000	/* fifo */
70 
71 #define	S_ISUID		0004000	/* set user id on execution */
72 #define	S_ISGID		0002000	/* set group id on execution */
73 #ifndef	_POSIX_SOURCE
74 #define	S_ISVTX		0001000	/* save swapped text even after use */
75 #define	S_IREAD		0000400	/* read permission, owner */
76 #define	S_IWRITE 	0000200	/* write permission, owner */
77 #define	S_IEXEC		0000100	/* execute/search permission, owner */
78 
79 #define	S_ENFMT 	0002000	/* enforcement-mode locking */
80 
81 #define	S_IFMT		_IFMT
82 #define	S_IFDIR		_IFDIR
83 #define	S_IFCHR		_IFCHR
84 #define	S_IFBLK		_IFBLK
85 #define	S_IFREG		_IFREG
86 #define	S_IFLNK		_IFLNK
87 #define	S_IFSOCK	_IFSOCK
88 #define	S_IFIFO		_IFIFO
89 #endif	/* !_POSIX_SOURCE */
90 
91 #define	S_IRWXU 	0000700	/* rwx, owner */
92 #define		S_IRUSR	0000400	/* read permission, owner */
93 #define		S_IWUSR	0000200	/* write permission, owner */
94 #define		S_IXUSR	0000100	/* execute/search permission, owner */
95 #define	S_IRWXG		0000070	/* rwx, group */
96 #define		S_IRGRP	0000040	/* read permission, group */
97 #define		S_IWGRP	0000020	/* write permission, grougroup */
98 #define		S_IXGRP	0000010	/* execute/search permission, group */
99 #define	S_IRWXO		0000007	/* rwx, other */
100 #define		S_IROTH	0000004	/* read permission, other */
101 #define		S_IWOTH	0000002	/* write permission, other */
102 #define		S_IXOTH	0000001	/* execute/search permission, other */
103 
104 #define	S_ISBLK(m)	(((m)&_IFMT) == _IFBLK)
105 #define	S_ISCHR(m)	(((m)&_IFMT) == _IFCHR)
106 #define	S_ISDIR(m)	(((m)&_IFMT) == _IFDIR)
107 #define	S_ISFIFO(m)	(((m)&_IFMT) == _IFIFO)
108 #define	S_ISREG(m)	(((m)&_IFMT) == _IFREG)
109 #ifndef	_POSIX_SOURCE
110 #define	S_ISLNK(m)	(((m)&_IFMT) == _IFLNK)
111 #define	S_ISSOCK(m)	(((m)&_IFMT) == _IFSOCK)
112 #endif
113 
114 int	chmod(char *, mode_t);
115 int	fstat(int, struct stat *);
116 int	mkdir(char *, mode_t);
117 int	mkfifo(char *, mode_t);
118 int	stat(char *, struct stat *);
119 mode_t	umask(mode_t);
120 
121 #ifdef	__cplusplus
122 }
123 #endif
124 
125 #endif	/* __SYS_STAT_H */
126