2  * Copyright (c) 2000-2008 Apple Inc. All rights reserved. 
   4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 
   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. 
  15  * Please obtain a copy of the License at 
  16  * http://www.opensource.apple.com/apsl/ and read it before using this file. 
  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. 
  26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 
  28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ 
  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. 
  38  * Redistribution and use in source and binary forms, with or without 
  39  * modification, are permitted provided that the following conditions 
  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. 
  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 
  66  *      @(#)stat.h      8.9 (Berkeley) 8/17/94 
  73 #include <sys/_types.h> 
  74 #include <sys/cdefs.h> 
  76 #include <machine/types.h> 
  78 #include <Availability.h> 
  81 /* [XSI] The timespec structure may be defined as described in <time.h> */ 
  82 #define __need_struct_timespec 
  84 #define __need_struct_user64_timespec 
  85 #define __need_struct_user32_timespec 
  87 #include <sys/_structs.h> 
  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 
  95 typedef __darwin_blkcnt_t       blkcnt_t
; 
 100 typedef __darwin_blksize_t      blksize_t
; 
 105 typedef __darwin_dev_t          dev_t
;          /* device number */ 
 110 typedef __darwin_ino_t          ino_t
;          /* inode number */ 
 114 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 
 116 typedef __darwin_ino64_t        ino64_t
;        /* 64bit inode number */ 
 119 #endif /* !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) */ 
 122 typedef __darwin_mode_t         mode_t
; 
 127 typedef __uint16_t              nlink_t
;        /* link count */ 
 132 typedef __darwin_uid_t          uid_t
;          /* user id */ 
 137 typedef __darwin_gid_t          gid_t
; 
 142 typedef __darwin_off_t          off_t
; 
 148 typedef __darwin_time_t         
time_t; 
 152 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 
 154  * XXX So deprecated, it would make your head spin 
 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 
 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 */ 
 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) */ 
 185 #else /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ 
 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 */ 
 197 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 
 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 
 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. 
 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! */ \ 
 228  * [XSI] This structure is used as the second parameter to the fstat(), 
 229  * lstat(), and stat() functions. 
 231 #if __DARWIN_64_BIT_INO_T 
 233 struct stat __DARWIN_STRUCT_STAT64
; 
 235 #else /* !__DARWIN_64_BIT_INO_T */ 
 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 */ 
 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 */ 
 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! */ 
 266 #endif /* __DARWIN_64_BIT_INO_T */ 
 268 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 
 270 #if !__DARWIN_ONLY_64_BIT_INO_T 
 272 struct stat64 __DARWIN_STRUCT_STAT64
