1 /*
2 Unix SMB/CIFS implementation.
3
4 POSIX NTVFS backend - xattr support using filesystem xattrs
5
6 Copyright (C) Andrew Tridgell 2004
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "system/filesys.h"
25 #include "lib/util/wrap_xattr.h"
26
27 #if defined(HAVE_XATTR_SUPPORT) && defined(XATTR_ADDITIONAL_OPTIONS)
_wrap_darwin_fgetxattr(int fd,const char * name,void * value,size_t size)28 static ssize_t _wrap_darwin_fgetxattr(int fd, const char *name, void *value, size_t size)
29 {
30 return fgetxattr(fd, name, value, size, 0, 0);
31 }
_wrap_darwin_getxattr(const char * path,const char * name,void * value,size_t size)32 static ssize_t _wrap_darwin_getxattr(const char *path, const char *name, void *value, size_t size)
33 {
34 return getxattr(path, name, value, size, 0, 0);
35 }
_wrap_darwin_fsetxattr(int fd,const char * name,void * value,size_t size,int flags)36 static int _wrap_darwin_fsetxattr(int fd, const char *name, void *value, size_t size, int flags)
37 {
38 return fsetxattr(fd, name, value, size, 0, flags);
39 }
_wrap_darwin_setxattr(const char * path,const char * name,void * value,size_t size,int flags)40 static int _wrap_darwin_setxattr(const char *path, const char *name, void *value, size_t size, int flags)
41 {
42 return setxattr(path, name, value, size, 0, flags);
43 }
_wrap_darwin_fremovexattr(int fd,const char * name)44 static int _wrap_darwin_fremovexattr(int fd, const char *name)
45 {
46 return fremovexattr(fd, name, 0);
47 }
_wrap_darwin_removexattr(const char * path,const char * name)48 static int _wrap_darwin_removexattr(const char *path, const char *name)
49 {
50 return removexattr(path, name, 0);
51 }
52 #define fgetxattr _wrap_darwin_fgetxattr
53 #define getxattr _wrap_darwin_getxattr
54 #define fsetxattr _wrap_darwin_fsetxattr
55 #define setxattr _wrap_darwin_setxattr
56 #define fremovexattr _wrap_darwin_fremovexattr
57 #define removexattr _wrap_darwin_removexattr
58 #elif !defined(HAVE_XATTR_SUPPORT)
_none_fgetxattr(int fd,const char * name,void * value,size_t size)59 static ssize_t _none_fgetxattr(int fd, const char *name, void *value, size_t size)
60 {
61 errno = ENOSYS;
62 return -1;
63 }
_none_getxattr(const char * path,const char * name,void * value,size_t size)64 static ssize_t _none_getxattr(const char *path, const char *name, void *value, size_t size)
65 {
66 errno = ENOSYS;
67 return -1;
68 }
_none_fsetxattr(int fd,const char * name,void * value,size_t size,int flags)69 static int _none_fsetxattr(int fd, const char *name, void *value, size_t size, int flags)
70 {
71 errno = ENOSYS;
72 return -1;
73 }
_none_setxattr(const char * path,const char * name,void * value,size_t size,int flags)74 static int _none_setxattr(const char *path, const char *name, void *value, size_t size, int flags)
75 {
76 errno = ENOSYS;
77 return -1;
78 }
_none_fremovexattr(int fd,const char * name)79 static int _none_fremovexattr(int fd, const char *name)
80 {
81 errno = ENOSYS;
82 return -1;
83 }
_none_removexattr(const char * path,const char * name)84 static int _none_removexattr(const char *path, const char *name)
85 {
86 errno = ENOSYS;
87 return -1;
88 }
89 #define fgetxattr _none_fgetxattr
90 #define getxattr _none_getxattr
91 #define fsetxattr _none_fsetxattr
92 #define setxattr _none_setxattr
93 #define fremovexattr _none_fremovexattr
94 #define removexattr _none_removexattr
95 #endif
96
wrap_fgetxattr(int fd,const char * name,void * value,size_t size)97 _PUBLIC_ ssize_t wrap_fgetxattr(int fd, const char *name, void *value, size_t size)
98 {
99 return fgetxattr(fd, name, value, size);
100 }
wrap_getxattr(const char * path,const char * name,void * value,size_t size)101 _PUBLIC_ ssize_t wrap_getxattr(const char *path, const char *name, void *value, size_t size)
102 {
103 return getxattr(path, name, value, size);
104 }
wrap_fsetxattr(int fd,const char * name,void * value,size_t size,int flags)105 _PUBLIC_ int wrap_fsetxattr(int fd, const char *name, void *value, size_t size, int flags)
106 {
107 return fsetxattr(fd, name, value, size, flags);
108 }
wrap_setxattr(const char * path,const char * name,void * value,size_t size,int flags)109 _PUBLIC_ int wrap_setxattr(const char *path, const char *name, void *value, size_t size, int flags)
110 {
111 return setxattr(path, name, value, size, flags);
112 }
wrap_fremovexattr(int fd,const char * name)113 _PUBLIC_ int wrap_fremovexattr(int fd, const char *name)
114 {
115 return fremovexattr(fd, name);
116 }
wrap_removexattr(const char * path,const char * name)117 _PUBLIC_ int wrap_removexattr(const char *path, const char *name)
118 {
119 return removexattr(path, name);
120 }
121
122