1*19c3b8c2SApple OSS Distributions /* 2*19c3b8c2SApple OSS Distributions * Copyright (c) 2000-2013 Apple Inc. All rights reserved. 3*19c3b8c2SApple OSS Distributions * 4*19c3b8c2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*19c3b8c2SApple OSS Distributions * 6*19c3b8c2SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*19c3b8c2SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*19c3b8c2SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*19c3b8c2SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*19c3b8c2SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*19c3b8c2SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*19c3b8c2SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*19c3b8c2SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*19c3b8c2SApple OSS Distributions * 15*19c3b8c2SApple OSS Distributions * Please obtain a copy of the License at 16*19c3b8c2SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*19c3b8c2SApple OSS Distributions * 18*19c3b8c2SApple OSS Distributions * The Original Code and all software distributed under the License are 19*19c3b8c2SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*19c3b8c2SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*19c3b8c2SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*19c3b8c2SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*19c3b8c2SApple OSS Distributions * Please see the License for the specific language governing rights and 24*19c3b8c2SApple OSS Distributions * limitations under the License. 25*19c3b8c2SApple OSS Distributions * 26*19c3b8c2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*19c3b8c2SApple OSS Distributions */ 28*19c3b8c2SApple OSS Distributions /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ 29*19c3b8c2SApple OSS Distributions /* 30*19c3b8c2SApple OSS Distributions * Copyright (c) 1989, 1993 31*19c3b8c2SApple OSS Distributions * The Regents of the University of California. All rights reserved. 32*19c3b8c2SApple OSS Distributions * 33*19c3b8c2SApple OSS Distributions * Redistribution and use in source and binary forms, with or without 34*19c3b8c2SApple OSS Distributions * modification, are permitted provided that the following conditions 35*19c3b8c2SApple OSS Distributions * are met: 36*19c3b8c2SApple OSS Distributions * 1. Redistributions of source code must retain the above copyright 37*19c3b8c2SApple OSS Distributions * notice, this list of conditions and the following disclaimer. 38*19c3b8c2SApple OSS Distributions * 2. Redistributions in binary form must reproduce the above copyright 39*19c3b8c2SApple OSS Distributions * notice, this list of conditions and the following disclaimer in the 40*19c3b8c2SApple OSS Distributions * documentation and/or other materials provided with the distribution. 41*19c3b8c2SApple OSS Distributions * 3. All advertising materials mentioning features or use of this software 42*19c3b8c2SApple OSS Distributions * must display the following acknowledgement: 43*19c3b8c2SApple OSS Distributions * This product includes software developed by the University of 44*19c3b8c2SApple OSS Distributions * California, Berkeley and its contributors. 45*19c3b8c2SApple OSS Distributions * 4. Neither the name of the University nor the names of its contributors 46*19c3b8c2SApple OSS Distributions * may be used to endorse or promote products derived from this software 47*19c3b8c2SApple OSS Distributions * without specific prior written permission. 48*19c3b8c2SApple OSS Distributions * 49*19c3b8c2SApple OSS Distributions * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 50*19c3b8c2SApple OSS Distributions * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 51*19c3b8c2SApple OSS Distributions * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 52*19c3b8c2SApple OSS Distributions * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 53*19c3b8c2SApple OSS Distributions * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54*19c3b8c2SApple OSS Distributions * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 55*19c3b8c2SApple OSS Distributions * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 56*19c3b8c2SApple OSS Distributions * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57*19c3b8c2SApple OSS Distributions * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58*19c3b8c2SApple OSS Distributions * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59*19c3b8c2SApple OSS Distributions * SUCH DAMAGE. 60*19c3b8c2SApple OSS Distributions * 61*19c3b8c2SApple OSS Distributions * @(#)unistd.h 8.2 (Berkeley) 1/7/94 62*19c3b8c2SApple OSS Distributions */ 63*19c3b8c2SApple OSS Distributions 64*19c3b8c2SApple OSS Distributions #ifndef _SYS_UNISTD_H_ 65*19c3b8c2SApple OSS Distributions #define _SYS_UNISTD_H_ 66*19c3b8c2SApple OSS Distributions 67*19c3b8c2SApple OSS Distributions #include <sys/cdefs.h> 68*19c3b8c2SApple OSS Distributions 69*19c3b8c2SApple OSS Distributions /* 70*19c3b8c2SApple OSS Distributions * Although we have saved user/group IDs, we do not use them in setuid 71*19c3b8c2SApple OSS Distributions * as described in POSIX 1003.1, because the feature does not work for 72*19c3b8c2SApple OSS Distributions * root. We use the saved IDs in seteuid/setegid, which are not currently 73*19c3b8c2SApple OSS Distributions * part of the POSIX 1003.1 specification. 74*19c3b8c2SApple OSS Distributions */ 75*19c3b8c2SApple OSS Distributions #ifdef _NOT_AVAILABLE 76*19c3b8c2SApple OSS Distributions #define _POSIX_SAVED_IDS /* saved set-user-ID and set-group-ID */ 77*19c3b8c2SApple OSS Distributions #endif 78*19c3b8c2SApple OSS Distributions 79*19c3b8c2SApple OSS Distributions #define _POSIX_VERSION 200112L 80*19c3b8c2SApple OSS Distributions #define _POSIX2_VERSION 200112L 81*19c3b8c2SApple OSS Distributions 82*19c3b8c2SApple OSS Distributions /* execution-time symbolic constants */ 83*19c3b8c2SApple OSS Distributions /* may disable terminal special characters */ 84*19c3b8c2SApple OSS Distributions #include <sys/_types/_posix_vdisable.h> 85*19c3b8c2SApple OSS Distributions 86*19c3b8c2SApple OSS Distributions #define _POSIX_THREAD_KEYS_MAX 128 87*19c3b8c2SApple OSS Distributions 88*19c3b8c2SApple OSS Distributions /* access function */ 89*19c3b8c2SApple OSS Distributions #define F_OK 0 /* test for existence of file */ 90*19c3b8c2SApple OSS Distributions #define X_OK (1<<0) /* test for execute or search permission */ 91*19c3b8c2SApple OSS Distributions #define W_OK (1<<1) /* test for write permission */ 92*19c3b8c2SApple OSS Distributions #define R_OK (1<<2) /* test for read permission */ 93*19c3b8c2SApple OSS Distributions 94*19c3b8c2SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 95*19c3b8c2SApple OSS Distributions /* 96*19c3b8c2SApple OSS Distributions * Extended access functions. 97*19c3b8c2SApple OSS Distributions * Note that we depend on these matching the definitions in sys/kauth.h, 98*19c3b8c2SApple OSS Distributions * but with the bits shifted left by 8. 99*19c3b8c2SApple OSS Distributions */ 100*19c3b8c2SApple OSS Distributions #define _READ_OK (1<<9) /* read file data / read directory */ 101*19c3b8c2SApple OSS Distributions #define _WRITE_OK (1<<10) /* write file data / add file to directory */ 102*19c3b8c2SApple OSS Distributions #define _EXECUTE_OK (1<<11) /* execute file / search in directory*/ 103*19c3b8c2SApple OSS Distributions #define _DELETE_OK (1<<12) /* delete file / delete directory */ 104*19c3b8c2SApple OSS Distributions #define _APPEND_OK (1<<13) /* append to file / add subdirectory to directory */ 105*19c3b8c2SApple OSS Distributions #define _RMFILE_OK (1<<14) /* - / remove file from directory */ 106*19c3b8c2SApple OSS Distributions #define _RATTR_OK (1<<15) /* read basic attributes */ 107*19c3b8c2SApple OSS Distributions #define _WATTR_OK (1<<16) /* write basic attributes */ 108*19c3b8c2SApple OSS Distributions #define _REXT_OK (1<<17) /* read extended attributes */ 109*19c3b8c2SApple OSS Distributions #define _WEXT_OK (1<<18) /* write extended attributes */ 110*19c3b8c2SApple OSS Distributions #define _RPERM_OK (1<<19) /* read permissions */ 111*19c3b8c2SApple OSS Distributions #define _WPERM_OK (1<<20) /* write permissions */ 112*19c3b8c2SApple OSS Distributions #define _CHOWN_OK (1<<21) /* change ownership */ 113*19c3b8c2SApple OSS Distributions 114*19c3b8c2SApple OSS Distributions #define _ACCESS_EXTENDED_MASK (_READ_OK | _WRITE_OK | _EXECUTE_OK | \ 115*19c3b8c2SApple OSS Distributions _DELETE_OK | _APPEND_OK | \ 116*19c3b8c2SApple OSS Distributions _RMFILE_OK | _REXT_OK | \ 117*19c3b8c2SApple OSS Distributions _WEXT_OK | _RATTR_OK | _WATTR_OK | _RPERM_OK | \ 118*19c3b8c2SApple OSS Distributions _WPERM_OK | _CHOWN_OK) 119*19c3b8c2SApple OSS Distributions #endif 120*19c3b8c2SApple OSS Distributions 121*19c3b8c2SApple OSS Distributions /* whence values for lseek(2) */ 122*19c3b8c2SApple OSS Distributions #include <sys/_types/_seek_set.h> 123*19c3b8c2SApple OSS Distributions 124*19c3b8c2SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 125*19c3b8c2SApple OSS Distributions /* whence values for lseek(2); renamed by POSIX 1003.1 */ 126*19c3b8c2SApple OSS Distributions #define L_SET SEEK_SET 127*19c3b8c2SApple OSS Distributions #define L_INCR SEEK_CUR 128*19c3b8c2SApple OSS Distributions #define L_XTND SEEK_END 129*19c3b8c2SApple OSS Distributions #endif 130*19c3b8c2SApple OSS Distributions 131*19c3b8c2SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 132*19c3b8c2SApple OSS Distributions struct accessx_descriptor { 133*19c3b8c2SApple OSS Distributions unsigned int ad_name_offset; 134*19c3b8c2SApple OSS Distributions int ad_flags; 135*19c3b8c2SApple OSS Distributions int ad_pad[2]; 136*19c3b8c2SApple OSS Distributions }; 137*19c3b8c2SApple OSS Distributions #define ACCESSX_MAX_DESCRIPTORS 100 138*19c3b8c2SApple OSS Distributions #define ACCESSX_MAX_TABLESIZE (16 * 1024) 139*19c3b8c2SApple OSS Distributions #endif 140*19c3b8c2SApple OSS Distributions 141*19c3b8c2SApple OSS Distributions /* configurable pathname variables */ 142*19c3b8c2SApple OSS Distributions #define _PC_LINK_MAX 1 143*19c3b8c2SApple OSS Distributions #define _PC_MAX_CANON 2 144*19c3b8c2SApple OSS Distributions #define _PC_MAX_INPUT 3 145*19c3b8c2SApple OSS Distributions #define _PC_NAME_MAX 4 146*19c3b8c2SApple OSS Distributions #define _PC_PATH_MAX 5 147*19c3b8c2SApple OSS Distributions #define _PC_PIPE_BUF 6 148*19c3b8c2SApple OSS Distributions #define _PC_CHOWN_RESTRICTED 7 149*19c3b8c2SApple OSS Distributions #define _PC_NO_TRUNC 8 150*19c3b8c2SApple OSS Distributions #define _PC_VDISABLE 9 151*19c3b8c2SApple OSS Distributions 152*19c3b8c2SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 153*19c3b8c2SApple OSS Distributions #define _PC_NAME_CHARS_MAX 10 154*19c3b8c2SApple OSS Distributions #define _PC_CASE_SENSITIVE 11 155*19c3b8c2SApple OSS Distributions #define _PC_CASE_PRESERVING 12 156*19c3b8c2SApple OSS Distributions #define _PC_EXTENDED_SECURITY_NP 13 157*19c3b8c2SApple OSS Distributions #define _PC_AUTH_OPAQUE_NP 14 158*19c3b8c2SApple OSS Distributions #endif 159*19c3b8c2SApple OSS Distributions 160*19c3b8c2SApple OSS Distributions #define _PC_2_SYMLINKS 15 /* Symlink supported in directory */ 161*19c3b8c2SApple OSS Distributions #define _PC_ALLOC_SIZE_MIN 16 /* Minimum storage actually allocated */ 162*19c3b8c2SApple OSS Distributions #define _PC_ASYNC_IO 17 /* Async I/O [AIO] supported? */ 163*19c3b8c2SApple OSS Distributions #define _PC_FILESIZEBITS 18 /* # of bits to represent file size */ 164*19c3b8c2SApple OSS Distributions #define _PC_PRIO_IO 19 /* Priority I/O [PIO] supported? */ 165*19c3b8c2SApple OSS Distributions #define _PC_REC_INCR_XFER_SIZE 20 /* Recommended increment for next two */ 166*19c3b8c2SApple OSS Distributions #define _PC_REC_MAX_XFER_SIZE 21 /* Recommended max file transfer size */ 167*19c3b8c2SApple OSS Distributions #define _PC_REC_MIN_XFER_SIZE 22 /* Recommended min file transfer size */ 168*19c3b8c2SApple OSS Distributions #define _PC_REC_XFER_ALIGN 23 /* Recommended buffer alignment */ 169*19c3b8c2SApple OSS Distributions #define _PC_SYMLINK_MAX 24 /* Max # of bytes in symlink name */ 170*19c3b8c2SApple OSS Distributions #define _PC_SYNC_IO 25 /* Sync I/O [SIO] supported? */ 171*19c3b8c2SApple OSS Distributions #define _PC_XATTR_SIZE_BITS 26 /* # of bits to represent maximum xattr size */ 172*19c3b8c2SApple OSS Distributions #define _PC_MIN_HOLE_SIZE 27 /* Recommended minimum hole size for sparse files */ 173*19c3b8c2SApple OSS Distributions 174*19c3b8c2SApple OSS Distributions /* configurable system strings */ 175*19c3b8c2SApple OSS Distributions #define _CS_PATH 1 176*19c3b8c2SApple OSS Distributions 177*19c3b8c2SApple OSS Distributions #ifndef KERNEL 178*19c3b8c2SApple OSS Distributions #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 179*19c3b8c2SApple OSS Distributions 180*19c3b8c2SApple OSS Distributions #include <machine/_types.h> 181*19c3b8c2SApple OSS Distributions #include <sys/_types/_size_t.h> 182*19c3b8c2SApple OSS Distributions #include <sys/_types/_ssize_t.h> 183*19c3b8c2SApple OSS Distributions #include <_types/_uint64_t.h> 184*19c3b8c2SApple OSS Distributions #include <_types/_uint32_t.h> 185*19c3b8c2SApple OSS Distributions #include <Availability.h> 186*19c3b8c2SApple OSS Distributions 187*19c3b8c2SApple OSS Distributions __BEGIN_DECLS 188*19c3b8c2SApple OSS Distributions 189*19c3b8c2SApple OSS Distributions int getattrlistbulk(int, void *, void *, size_t, uint64_t) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 190*19c3b8c2SApple OSS Distributions int getattrlistat(int, const char *, void *, void *, size_t, unsigned long) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 191*19c3b8c2SApple OSS Distributions int setattrlistat(int, const char *, void *, void *, size_t, uint32_t) __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0); 192*19c3b8c2SApple OSS Distributions ssize_t freadlink(int, char * __restrict, size_t) __API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0), watchos(9.0), bridgeos(7.0)); 193*19c3b8c2SApple OSS Distributions 194*19c3b8c2SApple OSS Distributions __END_DECLS 195*19c3b8c2SApple OSS Distributions 196*19c3b8c2SApple OSS Distributions #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 197*19c3b8c2SApple OSS Distributions 198*19c3b8c2SApple OSS Distributions #if __DARWIN_C_LEVEL >= 200809L 199*19c3b8c2SApple OSS Distributions 200*19c3b8c2SApple OSS Distributions #include <machine/_types.h> 201*19c3b8c2SApple OSS Distributions #include <sys/_types/_size_t.h> 202*19c3b8c2SApple OSS Distributions #include <sys/_types/_ssize_t.h> 203*19c3b8c2SApple OSS Distributions #include <sys/_types.h> 204*19c3b8c2SApple OSS Distributions #include <sys/_types/_uid_t.h> 205*19c3b8c2SApple OSS Distributions #include <sys/_types/_gid_t.h> 206*19c3b8c2SApple OSS Distributions #include <Availability.h> 207*19c3b8c2SApple OSS Distributions 208*19c3b8c2SApple OSS Distributions __BEGIN_DECLS 209*19c3b8c2SApple OSS Distributions 210*19c3b8c2SApple OSS Distributions int faccessat(int, const char *, int, int) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 211*19c3b8c2SApple OSS Distributions int fchownat(int, const char *, uid_t, gid_t, int) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 212*19c3b8c2SApple OSS Distributions int linkat(int, const char *, int, const char *, int) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 213*19c3b8c2SApple OSS Distributions ssize_t readlinkat(int, const char *, char *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 214*19c3b8c2SApple OSS Distributions int symlinkat(const char *, int, const char *) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 215*19c3b8c2SApple OSS Distributions int unlinkat(int, const char *, int) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 216*19c3b8c2SApple OSS Distributions 217*19c3b8c2SApple OSS Distributions __END_DECLS 218*19c3b8c2SApple OSS Distributions 219*19c3b8c2SApple OSS Distributions #endif /* __DARWIN_C_LEVEL >= 200809L */ 220*19c3b8c2SApple OSS Distributions #endif /* !KERNEL */ 221*19c3b8c2SApple OSS Distributions 222*19c3b8c2SApple OSS Distributions #endif /* !_SYS_UNISTD_H_ */ 223