this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at vchroot 632 lines 26 kB view raw
1/* 2 * Copyright (c) 2000-2008 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ 29/*- 30 * Copyright (c) 1982, 1986, 1989, 1993 31 * The Regents of the University of California. All rights reserved. 32 * (c) UNIX System Laboratories, Inc. 33 * All or some portions of this file are derived from material licensed 34 * to the University of California by American Telephone and Telegraph 35 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 36 * the permission of UNIX System Laboratories, Inc. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions 40 * are met: 41 * 1. Redistributions of source code must retain the above copyright 42 * notice, this list of conditions and the following disclaimer. 43 * 2. Redistributions in binary form must reproduce the above copyright 44 * notice, this list of conditions and the following disclaimer in the 45 * documentation and/or other materials provided with the distribution. 46 * 3. All advertising materials mentioning features or use of this software 47 * must display the following acknowledgement: 48 * This product includes software developed by the University of 49 * California, Berkeley and its contributors. 50 * 4. Neither the name of the University nor the names of its contributors 51 * may be used to endorse or promote products derived from this software 52 * without specific prior written permission. 53 * 54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 64 * SUCH DAMAGE. 65 * 66 * @(#)stat.h 8.9 (Berkeley) 8/17/94 67 */ 68 69 70#ifndef _SYS_STAT_H_ 71#define _SYS_STAT_H_ 72 73#include <sys/_types.h> 74#include <sys/cdefs.h> 75#ifdef KERNEL 76#include <machine/types.h> 77#else /* !KERNEL */ 78#include <Availability.h> 79#endif /* KERNEL */ 80 81/* [XSI] The timespec structure may be defined as described in <time.h> */ 82#define __need_struct_timespec 83#ifdef KERNEL 84#define __need_struct_user64_timespec 85#define __need_struct_user32_timespec 86#endif /* KERNEL */ 87#include <sys/_structs.h> 88 89/* 90 * [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t, 91 * gid_t, off_t, and time_t types shall be defined as described in 92 * <sys/types.h>. 93 */ 94#ifndef _BLKCNT_T 95typedef __darwin_blkcnt_t blkcnt_t; 96#define _BLKCNT_T 97#endif 98 99#ifndef _BLKSIZE_T 100typedef __darwin_blksize_t blksize_t; 101#define _BLKSIZE_T 102#endif 103 104#ifndef _DEV_T 105typedef __darwin_dev_t dev_t; /* device number */ 106#define _DEV_T 107#endif 108 109#ifndef _INO_T 110typedef __darwin_ino_t ino_t; /* inode number */ 111#define _INO_T 112#endif 113 114#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 115#ifndef _INO64_T 116typedef __darwin_ino64_t ino64_t; /* 64bit inode number */ 117#define _INO64_T 118#endif 119#endif /* !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) */ 120 121#ifndef _MODE_T 122typedef __darwin_mode_t mode_t; 123#define _MODE_T 124#endif 125 126#ifndef _NLINK_T 127typedef __uint16_t nlink_t; /* link count */ 128#define _NLINK_T 129#endif 130 131#ifndef _UID_T 132typedef __darwin_uid_t uid_t; /* user id */ 133#define _UID_T 134#endif 135 136#ifndef _GID_T 137typedef __darwin_gid_t gid_t; 138#define _GID_T 139#endif 140 141#ifndef _OFF_T 142typedef __darwin_off_t off_t; 143#define _OFF_T 144#endif 145 146#ifndef _TIME_T 147#define _TIME_T 148typedef __darwin_time_t time_t; 149#endif 150 151 152#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 153/* 154 * XXX So deprecated, it would make your head spin 155 * 156 * The old stat structure. In fact, this is not used by the kernel at all, 157 * and should not be used by user space, and should be removed from this 158 * header file entirely (along with the unused cvtstat() prototype in 159 * vnode_internal.h). 160 */ 161struct ostat { 162 __uint16_t st_dev; /* inode's device */ 163 ino_t st_ino; /* inode's number */ 164 mode_t st_mode; /* inode protection mode */ 165 nlink_t st_nlink; /* number of hard links */ 166 __uint16_t st_uid; /* user ID of the file's owner */ 167 __uint16_t st_gid; /* group ID of the file's group */ 168 __uint16_t st_rdev; /* device type */ 169 __int32_t st_size; /* file size, in bytes */ 170 struct timespec st_atimespec; /* time of last access */ 171 struct timespec st_mtimespec; /* time of last data modification */ 172 struct timespec st_ctimespec; /* time of last file status change */ 173 __int32_t st_blksize; /* optimal blocksize for I/O */ 174 __int32_t st_blocks; /* blocks allocated for file */ 175 __uint32_t st_flags; /* user defined flags for file */ 176 __uint32_t st_gen; /* file generation number */ 177}; 178 179#define __DARWIN_STRUCT_STAT64_TIMES \ 180 struct timespec st_atimespec; /* time of last access */ \ 181 struct timespec st_mtimespec; /* time of last data modification */ \ 182 struct timespec st_ctimespec; /* time of last status change */ \ 183 struct timespec st_birthtimespec; /* time of file creation(birth) */ 184 185#else /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ 186 187#define __DARWIN_STRUCT_STAT64_TIMES \ 188 time_t st_atime; /* [XSI] Time of last access */ \ 189 long st_atimensec; /* nsec of last access */ \ 190 time_t st_mtime; /* [XSI] Last data modification time */ \ 191 long st_mtimensec; /* last data modification nsec */ \ 192 time_t st_ctime; /* [XSI] Time of last status change */ \ 193 long st_ctimensec; /* nsec of last status change */ \ 194 time_t st_birthtime; /* File creation time(birth) */ \ 195 long st_birthtimensec; /* nsec of File creation time */ 196 197#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 198 199/* 200 * This structure is used as the second parameter to the fstat64(), 201 * lstat64(), and stat64() functions, and for struct stat when 202 * __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined 203 * above, depending on whether we use struct timespec or the direct 204 * components. 205 * 206 * This is simillar to stat except for 64bit inode number 207 * number instead of 32bit ino_t and the addition of create(birth) time. 208 */ 209#define __DARWIN_STRUCT_STAT64 { \ 210 dev_t st_dev; /* [XSI] ID of device containing file */ \ 211 mode_t st_mode; /* [XSI] Mode of file (see below) */ \ 212 nlink_t st_nlink; /* [XSI] Number of hard links */ \ 213 __darwin_ino64_t st_ino; /* [XSI] File serial number */ \ 214 uid_t st_uid; /* [XSI] User ID of the file */ \ 215 gid_t st_gid; /* [XSI] Group ID of the file */ \ 216 dev_t st_rdev; /* [XSI] Device ID */ \ 217 __DARWIN_STRUCT_STAT64_TIMES \ 218 off_t st_size; /* [XSI] file size, in bytes */ \ 219 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ \ 220 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ \ 221 __uint32_t st_flags; /* user defined flags for file */ \ 222 __uint32_t st_gen; /* file generation number */ \ 223 __int32_t st_lspare; /* RESERVED: DO NOT USE! */ \ 224 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ \ 225} 226 227/* 228 * [XSI] This structure is used as the second parameter to the fstat(), 229 * lstat(), and stat() functions. 230 */ 231#if __DARWIN_64_BIT_INO_T 232 233struct stat __DARWIN_STRUCT_STAT64; 234 235#else /* !__DARWIN_64_BIT_INO_T */ 236 237struct stat { 238 dev_t st_dev; /* [XSI] ID of device containing file */ 239 ino_t st_ino; /* [XSI] File serial number */ 240 mode_t st_mode; /* [XSI] Mode of file (see below) */ 241 nlink_t st_nlink; /* [XSI] Number of hard links */ 242 uid_t st_uid; /* [XSI] User ID of the file */ 243 gid_t st_gid; /* [XSI] Group ID of the file */ 244 dev_t st_rdev; /* [XSI] Device ID */ 245#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 246 struct timespec st_atimespec; /* time of last access */ 247 struct timespec st_mtimespec; /* time of last data modification */ 248 struct timespec st_ctimespec; /* time of last status change */ 249#else 250 time_t st_atime; /* [XSI] Time of last access */ 251 long st_atimensec; /* nsec of last access */ 252 time_t st_mtime; /* [XSI] Last data modification time */ 253 long st_mtimensec; /* last data modification nsec */ 254 time_t st_ctime; /* [XSI] Time of last status change */ 255 long st_ctimensec; /* nsec of last status change */ 256#endif 257 off_t st_size; /* [XSI] file size, in bytes */ 258 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ 259 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ 260 __uint32_t st_flags; /* user defined flags for file */ 261 __uint32_t st_gen; /* file generation number */ 262 __int32_t st_lspare; /* RESERVED: DO NOT USE! */ 263 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ 264}; 265 266#endif /* __DARWIN_64_BIT_INO_T */ 267 268#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 269 270#if !__DARWIN_ONLY_64_BIT_INO_T 271 272struct stat64 __DARWIN_STRUCT_STAT64; 273 274#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ 275 276#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 277 278 279#ifdef KERNEL 280#ifdef BSD_KERNEL_PRIVATE 281/* LP64 version of struct stat. time_t (see timespec) is a long and must 282 * grow when we're dealing with a 64-bit process. 283 * WARNING - keep in sync with struct stat 284 */ 285 286struct user64_stat { 287 dev_t st_dev; /* [XSI] ID of device containing file */ 288 ino_t st_ino; /* [XSI] File serial number */ 289 mode_t st_mode; /* [XSI] Mode of file (see below) */ 290 nlink_t st_nlink; /* [XSI] Number of hard links */ 291 uid_t st_uid; /* [XSI] User ID of the file */ 292 gid_t st_gid; /* [XSI] Group ID of the file */ 293 dev_t st_rdev; /* [XSI] Device ID */ 294#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 295 struct user64_timespec st_atimespec; /* time of last access */ 296 struct user64_timespec st_mtimespec; /* time of last data modification */ 297 struct user64_timespec st_ctimespec; /* time of last status change */ 298#else 299 user64_time_t st_atime; /* [XSI] Time of last access */ 300 user64_long_t st_atimensec; /* nsec of last access */ 301 user64_time_t st_mtime; /* [XSI] Last data modification */ 302 user64_long_t st_mtimensec; /* last data modification nsec */ 303 user64_time_t st_ctime; /* [XSI] Time of last status change */ 304 user64_long_t st_ctimensec; /* nsec of last status change */ 305#endif 306 off_t st_size; /* [XSI] File size, in bytes */ 307 blkcnt_t st_blocks; /* [XSI] Blocks allocated for file */ 308 blksize_t st_blksize; /* [XSI] Optimal blocksize for I/O */ 309 __uint32_t st_flags; /* user defined flags for file */ 310 __uint32_t st_gen; /* file generation number */ 311 __int32_t st_lspare; /* RESERVED: DO NOT USE! */ 312 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ 313}; 314 315/* ILP32 version of struct stat. 316 * WARNING - keep in sync with struct stat 317 */ 318 319struct user32_stat { 320 dev_t st_dev; /* [XSI] ID of device containing file */ 321 ino_t st_ino; /* [XSI] File serial number */ 322 mode_t st_mode; /* [XSI] Mode of file (see below) */ 323 nlink_t st_nlink; /* [XSI] Number of hard links */ 324 uid_t st_uid; /* [XSI] User ID of the file */ 325 gid_t st_gid; /* [XSI] Group ID of the file */ 326 dev_t st_rdev; /* [XSI] Device ID */ 327#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 328 struct user32_timespec st_atimespec; /* time of last access */ 329 struct user32_timespec st_mtimespec; /* time of last data modification */ 330 struct user32_timespec st_ctimespec; /* time of last status change */ 331#else 332 user32_time_t st_atime; /* [XSI] Time of last access */ 333 user32_long_t st_atimensec; /* nsec of last access */ 334 user32_time_t st_mtime; /* [XSI] Last data modification */ 335 user32_long_t st_mtimensec; /* last data modification nsec */ 336 user32_time_t st_ctime; /* [XSI] Time of last status change */ 337 user32_long_t st_ctimensec; /* nsec of last status change */ 338#endif 339 off_t st_size; /* [XSI] File size, in bytes */ 340 blkcnt_t st_blocks; /* [XSI] Blocks allocated for file */ 341 blksize_t st_blksize; /* [XSI] Optimal blocksize for I/O */ 342 __uint32_t st_flags; /* user defined flags for file */ 343 __uint32_t st_gen; /* file generation number */ 344 __int32_t st_lspare; /* RESERVED: DO NOT USE! */ 345 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ 346}; 347 348extern void munge_user64_stat(struct stat *sbp, struct user64_stat *usbp); 349extern void munge_user32_stat(struct stat *sbp, struct user32_stat *usbp); 350 351 352struct user64_stat64 { 353 dev_t st_dev; /* [XSI] ID of device containing file */ 354 mode_t st_mode; /* [XSI] Mode of file (see below) */ 355 nlink_t st_nlink; /* [XSI] Number of hard links */ 356 ino64_t st_ino; /* [XSI] File serial number */ 357 uid_t st_uid; /* [XSI] User ID of the file */ 358 gid_t st_gid; /* [XSI] Group ID of the file */ 359 dev_t st_rdev; /* [XSI] Device ID */ 360#ifndef _POSIX_C_SOURCE 361 struct user64_timespec st_atimespec; /* time of last access */ 362 struct user64_timespec st_mtimespec; /* time of last data modification */ 363 struct user64_timespec st_ctimespec; /* time of last status change */ 364 struct user64_timespec st_birthtimespec; /* time of file creation(birth) */ 365#else 366 user64_time_t st_atime; /* [XSI] Time of last access */ 367 user64_long_t st_atimensec; /* nsec of last access */ 368 user64_time_t st_mtime; /* [XSI] Last data modification time */ 369 user64_long_t st_mtimensec; /* last data modification nsec */ 370 user64_time_t st_ctime; /* [XSI] Time of last status change */ 371 user64_long_t st_ctimensec; /* nsec of last status change */ 372 user64_time_t st_birthtime; /* File creation time(birth) */ 373 user64_long_t st_birthtimensec; /* nsec of File creation time */ 374#endif 375 off_t st_size; /* [XSI] file size, in bytes */ 376 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ 377 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ 378 __uint32_t st_flags; /* user defined flags for file */ 379 __uint32_t st_gen; /* file generation number */ 380 __uint32_t st_lspare; /* RESERVED: DO NOT USE! */ 381 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ 382}; 383 384struct user32_stat64 { 385 dev_t st_dev; /* [XSI] ID of device containing file */ 386 mode_t st_mode; /* [XSI] Mode of file (see below) */ 387 nlink_t st_nlink; /* [XSI] Number of hard links */ 388 ino64_t st_ino; /* [XSI] File serial number */ 389 uid_t st_uid; /* [XSI] User ID of the file */ 390 gid_t st_gid; /* [XSI] Group ID of the file */ 391 dev_t st_rdev; /* [XSI] Device ID */ 392#ifndef _POSIX_C_SOURCE 393 struct user32_timespec st_atimespec; /* time of last access */ 394 struct user32_timespec st_mtimespec; /* time of last data modification */ 395 struct user32_timespec st_ctimespec; /* time of last status change */ 396 struct user32_timespec st_birthtimespec; /* time of file creation(birth) */ 397#else 398 user32_time_t st_atime; /* [XSI] Time of last access */ 399 user32_long_t st_atimensec; /* nsec of last access */ 400 user32_time_t st_mtime; /* [XSI] Last data modification time */ 401 user32_long_t st_mtimensec; /* last data modification nsec */ 402 user32_time_t st_ctime; /* [XSI] Time of last status change */ 403 user32_long_t st_ctimensec; /* nsec of last status change */ 404 user32_time_t st_birthtime; /* File creation time(birth) */ 405 user32_long_t st_birthtimensec; /* nsec of File creation time */ 406#endif 407 off_t st_size; /* [XSI] file size, in bytes */ 408 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ 409 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ 410 __uint32_t st_flags; /* user defined flags for file */ 411 __uint32_t st_gen; /* file generation number */ 412 __uint32_t st_lspare; /* RESERVED: DO NOT USE! */ 413 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ 414} __attribute__((packed,aligned(4))); 415 416extern void munge_user64_stat64(struct stat64 *sbp, struct user64_stat64 *usbp); 417extern void munge_user32_stat64(struct stat64 *sbp, struct user32_stat64 *usbp); 418 419#endif /* BSD_KERNEL_PRIVATE */ 420 421#endif /* KERNEL */ 422 423 424#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 425#define st_atime st_atimespec.tv_sec 426#define st_mtime st_mtimespec.tv_sec 427#define st_ctime st_ctimespec.tv_sec 428#define st_birthtime st_birthtimespec.tv_sec 429#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 430 431/* 432 * [XSI] The following are symbolic names for the values of type mode_t. They 433 * are bitmap values. 434 */ 435#ifndef S_IFMT 436/* File type */ 437#define S_IFMT 0170000 /* [XSI] type of file mask */ 438#define S_IFIFO 0010000 /* [XSI] named pipe (fifo) */ 439#define S_IFCHR 0020000 /* [XSI] character special */ 440#define S_IFDIR 0040000 /* [XSI] directory */ 441#define S_IFBLK 0060000 /* [XSI] block special */ 442#define S_IFREG 0100000 /* [XSI] regular */ 443#define S_IFLNK 0120000 /* [XSI] symbolic link */ 444#define S_IFSOCK 0140000 /* [XSI] socket */ 445#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 446#define S_IFWHT 0160000 /* OBSOLETE: whiteout */ 447#endif 448 449/* File mode */ 450/* Read, write, execute/search by owner */ 451#define S_IRWXU 0000700 /* [XSI] RWX mask for owner */ 452#define S_IRUSR 0000400 /* [XSI] R for owner */ 453#define S_IWUSR 0000200 /* [XSI] W for owner */ 454#define S_IXUSR 0000100 /* [XSI] X for owner */ 455/* Read, write, execute/search by group */ 456#define S_IRWXG 0000070 /* [XSI] RWX mask for group */ 457#define S_IRGRP 0000040 /* [XSI] R for group */ 458#define S_IWGRP 0000020 /* [XSI] W for group */ 459#define S_IXGRP 0000010 /* [XSI] X for group */ 460/* Read, write, execute/search by others */ 461#define S_IRWXO 0000007 /* [XSI] RWX mask for other */ 462#define S_IROTH 0000004 /* [XSI] R for other */ 463#define S_IWOTH 0000002 /* [XSI] W for other */ 464#define S_IXOTH 0000001 /* [XSI] X for other */ 465 466#define S_ISUID 0004000 /* [XSI] set user id on execution */ 467#define S_ISGID 0002000 /* [XSI] set group id on execution */ 468#define S_ISVTX 0001000 /* [XSI] directory restrcted delete */ 469 470#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 471#define S_ISTXT S_ISVTX /* sticky bit: not supported */ 472#define S_IREAD S_IRUSR /* backward compatability */ 473#define S_IWRITE S_IWUSR /* backward compatability */ 474#define S_IEXEC S_IXUSR /* backward compatability */ 475#endif 476#endif /* !S_IFMT */ 477 478/* 479 * [XSI] The following macros shall be provided to test whether a file is 480 * of the specified type. The value m supplied to the macros is the value 481 * of st_mode from a stat structure. The macro shall evaluate to a non-zero 482 * value if the test is true; 0 if the test is false. 483 */ 484#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) /* block special */ 485#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* char special */ 486#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* directory */ 487#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* fifo or socket */ 488#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* regular file */ 489#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* symbolic link */ 490#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) /* socket */ 491#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 492#define S_ISWHT(m) (((m) & S_IFMT) == S_IFWHT) /* OBSOLETE: whiteout */ 493#endif 494 495/* 496 * [XSI] The implementation may implement message queues, semaphores, or 497 * shared memory objects as distinct file types. The following macros 498 * shall be provided to test whether a file is of the specified type. 499 * The value of the buf argument supplied to the macros is a pointer to 500 * a stat structure. The macro shall evaluate to a non-zero value if 501 * the specified object is implemented as a distinct file type and the 502 * specified file type is contained in the stat structure referenced by 503 * buf. Otherwise, the macro shall evaluate to zero. 504 * 505 * NOTE: The current implementation does not do this, although 506 * this may change in future revisions, and co currently only 507 * provides these macros to ensure source compatability with 508 * implementations which do. 509 */ 510#define S_TYPEISMQ(buf) (0) /* Test for a message queue */ 511#define S_TYPEISSEM(buf) (0) /* Test for a semaphore */ 512#define S_TYPEISSHM(buf) (0) /* Test for a shared memory object */ 513 514/* 515 * [TYM] The implementation may implement typed memory objects as distinct 516 * file types, and the following macro shall test whether a file is of the 517 * specified type. The value of the buf argument supplied to the macros is 518 * a pointer to a stat structure. The macro shall evaluate to a non-zero 519 * value if the specified object is implemented as a distinct file type and 520 * the specified file type is contained in the stat structure referenced by 521 * buf. Otherwise, the macro shall evaluate to zero. 522 * 523 * NOTE: The current implementation does not do this, although 524 * this may change in future revisions, and co currently only 525 * provides this macro to ensure source compatability with 526 * implementations which do. 527 */ 528#define S_TYPEISTMO(buf) (0) /* Test for a typed memory object */ 529 530 531#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 532#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ 533 /* 7777 */ 534#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) 535 /* 0666 */ 536#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) 537 538#define S_BLKSIZE 512 /* block size used in the stat struct */ 539 540/* 541 * Definitions of flags stored in file flags word. 542 * 543 * Super-user and owner changeable flags. 544 */ 545#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */ 546#define UF_NODUMP 0x00000001 /* do not dump file */ 547#define UF_IMMUTABLE 0x00000002 /* file may not be changed */ 548#define UF_APPEND 0x00000004 /* writes to file may only append */ 549#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */ 550/* 551 * The following bit is reserved for FreeBSD. It is not implemented 552 * in Mac OS X. 553 */ 554/* #define UF_NOUNLINK 0x00000010 */ /* file may not be removed or renamed */ 555#define UF_COMPRESSED 0x00000020 /* file is hfs-compressed */ 556#define UF_TRACKED 0x00000040 /* file renames and deletes are tracked */ 557/* Bits 0x0080 through 0x4000 are currently undefined. */ 558#define UF_HIDDEN 0x00008000 /* hint that this item should not be */ 559 /* displayed in a GUI */ 560/* 561 * Super-user changeable flags. 562 */ 563#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */ 564#define SF_ARCHIVED 0x00010000 /* file is archived */ 565#define SF_IMMUTABLE 0x00020000 /* file may not be changed */ 566#define SF_APPEND 0x00040000 /* writes to file may only append */ 567 568/* 569 * The following two bits are reserved for FreeBSD. They are not 570 * implemented in Mac OS X. 571 */ 572/* #define SF_NOUNLINK 0x00100000 */ /* file may not be removed or renamed */ 573/* #define SF_SNAPSHOT 0x00200000 */ /* snapshot inode */ 574/* NOTE: There is no SF_HIDDEN bit. */ 575 576#ifdef KERNEL 577/* 578 * Shorthand abbreviations of above. 579 */ 580#define OPAQUE (UF_OPAQUE) 581#define APPEND (UF_APPEND | SF_APPEND) 582#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE) 583#endif 584#endif 585 586#ifndef KERNEL 587 588__BEGIN_DECLS 589/* [XSI] */ 590int chmod(const char *, mode_t) __DARWIN_ALIAS(chmod); 591int fchmod(int, mode_t) __DARWIN_ALIAS(fchmod); 592int fstat(int, struct stat *) __DARWIN_INODE64(fstat); 593int lstat(const char *, struct stat *) __DARWIN_INODE64(lstat); 594int mkdir(const char *, mode_t); 595int mkfifo(const char *, mode_t); 596int stat(const char *, struct stat *) __DARWIN_INODE64(stat); 597int mknod(const char *, mode_t, dev_t); 598mode_t umask(mode_t); 599 600#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 601#ifndef _FILESEC_T 602struct _filesec; 603typedef struct _filesec *filesec_t; 604#define _FILESEC_T 605#endif 606int chflags(const char *, __uint32_t); 607int chmodx_np(const char *, filesec_t); 608int fchflags(int, __uint32_t); 609int fchmodx_np(int, filesec_t); 610int fstatx_np(int, struct stat *, filesec_t) __DARWIN_INODE64(fstatx_np); 611int lchflags(const char *, __uint32_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); 612int lchmod(const char *, mode_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); 613int lstatx_np(const char *, struct stat *, filesec_t) __DARWIN_INODE64(lstatx_np); 614int mkdirx_np(const char *, filesec_t); 615int mkfifox_np(const char *, filesec_t); 616int statx_np(const char *, struct stat *, filesec_t) __DARWIN_INODE64(statx_np); 617int umaskx_np(filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); 618 619#if !__DARWIN_ONLY_64_BIT_INO_T 620/* The following deprecated routines are simillar to stat and friends except provide struct stat64 instead of struct stat */ 621int fstatx64_np(int, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); 622int lstatx64_np(const char *, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); 623int statx64_np(const char *, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); 624int fstat64(int, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); 625int lstat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); 626int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); 627#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ 628#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 629 630__END_DECLS 631#endif /* !KERNEL */ 632#endif /* !_SYS_STAT_H_ */