1f0bf889imp/*-
24736ccfpfg * SPDX-License-Identifier: BSD-3-Clause
34736ccfpfg *
48fb65cergrimes * Copyright (c) 1989, 1993
58fb65cergrimes *	The Regents of the University of California.  All rights reserved.
68fb65cergrimes *
78fb65cergrimes * Redistribution and use in source and binary forms, with or without
88fb65cergrimes * modification, are permitted provided that the following conditions
98fb65cergrimes * are met:
108fb65cergrimes * 1. Redistributions of source code must retain the above copyright
118fb65cergrimes *    notice, this list of conditions and the following disclaimer.
128fb65cergrimes * 2. Redistributions in binary form must reproduce the above copyright
138fb65cergrimes *    notice, this list of conditions and the following disclaimer in the
148fb65cergrimes *    documentation and/or other materials provided with the distribution.
157e6cabdimp * 3. Neither the name of the University nor the names of its contributors
168fb65cergrimes *    may be used to endorse or promote products derived from this software
178fb65cergrimes *    without specific prior written permission.
188fb65cergrimes *
198fb65cergrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
208fb65cergrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218fb65cergrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
228fb65cergrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
238fb65cergrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
248fb65cergrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
258fb65cergrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
268fb65cergrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
278fb65cergrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
288fb65cergrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
298fb65cergrimes * SUCH DAMAGE.
308fb65cergrimes *
318fb65cergrimes *	@(#)unistd.h	8.2 (Berkeley) 1/7/94
323b842d3peter * $FreeBSD$
338fb65cergrimes */
348fb65cergrimes
358fb65cergrimes#ifndef _SYS_UNISTD_H_
368fb65cergrimes#define	_SYS_UNISTD_H_
378fb65cergrimes
38f52df7dwollman#include <sys/cdefs.h>
39d3dd91fdufault
40f52df7dwollman/*
41f52df7dwollman * POSIX options and option groups we unconditionally do or don't
42f52df7dwollman * implement.  Those options which are implemented (or not) entirely
43f52df7dwollman * in user mode are defined in <unistd.h>.  Please keep this list in
44f52df7dwollman * alphabetical order.
45f52df7dwollman *
46f52df7dwollman * Anything which is defined as zero below **must** have an
47f52df7dwollman * implementation for the corresponding sysconf() which is able to
48f52df7dwollman * determine conclusively whether or not the feature is supported.
49f52df7dwollman * Anything which is defined as other than -1 below **must** have
50f52df7dwollman * complete headers, types, and function declarations as specified by
51f52df7dwollman * the POSIX standard; however, if the relevant sysconf() function
52f52df7dwollman * returns -1, the functions may be stubbed out.
53f52df7dwollman */
54a250a8cjhb#define	_POSIX_ADVISORY_INFO		200112L
551b87e43jhb#define	_POSIX_ASYNCHRONOUS_IO		200112L
56f52df7dwollman#define	_POSIX_CHOWN_RESTRICTED		1
57b186de9kib#define	_POSIX_CLOCK_SELECTION		(-1)
583f0806adavidxu#define	_POSIX_CPUTIME			200112L
59f52df7dwollman#define	_POSIX_FSYNC			200112L
60e5980f8wollman#define	_POSIX_IPV6			0
61f52df7dwollman#define	_POSIX_JOB_CONTROL		1
62f52df7dwollman#define	_POSIX_MAPPED_FILES		200112L
63b186de9kib#define	_POSIX_MEMLOCK			(-1)
64f52df7dwollman#define	_POSIX_MEMLOCK_RANGE		200112L
65f52df7dwollman#define	_POSIX_MEMORY_PROTECTION	200112L
664b7c266davidxu#define	_POSIX_MESSAGE_PASSING		200112L
67bbb208bwollman#define	_POSIX_MONOTONIC_CLOCK		200112L
68f52df7dwollman#define	_POSIX_NO_TRUNC			1
69b186de9kib#define	_POSIX_PRIORITIZED_IO		(-1)
70f6a975ekib#define	_POSIX_PRIORITY_SCHEDULING	0
71f52df7dwollman#define	_POSIX_RAW_SOCKETS		200112L
72ef2eb09davidxu#define	_POSIX_REALTIME_SIGNALS		200112L
7325320a2tijl#define	_POSIX_SEMAPHORES		200112L
74f52df7dwollman#define	_POSIX_SHARED_MEMORY_OBJECTS	200112L
75b186de9kib#define	_POSIX_SPORADIC_SERVER		(-1)
76b186de9kib#define	_POSIX_SYNCHRONIZED_IO		(-1)
77066797bdavidxu#define	_POSIX_TIMEOUTS			200112L
787571ee7davidxu#define	_POSIX_TIMERS			200112L
79b186de9kib#define	_POSIX_TYPED_MEMORY_OBJECTS	(-1)
80f52df7dwollman#define	_POSIX_VDISABLE			0xff
81f52df7dwollman
82f52df7dwollman#if __XSI_VISIBLE
83f52df7dwollman#define	_XOPEN_SHM			1
84b186de9kib#define	_XOPEN_STREAMS			(-1)
85f52df7dwollman#endif
868fb65cergrimes
878fb65cergrimes/*
883ea3e23bde * Although we have saved user/group IDs, we do not use them in setuid
893ea3e23bde * as described in POSIX 1003.1, because the feature does not work for
903ea3e23bde * root.  We use the saved IDs in seteuid/setegid, which are not currently
91f52df7dwollman * part of the POSIX 1003.1 specification.  XXX revisit for 1003.1-2001
92f52df7dwollman * as this is now mandatory.
938fb65cergrimes */
943ea3e23bde#ifdef	_NOT_AVAILABLE
95f52df7dwollman#define	_POSIX_SAVED_IDS	1 /* saved set-user-ID and set-group-ID */
963ea3e23bde#endif
978fb65cergrimes
98652e37bmike/* Define the POSIX.1 version we target for compliance. */
99652e37bmike#define	_POSIX_VERSION		200112L
100652e37bmike
1018fb65cergrimes/* access function */
1028fb65cergrimes#define	F_OK		0	/* test for existence of file */
1038fb65cergrimes#define	X_OK		0x01	/* test for execute or search permission */
1048fb65cergrimes#define	W_OK		0x02	/* test for write permission */
1058fb65cergrimes#define	R_OK		0x04	/* test for read permission */
1068fb65cergrimes
1078fb65cergrimes/* whence values for lseek(2) */
108d3bac74phk#ifndef SEEK_SET
1098fb65cergrimes#define	SEEK_SET	0	/* set file offset to offset */
1108fb65cergrimes#define	SEEK_CUR	1	/* set file offset to current plus offset */
1118fb65cergrimes#define	SEEK_END	2	/* set file offset to EOF plus offset */
11213f0f1epjd#endif
11391b5344pjd#if __BSD_VISIBLE
1144718e01pjd#define	SEEK_DATA	3	/* set file offset to next data past offset */
1154718e01pjd#define	SEEK_HOLE	4	/* set file offset to next hole past offset */
116d3bac74phk#endif
1178fb65cergrimes
1188fb65cergrimes#ifndef _POSIX_SOURCE
1198fb65cergrimes/* whence values for lseek(2); renamed by POSIX 1003.1 */
1208fb65cergrimes#define	L_SET		SEEK_SET
1218fb65cergrimes#define	L_INCR		SEEK_CUR
1228fb65cergrimes#define	L_XTND		SEEK_END
1238fb65cergrimes#endif
1248fb65cergrimes
1258fb65cergrimes/* configurable pathname variables */
1268fb65cergrimes#define	_PC_LINK_MAX		 1
1278fb65cergrimes#define	_PC_MAX_CANON		 2
1288fb65cergrimes#define	_PC_MAX_INPUT		 3
1298fb65cergrimes#define	_PC_NAME_MAX		 4
1308fb65cergrimes#define	_PC_PATH_MAX		 5
1318fb65cergrimes#define	_PC_PIPE_BUF		 6
1328fb65cergrimes#define	_PC_CHOWN_RESTRICTED	 7
1338fb65cergrimes#define	_PC_NO_TRUNC		 8
1348fb65cergrimes#define	_PC_VDISABLE		 9
1358fb65cergrimes
136f52df7dwollman#if __POSIX_VISIBLE >= 199309
137cd941aabde#define	_PC_ASYNC_IO		53
138cd941aabde#define	_PC_PRIO_IO		54
139cd941aabde#define	_PC_SYNC_IO		55
140f52df7dwollman#endif
141e28788fdufault
142f52df7dwollman#if __POSIX_VISIBLE >= 200112
143f52df7dwollman#define	_PC_ALLOC_SIZE_MIN	10
144f52df7dwollman#define	_PC_FILESIZEBITS	12
145f52df7dwollman#define	_PC_REC_INCR_XFER_SIZE	14
146f52df7dwollman#define	_PC_REC_MAX_XFER_SIZE	15
147f52df7dwollman#define	_PC_REC_MIN_XFER_SIZE	16
148f52df7dwollman#define	_PC_REC_XFER_ALIGN	17
149e5980f8wollman#define	_PC_SYMLINK_MAX		18
150f52df7dwollman#endif
151c68232frwatson
152f52df7dwollman#if __BSD_VISIBLE
153d862ecfrwatson#define	_PC_ACL_EXTENDED	59
154d862ecfrwatson#define	_PC_ACL_PATH_MAX	60
155d862ecfrwatson#define	_PC_CAP_PRESENT		61
156d862ecfrwatson#define	_PC_INF_PRESENT		62
157d862ecfrwatson#define	_PC_MAC_PRESENT		63
158ff27511trasz#define	_PC_ACL_NFS4		64
159f52df7dwollman#endif
160c68232frwatson
1614718e01pjd/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */
1624718e01pjd#define	_PC_MIN_HOLE_SIZE	21
1634718e01pjd
164f52df7dwollman#if __BSD_VISIBLE
165aee43c6peter/*
166aee43c6peter * rfork() options.
167aee43c6peter *
168769e0f9jasone * XXX currently, some operations without RFPROC set are not supported.
169aee43c6peter */
170cd941aabde#define	RFNAMEG		(1<<0)	/* UNIMPL new plan9 `name space' */
171cd941aabde#define	RFENVG		(1<<1)	/* UNIMPL copy plan9 `env space' */
172cd941aabde#define	RFFDG		(1<<2)	/* copy fd table */
173cd941aabde#define	RFNOTEG		(1<<3)	/* UNIMPL create new plan9 `note group' */
174cd941aabde#define	RFPROC		(1<<4)	/* change child (else changes curproc) */
175cd941aabde#define	RFMEM		(1<<5)	/* share `address space' */
176cd941aabde#define	RFNOWAIT	(1<<6)	/* give child to init */
177cd941aabde#define	RFCNAMEG	(1<<10)	/* UNIMPL zero plan9 `name space' */
178cd941aabde#define	RFCENVG		(1<<11)	/* UNIMPL zero plan9 `env space' */
179cd941aabde#define	RFCFDG		(1<<12)	/* close all fds, zero fd table */
180f52df7dwollman#define	RFTHREAD	(1<<13)	/* enable kernel thread support */
181f52df7dwollman#define	RFSIGSHARE	(1<<14)	/* share signal handlers */
182cd941aabde#define	RFLINUXTHPN	(1<<16)	/* do linux clone exit parent notification */
183f52df7dwollman#define	RFSTOPPED	(1<<17)	/* leave child in a stopped state */
184e2a805ftrhodes#define	RFHIGHPID	(1<<18)	/* use a pid higher than 10 (idleproc) */
18509ee3c9kib#define	RFTSIGZMB	(1<<19)	/* select signal for exit parent notification */
18609ee3c9kib#define	RFTSIGSHIFT	20	/* selected signal number is in bits 20-27  */
18709ee3c9kib#define	RFTSIGMASK	0xFF
18809ee3c9kib#define	RFTSIGNUM(flags)	(((flags) >> RFTSIGSHIFT) & RFTSIGMASK)
18909ee3c9kib#define	RFTSIGFLAGS(signum)	((signum) << RFTSIGSHIFT)
1905ecd1c9jonathan#define	RFPROCDESC	(1<<28)	/* return a process descriptor */
191245d842kevans/* kernel: parent sleeps until child exits (vfork) */
192245d842kevans#define	RFPPWAIT	(1<<31)
193245d842kevans/* user: vfork(2) semantics, clear signals */
194245d842kevans#define	RFSPAWN		(1U<<31)
19509ee3c9kib#define	RFFLAGS		(RFFDG | RFPROC | RFMEM | RFNOWAIT | RFCFDG | \
19609ee3c9kib    RFTHREAD | RFSIGSHARE | RFLINUXTHPN | RFSTOPPED | RFHIGHPID | RFTSIGZMB | \
197245d842kevans    RFPROCDESC | RFSPAWN | RFPPWAIT)
198245d842kevans#define	RFKERNELONLY	(RFSTOPPED | RFHIGHPID | RFPROCDESC)
1991dcc268dyson
200f52df7dwollman#endif /* __BSD_VISIBLE */
201aee43c6peter
2028fb65cergrimes#endif /* !_SYS_UNISTD_H_ */
203