From 6ed5e0d20856d72325d12be791c5e9271663d27b Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Tue, 5 Jan 2010 15:43:42 +0000 Subject: [PATCH] fixed a couple of issues that I encountered when testing our xattr support (in libgnu.so) with my current rsync port: * Node now opens its fd with O_RDONLY, as otherwise BFS will refuse to open (the attributes of) directories * Node::Get() and Node::Set() now make use of the encoded attribute type, as otherwise all created attributes would have the type 'XATR' (instead of the encoded haiku-specific type) * minor cleanup with respect to the line width limit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34904 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/gnu/xattr.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/gnu/xattr.cpp b/src/libs/gnu/xattr.cpp index 9396d772c7..fadb573112 100644 --- a/src/libs/gnu/xattr.cpp +++ b/src/libs/gnu/xattr.cpp @@ -109,7 +109,7 @@ private: struct Node { Node(const char* path, bool traverseSymlinks) { - fFileFD = open(path, O_RDWR | (traverseSymlinks ? 0 : O_NOTRAVERSE)); + fFileFD = open(path, O_RDONLY | (traverseSymlinks ? 0 : O_NOTRAVERSE)); fOwnsFileFD = true; } @@ -146,7 +146,7 @@ struct Node { attributeName.Init(attribute); int attributeFD = fs_fopen_attr(fFileFD, attributeName.name, - B_XATTR_TYPE, openMode); + attributeName.type, openMode); if (attributeFD < 0) { // translate B_ENTRY_NOT_FOUND to ENOATTR if (errno == B_ENTRY_NOT_FOUND) @@ -195,7 +195,7 @@ struct Node { } ssize_t bytesRead = fs_read_attr(fFileFD, attributeName.name, - B_XATTR_TYPE, 0, buffer, info.size); + info.type, 0, buffer, info.size); // translate B_ENTRY_NOT_FOUND to ENOATTR if (bytesRead < 0 && errno == B_ENTRY_NOT_FOUND) @@ -308,15 +308,16 @@ setxattr(const char* path, const char* attribute, const void* buffer, int -lsetxattr(const char* path, const char* attribute, const void* buffer, size_t size, - int flags) +lsetxattr(const char* path, const char* attribute, const void* buffer, + size_t size, int flags) { return Node(path, false).Set(attribute, flags, buffer, size); } int -fsetxattr(int fd, const char* attribute, const void* buffer, size_t size, int flags) +fsetxattr(int fd, const char* attribute, const void* buffer, size_t size, + int flags) { return Node(fd).Set(attribute, flags, buffer, size); }