1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
#ifndef EXTATTR_PORTABLE_H
#define EXTATTR_PORTABLE_H
/* OS detection */
#include "extattr_os.h"
struct hv;
/*
* Portable extattr functions. When these fail, they should return
* -errno, i.e.: < 0 indicates failure.
*/
static inline int
portable_setxattr (const char *path,
const char *attrname,
const void *attrvalue,
const size_t slen,
struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_setxattr(path, attrname, attrvalue, slen, flags);
#elif defined(EXTATTR_BSD)
return bsd_setxattr(path, attrname, attrvalue, slen, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_setxattr(path, attrname, attrvalue, slen, flags);
#else
return linux_setxattr(path, attrname, attrvalue, slen, flags);
#endif
}
static inline int
portable_fsetxattr (const int fd,
const char *attrname,
const void *attrvalue,
const size_t slen,
struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_fsetxattr(fd, attrname, attrvalue, slen, flags);
#elif defined(EXTATTR_BSD)
return bsd_fsetxattr(fd, attrname, attrvalue, slen, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_fsetxattr(fd, attrname, attrvalue, slen, flags);
#else
return linux_fsetxattr(fd, attrname, attrvalue, slen, flags);
#endif
}
static inline int
portable_getxattr (const char *path,
const char *attrname,
void *attrvalue,
const size_t slen,
struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_getxattr(path, attrname, attrvalue, slen, flags);
#elif defined(EXTATTR_BSD)
return bsd_getxattr(path, attrname, attrvalue, slen, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_getxattr(path, attrname, attrvalue, slen, flags);
#else
return linux_getxattr(path, attrname, attrvalue, slen, flags);
#endif
}
static inline int
portable_fgetxattr (const int fd,
const char *attrname,
void *attrvalue,
const size_t slen,
struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_fgetxattr(fd, attrname, attrvalue, slen, flags);
#elif defined(EXTATTR_BSD)
return bsd_fgetxattr(fd, attrname, attrvalue, slen, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_fgetxattr(fd, attrname, attrvalue, slen, flags);
#else
return linux_fgetxattr(fd, attrname, attrvalue, slen, flags);
#endif
}
static inline ssize_t
portable_lenxattr (const char *path, const char *attrname, struct hv *flags)
{
#ifdef EXTATTR_BSD
/* XXX: flags? Namespace? */
return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, NULL, 0);
#else
/* XXX: Can BSD use this too? Maybe once namespacing sorted. */
return portable_getxattr(path, attrname, NULL, 0, flags);
#endif
}
static inline int
portable_flenxattr (int fd, const char *attrname, struct hv *flags)
{
#ifdef EXTATTR_BSD
/* XXX: flags? Namespace? */
return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, NULL, 0);
#else
/* XXX: Can BSD use this too? Maybe once namespacing sorted. */
return portable_fgetxattr(fd, attrname, NULL, 0, flags);
#endif
}
static inline int
portable_removexattr (const char *path, const char *name, struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_removexattr(path, name, flags);
#elif defined(EXTATTR_BSD)
return bsd_removexattr(path, name, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_removexattr(path, name, flags);
#else
return linux_removexattr(path, name, flags);
#endif
}
static inline int
portable_fremovexattr (const int fd, const char *name, struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_fremovexattr(fd, name, flags);
#elif defined(EXTATTR_BSD)
return bsd_fremovexattr(fd, name, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_fremovexattr(fd, name, flags);
#else
return linux_fremovexattr(fd, name, flags);
#endif
}
static inline int
portable_listxattr(const char *path,
char *buf,
const size_t slen,
struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_listxattr(path, buf, slen, flags);
#elif defined(EXTATTR_BSD)
return bsd_listxattr(path, buf, slen, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_listxattr(path, buf, slen, flags);
#else
return linux_listxattr(path, buf, slen, flags);
#endif
}
static inline int
portable_flistxattr(const int fd,
char *buf,
const size_t slen,
struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_flistxattr(fd, buf, slen, flags);
#elif defined(EXTATTR_BSD)
return bsd_flistxattr(fd, buf, slen, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_flistxattr(fd, buf, slen, flags);
#else
return linux_flistxattr(fd, buf, slen, flags);
#endif
}
static inline int
portable_listxattrns(const char *path,
char *buf,
const size_t slen,
struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_listxattrns(path, buf, slen, flags);
#elif defined(EXTATTR_BSD)
return bsd_listxattrns(path, buf, slen, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_listxattrns(path, buf, slen, flags);
#else
return linux_listxattrns(path, buf, slen, flags);
#endif
}
static inline int
portable_flistxattrns(const int fd,
char *buf,
const size_t slen,
struct hv *flags)
{
#ifdef EXTATTR_MACOSX
return macosx_flistxattrns(fd, buf, slen, flags);
#elif defined(EXTATTR_BSD)
return bsd_flistxattrns(fd, buf, slen, flags);
#elif defined(EXTATTR_SOLARIS)
return solaris_flistxattrns(fd, buf, slen, flags);
#else
return linux_flistxattrns(fd, buf, slen, flags);
#endif
}
#endif /* EXTATTR_PORTABLE_H */
|