XRootD
Loading...
Searching...
No Matches
XrdCephXAttr.cc
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2014-2015 by European Organization for Nuclear Research (CERN)
3// Author: Sebastien Ponce <sebastien.ponce@cern.ch>
4//------------------------------------------------------------------------------
5// This file is part of the XRootD software suite.
6//
7// XRootD is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// XRootD is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19//
20// In applying this licence, CERN does not waive the privileges and immunities
21// granted to it by virtue of its status as an Intergovernmental Organization
22// or submit itself to any jurisdiction.
23//------------------------------------------------------------------------------
24
25#include "XrdVersion.hh"
27#include "XrdSys/XrdSysError.hh"
28#include "XrdOuc/XrdOucTrace.hh"
30
32XrdOucTrace XrdCephXattrTrace(&XrdCephXattrEroute);
33
34extern "C"
35{
38 const char *config_fn,
39 const char *parms)
40 {
41 // Do the herald thing
42 XrdCephXattrEroute.SetPrefix("cephxattr_");
43 XrdCephXattrEroute.logger(errP->logger());
44 XrdCephXattrEroute.Say("++++++ CERN/IT-DSS XrdCephXattr");
45 // set parameters
46 try {
48 } catch (std::exception &e) {
49 XrdCephXattrEroute.Say("CephXattr loading failed with exception. Check the syntax of parameters : ", parms);
50 return 0;
51 }
52 return new XrdCephXAttr();
53 }
54}
55
57
59
60int XrdCephXAttr::Del(const char *Aname, const char *Path, int fd) {
61 try {
62 return ceph_posix_removexattr(0, Path, Aname);
63 } catch (std::exception &e) {
64 XrdCephXattrEroute.Say("Del : invalid syntax in file parameters", Path);
65 return -EINVAL;
66 }
67}
68
72
73int XrdCephXAttr::Get(const char *Aname, void *Aval, int Avsz,
74 const char *Path, int fd) {
75 if (fd >= 0) {
76 return ceph_posix_fgetxattr(fd, Aname, Aval, Avsz);
77 } else {
78 try {
79 return ceph_posix_getxattr(0, Path, Aname, Aval, Avsz);
80 } catch (std::exception &e) {
81 XrdCephXattrEroute.Say("Get : invalid syntax in file parameters", Path);
82 return -EINVAL;
83 }
84 }
85}
86
87int XrdCephXAttr::List(AList **aPL, const char *Path, int fd, int getSz) {
88 if (fd > 0) {
89 return ceph_posix_flistxattrs(fd, aPL, getSz);
90 } else {
91 try {
92 return ceph_posix_listxattrs(0, Path, aPL, getSz);
93 } catch (std::exception &e) {
94 XrdCephXattrEroute.Say("List : invalid syntax in file parameters", Path);
95 return -EINVAL;
96 }
97 }
98}
99
100int XrdCephXAttr::Set(const char *Aname, const void *Aval, int Avsz,
101 const char *Path, int fd, int isNew) {
102 if (fd >= 0) {
103 return ceph_posix_fsetxattr(fd, Aname, Aval, Avsz, 0);
104 } else {
105 try {
106 return ceph_posix_setxattr(0, Path, Aname, Aval, Avsz, 0);
107 } catch (std::exception &e) {
108 XrdCephXattrEroute.Say("Set : invalid syntax in file parameters", Path);
109 return -EINVAL;
110 }
111 }
112}
113
ssize_t ceph_posix_getxattr(XrdOucEnv *env, const char *path, const char *name, void *value, size_t size)
int ceph_posix_listxattrs(XrdOucEnv *env, const char *path, XrdSysXAttr::AList **aPL, int getSz)
void ceph_posix_set_defaults(const char *value)
int ceph_posix_fsetxattr(int fd, const char *name, const void *value, size_t size, int flags)
int ceph_posix_removexattr(XrdOucEnv *env, const char *path, const char *name)
ssize_t ceph_posix_setxattr(XrdOucEnv *env, const char *path, const char *name, const void *value, size_t size, int flags)
int ceph_posix_flistxattrs(int fd, XrdSysXAttr::AList **aPL, int getSz)
ssize_t ceph_posix_fgetxattr(int fd, const char *name, void *value, size_t size)
void ceph_posix_freexattrlist(XrdSysXAttr::AList *aPL)
XrdSysError XrdCephXattrEroute(0)
XrdSysXAttr * XrdSysGetXAttrObject(XrdSysError *errP, const char *config_fn, const char *parms)
XrdVERSIONINFO(XrdSysGetXAttrObject, XrdCephXAttr)
XrdOucString Path
virtual int Set(const char *Aname, const void *Aval, int Avsz, const char *Path, int fd=-1, int isNew=0)
virtual int List(AList **aPL, const char *Path, int fd=-1, int getSz=0)
virtual void Free(AList *aPL)
virtual ~XrdCephXAttr()
Destructor.
virtual int Del(const char *Aname, const char *Path, int fd=-1)
virtual int Get(const char *Aname, void *Aval, int Avsz, const char *Path, int fd=-1)
XrdCephXAttr()
Constructor.
XrdSysLogger * logger(XrdSysLogger *lp=0)