Patch by Vincent Duvert: Added support for BSDish xattrs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32841 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3ab7752ce8
commit
b1c06fc64a
58
src/build/libroot/fs_attr_bsdxattr.h
Normal file
58
src/build/libroot/fs_attr_bsdxattr.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef FS_ATTR_BSDXATTR_H
|
||||
#define FS_ATTR_BSDXATTR_H
|
||||
|
||||
/*! Included by fs_attr_untyped.cpp. Interfaces with BSD xattr support.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/xattr.h>
|
||||
|
||||
|
||||
// the namespace all attributes live in
|
||||
static const char* kAttributeNamespace = "user.haiku.";
|
||||
static const int kAttributeNamespaceLen = 11;
|
||||
|
||||
|
||||
static ssize_t
|
||||
list_attributes(int fd, const char* path, char* buffer, size_t bufferSize)
|
||||
{
|
||||
if (fd >= 0)
|
||||
return flistxattr(fd, buffer, bufferSize, 0);
|
||||
return listxattr(path, buffer, bufferSize, XATTR_NOFOLLOW);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t
|
||||
get_attribute(int fd, const char* path, const char* attribute, void* buffer,
|
||||
size_t bufferSize)
|
||||
{
|
||||
if (fd >= 0)
|
||||
return fgetxattr(fd, attribute, buffer, bufferSize, 0, 0);
|
||||
return getxattr(path, attribute, buffer, bufferSize, 0, XATTR_NOFOLLOW);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
set_attribute(int fd, const char* path, const char* attribute,
|
||||
const void* buffer, size_t bufferSize)
|
||||
{
|
||||
if (fd >= 0)
|
||||
return fsetxattr(fd, attribute, buffer, bufferSize, 0, 0);
|
||||
return setxattr(path, attribute, buffer, bufferSize, 0, XATTR_NOFOLLOW);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
remove_attribute(int fd, const char* path, const char* attribute)
|
||||
{
|
||||
if (fd >= 0)
|
||||
return fremovexattr(fd, attribute, 0);
|
||||
return removexattr(path, attribute, XATTR_NOFOLLOW);
|
||||
}
|
||||
|
||||
|
||||
#endif // FS_ATTR_BSDXATTR_H
|
@ -43,6 +43,8 @@
|
||||
# include "fs_attr_xattr.h"
|
||||
#elif defined(HAIKU_HOST_PLATFORM_FREEBSD)
|
||||
# include "fs_attr_extattr.h"
|
||||
#elif defined(HAIKU_HOST_PLATFORM_DARWIN)
|
||||
# include "fs_attr_bsdxattr.h"
|
||||
#else
|
||||
# error No attribute support for this host platform!
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user