; 
 274 #endif /* !__DARWIN_ONLY_64_BIT_INO_T */ 
 276 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 
 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 
 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 */ 
 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 */ 
 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! */ 
 315 /* ILP32 version of struct stat. 
 316  * WARNING - keep in sync with struct 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 */ 
 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 */ 
 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! */ 
 348 extern void munge_user64_stat(struct stat 
*sbp
, struct user64_stat 
*usbp
); 
 349 extern void munge_user32_stat(struct stat 
*sbp
, struct user32_stat 
*usbp
); 
 352 struct 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) */ 
 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 */ 
 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! */ 
 384 struct 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) */ 
 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 */ 
 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))); 
 416 extern void munge_user64_stat64(struct stat64 
*sbp
, struct user64_stat64 
*usbp
); 
 417 extern void munge_user32_stat64(struct stat64 
*sbp
, struct user32_stat64 
*usbp
); 
 419 #endif /* BSD_KERNEL_PRIVATE */ 
 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) */ 
 432  * [XSI] The following are symbolic names for the values of type mode_t.  They 
 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         /* whiteout */ 
 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 */ 
 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 */ 
 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 */ 
 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. 
 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)     /* whiteout */ 
 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. 
 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. 
 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 */ 
 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. 
 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. 
 528 #define S_TYPEISTMO(buf)        (0)     /* Test for a typed memory object */ 
 531 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 
 532 #define ACCESSPERMS     (S_IRWXU|S_IRWXG|S_IRWXO)       /* 0777 */ 
 534 #define ALLPERMS        (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) 
 536 #define DEFFILEMODE     (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) 
 538 #define S_BLKSIZE       512             /* block size used in the stat struct */ 
 541  * Definitions of flags stored in file flags word. 
 543  * Super-user and owner changeable flags. 
 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 */ 
 551  * The following bit is reserved for FreeBSD.  It is not implemented 
 554 /* #define UF_NOUNLINK  0x00000010 */   /* file may not be removed or renamed */ 
 555 #define UF_COMPRESSED   0x00000020      /* file is hfs-compressed */ 
 556 /* Bits 0x0040 through 0x4000 are currently undefined. */ 
 557 #define UF_HIDDEN       0x00008000      /* hint that this item should not be */ 
 558                                         /* displayed in a GUI */ 
 560  * Super-user changeable flags. 
 562 #define SF_SETTABLE     0xffff0000      /* mask of superuser changeable flags */ 
 563 #define SF_ARCHIVED     0x00010000      /* file is archived */ 
 564 #define SF_IMMUTABLE    0x00020000      /* file may not be changed */ 
 565 #define SF_APPEND       0x00040000      /* writes to file may only append */ 
 568  * The following two bits are reserved for FreeBSD.  They are not 
 569  * implemented in Mac OS X. 
 571 /* #define SF_NOUNLINK  0x00100000 */   /* file may not be removed or renamed */ 
 572 /* #define SF_SNAPSHOT  0x00200000 */   /* snapshot inode */ 
 573 /* NOTE: There is no SF_HIDDEN bit. */ 
 577  * Shorthand abbreviations of above. 
 579 #define OPAQUE          (UF_OPAQUE) 
 580 #define APPEND          (UF_APPEND | SF_APPEND) 
 581 #define IMMUTABLE       (UF_IMMUTABLE | SF_IMMUTABLE) 
 589 int     chmod(const char *, mode_t
) __DARWIN_ALIAS(chmod
); 
 590 int     fchmod(int, mode_t
) __DARWIN_ALIAS(fchmod
); 
 591 int     fstat(int, struct stat 
*) __DARWIN_INODE64(fstat
); 
 592 int     lstat(const char *, struct stat 
*) __DARWIN_INODE64(lstat
); 
 593 int     mkdir(const char *, mode_t
); 
 594 int     mkfifo(const char *, mode_t
); 
 595 int     stat(const char *, struct stat 
*) __DARWIN_INODE64(stat
); 
 596 int     mknod(const char *, mode_t
, dev_t
); 
 597 mode_t  
umask(mode_t
); 
 599 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 
 602 typedef struct _filesec 
*filesec_t
; 
 605 int     chflags(const char *, __uint32_t
); 
 606 int     chmodx_np(const char *, filesec_t
); 
 607 int     fchflags(int, __uint32_t
); 
 608 int     fchmodx_np(int, filesec_t
); 
 609 int     fstatx_np(int, struct stat 
*, filesec_t
) __DARWIN_INODE64(fstatx_np
); 
 610 int     lchflags(const char *, __uint32_t
); 
 611 int     lchmod(const char *, mode_t
); 
 612 int     lstatx_np(const char *, struct stat 
*, filesec_t
) __DARWIN_INODE64(lstatx_np
); 
 613 int     mkdirx_np(const char *, filesec_t
); 
 614 int     mkfifox_np(const char *, filesec_t
); 
 615 int     statx_np(const char *, struct stat 
*, filesec_t
) __DARWIN_INODE64(statx_np
); 
 616 int     umaskx_np(filesec_t
); 
 618 #if !__DARWIN_ONLY_64_BIT_INO_T 
 619 /* The following deprecated routines are simillar to stat and friends except provide struct stat64 instead of struct stat  */ 
 620 int     fstatx64_np(int, struct stat64 
*, filesec_t
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_6
,__IPHONE_NA
,__IPHONE_NA
); 
 621 int     lstatx64_np(const char *, struct stat64 
*, filesec_t
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_6
,__IPHONE_NA
,__IPHONE_NA
); 
 622 int     statx64_np(const char *, struct stat64 
*, filesec_t
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_6
,__IPHONE_NA
,__IPHONE_NA
); 
 623 int     fstat64(int, struct stat64 
*) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_6
,__IPHONE_NA
,__IPHONE_NA
); 
 624 int     lstat64(const char *, struct stat64 
*) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_6
,__IPHONE_NA
,__IPHONE_NA
); 
 625 int     stat64(const char *, struct stat64 
*) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5
,__MAC_10_6
,__IPHONE_NA
,__IPHONE_NA
); 
 626 #endif /* !__DARWIN_ONLY_64_BIT_INO_T */ 
 627 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 
 631 #endif /* !_SYS_STAT_H_ */