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/>.
35 #ifdef HAVE_SYS_PARAM_H
36 #include <sys/param.h>
39 /* This include is required on UNIX (*BSD, AIX, ...) for statfs() */
40 #if !defined(LINUX) && defined(HAVE_SYS_MOUNT_H)
41 #include <sys/mount.h>
48 /* This include is required on Linux for statfs() */
57 #ifdef HAVE_ACL_LIBACL_H
58 #include <acl/libacl.h>
61 #ifdef HAVE_SYS_FS_S5PARAM_H
62 #include <sys/fs/s5param.h>
65 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
66 #include <sys/filsys.h>
69 #ifdef HAVE_SYS_STATFS_H
70 # include <sys/statfs.h>
74 #include <sys/dustat.h>
77 #ifdef HAVE_SYS_STATVFS_H
78 #include <sys/statvfs.h>
81 #ifdef HAVE_SYS_FILIO_H
82 #include <sys/filio.h>
85 #ifdef HAVE_SYS_FILE_H
92 #ifdef HAVE_SYS_FCNTL_H
93 #include <sys/fcntl.h>
97 #ifdef HAVE_SYS_MODE_H
98 /* apparently AIX needs this for S_ISLNK */
100 #include <sys/mode.h>
104 #ifdef HAVE_SYS_IOCTL_H
105 #include <sys/ioctl.h>
108 #ifdef HAVE_SYS_UIO_H
112 /* mutually exclusive (SuSE 8.2) */
113 #if defined(HAVE_SYS_XATTR_H)
114 #include <sys/xattr.h>
115 #elif defined(HAVE_ATTR_XATTR_H)
116 #include <attr/xattr.h>
117 #elif defined(HAVE_SYS_ATTRIBUTES_H)
118 #include <sys/attributes.h>
119 #elif defined(HAVE_ATTR_ATTRIBUTES_H)
120 #include <attr/attributes.h>
127 #ifdef HAVE_SYS_EXTATTR_H
128 #include <sys/extattr.h>
131 #ifdef HAVE_SYS_RESOURCE_H
132 #include <sys/resource.h>
136 #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
139 #ifndef XATTR_REPLACE
140 #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
143 /* Some POSIX definitions for those without */
146 #define S_IFDIR 0x4000
149 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
152 #define S_IRWXU 00700 /* read, write, execute: owner */
155 #define S_IRUSR 00400 /* read permission: owner */
158 #define S_IWUSR 00200 /* write permission: owner */
161 #define S_IXUSR 00100 /* execute permission: owner */
164 #define S_IRWXG 00070 /* read, write, execute: group */
167 #define S_IRGRP 00040 /* read permission: group */
170 #define S_IWGRP 00020 /* write permission: group */
173 #define S_IXGRP 00010 /* execute permission: group */
176 #define S_IRWXO 00007 /* read, write, execute: other */
179 #define S_IROTH 00004 /* read permission: other */
182 #define S_IWOTH 00002 /* write permission: other */
185 #define S_IXOTH 00001 /* execute permission: other */
189 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
193 #define MAXPATHLEN 256
201 #define mkdir(d,m) _mkdir(d)
209 this allows us to use a uniform error handling for our xattr
213 #define ENOATTR ENODATA
217 #if !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
219 ssize_t
rep_getxattr (const char *path
, const char *name
, void *value
, size_t size
);
220 #define getxattr(path, name, value, size) rep_getxattr(path, name, value, size)
221 /* define is in "replace.h" */
222 ssize_t
rep_fgetxattr (int filedes
, const char *name
, void *value
, size_t size
);
223 #define fgetxattr(filedes, name, value, size) rep_fgetxattr(filedes, name, value, size)
224 /* define is in "replace.h" */
225 ssize_t
rep_listxattr (const char *path
, char *list
, size_t size
);
226 #define listxattr(path, list, size) rep_listxattr(path, list, size)
227 /* define is in "replace.h" */
228 ssize_t
rep_flistxattr (int filedes
, char *list
, size_t size
);
229 #define flistxattr(filedes, value, size) rep_flistxattr(filedes, value, size)
230 /* define is in "replace.h" */
231 int rep_removexattr (const char *path
, const char *name
);
232 #define removexattr(path, name) rep_removexattr(path, name)
233 /* define is in "replace.h" */
234 int rep_fremovexattr (int filedes
, const char *name
);
235 #define fremovexattr(filedes, name) rep_fremovexattr(filedes, name)
236 /* define is in "replace.h" */
237 int rep_setxattr (const char *path
, const char *name
, const void *value
, size_t size
, int flags
);
238 #define setxattr(path, name, value, size, flags) rep_setxattr(path, name, value, size, flags)
239 /* define is in "replace.h" */
240 int rep_fsetxattr (int filedes
, const char *name
, const void *value
, size_t size
, int flags
);
241 #define fsetxattr(filedes, name, value, size, flags) rep_fsetxattr(filedes, name, value, size, flags)
242 /* define is in "replace.h" */
244 #endif /* !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS) */
246 #ifdef HAVE_LINUX_OPENAT2_H
247 #include <linux/openat2.h>
248 #else /* ! HAVE_LINUX_OPENAT2_H */
249 /* how->resolve flags for openat2(2). */
250 #define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings
251 (includes bind-mounts). */
252 #define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style
254 #define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks
255 (implies OEXT_NO_MAGICLINKS) */
256 #define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like
257 "..", symlinks, and absolute
258 paths which escape the dirfd. */
259 #define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".."
260 be scoped inside the dirfd
261 (similar to chroot(2)). */
262 #define RESOLVE_CACHED 0x20 /* Only complete if resolution can be
263 completed through cached lookup. May
264 return -EAGAIN if that's not
266 struct __rep_open_how
{
271 #define open_how __rep_open_how
272 #endif /* ! HAVE_LINUX_OPENAT2_H */
275 long rep_openat2(int dirfd
, const char *pathname
,
276 struct open_how
*how
, size_t size
);
277 #define openat2(dirfd, pathname, how, size) \
278 rep_openat2(dirfd, pathname, how, size)
279 #endif /* !HAVE_OPENAT2 */