[BACK]Return to stat.h CVS log [TXT][DIR] Up to [local] / sys / sys

Annotation of sys/sys/stat.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: stat.h,v 1.16 2005/12/13 00:35:23 millert Exp $       */
                      2: /*     $NetBSD: stat.h,v 1.20 1996/05/16 22:17:49 cgd Exp $    */
                      3:
                      4: /*-
                      5:  * Copyright (c) 1982, 1986, 1989, 1993
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  * (c) UNIX System Laboratories, Inc.
                      8:  * All or some portions of this file are derived from material licensed
                      9:  * to the University of California by American Telephone and Telegraph
                     10:  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
                     11:  * the permission of UNIX System Laboratories, Inc.
                     12:  *
                     13:  * Redistribution and use in source and binary forms, with or without
                     14:  * modification, are permitted provided that the following conditions
                     15:  * are met:
                     16:  * 1. Redistributions of source code must retain the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer.
                     18:  * 2. Redistributions in binary form must reproduce the above copyright
                     19:  *    notice, this list of conditions and the following disclaimer in the
                     20:  *    documentation and/or other materials provided with the distribution.
                     21:  * 3. Neither the name of the University nor the names of its contributors
                     22:  *    may be used to endorse or promote products derived from this software
                     23:  *    without specific prior written permission.
                     24:  *
                     25:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     26:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     27:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     28:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     29:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     30:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     31:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     32:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     33:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     34:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     35:  * SUCH DAMAGE.
                     36:  *
                     37:  *     @(#)stat.h      8.9 (Berkeley) 8/17/94
                     38:  */
                     39:
                     40: #ifndef _SYS_STAT_H_
                     41: #define        _SYS_STAT_H_
                     42:
                     43: #include <sys/cdefs.h>
                     44: #include <sys/time.h>
                     45:
                     46: #ifdef _KERNEL
                     47: struct stat43 {
                     48:        u_int16_t st_dev;               /* inode's device */
                     49:        ino_t     st_ino;               /* inode's number */
                     50:        u_int16_t st_mode;              /* inode protection mode */
                     51:        u_int16_t st_nlink;             /* number of hard links */
                     52:        u_int16_t st_uid;               /* user ID of the file's owner */
                     53:        u_int16_t st_gid;               /* group ID of the file's group */
                     54:        u_int16_t st_rdev;              /* device type */
                     55:        int32_t   st_size;              /* file size, in bytes */
                     56:        struct  timespec st_atimespec;  /* time of last access */
                     57:        struct  timespec st_mtimespec;  /* time of last data modification */
                     58:        struct  timespec st_ctimespec;  /* time of last file status change */
                     59:        int32_t   st_blksize;           /* optimal blocksize for I/O */
                     60:        int32_t   st_blocks;            /* blocks allocated for file */
                     61:        u_int32_t st_flags;             /* user defined flags for file */
                     62:        u_int32_t st_gen;               /* file generation number */
                     63: };
                     64:
                     65: struct stat35 {
                     66:        dev_t     st_dev;               /* inode's device */
                     67:        ino_t     st_ino;               /* inode's number */
                     68:        u_int16_t  st_mode;             /* inode protection mode */
                     69:        u_int16_t  st_nlink;            /* number of hard links */
                     70:        uid_t     st_uid;               /* user ID of the file's owner */
                     71:        gid_t     st_gid;               /* group ID of the file's group */
                     72:        dev_t     st_rdev;              /* device type */
                     73:        struct  timespec st_atimespec;  /* time of last access */
                     74:        struct  timespec st_mtimespec;  /* time of last data modification */
                     75:        struct  timespec st_ctimespec;  /* time of last file status change */
                     76:        off_t     st_size;              /* file size, in bytes */
                     77:        int64_t   st_blocks;            /* blocks allocated for file */
                     78:        u_int32_t st_blksize;           /* optimal blocksize for I/O */
                     79:        u_int32_t st_flags;             /* user defined flags for file */
                     80:        u_int32_t st_gen;               /* file generation number */
                     81:        int32_t   st_lspare;
                     82:        int64_t   st_qspare[2];
                     83: };
                     84: #endif /* !_KERNEL */
                     85:
                     86: struct stat {
                     87:        dev_t     st_dev;               /* inode's device */
                     88:        ino_t     st_ino;               /* inode's number */
                     89:        mode_t    st_mode;              /* inode protection mode */
                     90:        nlink_t   st_nlink;             /* number of hard links */
                     91:        uid_t     st_uid;               /* user ID of the file's owner */
                     92:        gid_t     st_gid;               /* group ID of the file's group */
                     93:        dev_t     st_rdev;              /* device type */
                     94:        int32_t   st_lspare0;
                     95: #if __BSD_VISIBLE
                     96:        struct  timespec st_atimespec;  /* time of last access */
                     97:        struct  timespec st_mtimespec;  /* time of last data modification */
                     98:        struct  timespec st_ctimespec;  /* time of last file status change */
                     99: #else
                    100:        time_t    st_atime;             /* time of last access */
                    101:        long      st_atimensec;         /* nsec of last access */
                    102:        time_t    st_mtime;             /* time of last data modification */
                    103:        long      st_mtimensec;         /* nsec of last data modification */
                    104:        time_t    st_ctime;             /* time of last file status change */
                    105:        long      st_ctimensec;         /* nsec of last file status change */
                    106: #endif /* __BSD_VISIBLE */
                    107:        off_t     st_size;              /* file size, in bytes */
                    108:        int64_t   st_blocks;            /* blocks allocated for file */
                    109:        u_int32_t st_blksize;           /* optimal blocksize for I/O */
                    110:        u_int32_t st_flags;             /* user defined flags for file */
                    111:        u_int32_t st_gen;               /* file generation number */
                    112:        int32_t   st_lspare1;
                    113: #if __BSD_VISIBLE
                    114:        struct  timespec __st_birthtimespec; /* time of file creation */
                    115: #else
                    116:        time_t    __st_birthtime;       /* time of file creation */
                    117:        long      __st_birthtimensec;   /* nsec of file creation */
                    118: #endif
                    119:        int64_t   st_qspare[2];
                    120: };
                    121: #if __BSD_VISIBLE
                    122: #define        st_atime        st_atimespec.tv_sec
                    123: #define        st_atimensec    st_atimespec.tv_nsec
                    124: #define        st_mtime        st_mtimespec.tv_sec
                    125: #define        st_mtimensec    st_mtimespec.tv_nsec
                    126: #define        st_ctime        st_ctimespec.tv_sec
                    127: #define        st_ctimensec    st_ctimespec.tv_nsec
                    128: #endif
                    129:
                    130: #define        S_ISUID 0004000                 /* set user id on execution */
                    131: #define        S_ISGID 0002000                 /* set group id on execution */
                    132: #if __BSD_VISIBLE
                    133: #define        S_ISTXT 0001000                 /* sticky bit */
                    134: #endif
                    135:
                    136: #define        S_IRWXU 0000700                 /* RWX mask for owner */
                    137: #define        S_IRUSR 0000400                 /* R for owner */
                    138: #define        S_IWUSR 0000200                 /* W for owner */
                    139: #define        S_IXUSR 0000100                 /* X for owner */
                    140:
                    141: #if __BSD_VISIBLE
                    142: #define        S_IREAD         S_IRUSR
                    143: #define        S_IWRITE        S_IWUSR
                    144: #define        S_IEXEC         S_IXUSR
                    145: #endif
                    146:
                    147: #define        S_IRWXG 0000070                 /* RWX mask for group */
                    148: #define        S_IRGRP 0000040                 /* R for group */
                    149: #define        S_IWGRP 0000020                 /* W for group */
                    150: #define        S_IXGRP 0000010                 /* X for group */
                    151:
                    152: #define        S_IRWXO 0000007                 /* RWX mask for other */
                    153: #define        S_IROTH 0000004                 /* R for other */
                    154: #define        S_IWOTH 0000002                 /* W for other */
                    155: #define        S_IXOTH 0000001                 /* X for other */
                    156:
                    157: #if __XPG_VISIBLE || __BSD_VISIBLE
                    158: #define        S_IFMT   0170000                /* type of file mask */
                    159: #define        S_IFIFO  0010000                /* named pipe (fifo) */
                    160: #define        S_IFCHR  0020000                /* character special */
                    161: #define        S_IFDIR  0040000                /* directory */
                    162: #define        S_IFBLK  0060000                /* block special */
                    163: #define        S_IFREG  0100000                /* regular */
                    164: #define        S_IFLNK  0120000                /* symbolic link */
                    165: #define        S_IFSOCK 0140000                /* socket */
                    166: #define        S_ISVTX  0001000                /* save swapped text even after use */
                    167: #endif
                    168:
                    169: #define        S_ISDIR(m)      ((m & 0170000) == 0040000)      /* directory */
                    170: #define        S_ISCHR(m)      ((m & 0170000) == 0020000)      /* char special */
                    171: #define        S_ISBLK(m)      ((m & 0170000) == 0060000)      /* block special */
                    172: #define        S_ISREG(m)      ((m & 0170000) == 0100000)      /* regular file */
                    173: #define        S_ISFIFO(m)     ((m & 0170000) == 0010000)      /* fifo */
                    174: #if __POSIX_VISIBLE >= 200112 || __BSD_VISIBLE
                    175: #define        S_ISLNK(m)      ((m & 0170000) == 0120000)      /* symbolic link */
                    176: #define        S_ISSOCK(m)     ((m & 0170000) == 0140000)      /* socket */
                    177: #endif
                    178:
                    179: #if __BSD_VISIBLE
                    180: #define        ACCESSPERMS     (S_IRWXU|S_IRWXG|S_IRWXO)       /* 00777 */
                    181:                                                        /* 07777 */
                    182: #define        ALLPERMS        (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
                    183:                                                        /* 00666 */
                    184: #define        DEFFILEMODE     (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
                    185:
                    186: #define        S_BLKSIZE       512             /* block size used in the stat struct */
                    187:
                    188: /*
                    189:  * Definitions of flags stored in file flags word.
                    190:  *
                    191:  * Super-user and owner changeable flags.
                    192:  */
                    193: #define        UF_SETTABLE     0x0000ffff      /* mask of owner changeable flags */
                    194: #define        UF_NODUMP       0x00000001      /* do not dump file */
                    195: #define        UF_IMMUTABLE    0x00000002      /* file may not be changed */
                    196: #define        UF_APPEND       0x00000004      /* writes to file may only append */
                    197: #define        UF_OPAQUE       0x00000008      /* directory is opaque wrt. union */
                    198: /*
                    199:  * Super-user changeable flags.
                    200:  */
                    201: #define        SF_SETTABLE     0xffff0000      /* mask of superuser changeable flags */
                    202: #define        SF_ARCHIVED     0x00010000      /* file is archived */
                    203: #define        SF_IMMUTABLE    0x00020000      /* file may not be changed */
                    204: #define        SF_APPEND       0x00040000      /* writes to file may only append */
                    205:
                    206: #ifdef _KERNEL
                    207: /*
                    208:  * Shorthand abbreviations of above.
                    209:  */
                    210: #define        OPAQUE          (UF_OPAQUE)
                    211: #define        APPEND          (UF_APPEND | SF_APPEND)
                    212: #define        IMMUTABLE       (UF_IMMUTABLE | SF_IMMUTABLE)
                    213: #endif /* _KERNEL */
                    214: #endif /* __BSD_VISIBLE */
                    215:
                    216: #ifndef _KERNEL
                    217: __BEGIN_DECLS
                    218: int    chmod(const char *, mode_t);
                    219: int    fstat(int, struct stat *);
                    220: int    mknod(const char *, mode_t, dev_t);
                    221: int    mkdir(const char *, mode_t);
                    222: int    mkfifo(const char *, mode_t);
                    223: int    stat(const char *, struct stat *);
                    224: mode_t umask(mode_t);
                    225: #if __BSD_VISIBLE
                    226: int    chflags(const char *, unsigned int);
                    227: int    fchflags(int, unsigned int);
                    228: int    fchmod(int, mode_t);
                    229: int    lstat(const char *, struct stat *);
                    230: int    isfdtype(int, int);
                    231: #endif
                    232: __END_DECLS
                    233: #endif
                    234: #endif /* !_SYS_STAT_H_ */

CVSweb