Ignore the usually-ignored files in git
[findutils.git] / lib / modetype.h
blob60ddb432ea767caf29bd93a95bd3beb8de8db39b
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 2, or (at your option)
8 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, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18 USA.
21 /* POSIX.1 doesn't mention the S_IFMT bits; instead, it uses S_IStype
22 test macros. To make storing file types more convenient, define
23 them; the values don't need to correspond to what the kernel uses,
24 because of the way we use them. */
25 #ifndef INC_MODETYPE_H
26 #define INC_MODETYPE_H 1
28 #ifndef S_IFMT /* Doesn't have traditional Unix macros. */
29 #define S_IFBLK 1
30 #define S_IFCHR 2
31 #define S_IFDIR 4
32 #define S_IFREG 8
33 #ifdef S_ISLNK
34 #define S_IFLNK 16
35 #endif
36 #ifdef S_ISFIFO
37 #define S_IFIFO 32
38 #endif
39 #ifdef S_ISSOCK
40 #define S_IFSOCK 64
41 #endif
42 #ifdef S_ISDOOR
43 #define S_IFDOOR 128
44 #endif
45 #endif /* !S_IFMT */
47 #ifdef STAT_MACROS_BROKEN
48 #undef S_ISBLK
49 #undef S_ISCHR
50 #undef S_ISDIR
51 #undef S_ISREG
52 #undef S_ISFIFO
53 #undef S_ISLNK
54 #undef S_ISSOCK
55 #undef S_ISDOOR
56 #undef S_ISMPB
57 #undef S_ISMPC
58 #undef S_ISNWK
59 #endif
61 /* Do the reverse: define the POSIX.1 macros for traditional Unix systems
62 that don't have them. */
63 #if !defined(S_ISBLK) && defined(S_IFBLK)
64 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
65 #endif
66 #if !defined(S_ISCHR) && defined(S_IFCHR)
67 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
68 #endif
69 #if !defined(S_ISDIR) && defined(S_IFDIR)
70 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
71 #endif
72 #if !defined(S_ISREG) && defined(S_IFREG)
73 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
74 #endif
75 #if !defined(S_ISFIFO) && defined(S_IFIFO)
76 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
77 #endif
78 #if !defined(S_ISLNK) && defined(S_IFLNK)
79 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
80 #endif
81 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
82 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
83 #endif
84 #if !defined(S_ISDOOR) && defined(S_IFDOOR)
85 #define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
86 #endif
87 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
88 /* Also available on Coherent, according to
89 * Albert D. Cahalan (acahalan@cs.uml.edu)
91 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) /* multiplexed block device */
92 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) /* multiplexed char device */
93 /* GNU BFD library source uses type letter 'm' for these */
94 #endif
96 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
97 /* Apparently HPUX ls gives 'n' as the type letter for these. */
98 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
99 #endif
101 #endif
103 /* The above macros don't handle
104 * /bin/ls letters Mode What is it?
105 * S_IFNAM (Xenix "name files")
106 * H S_ISCDF (HPUX Context Dependent Files)
107 * S_IFCMP
108 * S_IFSHAD
112 In message <199907051927.PAA01106@jupiter.cs.uml.edu>
113 Albert Cahalan wrote:-
115 BTW, I believe many of these can't actually exist on disk.
116 Some of these (like S_IFSHAD AFAIK) are not seen by userspace.
118 hex name ls octal description
119 0000 000000 SCO out-of-service inode, BSD unknown type
120 1000 S_IFIFO p| 010000 fifo (named pipe)
121 2000 S_IFCHR c 020000 character special
122 3000 S_IFMPC 030000 multiplexed character device (Coherent)
123 4000 S_IFDIR d/ 040000 directory
124 5000 S_IFNAM 050000 XENIX special named file
125 6000 S_IFBLK b 060000 block special
126 7000 S_IFMPB 070000 multiplexed block device (Coherent)
127 8000 S_IFREG - 100000 regular
128 9000 S_IFCMP 110000 VxFS compressed (file?)
129 9000 S_IFNWK 110000 HP-UX network special
130 a000 S_IFLNK l@ 120000 symbolic link
131 b000 S_IFSHAD 130000 Solaris shadow inode for ACL
132 c000 S_IFSOCK s= 140000 socket (also "S_IFSOC" on VxFS)
133 d000 S_IFDOOR D 150000 Solaris door
134 e000 S_IFWHT w% 160000 BSD whiteout (not used for inode)
135 f000 S_IFMT 170000 mask (not used for inode)
136 hex name ls octal description
137 0200 S_ISVTX 001000 save swapped text even after use
138 0400 S_ISGID 002000 set group ID on execution
139 0400 S_ENFMT 002000 SysV forced file locking (shared w/ S_ISGID)
140 0800 S_CDF 004000 HP-UX hidden directory
141 0800 S_ISUID 004000 set user ID on execution