Switch to unified view

a/src/utils/pxattr.cpp b/src/utils/pxattr.cpp
...
...
22
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
OTHER DEALINGS IN THE SOFTWARE.
23
OTHER DEALINGS IN THE SOFTWARE.
24
*/
24
*/
25
25
26
/** \file pxattr.cpp 
26
/** \file pxattr.cpp 
27
    \brief This is a comment for file pxattr.cpp 
27
    \brief Portable External Attributes API
28
 */
28
 */
29
29
30
// We want this to compile even to empty on non-supported systems. makes
30
#if defined(__gnu_linux__) || \
31
// things easier for autoconf
31
    (defined(__FreeBSD_kernel__)&&defined(__GLIBC__)&&!defined(__FreeBSD__)) ||\
32
#if defined(__FreeBSD__) || defined(__gnu_linux__) || defined(__APPLE__) || \
33
    defined(__CYGWIN32__)
32
    defined(__CYGWIN32__)
33
#define PXALINUX
34
#endif
35
36
// If the platform is not supported, let this file be empty instead of
37
// breaking the compile, this will let the build work if the rest of
38
// the software is not actually calling us.
39
#if defined(__FreeBSD__) || defined(PXALINUX) || defined(__APPLE__)
40
34
41
35
#ifndef TEST_PXATTR
42
#ifndef TEST_PXATTR
36
37
#include <sys/types.h>
43
#include <sys/types.h>
38
#include <errno.h>
44
#include <errno.h>
39
#include <stdlib.h>
45
#include <stdlib.h>
40
#include <stdio.h>
46
#include <stdio.h>
41
47
42
#if defined(__FreeBSD__)
48
#if defined(__FreeBSD__)
43
#include <sys/extattr.h>
49
#include <sys/extattr.h>
44
#include <sys/uio.h>
50
#include <sys/uio.h>
45
#elif defined(__gnu_linux__)
51
#elif defined(PXALINUX)
46
#include <sys/xattr.h>
47
#elif defined(__CYGWIN32__)
48
#include <sys/xattr.h>
52
#include <sys/xattr.h>
49
#elif defined(__APPLE__)
53
#elif defined(__APPLE__)
50
#include <sys/xattr.h>
54
#include <sys/xattr.h>
51
#else
55
#else
52
#error "Unknown system can't compile"
56
#error "Unknown system can't compile"
...
...
109
    }
113
    }
110
    } else {
114
    } else {
111
    ret = extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, 
115
    ret = extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, 
112
                 name.c_str(), buf.buf, ret);
116
                 name.c_str(), buf.buf, ret);
113
    }
117
    }
114
#elif defined(__gnu_linux__)
118
#elif defined(PXALINUX)
115
    if (fd < 0) {
119
    if (fd < 0) {
116
    if (flags & PXATTR_NOFOLLOW) {
120
    if (flags & PXATTR_NOFOLLOW) {
117
        ret = lgetxattr(path.c_str(), name.c_str(), 0, 0);
121
        ret = lgetxattr(path.c_str(), name.c_str(), 0, 0);
118
    } else {
122
    } else {
119
        ret = getxattr(path.c_str(), name.c_str(), 0, 0);
123
        ret = getxattr(path.c_str(), name.c_str(), 0, 0);
...
...
216
    }
220
    }
217
    } else {
221
    } else {
218
    ret = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, 
222
    ret = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, 
219
                 name.c_str(), value.c_str(), value.length());
223
                 name.c_str(), value.c_str(), value.length());
220
    }
224
    }
221
#elif defined(__gnu_linux__)
225
#elif defined(PXALINUX)
222
    int opts = 0;
226
    int opts = 0;
223
    if (flags & PXATTR_CREATE)
227
    if (flags & PXATTR_CREATE)
224
    opts = XATTR_CREATE;
228
    opts = XATTR_CREATE;
225
    else if (flags & PXATTR_REPLACE)
229
    else if (flags & PXATTR_REPLACE)
226
    opts = XATTR_REPLACE;
230
    opts = XATTR_REPLACE;
...
...
276
                      name.c_str());
280
                      name.c_str());
277
    }
281
    }
278
    } else {
282
    } else {
279
    ret = extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name.c_str());
283
    ret = extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name.c_str());
280
    }
284
    }
281
#elif defined(__gnu_linux__)
285
#elif defined(PXALINUX)
282
    if (fd < 0) {
286
    if (fd < 0) {
283
    if (flags & PXATTR_NOFOLLOW) {
287
    if (flags & PXATTR_NOFOLLOW) {
284
        ret = lremovexattr(path.c_str(), name.c_str());
288
        ret = lremovexattr(path.c_str(), name.c_str());
285
    } else {
289
    } else {
286
        ret = removexattr(path.c_str(), name.c_str());
290
        ret = removexattr(path.c_str(), name.c_str());
...
...
331
                    buf.buf, ret);
335
                    buf.buf, ret);
332
    }
336
    }
333
    } else {
337
    } else {
334
    ret = extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, buf.buf, ret);
338
    ret = extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, buf.buf, ret);
335
    }
339
    }
336
#elif defined(__gnu_linux__)
340
#elif defined(PXALINUX)
337
    if (fd < 0) {
341
    if (fd < 0) {
338
    if (flags & PXATTR_NOFOLLOW) {
342
    if (flags & PXATTR_NOFOLLOW) {
339
        ret = llistxattr(path.c_str(), 0, 0);
343
        ret = llistxattr(path.c_str(), 0, 0);
340
    } else {
344
    } else {
341
        ret = listxattr(path.c_str(), 0, 0);
345
        ret = listxattr(path.c_str(), 0, 0);
...
...
448
bool list(int fd, vector<string>* names, flags flags, nspace dom)
452
bool list(int fd, vector<string>* names, flags flags, nspace dom)
449
{
453
{
450
    return list(fd, nullstring, names, flags, dom);
454
    return list(fd, nullstring, names, flags, dom);
451
}
455
}
452
456
453
#if defined(__gnu_linux__) || defined(COMPAT1)
457
#if defined(PXALINUX) || defined(COMPAT1)
454
static const string userstring("user.");
458
static const string userstring("user.");
455
#else
459
#else
456
static const string userstring("");
460
static const string userstring("");
457
#endif
461
#endif
458
bool sysname(nspace dom, const string& pname, string* sname)
462
bool sysname(nspace dom, const string& pname, string* sname)