add ACCESSPERMS, ALLPERMS; Cleanups for 4.4BSD-Lite
[unix-history] / usr / src / sys / sys / stat.h
CommitLineData
5738e669 1/*-
56559b70
KB
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
da7c5cc6 4 *
5738e669 5 * %sccs.include.redist.c%
b71cbf16 6 *
0509845d 7 * @(#)stat.h 8.2 (Berkeley) %G%
da7c5cc6 8 */
179fed83 9
981c9c55 10#include <sys/time.h>
9942ea0a
KM
11
12struct ostat {
3af4dec7 13 unsigned short st_dev; /* inode's device */
981c9c55
KM
14 ino_t st_ino; /* inode's number */
15 mode_t st_mode; /* inode protection mode */
16 nlink_t st_nlink; /* number of hard links */
3af4dec7
KB
17 unsigned short st_uid; /* user ID of the file's owner */
18 unsigned short st_gid; /* group ID of the file's group */
19 unsigned short st_rdev; /* device type */
981c9c55 20 long st_size; /* file size, in bytes */
9942ea0a
KM
21 struct timespec st_atimespec; /* time of last access */
22 struct timespec st_mtimespec; /* time of last data modification */
23 struct timespec st_ctimespec; /* time of last file status change */
981c9c55
KM
24 long st_blksize; /* optimal blocksize for I/O */
25 long st_blocks; /* blocks allocated for file */
3af4dec7
KB
26 unsigned long st_flags; /* user defined flags for file */
27 unsigned long st_gen; /* file generation number */
981c9c55
KM
28};
29
9942ea0a 30struct stat {
b71cbf16
KB
31 dev_t st_dev; /* inode's device */
32 ino_t st_ino; /* inode's number */
33 mode_t st_mode; /* inode protection mode */
34 nlink_t st_nlink; /* number of hard links */
35 uid_t st_uid; /* user ID of the file's owner */
36 gid_t st_gid; /* group ID of the file's group */
37 dev_t st_rdev; /* device type */
9942ea0a
KM
38 struct timespec st_atimespec; /* time of last access */
39 struct timespec st_mtimespec; /* time of last data modification */
40 struct timespec st_ctimespec; /* time of last file status change */
b71cbf16 41 off_t st_size; /* file size, in bytes */
981c9c55 42 quad_t st_blocks; /* blocks allocated for file */
3af4dec7
KB
43 unsigned long st_blksize; /* optimal blocksize for I/O */
44 unsigned long st_flags; /* user defined flags for file */
45 unsigned long st_gen; /* file generation number */
9942ea0a
KM
46 long st_lspare;
47 quad_t st_qspare[2];
179fed83 48};
9942ea0a
KM
49#define st_atime st_atimespec.ts_sec
50#define st_mtime st_mtimespec.ts_sec
51#define st_ctime st_ctimespec.ts_sec
179fed83 52
b71cbf16
KB
53#define S_ISUID 0004000 /* set user id on execution */
54#define S_ISGID 0002000 /* set group id on execution */
55#ifndef _POSIX_SOURCE
56#define S_ISTXT 0001000 /* sticky bit */
57#endif
58
59#define S_IRWXU 0000700 /* RWX mask for owner */
60#define S_IRUSR 0000400 /* R for owner */
61#define S_IWUSR 0000200 /* W for owner */
62#define S_IXUSR 0000100 /* X for owner */
63
64#ifndef _POSIX_SOURCE
65#define S_IREAD S_IRUSR
66#define S_IWRITE S_IWUSR
67#define S_IEXEC S_IXUSR
68#endif
69
70#define S_IRWXG 0000070 /* RWX mask for group */
71#define S_IRGRP 0000040 /* R for group */
72#define S_IWGRP 0000020 /* W for group */
73#define S_IXGRP 0000010 /* X for group */
74
75#define S_IRWXO 0000007 /* RWX mask for other */
76#define S_IROTH 0000004 /* R for other */
77#define S_IWOTH 0000002 /* W for other */
78#define S_IXOTH 0000001 /* X for other */
79
80#ifndef _POSIX_SOURCE
db035faa 81#define S_IFMT 0170000 /* type of file mask */
b71cbf16
KB
82#define S_IFIFO 0010000 /* named pipe (fifo) */
83#define S_IFCHR 0020000 /* character special */
84#define S_IFDIR 0040000 /* directory */
85#define S_IFBLK 0060000 /* block special */
86#define S_IFREG 0100000 /* regular */
87#define S_IFLNK 0120000 /* symbolic link */
88#define S_IFSOCK 0140000 /* socket */
b71cbf16 89#define S_ISVTX 0001000 /* save swapped text even after use */
db035faa 90#endif
5eb19442 91
fd78ff3d
KB
92#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */
93#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */
94#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */
95#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */
96#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */
97#ifndef _POSIX_SOURCE
98#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */
99#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */
100#endif
4f41789c 101
db035faa 102#ifndef _POSIX_SOURCE
0509845d
KB
103 /* 0777 */
104#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
105 /* 7777 */
106#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
db035faa
KB
107 /* 0666 */
108#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
109
110#define S_BLKSIZE 512 /* block size used in the stat struct */
111
4f41789c
KM
112/*
113 * Definitions of flags stored in file flags word.
114 *
973030c6 115 * Super-user and owner changeable flags.
4f41789c 116 */
973030c6 117#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
359e7bb4
KB
118#define UF_NODUMP 0x00000001 /* do not dump file */
119#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
120#define UF_APPEND 0x00000004 /* writes to file may only append */
4f41789c 121/*
973030c6 122 * Super-user changeable flags.
4f41789c 123 */
973030c6 124#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
359e7bb4
KB
125#define SF_ARCHIVED 0x00010000 /* file is archived */
126#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
127#define SF_APPEND 0x00040000 /* writes to file may only append */
128
129#ifdef KERNEL
103d5874
KM
130/*
131 * Shorthand abbreviations of above.
132 */
359e7bb4
KB
133#define APPEND (UF_APPEND | SF_APPEND)
134#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
135#endif
b71cbf16
KB
136#endif
137
0f9e0ffb 138#ifndef KERNEL
91befe9c
KB
139#include <sys/cdefs.h>
140
141__BEGIN_DECLS
91befe9c
KB
142int chmod __P((const char *, mode_t));
143int fstat __P((int, struct stat *));
144int mkdir __P((const char *, mode_t));
145int mkfifo __P((const char *, mode_t));
146int stat __P((const char *, struct stat *));
fd78ff3d 147mode_t umask __P((mode_t));
0f3392b1 148#ifndef _POSIX_SOURCE
fd78ff3d
KB
149int chflags __P((const char *, u_long));
150int fchflags __P((int, u_long));
8e81988a 151int fchmod __P((int, mode_t));
0f3392b1 152int lstat __P((const char *, struct stat *));
fd78ff3d 153#endif
91befe9c 154__END_DECLS
0f9e0ffb 155#endif