source: trunk/src/emx/include/sys/stat.h@ 1940

Last change on this file since 1940 was 1940, checked in by bird, 21 years ago

Added fchmod and reimplemented chmod and lchmod.

  • Property cvs2svn:cvs-rev set to 1.8
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 12.7 KB
Line 
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.12 (Berkeley) 6/16/95
39 * $FreeBSD: src/sys/sys/stat.h,v 1.37 2003/05/22 17:07:57 mike Exp $
40 */
41
42/** @file
43 * FreeBSD 5.1
44 * @changed bird: EMX isms and hid the BSD specific structs and related stuff.
45 */
46
47#ifndef _SYS_STAT_H_
48#define _SYS_STAT_H_
49
50#include <sys/cdefs.h>
51#include <sys/_types.h>
52
53/* XXX missing blkcnt_t, blksize_t. */
54
55#ifndef _DEV_T_DECLARED
56typedef __dev_t dev_t;
57#define _DEV_T_DECLARED
58#endif
59
60#ifndef _FFLAGS_T_DECLARED
61typedef __fflags_t fflags_t;
62#define _FFLAGS_T_DECLARED
63#endif
64
65#if !defined(_GID_T_DECLARED) && !defined(_GID_T) /* bird: emx */
66typedef __gid_t gid_t;
67#define _GID_T_DECLARED
68#define _GID_T /* bird: emx */
69#endif
70
71#if !defined(_INO_T_DECLARED) && !defined(_INO_T) /* bird: emx */
72typedef __ino_t ino_t;
73#define _INO_T_DECLARED
74#define _INO_T /* bird: emx */
75#endif
76
77#if !defined(_MODE_T_DECLARED) && !defined(_MODE_T) /* bird: emx */
78typedef __mode_t mode_t;
79#define _MODE_T_DECLARED
80#define _MODE_T /* bird: emx */
81#endif
82
83#ifndef _NLINK_T_DECLARED
84typedef __nlink_t nlink_t;
85#define _NLINK_T_DECLARED
86#endif
87
88#if !defined(_OFF_T_DECLARED) && !defined(_OFF_T) /* bird: emx */
89typedef __off_t off_t;
90#define _OFF_T_DECLARED
91#define _OFF_T /* bird: emx */
92#endif
93
94#if !defined(_TIME_T_DECLARED) && !defined(_TIME_T) /* bird: emx */
95typedef __time_t time_t;
96#define _TIME_T_DECLARED
97#define _TIME_T /* bird: emx */
98#endif
99
100#if !defined(_UID_T_DECLARED) && !defined(_UID_T) /* bird: emx */
101typedef __uid_t uid_t;
102#define _UID_T_DECLARED
103#define _UID_T /* bird: emx */
104#endif
105
106#if !defined(_KERNEL) && __BSD_VISIBLE
107/*
108 * XXX we need this for struct timespec. We get miscellaneous namespace
109 * pollution with it.
110 */
111#include <sys/time.h>
112#endif
113
114#if !__BSD_VISIBLE
115#include <sys/_timespec.h>
116#endif
117
118#if 0 /* bird: emx */
119#if __BSD_VISIBLE
120struct ostat {
121 __uint16_t st_dev; /* inode's device */
122 ino_t st_ino; /* inode's number */
123 mode_t st_mode; /* inode protection mode */
124 nlink_t st_nlink; /* number of hard links */
125 __uint16_t st_uid; /* user ID of the file's owner */
126 __uint16_t st_gid; /* group ID of the file's group */
127 __uint16_t st_rdev; /* device type */
128 __int32_t st_size; /* file size, in bytes */
129 struct timespec st_atimespec; /* time of last access */
130 struct timespec st_mtimespec; /* time of last data modification */
131 struct timespec st_ctimespec; /* time of last file status change */
132 __int32_t st_blksize; /* optimal blocksize for I/O */
133 __int32_t st_blocks; /* blocks allocated for file */
134 fflags_t st_flags; /* user defined flags for file */
135 __uint32_t st_gen; /* file generation number */
136};
137#endif /* __BSD_VISIBLE */
138#endif /* bird: emx */
139
140struct stat {
141 __udev_t st_dev; /* inode's device */
142 ino_t st_ino; /* inode's number */
143 mode_t st_mode; /* inode protection mode */
144 nlink_t st_nlink; /* number of hard links */
145 uid_t st_uid; /* user ID of the file's owner */
146 gid_t st_gid; /* group ID of the file's group */
147 __udev_t st_rdev; /* device type */
148#if 1 /* bird: emx */
149 time_t st_atime;
150 time_t st_mtime;
151 time_t st_ctime;
152#else /* bird: emx */
153#if __BSD_VISIBLE
154 struct timespec st_atimespec; /* time of last access */
155 struct timespec st_mtimespec; /* time of last data modification */
156 struct timespec st_ctimespec; /* time of last file status change */
157#else
158 time_t st_atime; /* time of last access */
159 long st_atimensec; /* nsec of last access */
160 time_t st_mtime; /* time of last data modification */
161 long st_mtimensec; /* nsec of last data modification */
162 time_t st_ctime; /* time of last file status change */
163 long st_ctimensec; /* nsec of last file status change */
164#endif
165#endif /* bird: emx */
166 off_t st_size; /* file size, in bytes */
167 __int64_t st_blocks; /* blocks allocated for file */
168 __uint32_t st_blksize; /* optimal blocksize for I/O */
169#if 1 /* bird: emx: */
170 long st_attr; /* emx: OS/2 & DOS attributes */
171#else /* bird: emx */
172
173 fflags_t st_flags; /* user defined flags for file */
174 __uint32_t st_gen; /* file generation number */
175 __int32_t st_lspare;
176#if __BSD_VISIBLE
177 struct timespec st_birthtimespec; /* time of file creation */
178 /*
179 * Explicitly pad st_birthtimespec to 16 bytes so that the size of
180 * struct stat is backwards compatible. We use bitfields instead
181 * of an array of chars so that this doesn't require a C99 compiler
182 * to compile if the size of the padding is 0. We use 2 bitfields
183 * to cover up to 64 bits on 32-bit machines. We assume that
184 * CHAR_BIT is 8...
185 */
186 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
187 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
188#else
189 time_t st_birthtime; /* time of file creation */
190 long st_birthtimensec; /* nsec of file creation */
191 unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
192 unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
193#endif
194#endif /* bird: emx - end */
195};
196
197#if 0 /* bird: emx */
198#if __BSD_VISIBLE
199struct nstat {
200 __udev_t st_dev; /* inode's device */
201 ino_t st_ino; /* inode's number */
202 __uint32_t st_mode; /* inode protection mode */
203 __uint32_t st_nlink; /* number of hard links */
204 uid_t st_uid; /* user ID of the file's owner */
205 gid_t st_gid; /* group ID of the file's group */
206 __udev_t st_rdev; /* device type */
207 struct timespec st_atimespec; /* time of last access */
208 struct timespec st_mtimespec; /* time of last data modification */
209 struct timespec st_ctimespec; /* time of last file status change */
210 off_t st_size; /* file size, in bytes */
211 __int64_t st_blocks; /* blocks allocated for file */
212 __uint32_t st_blksize; /* optimal blocksize for I/O */
213 fflags_t st_flags; /* user defined flags for file */
214 __uint32_t st_gen; /* file generation number */
215 struct timespec st_birthtimespec; /* time of file creation */
216 /*
217 * See above about the following padding.
218 */
219 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
220 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
221};
222#endif
223#endif /* bird: emx */
224
225#if 0 /* bird: emx */
226#if __BSD_VISIBLE
227#define st_atime st_atimespec.tv_sec
228#define st_mtime st_mtimespec.tv_sec
229#define st_ctime st_ctimespec.tv_sec
230#define st_birthtime st_birthtimespec.tv_sec
231#endif
232#endif /* bird: emx */
233
234#define S_ISUID 0004000 /* set user id on execution */
235#define S_ISGID 0002000 /* set group id on execution */
236#if __BSD_VISIBLE
237#define S_ISTXT 0001000 /* sticky bit */
238#endif
239
240#define S_IRWXU 0000700 /* RWX mask for owner */
241#define S_IRUSR 0000400 /* R for owner */
242#define S_IWUSR 0000200 /* W for owner */
243#define S_IXUSR 0000100 /* X for owner */
244
245#if __BSD_VISIBLE
246#define S_IREAD S_IRUSR
247#define S_IWRITE S_IWUSR
248#define S_IEXEC S_IXUSR
249#endif
250
251#define S_IRWXG 0000070 /* RWX mask for group */
252#define S_IRGRP 0000040 /* R for group */
253#define S_IWGRP 0000020 /* W for group */
254#define S_IXGRP 0000010 /* X for group */
255
256#define S_IRWXO 0000007 /* RWX mask for other */
257#define S_IROTH 0000004 /* R for other */
258#define S_IWOTH 0000002 /* W for other */
259#define S_IXOTH 0000001 /* X for other */
260
261#if __XSI_VISIBLE
262#define S_IFMT 0170000 /* type of file mask */
263#define S_IFIFO 0010000 /* named pipe (fifo) */
264#define S_IFCHR 0020000 /* character special */
265#define S_IFDIR 0040000 /* directory */
266#define S_IFBLK 0060000 /* block special */
267#define S_IFREG 0100000 /* regular */
268#define S_IFLNK 0120000 /* symbolic link */
269#define S_IFSOCK 0140000 /* socket */
270#define S_ISVTX 0001000 /* save swapped text even after use */
271#endif
272#if __BSD_VISIBLE
273#define S_IFWHT 0160000 /* whiteout */
274#endif
275
276#define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
277#define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
278#define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
279#define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
280#define S_ISFIFO(m) (((m) & 0170000) == 0010000) /* fifo or socket */
281#if __POSIX_VISIBLE >= 200112
282#define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
283#define S_ISSOCK(m) (((m) & 0170000) == 0140000) /* socket */
284#endif
285#if __XSI_VISIBLE
286#define S_ISWHT(m) (((m) & 0170000) == 0160000) /* whiteout */
287#endif
288
289#if __BSD_VISIBLE
290#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
291 /* 7777 */
292#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
293 /* 0666 */
294#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
295
296#define S_BLKSIZE 512 /* block size used in the stat struct */
297
298/*
299 * Definitions of flags stored in file flags word.
300 *
301 * Super-user and owner changeable flags.
302 */
303#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
304#define UF_NODUMP 0x00000001 /* do not dump file */
305#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
306#define UF_APPEND 0x00000004 /* writes to file may only append */
307#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
308#define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
309/*
310 * Super-user changeable flags.
311 */
312#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
313#define SF_ARCHIVED 0x00010000 /* file is archived */
314#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
315#define SF_APPEND 0x00040000 /* writes to file may only append */
316#define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
317#define SF_SNAPSHOT 0x00200000 /* snapshot inode */
318
319#ifdef _KERNEL
320/*
321 * Shorthand abbreviations of above.
322 */
323#define OPAQUE (UF_OPAQUE)
324#define APPEND (UF_APPEND | SF_APPEND)
325#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
326#define NOUNLINK (UF_NOUNLINK | SF_NOUNLINK)
327#endif
328
329#endif /* __BSD_VISIBLE */
330
331#ifndef _KERNEL
332__BEGIN_DECLS
333#if __BSD_VISIBLE
334/** @todo int chflags(const char *, unsigned long); */
335#endif
336int chmod(const char *, mode_t);
337#if __BSD_VISIBLE
338/** @todo int fchflags(int, unsigned long); */
339int fchmod(int, mode_t);
340#endif
341int fstat(int, struct stat *);
342#if __BSD_VISIBLE
343/** @todo int lchflags(const char *, int); */
344int lchmod(const char *, mode_t);
345#endif
346#if __POSIX_VISIBLE >= 200112
347int lstat(const char *, struct stat *);
348#endif
349int mkdir(const char *, mode_t);
350/** @todo int mkfifo(const char *, mode_t); */
351int stat(const char *, struct stat *);
352mode_t umask(mode_t);
353
354/* bird: emx stuff - start */
355#if !defined (_POSIX_SOURCE) || defined (_WITH_UNDERSCORE) || defined(__USE_EMX)
356int _chmod (__const__ char *, int);
357int _fstat (int, struct stat *);
358int _mkdir (__const__ char *, long);
359/* _mkfifo() */
360int _stat (__const__ char *, struct stat *);
361int _umask (int);
362#endif
363/* bird: emx stuff - end */
364
365__END_DECLS
366#endif /* !_KERNEL */
367
368#endif /* !_SYS_STAT_H_ */
369
Note: See TracBrowser for help on using the repository browser.