87e6e5f1f885dd0fff2b5756bc5f57890a798367
[reactos.git] / reactos / drivers / lib / oskittcp / include / freebsd / src / sys / sys / stat.h
1 /*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)stat.h 8.6 (Berkeley) 3/8/94
39 */
40
41 #ifndef _SYS_STAT_H_
42 #define _SYS_STAT_H_
43
44 /*
45 * XXX we need this for struct timespec. We get miscellaneous namespace
46 * pollution with it. struct timespace itself is namespace pollution if
47 * _POSIX_SOURCE is defined.
48 */
49 #include <sys/time.h>
50
51 #ifndef _POSIX_SOURCE
52 struct ostat {
53 unsigned short st_dev; /* inode's device */
54 ino_t st_ino; /* inode's number */
55 mode_t st_mode; /* inode protection mode */
56 nlink_t st_nlink; /* number of hard links */
57 unsigned short st_uid; /* user ID of the file's owner */
58 unsigned short st_gid; /* group ID of the file's group */
59 unsigned short st_rdev; /* device type */
60 long st_size; /* file size, in bytes */
61 struct timespec st_atimespec; /* time of last access */
62 struct timespec st_mtimespec; /* time of last data modification */
63 struct timespec st_ctimespec; /* time of last file status change */
64 long st_blksize; /* optimal blocksize for I/O */
65 long st_blocks; /* blocks allocated for file */
66 unsigned long st_flags; /* user defined flags for file */
67 unsigned long st_gen; /* file generation number */
68 };
69 #endif /* !_POSIX_SOURCE */
70
71 struct stat {
72 dev_t st_dev; /* inode's device */
73 ino_t st_ino; /* inode's number */
74 mode_t st_mode; /* inode protection mode */
75 nlink_t st_nlink; /* number of hard links */
76 uid_t st_uid; /* user ID of the file's owner */
77 gid_t st_gid; /* group ID of the file's group */
78 dev_t st_rdev; /* device type */
79 struct timespec st_atimespec; /* time of last access */
80 struct timespec st_mtimespec; /* time of last data modification */
81 struct timespec st_ctimespec; /* time of last file status change */
82 off_t st_size; /* file size, in bytes */
83 quad_t st_blocks; /* blocks allocated for file */
84 unsigned long st_blksize; /* optimal blocksize for I/O */
85 unsigned long st_flags; /* user defined flags for file */
86 unsigned long st_gen; /* file generation number */
87 long st_lspare;
88 quad_t st_qspare[2];
89 };
90 #define st_atime st_atimespec.ts_sec
91 #define st_mtime st_mtimespec.ts_sec
92 #define st_ctime st_ctimespec.ts_sec
93
94 #define S_ISUID 0004000 /* set user id on execution */
95 #define S_ISGID 0002000 /* set group id on execution */
96 #ifndef _POSIX_SOURCE
97 #define S_ISTXT 0001000 /* sticky bit */
98 #endif
99
100 #define S_IRWXU 0000700 /* RWX mask for owner */
101 #define S_IRUSR 0000400 /* R for owner */
102 #define S_IWUSR 0000200 /* W for owner */
103 #define S_IXUSR 0000100 /* X for owner */
104
105 #ifndef _POSIX_SOURCE
106 #define S_IREAD S_IRUSR
107 #define S_IWRITE S_IWUSR
108 #define S_IEXEC S_IXUSR
109 #endif
110
111 #define S_IRWXG 0000070 /* RWX mask for group */
112 #define S_IRGRP 0000040 /* R for group */
113 #define S_IWGRP 0000020 /* W for group */
114 #define S_IXGRP 0000010 /* X for group */
115
116 #define S_IRWXO 0000007 /* RWX mask for other */
117 #define S_IROTH 0000004 /* R for other */
118 #define S_IWOTH 0000002 /* W for other */
119 #define S_IXOTH 0000001 /* X for other */
120
121 #ifndef _POSIX_SOURCE
122 #define S_IFMT 0170000 /* type of file mask */
123 #define S_IFIFO 0010000 /* named pipe (fifo) */
124 #define S_IFCHR 0020000 /* character special */
125 #define S_IFDIR 0040000 /* directory */
126 #define S_IFBLK 0060000 /* block special */
127 #define S_IFREG 0100000 /* regular */
128 #define S_IFLNK 0120000 /* symbolic link */
129 #define S_IFSOCK 0140000 /* socket */
130 #define S_ISVTX 0001000 /* save swapped text even after use */
131 #endif
132
133 #define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
134 #define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
135 #define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
136 #define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
137 #define S_ISFIFO(m) (((m) & 0170000) == 0010000 || \
138 ((m) & 0170000) == 0140000) /* fifo or socket */
139 #ifndef _POSIX_SOURCE
140 #define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
141 #define S_ISSOCK(m) (((m) & 0170000) == 0010000 || \
142 ((m) & 0170000) == 0140000) /* fifo or socket */
143 #endif
144
145 #ifndef _POSIX_SOURCE
146 #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
147 /* 7777 */
148 #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
149 /* 0666 */
150 #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
151
152 #define S_BLKSIZE 512 /* block size used in the stat struct */
153
154 /*
155 * Definitions of flags stored in file flags word.
156 *
157 * Super-user and owner changeable flags.
158 */
159 #define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
160 #define UF_NODUMP 0x00000001 /* do not dump file */
161 #define UF_IMMUTABLE 0x00000002 /* file may not be changed */
162 #define UF_APPEND 0x00000004 /* writes to file may only append */
163 /*
164 * Super-user changeable flags.
165 */
166 #define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
167 #define SF_ARCHIVED 0x00010000 /* file is archived */
168 #define SF_IMMUTABLE 0x00020000 /* file may not be changed */
169 #define SF_APPEND 0x00040000 /* writes to file may only append */
170
171 #ifdef KERNEL
172 /*
173 * Shorthand abbreviations of above.
174 */
175 #define APPEND (UF_APPEND | SF_APPEND)
176 #define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
177 #endif
178
179 #endif /* !_POSIX_SOURCE */
180
181 #ifdef KERNEL
182 void cvtstat __P((struct stat *, struct ostat *));
183 #else /* KERNEL */
184 #include <sys/cdefs.h>
185
186 __BEGIN_DECLS
187 int chmod __P((const char *, mode_t));
188 int fstat __P((int, struct stat *));
189 int mkdir __P((const char *, mode_t));
190 int mkfifo __P((const char *, mode_t));
191 int stat __P((const char *, struct stat *));
192 mode_t umask __P((mode_t));
193 #ifndef _POSIX_SOURCE
194 int chflags __P((const char *, u_long));
195 int fchflags __P((int, u_long));
196 int fchmod __P((int, mode_t));
197 int lstat __P((const char *, struct stat *));
198 #endif
199 __END_DECLS
200
201 #endif /* KERNEL */
202
203 #endif /* !_SYS_STAT_H_ */