1 /* 2 * Copyright (c) 1982, 1986, 1989 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)stat.h 7.4 (Berkeley) 03/14/90 18 */ 19 20 struct stat 21 { 22 dev_t st_dev; /* inode's device */ 23 ino_t st_ino; /* inode's number */ 24 mode_t st_mode; /* inode protection mode */ 25 nlink_t st_nlink; /* number of hard links */ 26 uid_t st_uid; /* user ID of the file's owner */ 27 gid_t st_gid; /* group ID of the file's group */ 28 dev_t st_rdev; /* device type */ 29 off_t st_size; /* file size, in bytes */ 30 time_t st_atime; /* time of last access */ 31 long st_spare1; 32 time_t st_mtime; /* time of last data modification */ 33 long st_spare2; 34 time_t st_ctime; /* time of last file status change */ 35 long st_spare3; 36 long st_blksize; /* optimal blocksize for I/O */ 37 long st_blocks; /* blocks allocated for file */ 38 u_long st_flags; /* user defined flags for file */ 39 u_long st_gen; /* file generation number */ 40 }; 41 42 #define S_ISUID 0004000 /* set user id on execution */ 43 #define S_ISGID 0002000 /* set group id on execution */ 44 #ifndef _POSIX_SOURCE 45 #define S_ISTXT 0001000 /* sticky bit */ 46 #endif 47 48 #define S_IRWXU 0000700 /* RWX mask for owner */ 49 #define S_IRUSR 0000400 /* R for owner */ 50 #define S_IWUSR 0000200 /* W for owner */ 51 #define S_IXUSR 0000100 /* X for owner */ 52 53 #ifndef _POSIX_SOURCE 54 #define S_IREAD S_IRUSR 55 #define S_IWRITE S_IWUSR 56 #define S_IEXEC S_IXUSR 57 #endif 58 59 #define S_IRWXG 0000070 /* RWX mask for group */ 60 #define S_IRGRP 0000040 /* R for group */ 61 #define S_IWGRP 0000020 /* W for group */ 62 #define S_IXGRP 0000010 /* X for group */ 63 64 #define S_IRWXO 0000007 /* RWX mask for other */ 65 #define S_IROTH 0000004 /* R for other */ 66 #define S_IWOTH 0000002 /* W for other */ 67 #define S_IXOTH 0000001 /* X for other */ 68 69 #ifndef _POSIX_SOURCE 70 #define S_IFMT 0170000 /* type of file */ 71 #define S_IFIFO 0010000 /* named pipe (fifo) */ 72 #define S_IFCHR 0020000 /* character special */ 73 #define S_IFDIR 0040000 /* directory */ 74 #define S_IFBLK 0060000 /* block special */ 75 #define S_IFREG 0100000 /* regular */ 76 #define S_IFLNK 0120000 /* symbolic link */ 77 #define S_IFSOCK 0140000 /* socket */ 78 79 #define S_ISVTX 0001000 /* save swapped text even after use */ 80 81 #define S_BLKSIZE 512 /* block size used in the stat struct */ 82 #endif 83 84 #define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ 85 #define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ 86 #define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ 87 #define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ 88 #define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ 89 #ifndef _POSIX_SOURCE 90 #define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ 91 #define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ 92 #endif 93