CI: add samba-no-opath
[metze/samba-autobuild/.git] / lib / replace / system / filesys.h
1 #ifndef _system_filesys_h
2 #define _system_filesys_h
3 /*
4    Unix SMB/CIFS implementation.
5
6    filesystem system include wrappers
7
8    Copyright (C) Andrew Tridgell 2004
9
10      ** NOTE! The following LGPL license applies to the replace
11      ** library. This does NOT imply that all of Samba is released
12      ** under the LGPL
13
14    This library is free software; you can redistribute it and/or
15    modify it under the terms of the GNU Lesser General Public
16    License as published by the Free Software Foundation; either
17    version 3 of the License, or (at your option) any later version.
18
19    This library is distributed in the hope that it will be useful,
20    but WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22    Lesser General Public License for more details.
23
24    You should have received a copy of the GNU Lesser General Public
25    License along with this library; if not, see <http://www.gnu.org/licenses/>.
26
27 */
28
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
32
33 #include <sys/stat.h>
34
35 #ifdef HAVE_SYS_PARAM_H
36 #include <sys/param.h>
37 #endif
38
39 #ifdef HAVE_SYS_MOUNT_H
40 #include <sys/mount.h>
41 #endif
42
43 #ifdef HAVE_MNTENT_H
44 #include <mntent.h>
45 #endif
46
47 #ifdef HAVE_SYS_VFS_H
48 #include <sys/vfs.h>
49 #endif
50
51 #ifdef HAVE_SYS_ACL_H
52 #include <sys/acl.h>
53 #endif
54
55 #ifdef HAVE_ACL_LIBACL_H
56 #include <acl/libacl.h>
57 #endif
58
59 #ifdef HAVE_SYS_FS_S5PARAM_H
60 #include <sys/fs/s5param.h>
61 #endif
62
63 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
64 #include <sys/filsys.h>
65 #endif
66
67 #ifdef HAVE_SYS_STATFS_H
68 # include <sys/statfs.h>
69 #endif
70
71 #ifdef HAVE_DUSTAT_H
72 #include <sys/dustat.h>
73 #endif
74
75 #ifdef HAVE_SYS_STATVFS_H
76 #include <sys/statvfs.h>
77 #endif
78
79 #ifdef HAVE_SYS_FILIO_H
80 #include <sys/filio.h>
81 #endif
82
83 #ifdef HAVE_SYS_FILE_H
84 #include <sys/file.h>
85 #endif
86
87 #ifdef HAVE_FCNTL_H
88 #include <fcntl.h>
89 #else
90 #ifdef HAVE_SYS_FCNTL_H
91 #include <sys/fcntl.h>
92 #endif
93 #endif
94
95 #ifdef HAVE_SYS_MODE_H
96 /* apparently AIX needs this for S_ISLNK */
97 #ifndef S_ISLNK
98 #include <sys/mode.h>
99 #endif
100 #endif
101
102 #ifdef HAVE_SYS_IOCTL_H
103 #include <sys/ioctl.h>
104 #endif
105
106 #ifdef HAVE_SYS_UIO_H
107 #include <sys/uio.h>
108 #endif
109
110 /* mutually exclusive (SuSE 8.2) */
111 #if defined(HAVE_SYS_XATTR_H)
112 #include <sys/xattr.h>
113 #elif defined(HAVE_ATTR_XATTR_H)
114 #include <attr/xattr.h>
115 #elif defined(HAVE_SYS_ATTRIBUTES_H)
116 #include <sys/attributes.h>
117 #elif defined(HAVE_ATTR_ATTRIBUTES_H)
118 #include <attr/attributes.h>
119 #endif
120
121 #ifdef HAVE_SYS_EA_H
122 #include <sys/ea.h>
123 #endif
124
125 #ifdef HAVE_SYS_EXTATTR_H
126 #include <sys/extattr.h>
127 #endif
128
129 #ifdef HAVE_SYS_RESOURCE_H
130 #include <sys/resource.h>
131 #endif
132
133 #ifndef XATTR_CREATE
134 #define XATTR_CREATE  0x1       /* set value, fail if attr already exists */
135 #endif
136
137 #ifndef XATTR_REPLACE
138 #define XATTR_REPLACE 0x2       /* set value, fail if attr does not exist */
139 #endif
140
141 /* Some POSIX definitions for those without */
142
143 #ifndef S_IFDIR
144 #define S_IFDIR         0x4000
145 #endif
146 #ifndef S_ISDIR
147 #define S_ISDIR(mode)   ((mode & 0xF000) == S_IFDIR)
148 #endif
149 #ifndef S_IRWXU
150 #define S_IRWXU 00700           /* read, write, execute: owner */
151 #endif
152 #ifndef S_IRUSR
153 #define S_IRUSR 00400           /* read permission: owner */
154 #endif
155 #ifndef S_IWUSR
156 #define S_IWUSR 00200           /* write permission: owner */
157 #endif
158 #ifndef S_IXUSR
159 #define S_IXUSR 00100           /* execute permission: owner */
160 #endif
161 #ifndef S_IRWXG
162 #define S_IRWXG 00070           /* read, write, execute: group */
163 #endif
164 #ifndef S_IRGRP
165 #define S_IRGRP 00040           /* read permission: group */
166 #endif
167 #ifndef S_IWGRP
168 #define S_IWGRP 00020           /* write permission: group */
169 #endif
170 #ifndef S_IXGRP
171 #define S_IXGRP 00010           /* execute permission: group */
172 #endif
173 #ifndef S_IRWXO
174 #define S_IRWXO 00007           /* read, write, execute: other */
175 #endif
176 #ifndef S_IROTH
177 #define S_IROTH 00004           /* read permission: other */
178 #endif
179 #ifndef S_IWOTH
180 #define S_IWOTH 00002           /* write permission: other */
181 #endif
182 #ifndef S_IXOTH
183 #define S_IXOTH 00001           /* execute permission: other */
184 #endif
185
186 #ifndef O_ACCMODE
187 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
188 #endif
189
190 #ifndef MAXPATHLEN
191 #define MAXPATHLEN 256
192 #endif
193
194 #ifndef SEEK_SET
195 #define SEEK_SET 0
196 #endif
197
198 #ifdef _WIN32
199 #define mkdir(d,m) _mkdir(d)
200 #endif
201
202 #ifdef DISABLE_OPATH
203 #undef O_PATH
204 #endif
205
206 /*
207    this allows us to use a uniform error handling for our xattr
208    wrappers
209 */
210 #ifndef ENOATTR
211 #define ENOATTR ENODATA
212 #endif
213
214
215 #if !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
216
217 ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t size);
218 #define getxattr(path, name, value, size) rep_getxattr(path, name, value, size)
219 /* define is in "replace.h" */
220 ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size);
221 #define fgetxattr(filedes, name, value, size) rep_fgetxattr(filedes, name, value, size)
222 /* define is in "replace.h" */
223 ssize_t rep_listxattr (const char *path, char *list, size_t size);
224 #define listxattr(path, list, size) rep_listxattr(path, list, size)
225 /* define is in "replace.h" */
226 ssize_t rep_flistxattr (int filedes, char *list, size_t size);
227 #define flistxattr(filedes, value, size) rep_flistxattr(filedes, value, size)
228 /* define is in "replace.h" */
229 int rep_removexattr (const char *path, const char *name);
230 #define removexattr(path, name) rep_removexattr(path, name)
231 /* define is in "replace.h" */
232 int rep_fremovexattr (int filedes, const char *name);
233 #define fremovexattr(filedes, name) rep_fremovexattr(filedes, name)
234 /* define is in "replace.h" */
235 int rep_setxattr (const char *path, const char *name, const void *value, size_t size, int flags);
236 #define setxattr(path, name, value, size, flags) rep_setxattr(path, name, value, size, flags)
237 /* define is in "replace.h" */
238 int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
239 #define fsetxattr(filedes, name, value, size, flags) rep_fsetxattr(filedes, name, value, size, flags)
240 /* define is in "replace.h" */
241
242 #endif /* !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS) */
243
244 #endif