From be32ddee052ee73f74e744a2e907865667b042fa Mon Sep 17 00:00:00 2001 From: Ben Summers Date: Fri, 6 Jan 2006 10:02:44 +0000 Subject: Simple test for xattr support in test/bbackupd, fix xattr support for Darwin, move xattr adjustments to BoxPlatform.h to use globally --- lib/backupclient/BackupClientFileAttributes.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'lib/backupclient') 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(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); -- cgit v1.2.3