1 #ifndef _system_filesys_h
2 #define _system_filesys_h
4 Unix SMB/CIFS implementation.
6 filesystem system include wrappers
8 Copyright (C) Andrew Tridgell 2004
10 ** NOTE! The following LGPL license applies to the replace
11 ** library. This does NOT imply that all of Samba is released
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.
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.
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/>.
32 #ifdef HAVE_SYS_PARAM_H
33 #include <sys/param.h>
36 #ifdef HAVE_SYS_MOUNT_H
37 #include <sys/mount.h>
52 #ifdef HAVE_ACL_LIBACL_H
53 #include <acl/libacl.h>
56 #ifdef HAVE_SYS_FS_S5PARAM_H
57 #include <sys/fs/s5param.h>
60 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
61 #include <sys/filsys.h>
64 #ifdef HAVE_SYS_STATFS_H
65 # include <sys/statfs.h>
69 #include <sys/dustat.h>
72 #ifdef HAVE_SYS_STATVFS_H
73 #include <sys/statvfs.h>
76 #ifdef HAVE_SYS_FILIO_H
77 #include <sys/filio.h>
80 #ifdef HAVE_SYS_FILE_H
87 #ifdef HAVE_SYS_FCNTL_H
88 #include <sys/fcntl.h>
92 #ifdef HAVE_SYS_MODE_H
93 /* apparently AIX needs this for S_ISLNK */
99 #ifdef HAVE_SYS_IOCTL_H
100 #include <sys/ioctl.h>
103 #ifdef HAVE_SYS_UIO_H
108 * Veritas File System. Often in addition to native.
111 #if defined(HAVE_SYS_FS_VX_QUOTA_H)
115 #if HAVE_SYS_ATTRIBUTES_H
116 #include <sys/attributes.h>
117 #elif HAVE_ATTR_ATTRIBUTES_H
118 #include <attr/attributes.h>
121 /* mutually exclusive (SuSE 8.2) */
122 #if HAVE_ATTR_XATTR_H
123 #include <attr/xattr.h>
124 #elif HAVE_SYS_XATTR_H
125 #include <sys/xattr.h>
132 #ifdef HAVE_SYS_EXTATTR_H
133 #include <sys/extattr.h>
136 #ifdef HAVE_SYS_RESOURCE_H
137 #include <sys/resource.h>
141 #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
144 #ifndef XATTR_REPLACE
145 #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
148 /* Some POSIX definitions for those without */
151 #define S_IFDIR 0x4000
154 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
157 #define S_IRWXU 00700 /* read, write, execute: owner */
160 #define S_IRUSR 00400 /* read permission: owner */
163 #define S_IWUSR 00200 /* write permission: owner */
166 #define S_IXUSR 00100 /* execute permission: owner */
169 #define S_IRWXG 00070 /* read, write, execute: group */
172 #define S_IRGRP 00040 /* read permission: group */
175 #define S_IWGRP 00020 /* write permission: group */
178 #define S_IXGRP 00010 /* execute permission: group */
181 #define S_IRWXO 00007 /* read, write, execute: other */
184 #define S_IROTH 00004 /* read permission: other */
187 #define S_IWOTH 00002 /* write permission: other */
190 #define S_IXOTH 00001 /* execute permission: other */
194 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
198 #define MAXPATHLEN 256
206 #define mkdir(d,m) _mkdir(d)
210 # ifndef UID_WRAPPER_DISABLE
211 # ifndef UID_WRAPPER_NOT_REPLACE
212 # define UID_WRAPPER_REPLACE
213 # endif /* UID_WRAPPER_NOT_REPLACE */
214 # include "../uid_wrapper/uid_wrapper.h"
215 # endif /* UID_WRAPPER_DISABLE */
216 #else /* UID_WRAPPER */
217 # define uwrap_enabled() 0
218 #endif /* UID_WRAPPER */
221 this allows us to use a uniform error handling for our xattr
225 #define ENOATTR ENODATA
229 #if !defined(HAVE_GETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
230 ssize_t
rep_getxattr (const char *path
, const char *name
, void *value
, size_t size
);
231 #define getxattr(path, name, value, size) rep_getxattr(path, name, value, size)
232 /* define is in "replace.h" */
235 #if !defined(HAVE_FGETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
236 ssize_t
rep_fgetxattr (int filedes
, const char *name
, void *value
, size_t size
);
237 #define fgetxattr(filedes, name, value, size) rep_fgetxattr(filedes, name, value, size)
238 /* define is in "replace.h" */
241 #if !defined(HAVE_LISTXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
242 ssize_t
rep_listxattr (const char *path
, char *list
, size_t size
);
243 #define listxattr(path, list, size) rep_listxattr(path, list, size)
244 /* define is in "replace.h" */
247 #if !defined(HAVE_FLISTXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
248 ssize_t
rep_flistxattr (int filedes
, char *list
, size_t size
);
249 #define flistxattr(filedes, value, size) rep_flistxattr(filedes, value, size)
250 /* define is in "replace.h" */
253 #if !defined(HAVE_REMOVEXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
254 int rep_removexattr (const char *path
, const char *name
);
255 #define removexattr(path, name) rep_removexattr(path, name)
256 /* define is in "replace.h" */
259 #if !defined(HAVE_FREMOVEXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
260 int rep_fremovexattr (int filedes
, const char *name
);
261 #define fremovexattr(filedes, name) rep_fremovexattr(filedes, name)
262 /* define is in "replace.h" */
265 #if !defined(HAVE_SETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
266 int rep_setxattr (const char *path
, const char *name
, const void *value
, size_t size
, int flags
);
267 #define setxattr(path, name, value, size, flags) rep_setxattr(path, name, value, size, flags)
268 /* define is in "replace.h" */
271 #if !defined(HAVE_FSETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
272 int rep_fsetxattr (int filedes
, const char *name
, const void *value
, size_t size
, int flags
);
273 #define fsetxattr(filedes, name, value, size, flags) rep_fsetxattr(filedes, name, value, size, flags)
274 /* define is in "replace.h" */