Add some more *at() system calls.
[dragonfly.git] / sys / sys / stat.h
CommitLineData
984263bc
MD
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.
65c1e252 18 * 3. Neither the name of the University nor the names of its contributors
984263bc
MD
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.20 1999/12/29 04:24:47 peter Exp $
91fdc001 36 * $DragonFly: src/sys/sys/stat.h,v 1.14 2008/11/11 00:55:49 pavalos Exp $
984263bc
MD
37 */
38
39#ifndef _SYS_STAT_H_
40#define _SYS_STAT_H_
41
1bd40720 42#if !defined(_POSIX_SOURCE)
984263bc
MD
43/*
44 * XXX we need this for struct timespec. We get miscellaneous namespace
45 * pollution with it.
46 */
1bd40720 47#ifndef _SYS_TIME_H_
984263bc
MD
48#include <sys/time.h>
49#endif
1d3685c4
SS
50#else /* !_POSIX_SOURCE */
51#include <sys/_timespec.h>
1bd40720 52#endif /* _POSIX_SOURCE */
984263bc
MD
53
54#ifdef _KERNEL
55#define __dev_t udev_t
56#else
57#define __dev_t dev_t
58#endif
59
7d15906a
MD
60/*
61 * stat structure notes:
62 *
d98152a8 63 * NOTE: st_fsmid removed in DragonFly 2.5.x.
7d15906a 64 */
984263bc 65struct stat {
984263bc 66 ino_t st_ino; /* inode's number */
984263bc 67 nlink_t st_nlink; /* number of hard links */
f91a71dd
JS
68 __dev_t st_dev; /* inode's device */
69 mode_t st_mode; /* inode protection mode */
70 uint16_t st_padding1;
984263bc
MD
71 uid_t st_uid; /* user ID of the file's owner */
72 gid_t st_gid; /* group ID of the file's group */
73 __dev_t st_rdev; /* device type */
0dc5d89e
SS
74 struct timespec st_atim; /* time of last access */
75 struct timespec st_mtim; /* time of last data modification */
76 struct timespec st_ctim; /* time of last file status change */
984263bc
MD
77 off_t st_size; /* file size, in bytes */
78 int64_t st_blocks; /* blocks allocated for file */
79 u_int32_t st_blksize; /* optimal blocksize for I/O */
80 u_int32_t st_flags; /* user defined flags for file */
81 u_int32_t st_gen; /* file generation number */
82 int32_t st_lspare;
d98152a8
MD
83 int64_t st_qspare1; /* was recursive change detect */
84 int64_t st_qspare2;
984263bc
MD
85};
86
d98152a8 87/*#define _ST_FSMID_PRESENT_*/
356dd689 88#define _ST_FLAGS_PRESENT_
7d15906a 89
984263bc
MD
90#undef __dev_t
91
0dc5d89e
SS
92#define st_atime st_atim.tv_sec
93#define st_mtime st_mtim.tv_sec
94#define st_ctime st_ctim.tv_sec
95
96/* BSD compatibility */
984263bc 97#ifndef _POSIX_SOURCE
0dc5d89e
SS
98#define st_atimespec st_atim
99#define st_mtimespec st_mtim
100#define st_ctimespec st_ctim
984263bc
MD
101#endif
102
103#define S_ISUID 0004000 /* set user id on execution */
104#define S_ISGID 0002000 /* set group id on execution */
105#ifndef _POSIX_SOURCE
106#define S_ISTXT 0001000 /* sticky bit */
107#endif
108
109#define S_IRWXU 0000700 /* RWX mask for owner */
110#define S_IRUSR 0000400 /* R for owner */
111#define S_IWUSR 0000200 /* W for owner */
112#define S_IXUSR 0000100 /* X for owner */
113
114#ifndef _POSIX_SOURCE
115#define S_IREAD S_IRUSR
116#define S_IWRITE S_IWUSR
117#define S_IEXEC S_IXUSR
118#endif
119
120#define S_IRWXG 0000070 /* RWX mask for group */
121#define S_IRGRP 0000040 /* R for group */
122#define S_IWGRP 0000020 /* W for group */
123#define S_IXGRP 0000010 /* X for group */
124
125#define S_IRWXO 0000007 /* RWX mask for other */
126#define S_IROTH 0000004 /* R for other */
127#define S_IWOTH 0000002 /* W for other */
128#define S_IXOTH 0000001 /* X for other */
129
130#ifndef _POSIX_SOURCE
131#define S_IFMT 0170000 /* type of file mask */
132#define S_IFIFO 0010000 /* named pipe (fifo) */
133#define S_IFCHR 0020000 /* character special */
134#define S_IFDIR 0040000 /* directory */
135#define S_IFBLK 0060000 /* block special */
136#define S_IFREG 0100000 /* regular */
50626622 137#define S_IFDB 0110000 /* record access file */
984263bc
MD
138#define S_IFLNK 0120000 /* symbolic link */
139#define S_IFSOCK 0140000 /* socket */
140#define S_IFWHT 0160000 /* whiteout */
141#define S_ISVTX 0001000 /* save swapped text even after use */
142#endif
143
144#define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
145#define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
146#define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
147#define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
50626622 148#define S_ISDB(m) (((m) & 0170000) == 0110000) /* record access file */
984263bc
MD
149#define S_ISFIFO(m) (((m) & 0170000) == 0010000) /* fifo or socket */
150#ifndef _POSIX_SOURCE
151#define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
152#define S_ISSOCK(m) (((m) & 0170000) == 0140000) /* socket */
153#define S_ISWHT(m) (((m) & 0170000) == 0160000) /* whiteout */
154#endif
155
6ea45f25
SK
156/*
157 * The value of `buf' is a pointer to a `stat' data structure. Since we don't
158 * implement message queues as distinct file types, the following macro
159 * evaluates to zero.
160 * XXX: What about semaphores and shared memory objects ?
161 */
162#define S_TYPEISMQ(buf) (0) /* message queue */
163
984263bc
MD
164#ifndef _POSIX_SOURCE
165#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
166 /* 7777 */
167#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
168 /* 0666 */
169#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
170
171#define S_BLKSIZE 512 /* block size used in the stat struct */
172
173/*
174 * Definitions of flags stored in file flags word.
175 *
176 * Super-user and owner changeable flags.
177 */
178#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
179#define UF_NODUMP 0x00000001 /* do not dump file */
180#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
181#define UF_APPEND 0x00000004 /* writes to file may only append */
182#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
183#define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
33036abf
MD
184#define UF_FBSDRSVD20 0x00000020 /* (unused) */
185#define UF_NOHISTORY 0x00000040 /* do not retain history/snapshots */
e9b56058 186#define UF_CACHE 0x00000080 /* enable data swapcache */
984263bc
MD
187/*
188 * Super-user changeable flags.
189 */
190#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
191#define SF_ARCHIVED 0x00010000 /* file is archived */
192#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
193#define SF_APPEND 0x00040000 /* writes to file may only append */
194#define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
33036abf
MD
195#define SF_FBSDRSVD20 0x00200000 /* (used by FreeBSD for snapshots) */
196#define SF_NOHISTORY 0x00400000 /* do not retain history/snapshots */
e9b56058 197#define SF_NOCACHE 0x00800000 /* disable data swapcache */
984263bc
MD
198
199#ifdef _KERNEL
200/*
201 * Shorthand abbreviations of above.
202 */
203#define OPAQUE (UF_OPAQUE)
204#define APPEND (UF_APPEND | SF_APPEND)
205#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
206#define NOUNLINK (UF_NOUNLINK | SF_NOUNLINK)
207#endif
208
209#endif /* !_POSIX_SOURCE */
210
44a09dd6 211#if !defined(_KERNEL) || defined(_KERNEL_VIRTUAL)
984263bc
MD
212#include <sys/cdefs.h>
213
214__BEGIN_DECLS
b153f746 215int chmod (const char *, mode_t);
509a01fa 216#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
8cde3c79 217int fchmodat (int, const char *, mode_t, int);
509a01fa 218#endif
b153f746
RG
219int fstat (int, struct stat *);
220int mkdir (const char *, mode_t);
221int mkfifo (const char *, mode_t);
330f6769
SW
222#if !defined(_MKNOD_DECLARED) && __XSI_VISIBLE
223int mknod(const char *, mode_t, dev_t);
224#define _MKNOD_DECLARED
225#endif
b153f746
RG
226int stat (const char *, struct stat *);
227mode_t umask (mode_t);
6d98f93c
SW
228#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
229int fstatat(int, const char *, struct stat *, int);
230int mkdirat(int, const char *, mode_t);
231int mkfifoat(int, const char *, mode_t);
232#endif
233#if __BSD_VISIBLE || __XSI_VISIBLE >= 700
234int mknodat(int, const char *, mode_t, dev_t);
235#endif
984263bc
MD
236
237#ifndef _POSIX_SOURCE
b153f746
RG
238int chflags (const char *, u_long);
239int fchflags (int, u_long);
91fdc001 240int lchflags (const char *, u_long);
b153f746
RG
241int fchmod (int, mode_t);
242int lchmod (const char *, mode_t);
243int lstat (const char *, struct stat *);
984263bc
MD
244#endif
245__END_DECLS
246
44a09dd6 247#endif
984263bc
MD
248
249#endif /* !_SYS_STAT_H_ */