vm: fix sanity checks on arm
[minix.git] / sys / sys / stat.h
blob06a5a347e71a99bc5da6abffcaa98b09c1e9ac80
1 /* $NetBSD: stat.h,v 1.63 2011/09/04 10:02:33 christos Exp $ */
3 /*-
4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
36 * @(#)stat.h 8.12 (Berkeley) 8/17/94
39 #ifndef _SYS_STAT_H_
40 #define _SYS_STAT_H_
42 #include <sys/featuretest.h>
43 #include <sys/types.h> /* XXX */
45 #if defined(_NETBSD_SOURCE)
46 #include <sys/time.h>
47 #endif
49 struct stat {
50 big_dev_t st_dev; /* inode's device */
51 big_mode_t st_mode; /* inode protection mode */
52 big_ino_t st_ino; /* inode's number */
53 big_nlink_t st_nlink; /* number of hard links */
54 big_uid_t st_uid; /* user ID of the file's owner */
55 big_gid_t st_gid; /* group ID of the file's group */
56 big_dev_t st_rdev; /* device type */
57 #if defined(_NETBSD_SOURCE)
58 struct timespec st_atimespec;/* time of last access */
59 struct timespec st_mtimespec;/* time of last data modification */
60 struct timespec st_ctimespec;/* time of last file status change */
61 struct timespec st_birthtimespec; /* time of creation */
62 #else
63 time_t st_atime; /* time of last access */
64 long st_atimensec; /* nsec of last access */
65 time_t st_mtime; /* time of last data modification */
66 long st_mtimensec; /* nsec of last data modification */
67 time_t st_ctime; /* time of last file status change */
68 long st_ctimensec; /* nsec of last file status change */
69 time_t st_birthtime; /* time of creation */
70 long st_birthtimensec; /* nsec of time of creation */
71 #endif
72 #ifdef ST_SIZE_OFF_T
73 off_t st_size; /* file size, in off_t bytes */
74 off_t st_size_rest;
75 #else
76 big_off_t st_size; /* file size, in bytes */
77 #endif
78 blkcnt_t st_blocks; /* blocks allocated for file */
79 blksize_t st_blksize; /* optimal blocksize for I/O */
80 u32_t st_flags; /* user defined flags for file */
81 u32_t st_gen; /* file generation number */
82 u32_t st_spare[2];
85 struct minix_prev_stat {
86 short st_dev; /* major/minor device number */
87 ino_t st_ino; /* i-node number */
88 mode_t st_mode; /* file mode, protection bits, etc. */
89 nlink_t st_nlink; /* # links; */
90 short st_uid; /* uid of the file's owner */
91 short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
92 short st_rdev;
93 off_t st_size; /* file size */
94 time_t st_atime; /* time of last access */
95 time_t st_mtime; /* time of last data modification */
96 time_t st_ctime; /* time of last file status change */
99 #if defined(_NETBSD_SOURCE)
100 #define st_atime st_atimespec.tv_sec
101 #define st_atimensec st_atimespec.tv_nsec
102 #define st_mtime st_mtimespec.tv_sec
103 #define st_mtimensec st_mtimespec.tv_nsec
104 #define st_ctime st_ctimespec.tv_sec
105 #define st_ctimensec st_ctimespec.tv_nsec
106 #define st_birthtime st_birthtimespec.tv_sec
107 #define st_birthtimensec st_birthtimespec.tv_nsec
108 #endif
110 #define S_ISUID 0004000 /* set user id on execution */
111 #define S_ISGID 0002000 /* set group id on execution */
112 #if defined(_NETBSD_SOURCE)
113 #define S_ISTXT 0001000 /* sticky bit */
114 #endif
116 #define S_IRWXU 0000700 /* RWX mask for owner */
117 #define S_IRUSR 0000400 /* R for owner */
118 #define S_IWUSR 0000200 /* W for owner */
119 #define S_IXUSR 0000100 /* X for owner */
121 #if defined(_NETBSD_SOURCE)
122 #define S_IREAD S_IRUSR
123 #define S_IWRITE S_IWUSR
124 #define S_IEXEC S_IXUSR
125 #endif
127 #define S_IRWXG 0000070 /* RWX mask for group */
128 #define S_IRGRP 0000040 /* R for group */
129 #define S_IWGRP 0000020 /* W for group */
130 #define S_IXGRP 0000010 /* X for group */
132 #define S_IRWXO 0000007 /* RWX mask for other */
133 #define S_IROTH 0000004 /* R for other */
134 #define S_IWOTH 0000002 /* W for other */
135 #define S_IXOTH 0000001 /* X for other */
137 #define _S_IFMT 0170000 /* type of file mask */
138 #define _S_IFIFO 0010000 /* named pipe (fifo) */
139 #define _S_IFCHR 0020000 /* character special */
140 #define _S_IFDIR 0040000 /* directory */
141 #define _S_IFBLK 0060000 /* block special */
142 #define _S_IFREG 0100000 /* regular */
143 #define _S_IFLNK 0120000 /* symbolic link */
144 #define _S_ISVTX 0001000 /* save swapped text even after use */
145 #define _S_IFSOCK 0140000 /* socket */
146 #define _S_IFWHT 0160000 /* whiteout */
147 #define _S_ARCH1 0200000 /* Archive state 1, ls -l shows 'a' */
148 #define _S_ARCH2 0400000 /* Archive state 2, ls -l shows 'A' */
150 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
151 #define S_IFMT _S_IFMT
152 #define S_IFIFO _S_IFIFO
153 #define S_IFCHR _S_IFCHR
154 #define S_IFDIR _S_IFDIR
155 #define S_IFBLK _S_IFBLK
156 #define S_IFREG _S_IFREG
157 #define S_IFLNK _S_IFLNK
158 #define S_ISVTX _S_ISVTX
159 #endif
160 #if ((_XOPEN_SOURCE - 0) >= 600) || defined(_NETBSD_SOURCE)
161 #define S_IFSOCK _S_IFSOCK
162 #endif
163 #if defined(_NETBSD_SOURCE)
164 #define S_IFWHT _S_IFWHT
166 #define S_ARCH1 _S_ARCH1
167 #define S_ARCH2 _S_ARCH2
168 #endif
170 #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) /* directory */
171 #define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) /* char special */
172 #define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) /* block special */
173 #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) /* regular file */
174 #define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) /* fifo */
175 #if ((_POSIX_C_SOURCE - 0) >= 200112L) || defined(_XOPEN_SOURCE) || \
176 defined(_NETBSD_SOURCE)
177 #define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* symbolic link */
178 #endif
179 #if ((_POSIX_C_SOURCE - 0) >= 200112L) || ((_XOPEN_SOURCE - 0) >= 600) || \
180 defined(_NETBSD_SOURCE)
181 #define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK) /* socket */
182 #endif
183 #if defined(_NETBSD_SOURCE)
184 #define S_ISWHT(m) (((m) & _S_IFMT) == _S_IFWHT) /* whiteout */
185 #endif
187 #if defined(_NETBSD_SOURCE)
188 #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
189 /* 7777 */
190 #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
191 /* 0666 */
192 #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
194 #define S_BLKSIZE 512 /* block size used in the stat struct */
197 * Definitions of flags stored in file flags word.
199 * Super-user and owner changeable flags.
201 #define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
202 #define UF_NODUMP 0x00000001 /* do not dump file */
203 #define UF_IMMUTABLE 0x00000002 /* file may not be changed */
204 #define UF_APPEND 0x00000004 /* writes to file may only append */
205 #define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
206 /* UF_NOUNLINK 0x00000010 [NOT IMPLEMENTED] */
208 * Super-user changeable flags.
210 #define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
211 #define SF_ARCHIVED 0x00010000 /* file is archived */
212 #define SF_IMMUTABLE 0x00020000 /* file may not be changed */
213 #define SF_APPEND 0x00040000 /* writes to file may only append */
215 #endif /* _NETBSD_SOURCE */
217 #if defined(__minix)
218 #include <machine/vmparam.h>
219 /* Convenient constant to use when st_blocksize field is required. */
220 #define MINIX_ST_BLKSIZE PAGE_SIZE
221 #endif
223 #if !defined(_KERNEL) && !defined(_STANDALONE)
224 #include <sys/cdefs.h>
226 __BEGIN_DECLS
227 int chmod(const char *, mode_t);
228 int mkdir(const char *, mode_t);
229 int mkfifo(const char *, mode_t);
230 #ifndef __LIBC12_SOURCE__
231 int stat(const char *, struct stat *) __RENAME(__stat50);
232 int fstat(int, struct stat *) __RENAME(__fstat50);
233 #endif
234 mode_t umask(mode_t);
235 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
236 int fchmod(int, mode_t);
237 #ifndef __LIBC12_SOURCE__
238 int lstat(const char *, struct stat *) __RENAME(__lstat50);
239 int mknod(const char *, mode_t, dev_t) __RENAME(__mknod50);
240 #endif
241 #endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
242 __END_DECLS
244 #endif /* !_KERNEL && !_STANDALONE */
245 #endif /* !_SYS_STAT_H_ */