summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Summers <ben@fluffy.co.uk>2006-01-06 10:02:44 +0000
committerBen Summers <ben@fluffy.co.uk>2006-01-06 10:02:44 +0000
commitbe32ddee052ee73f74e744a2e907865667b042fa (patch)
tree55b5bd98cafc3554c58a76cbfda9084f725171c6 /lib
parent143bb18701167817d218ea7027365a274f6433f4 (diff)
Simple test for xattr support in test/bbackupd, fix xattr support for Darwin, move xattr adjustments to BoxPlatform.h to use globally
Diffstat (limited to 'lib')
-rw-r--r--lib/backupclient/BackupClientFileAttributes.cpp24
-rw-r--r--lib/common/BoxPlatform.h13
2 files changed, 20 insertions, 17 deletions
diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp
index 4fbdd90a..70c0d09d 100644
--- a/lib/backupclient/BackupClientFileAttributes.cpp
+++ b/lib/backupclient/BackupClientFileAttributes.cpp
@@ -33,19 +33,6 @@
#include "MemLeakFindOn.h"
-// Handle differing xattr APIs
-#ifdef HAVE_SYS_XATTR_H
- #if !defined(HAVE_LLISTXATTR) && defined(HAVE_LISTXATTR) && HAVE_DECL_XATTR_NOFOLLOW
- #define llistxattr(a,b,c) listxattr(a,b,c,XATTR_NOFOLLOW)
- #endif
- #if !defined(HAVE_LGETXATTR) && defined(HAVE_GETXATTR) && HAVE_DECL_XATTR_NOFOLLOW
- #define lgetxattr(a,b,c,d) getxattr(a,b,c,d,0,XATTR_NOFOLLOW)
- #endif
- #if !defined(HAVE_LSETXATTR) && defined(HAVE_SETXATTR) && HAVE_DECL_XATTR_NOFOLLOW
- #define lsetxattr(a,b,c,d,e) setxattr(a,b,c,d,0,(e)|XATTR_NOFOLLOW)
- #endif
-#endif
-
// set packing to one byte
#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "BeginStructPackForWire.h"
@@ -521,18 +508,21 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc
int valueSizeOffset = xattrSize;
xattrSize += sizeof(u_int32_t);
- // This gets the attribute value (may be text or binary), no termination
- int valueSize = ::lgetxattr(Filename, attrKey.c_str(), buffer+xattrSize, xattrBufferSize-xattrSize);
+ // Find size of attribute (must call with buffer and length 0 on some platforms,
+ // as -1 is returned if the data doesn't fit.)
+ int valueSize = ::lgetxattr(Filename, attrKey.c_str(), 0, 0);
+ // Resize block, if needed
if(xattrSize+valueSize>xattrBufferSize)
{
xattrBufferSize = (xattrBufferSize+valueSize)*2;
outputBlock.ResizeBlock(xattrBufferSize);
buffer = static_cast<unsigned char*>(outputBlock.GetBuffer());
-
- valueSize = ::lgetxattr(Filename, attrKey.c_str(), buffer+xattrSize, xattrBufferSize-xattrSize);
}
+ // This gets the attribute value (may be text or binary), no termination
+ valueSize = ::lgetxattr(Filename, attrKey.c_str(), buffer+xattrSize, xattrBufferSize-xattrSize);
+
if(valueSize<0)
{
THROW_EXCEPTION(CommonException, OSFileError);
diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h
index 9906b33c..42eb13e8 100644
--- a/lib/common/BoxPlatform.h
+++ b/lib/common/BoxPlatform.h
@@ -62,6 +62,19 @@
#define STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#endif
+// Handle differing xattr APIs
+#ifdef HAVE_SYS_XATTR_H
+ #if !defined(HAVE_LLISTXATTR) && defined(HAVE_LISTXATTR) && HAVE_DECL_XATTR_NOFOLLOW
+ #define llistxattr(a,b,c) listxattr(a,b,c,XATTR_NOFOLLOW)
+ #endif
+ #if !defined(HAVE_LGETXATTR) && defined(HAVE_GETXATTR) && HAVE_DECL_XATTR_NOFOLLOW
+ #define lgetxattr(a,b,c,d) getxattr(a,b,c,d,0,XATTR_NOFOLLOW)
+ #endif
+ #if !defined(HAVE_LSETXATTR) && defined(HAVE_SETXATTR) && HAVE_DECL_XATTR_NOFOLLOW
+ #define lsetxattr(a,b,c,d,e) setxattr(a,b,c,d,0,(e)|XATTR_NOFOLLOW)
+ #endif
+#endif
+
#if defined WIN32 && !defined __MINGW32__
typedef __int8 int8_t;
typedef __int16 int16_t;