1 /* modetype.h -- file type bits definitions for POSIX systems
2 Requires sys/types.h sys/stat.h.
3 Copyright (C) 1990, 2007 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 /* POSIX.1 doesn't mention the S_IFMT bits; instead, it uses S_IStype
20 test macros. To make storing file types more convenient, define
21 them; the values don't need to correspond to what the kernel uses,
22 because of the way we use them. */
23 #ifndef INC_MODETYPE_H
24 #define INC_MODETYPE_H 1
26 #ifndef S_IFMT /* Doesn't have traditional Unix macros. */
45 #ifdef STAT_MACROS_BROKEN
59 /* Do the reverse: define the POSIX.1 macros for traditional Unix systems
60 that don't have them. */
61 #if !defined(S_ISBLK) && defined(S_IFBLK)
62 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
64 #if !defined(S_ISCHR) && defined(S_IFCHR)
65 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
67 #if !defined(S_ISDIR) && defined(S_IFDIR)
68 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
70 #if !defined(S_ISREG) && defined(S_IFREG)
71 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
73 #if !defined(S_ISFIFO) && defined(S_IFIFO)
74 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
76 #if !defined(S_ISLNK) && defined(S_IFLNK)
77 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
79 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
80 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
82 #if !defined(S_ISDOOR) && defined(S_IFDOOR)
83 #define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
85 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
86 /* Also available on Coherent, according to
87 * Albert D. Cahalan (acahalan@cs.uml.edu)
89 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) /* multiplexed block device */
90 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) /* multiplexed char device */
91 /* GNU BFD library source uses type letter 'm' for these */
94 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
95 /* Apparently HPUX ls gives 'n' as the type letter for these. */
96 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
101 /* The above macros don't handle
102 * /bin/ls letters Mode What is it?
103 * S_IFNAM (Xenix "name files")
104 * H S_ISCDF (HPUX Context Dependent Files)
110 In message <199907051927.PAA01106@jupiter.cs.uml.edu>
111 Albert Cahalan wrote:-
113 BTW, I believe many of these can't actually exist on disk.
114 Some of these (like S_IFSHAD AFAIK) are not seen by userspace.
116 hex name ls octal description
117 0000 000000 SCO out-of-service inode, BSD unknown type
118 1000 S_IFIFO p| 010000 fifo (named pipe)
119 2000 S_IFCHR c 020000 character special
120 3000 S_IFMPC 030000 multiplexed character device (Coherent)
121 4000 S_IFDIR d/ 040000 directory
122 5000 S_IFNAM 050000 XENIX special named file
123 6000 S_IFBLK b 060000 block special
124 7000 S_IFMPB 070000 multiplexed block device (Coherent)
125 8000 S_IFREG - 100000 regular
126 9000 S_IFCMP 110000 VxFS compressed (file?)
127 9000 S_IFNWK 110000 HP-UX network special
128 a000 S_IFLNK l@ 120000 symbolic link
129 b000 S_IFSHAD 130000 Solaris shadow inode for ACL
130 c000 S_IFSOCK s= 140000 socket (also "S_IFSOC" on VxFS)
131 d000 S_IFDOOR D 150000 Solaris door
132 e000 S_IFWHT w% 160000 BSD whiteout (not used for inode)
133 f000 S_IFMT 170000 mask (not used for inode)
134 hex name ls octal description
135 0200 S_ISVTX 001000 save swapped text even after use
136 0400 S_ISGID 002000 set group ID on execution
137 0400 S_ENFMT 002000 SysV forced file locking (shared w/ S_ISGID)
138 0800 S_CDF 004000 HP-UX hidden directory
139 0800 S_ISUID 004000 set user ID on execution