From f93c56c2ddbf7346e425bfb9271fdf6782c5a037 Mon Sep 17 00:00:00 2001 From: Andreas Joachim Peters Date: Thu, 23 May 2024 13:47:33 +0200 Subject: [PATCH] S3: add MacOSX xattr translation --- src/XrdS3/XrdS3ObjectStore.cc | 1 + src/XrdS3/XrdS3Utils.cc | 1 + src/XrdS3/XrdS3XAttr.hh | 65 +++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/XrdS3/XrdS3XAttr.hh diff --git a/src/XrdS3/XrdS3ObjectStore.cc b/src/XrdS3/XrdS3ObjectStore.cc index cab5d576198..09a537dcf8c 100644 --- a/src/XrdS3/XrdS3ObjectStore.cc +++ b/src/XrdS3/XrdS3ObjectStore.cc @@ -279,6 +279,7 @@ S3ObjectStore::Object::~Object() { } // TODO: Replace with the real XrdPosix_Listxattr once implemented. +#include "XrdS3XAttr.hh" #define XrdPosix_Listxattr listxattr //------------------------------------------------------------------------------ diff --git a/src/XrdS3/XrdS3Utils.cc b/src/XrdS3/XrdS3Utils.cc index 406deb70970..a6f2c6518eb 100644 --- a/src/XrdS3/XrdS3Utils.cc +++ b/src/XrdS3/XrdS3Utils.cc @@ -322,6 +322,7 @@ std::string S3Utils::GetXattr(const std::filesystem::path &path, } #include +#include "XrdS3XAttr.hh" #define XrdPosix_Setxattr setxattr // TODO: Replace by XrdPosix_Setxattr once implemented diff --git a/src/XrdS3/XrdS3XAttr.hh b/src/XrdS3/XrdS3XAttr.hh new file mode 100644 index 00000000000..faa33a5ef7d --- /dev/null +++ b/src/XrdS3/XrdS3XAttr.hh @@ -0,0 +1,65 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2024 by European Organization for Nuclear Research (CERN) +// Author: Andreas-Joachim Peters / CERN EOS Project +//------------------------------------------------------------------------------ +// This file is part of the XRootD software suite. +// +// XRootD is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XRootD is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with XRootD. If not, see . +// +// In applying this licence, CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +//------------------------------------------------------------------------------ + +#pragma once + +#ifdef __APPLE__ +// Macros to translate Linux xattr function names to macOS equivalents +#define getxattr(path, name, value, size) \ + xattr_getxattr(path, name, value, size, 0, 0) + +#define lgetxattr(path, name, value, size) \ + xattr_getxattr(path, name, value, size, 0, XATTR_NOFOLLOW) + +#define fgetxattr(fd, name, value, size) \ + fgetxattr(fd, name, value, size) + +#define setxattr(path, name, value, size, flags) \ + xattr_setxattr(path, name, value, size, 0, flags) + +#define lsetxattr(path, name, value, size, flags) \ + xattr_setxattr(path, name, value, size, 0, XATTR_NOFOLLOW) + +#define fsetxattr(fd, name, value, size, flags) \ + fsetxattr(fd, name, value, size, flags) + +#define removexattr(path, name) \ + xattr_removexattr(path, name, 0) + +#define lremovexattr(path, name) \ + xattr_removexattr(path, name, XATTR_NOFOLLOW) + +#define fremovexattr(fd, name) \ + fremovexattr(fd, name) + +#define listxattr(path, list, size) \ + xattr_listxattr(path, list, size, 0) + +#define llistxattr(path, list, size) \ + xattr_listxattr(path, list, size, XATTR_NOFOLLOW) + +#define flistxattr(fd, list, size) \ + flistxattr(fd, list, size) +#endif +