source: branches/libc-0.6/src/emx/include/sys/stat.h

Last change on this file was 3809, checked in by bird, 11 years ago

0.6: s/const/const/g - just use the (now) standard 'const' everywhere in emx and kLIBC code. Avoid changing external code too much. fixes #279.

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