Back to index

lightning-sunbird  0.9+nobinonly
stat.h
Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1982, 1986, 1989, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  * (c) UNIX System Laboratories, Inc.
00005  * All or some portions of this file are derived from material licensed
00006  * to the University of California by American Telephone and Telegraph
00007  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
00008  * the permission of UNIX System Laboratories, Inc.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * [3 Deleted as of 22Jul99, see
00019  *     ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
00020  *        for details]
00021  * 4. Neither the name of the University nor the names of its contributors
00022  *    may be used to endorse or promote products derived from this software
00023  *    without specific prior written permission.
00024  *
00025  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00026  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00028  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00029  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00031  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00032  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00034  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00035  * SUCH DAMAGE.
00036  *
00037  *     @(#)stat.h    8.6 (Berkeley) 3/8/94
00038  */
00039 
00040 /* Adapted for GUSI by Matthias Neeracher <neeri@iis.ee.ethz.ch> */
00041 
00042 #ifndef _SYS_STAT_H_
00043 #define       _SYS_STAT_H_
00044 
00045 #include <time.h>
00046 #include <sys/types.h>
00047 
00048 struct stat {
00049        dev_t  st_dev;                     /* inode's device */
00050        ino_t  st_ino;                     /* inode's number */
00051        mode_t st_mode;             /* inode protection mode */
00052        nlink_t       st_nlink;            /* number of hard links */
00053        uid_t  st_uid;                     /* user ID of the file's owner */
00054        gid_t  st_gid;                     /* group ID of the file's group */
00055        dev_t  st_rdev;             /* device type */
00056        time_t st_atime;            /* time of last access */
00057        time_t st_mtime;            /* time of last data modification */
00058        time_t st_ctime;            /* time of last file status change */
00059        off_t  st_size;             /* file size, in bytes */
00060        long   st_blocks;           /* blocks allocated for file */
00061        unsigned long st_blksize;   /* optimal blocksize for I/O */
00062        unsigned long st_flags;     /* user defined flags for file */
00063 };
00064 
00065 #define       S_ISUID       0004000                     /* set user id on execution */
00066 #define       S_ISGID       0002000                     /* set group id on execution */
00067 
00068 #define       S_IRWXU       0000700                     /* RWX mask for owner */
00069 #define       S_IRUSR       0000400                     /* R for owner */
00070 #define       S_IWUSR       0000200                     /* W for owner */
00071 #define       S_IXUSR       0000100                     /* X for owner */
00072 
00073 #define       S_IRWXG       0000070                     /* RWX mask for group */
00074 #define       S_IRGRP       0000040                     /* R for group */
00075 #define       S_IWGRP       0000020                     /* W for group */
00076 #define       S_IXGRP       0000010                     /* X for group */
00077 
00078 #define       S_IRWXO       0000007                     /* RWX mask for other */
00079 #define       S_IROTH       0000004                     /* R for other */
00080 #define       S_IWOTH       0000002                     /* W for other */
00081 #define       S_IXOTH       0000001                     /* X for other */
00082 
00083 #define       S_IFMT  0170000             /* type of file mask */
00084 #define       S_IFIFO        0010000             /* named pipe (fifo) */
00085 #define       S_IFCHR        0020000             /* character special */
00086 #define       S_IFDIR        0040000             /* directory */
00087 #define       S_IFBLK        0060000             /* block special */
00088 #define       S_IFREG        0100000             /* regular */
00089 #define       S_IFLNK        0120000             /* symbolic link */
00090 #define       S_IFSOCK 0140000            /* socket */
00091 
00092 #define       S_ISDIR(m)    ((m & 0170000) == 0040000)  /* directory */
00093 #define       S_ISCHR(m)    ((m & 0170000) == 0020000)  /* char special */
00094 #define       S_ISBLK(m)    ((m & 0170000) == 0060000)  /* block special */
00095 #define       S_ISREG(m)    ((m & 0170000) == 0100000)  /* regular file */
00096 #define       S_ISFIFO(m)   ((m & 0170000) == 0100000 || \
00097                       (m & 0170000) == 0140000)  /* fifo or socket */
00098 #define       S_ISLNK(m)    ((m & 0170000) == 0120000)  /* symbolic link */
00099 #define       S_ISSOCK(m)   ((m & 0170000) == 0100000 || \
00100                       (m & 0170000) == 0140000)  /* fifo or socket */
00101 
00102 #include <sys/cdefs.h>
00103 
00104 __BEGIN_DECLS
00105 int    chmod __P((const char *, mode_t));
00106 int    fstat __P((int, struct stat *));
00107 int    mkdir __P((const char *, ...));
00108 int    stat __P((const char *, struct stat *));
00109 int    lstat __P((const char *, struct stat *));
00110 __END_DECLS
00111 
00112 #endif /* !_SYS_STAT_H_ */