Ticket #4372: bsdxattr.diff

File bsdxattr.diff, 2.1 KB (added by VinDuv, 15 years ago)
  • src/build/libroot/fs_attr_untyped.cpp

     
    4343#   include "fs_attr_xattr.h"
    4444#elif defined(HAIKU_HOST_PLATFORM_FREEBSD)
    4545#   include "fs_attr_extattr.h"
     46#elif defined(HAIKU_HOST_PLATFORM_DARWIN)
     47#   include "fs_attr_bsdxattr.h"
    4648#else
    4749#   error No attribute support for this host platform!
    4850#endif
  • src/build/libroot/fs_attr_bsdxattr.h

     
     1/*
     2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef FS_ATTR_BSDXATTR_H
     6#define FS_ATTR_BSDXATTR_H
     7
     8/*! Included by fs_attr_untyped.cpp. Interfaces with BSD xattr support.
     9*/
     10
     11
     12#include <sys/xattr.h>
     13
     14
     15// the namespace all attributes live in
     16static const char* kAttributeNamespace = "user.haiku.";
     17static const int kAttributeNamespaceLen = 11;
     18
     19
     20static ssize_t
     21list_attributes(int fd, const char* path, char* buffer, size_t bufferSize)
     22{
     23    if (fd >= 0)
     24        return flistxattr(fd, buffer, bufferSize, 0);
     25    return listxattr(path, buffer, bufferSize, XATTR_NOFOLLOW);
     26}
     27
     28
     29static ssize_t
     30get_attribute(int fd, const char* path, const char* attribute, void* buffer,
     31    size_t bufferSize)
     32{
     33    if (fd >= 0)
     34        return fgetxattr(fd, attribute, buffer, bufferSize, 0, 0);
     35    return getxattr(path, attribute, buffer, bufferSize, 0, XATTR_NOFOLLOW);
     36}
     37
     38
     39static int
     40set_attribute(int fd, const char* path, const char* attribute,
     41    const void* buffer, size_t bufferSize)
     42{
     43    if (fd >= 0)
     44        return fsetxattr(fd, attribute, buffer, bufferSize, 0, 0);
     45    return setxattr(path, attribute, buffer, bufferSize, 0, XATTR_NOFOLLOW);
     46}
     47
     48
     49static int
     50remove_attribute(int fd, const char* path, const char* attribute)
     51{
     52    if (fd >= 0)
     53        return fremovexattr(fd, attribute, 0);
     54    return removexattr(path, attribute, XATTR_NOFOLLOW);
     55}
     56
     57
     58#endif  // FS_ATTR_BSDXATTR_H