1 /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
20 * POSIX Standard: 5.6 File Characteristics <sys/stat.h>
32 #if defined(__USE_BSD) || defined(__USE_MISC)
33 #define S_IFMT __S_IFMT
34 #define S_IFDIR __S_IFDIR
35 #define S_IFCHR __S_IFCHR
36 #define S_IFBLK __S_IFBLK
37 #define S_IFREG __S_IFREG
38 #define S_IFLNK __S_IFLNK
39 #define S_IFSOCK __S_IFSOCK
40 #define S_IFIFO __S_IFIFO
43 /* Test macros for file types. */
45 #define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask))
47 #define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR)
48 #define S_ISCHR(mode) __S_ISTYPE((mode), __S_IFCHR)
49 #define S_ISBLK(mode) __S_ISTYPE((mode), __S_IFBLK)
50 #define S_ISREG(mode) __S_ISTYPE((mode), __S_IFREG)
51 #define S_ISFIFO(mode) __S_ISTYPE((mode), __S_IFIFO)
54 #define S_ISLNK(mode) __S_ISTYPE((mode), __S_IFLNK)
55 #define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK)
59 /* Protection bits. */
61 #define S_ISUID __S_ISUID /* Set user ID on execution. */
62 #define S_ISGID __S_ISGID /* Set group ID on execution. */
64 #if defined(__USE_BSD) || defined(__USE_MISC)
65 #define S_ISVTX __S_ISVTX /* Save swapped text after use (sticky bit). */
68 #define S_IRUSR __S_IREAD /* Read by owner. */
69 #define S_IWUSR __S_IWRITE /* Write by owner. */
70 #define S_IXUSR __S_IEXEC /* Execute by owner. */
71 /* Read, write, and execute by owner. */
72 #define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC)
74 #if defined(__USE_MISC) && defined(__USE_BSD)
75 #define S_IREAD S_IRUSR
76 #define S_IWRITE S_IWUSR
77 #define S_IEXEC S_IXUSR
80 #define S_IRGRP (S_IRUSR >> 3) /* Read by group. */
81 #define S_IWGRP (S_IWUSR >> 3) /* Write by group. */
82 #define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */
83 /* Read, write, and execute by group. */
84 #define S_IRWXG (S_IRWXU >> 3)
86 #define S_IROTH (S_IRGRP >> 3) /* Read by others. */
87 #define S_IWOTH (S_IWGRP >> 3) /* Write by others. */
88 #define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */
89 /* Read, write, and execute by others. */
90 #define S_IRWXO (S_IRXWG >> 3)
93 /* Get file attributes for FILE and put them in BUF. */
94 extern int __stat __P ((__const char *__file, struct stat * __buf));
95 extern int stat __P ((__const char *__file, struct stat * __buf));
97 /* Get file attributes for the file, device, pipe, or socket
98 that file descriptor FD is open on and put them in BUF. */
99 extern int __fstat __P ((int __fd, struct stat * __buf));
100 extern int fstat __P ((int __fd, struct stat * __buf));
102 /* Get file attributes about FILE and put them in BUF.
103 If FILE is a symbolic link, do not follow it. */
104 extern int __lstat __P ((__const char *__file, struct stat * __buf));
106 extern int lstat __P ((__const char *__file, struct stat * __buf));
109 /* Set file access permissions for FILE to MODE.
110 This takes an `int' MODE argument because that
111 is what `mode_t's get widened to. */
112 extern int __chmod __P ((__const char *__file, __mode_t __mode));
113 extern int chmod __P ((__const char *__file, __mode_t __mode));
115 /* Set file access permissions of the file FD is open on to MODE. */
116 extern int __fchmod __P ((int __fd, __mode_t __mode));
118 extern int fchmod __P ((int __fd, __mode_t __mode));
122 /* Set the file creation mask of the current process to MASK,
123 and return the old creation mask. */
124 extern __mode_t __umask __P ((__mode_t __mask));
125 extern __mode_t umask __P ((__mode_t __mask));
128 /* Get the current `umask' value without changing it.
129 This function is only available under the GNU Hurd. */
130 extern __mode_t getumask __P ((void));
133 /* Create a new directory named PATH, with permission bits MODE. */
134 extern int __mkdir __P ((__const char *__path, __mode_t __mode));
135 extern int mkdir __P ((__const char *__path, __mode_t __mode));
137 /* Create a device file named PATH, with permission and special bits MODE
138 and device number DEV (which can be constructed from major and minor
139 device numbers with the `makedev' macro above). */
140 extern int __mknod __P ((__const char *__path,
141 __mode_t __mode, __dev_t __dev));
142 #if defined(__USE_MISC) || defined(__USE_BSD)
143 extern int mknod __P ((__const char *__path,
144 __mode_t __mode, __dev_t __dev));
148 /* Create a new FIFO named PATH, with permission bits MODE. */
149 extern int mkfifo __P ((__const char *__path, __mode_t __mode));
153 #endif /* sys/stat.h */