1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1989, 1993
5 *	The Regents of the University of California.  All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 *    may be used to endorse or promote products derived from this software
17 *    without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _SYS_UNISTD_H_
33#define	_SYS_UNISTD_H_
34
35#include <sys/cdefs.h>
36
37/*
38 * POSIX options and option groups we unconditionally do or don't
39 * implement.  Those options which are implemented (or not) entirely
40 * in user mode are defined in <unistd.h>.  Please keep this list in
41 * alphabetical order.
42 *
43 * Anything which is defined as zero below **must** have an
44 * implementation for the corresponding sysconf() which is able to
45 * determine conclusively whether or not the feature is supported.
46 * Anything which is defined as other than -1 below **must** have
47 * complete headers, types, and function declarations as specified by
48 * the POSIX standard; however, if the relevant sysconf() function
49 * returns -1, the functions may be stubbed out.
50 */
51#define	_POSIX_ADVISORY_INFO		200112L
52#define	_POSIX_ASYNCHRONOUS_IO		200112L
53#define	_POSIX_CHOWN_RESTRICTED		1
54#define	_POSIX_CLOCK_SELECTION		(-1)
55#define	_POSIX_CPUTIME			200112L
56#define	_POSIX_FSYNC			200112L
57#define	_POSIX_IPV6			0
58#define	_POSIX_JOB_CONTROL		1
59#define	_POSIX_MAPPED_FILES		200112L
60#define	_POSIX_MEMLOCK			(-1)
61#define	_POSIX_MEMLOCK_RANGE		200112L
62#define	_POSIX_MEMORY_PROTECTION	200112L
63#define	_POSIX_MESSAGE_PASSING		200112L
64#define	_POSIX_MONOTONIC_CLOCK		200112L
65#define	_POSIX_NO_TRUNC			1
66#define	_POSIX_PRIORITIZED_IO		(-1)
67#define	_POSIX_PRIORITY_SCHEDULING	0
68#define	_POSIX_RAW_SOCKETS		200112L
69#define	_POSIX_REALTIME_SIGNALS		200112L
70#define	_POSIX_SEMAPHORES		200112L
71#define	_POSIX_SHARED_MEMORY_OBJECTS	200112L
72#define	_POSIX_SPORADIC_SERVER		(-1)
73#define	_POSIX_SYNCHRONIZED_IO		(-1)
74#define	_POSIX_TIMEOUTS			200112L
75#define	_POSIX_TIMERS			200112L
76#define	_POSIX_TYPED_MEMORY_OBJECTS	(-1)
77#define	_POSIX_VDISABLE			0xff
78
79#if __XSI_VISIBLE
80#define	_XOPEN_SHM			1
81#define	_XOPEN_STREAMS			(-1)
82#endif
83
84/*
85 * Although we have saved user/group IDs, we do not use them in setuid
86 * as described in POSIX 1003.1, because the feature does not work for
87 * root.  We use the saved IDs in seteuid/setegid, which are not currently
88 * part of the POSIX 1003.1 specification.  XXX revisit for 1003.1-2001
89 * as this is now mandatory.
90 */
91#ifdef	_NOT_AVAILABLE
92#define	_POSIX_SAVED_IDS	1 /* saved set-user-ID and set-group-ID */
93#endif
94
95/* Define the POSIX.1 version we target for compliance. */
96#define	_POSIX_VERSION		200112L
97
98/* access function */
99#define	F_OK		0	/* test for existence of file */
100#define	X_OK		0x01	/* test for execute or search permission */
101#define	W_OK		0x02	/* test for write permission */
102#define	R_OK		0x04	/* test for read permission */
103
104/* whence values for lseek(2) */
105#ifndef SEEK_SET
106#define	SEEK_SET	0	/* set file offset to offset */
107#define	SEEK_CUR	1	/* set file offset to current plus offset */
108#define	SEEK_END	2	/* set file offset to EOF plus offset */
109#endif
110#if __BSD_VISIBLE
111#define	SEEK_DATA	3	/* set file offset to next data past offset */
112#define	SEEK_HOLE	4	/* set file offset to next hole past offset */
113#endif
114
115#ifndef _POSIX_SOURCE
116/* whence values for lseek(2); renamed by POSIX 1003.1 */
117#define	L_SET		SEEK_SET
118#define	L_INCR		SEEK_CUR
119#define	L_XTND		SEEK_END
120#endif
121
122/* configurable pathname variables */
123#define	_PC_LINK_MAX		 1
124#define	_PC_MAX_CANON		 2
125#define	_PC_MAX_INPUT		 3
126#define	_PC_NAME_MAX		 4
127#define	_PC_PATH_MAX		 5
128#define	_PC_PIPE_BUF		 6
129#define	_PC_CHOWN_RESTRICTED	 7
130#define	_PC_NO_TRUNC		 8
131#define	_PC_VDISABLE		 9
132
133#if __POSIX_VISIBLE >= 199309
134#define	_PC_ASYNC_IO		53
135#define	_PC_PRIO_IO		54
136#define	_PC_SYNC_IO		55
137#endif
138
139#if __POSIX_VISIBLE >= 200112
140#define	_PC_ALLOC_SIZE_MIN	10
141#define	_PC_FILESIZEBITS	12
142#define	_PC_REC_INCR_XFER_SIZE	14
143#define	_PC_REC_MAX_XFER_SIZE	15
144#define	_PC_REC_MIN_XFER_SIZE	16
145#define	_PC_REC_XFER_ALIGN	17
146#define	_PC_SYMLINK_MAX		18
147#endif
148
149#if __BSD_VISIBLE
150#define	_PC_ACL_EXTENDED	59
151#define	_PC_ACL_PATH_MAX	60
152#define	_PC_CAP_PRESENT		61
153#define	_PC_INF_PRESENT		62
154#define	_PC_MAC_PRESENT		63
155#define	_PC_ACL_NFS4		64
156#define	_PC_DEALLOC_PRESENT	65
157#endif
158
159/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */
160#define	_PC_MIN_HOLE_SIZE	21
161
162#if __BSD_VISIBLE
163/*
164 * rfork() options.
165 *
166 * XXX currently, some operations without RFPROC set are not supported.
167 */
168#define	RFNAMEG		(1<<0)	/* UNIMPL new plan9 `name space' */
169#define	RFENVG		(1<<1)	/* UNIMPL copy plan9 `env space' */
170#define	RFFDG		(1<<2)	/* copy fd table */
171#define	RFNOTEG		(1<<3)	/* UNIMPL create new plan9 `note group' */
172#define	RFPROC		(1<<4)	/* change child (else changes curproc) */
173#define	RFMEM		(1<<5)	/* share `address space' */
174#define	RFNOWAIT	(1<<6)	/* give child to init */
175#define	RFCNAMEG	(1<<10)	/* UNIMPL zero plan9 `name space' */
176#define	RFCENVG		(1<<11)	/* UNIMPL zero plan9 `env space' */
177#define	RFCFDG		(1<<12)	/* close all fds, zero fd table */
178#define	RFTHREAD	(1<<13)	/* enable kernel thread support */
179#define	RFSIGSHARE	(1<<14)	/* share signal handlers */
180#define	RFLINUXTHPN	(1<<16)	/* do linux clone exit parent notification */
181#define	RFSTOPPED	(1<<17)	/* leave child in a stopped state */
182#define	RFHIGHPID	(1<<18)	/* use a pid higher than 10 (idleproc) */
183#define	RFTSIGZMB	(1<<19)	/* select signal for exit parent notification */
184#define	RFTSIGSHIFT	20	/* selected signal number is in bits 20-27  */
185#define	RFTSIGMASK	0xFF
186#define	RFTSIGNUM(flags)	(((flags) >> RFTSIGSHIFT) & RFTSIGMASK)
187#define	RFTSIGFLAGS(signum)	((signum) << RFTSIGSHIFT)
188#define	RFPROCDESC	(1<<28)	/* return a process descriptor */
189/* kernel: parent sleeps until child exits (vfork) */
190#define	RFPPWAIT	(1<<31)
191/* user: vfork(2) semantics, clear signals */
192#define	RFSPAWN		(1U<<31)
193#define	RFFLAGS		(RFFDG | RFPROC | RFMEM | RFNOWAIT | RFCFDG | \
194    RFTHREAD | RFSIGSHARE | RFLINUXTHPN | RFSTOPPED | RFHIGHPID | RFTSIGZMB | \
195    RFPROCDESC | RFSPAWN | RFPPWAIT)
196#define	RFKERNELONLY	(RFSTOPPED | RFHIGHPID | RFPROCDESC)
197
198/* kcmp() options. */
199#define	KCMP_FILE	100
200#define	KCMP_FILEOBJ	101
201#define	KCMP_FILES	102
202#define	KCMP_SIGHAND	103
203#define	KCMP_VM		104
204
205#define	SWAPOFF_FORCE	0x00000001
206
207/*
208 * close_range() options.
209 */
210#define	CLOSE_RANGE_CLOEXEC	(1<<2)
211
212#endif /* __BSD_VISIBLE */
213
214#endif /* !_SYS_UNISTD_H_ */
215