XRootD
XrdSysXAttr Class Referenceabstract

#include <XrdSysXAttr.hh>

+ Inheritance diagram for XrdSysXAttr:
+ Collaboration diagram for XrdSysXAttr:

Classes

struct  AList
 

Public Member Functions

 XrdSysXAttr ()
 Constructor and Destructor. More...
 
virtual ~XrdSysXAttr ()
 
virtual int Copy (const char *iPath, int iFD, const char *oPath, int oFD, const char *Aname=0)
 
virtual int Del (const char *Aname, const char *Path, int fd=-1)=0
 
virtual void Free (AList *aPL)=0
 
virtual int Get (const char *Aname, void *Aval, int Avsz, const char *Path, int fd=-1)=0
 
virtual int List (AList **aPL, const char *Path, int fd=-1, int getSz=0)=0
 
virtual int Set (const char *Aname, const void *Aval, int Avsz, const char *Path, int fd=-1, int isNew=0)=0
 
virtual XrdSysErrorSetMsgRoute (XrdSysError *errP)
 

Protected Attributes

XrdSysErrorSay
 

Detailed Description

Definition at line 42 of file XrdSysXAttr.hh.


Class Documentation

◆ XrdSysXAttr::AList

struct XrdSysXAttr::AList

Definition of a structure to hold an attribute name and the size of the name as well as the size of its associated value. The structure is a list and is used as an argument to Free() and is returned by List(). The size of the struct is dynamic and should be sized to hold all of the information.

Definition at line 52 of file XrdSysXAttr.hh.

+ Collaboration diagram for XrdSysXAttr::AList:
Class Members
char Name[1] Start of the name (size of struct is dynamic)
AList * Next -> next element.
int Nlen The length of the attribute name that follows.
int Vlen The length of the attribute value;.

Constructor & Destructor Documentation

◆ XrdSysXAttr()

XrdSysXAttr::XrdSysXAttr ( )
inline

Constructor and Destructor.

Definition at line 186 of file XrdSysXAttr.hh.

186 : Say(0) {}
XrdSysError * Say
Definition: XrdSysXAttr.hh:191

◆ ~XrdSysXAttr()

virtual XrdSysXAttr::~XrdSysXAttr ( )
inlinevirtual

Definition at line 187 of file XrdSysXAttr.hh.

187 {}

Member Function Documentation

◆ Copy()

int XrdSysXAttr::Copy ( const char *  iPath,
int  iFD,
const char *  oPath,
int  oFD,
const char *  Aname = 0 
)
virtual

Copy one or all extended attributes from one file to another (a default implementation is supplied).

Parameters
iPath-> Path of the file whose attribute(s) are to be copied.
iFDIf >=0 is the file descriptor of the opened source file.
oPath-> Path of the file to receive the extended attribute(s). Duplicate attributes are replaced.
oFDIf >=0 is the file descriptor of the opened target file.
Aname-> if nil, the all of the attributes of the source file are copied. Otherwise, only the attribute name pointed to by Aname is copied. If Aname does not exist or extended attributes are not supported, the operation succeeds by copying nothing.
Returns
=0 Attribute(s) successfully copied, did not exist, or extended attributes are not supported for source or target.
<0 Attribute(s) not copied, the return value is -errno that describes the reason for the failure.

Definition at line 42 of file XrdSysXAttr.cc.

44 {
45  char *bP;
46  int sz, rc = 0;
47 
48 // Check if all attributes are to be copied. If so, do it.
49 //
50  if (!Aname)
51  {AList *aP = 0, *aNow;
52  char *Buff;
53  int maxSz;
54 
55  // Get all of the attributes for the input
56  //
57  if ((maxSz = List(&aP, iPath, iFD, 1)) <= 0)
58  return maxSz == 0 || maxSz == -ENOTSUP;
59 
60  // Allocate a buffer to hold the largest attribute value (plus some)
61  //
62  maxSz += 4096;
63  Buff = (char *)malloc(maxSz);
64 
65  // Get each value and set it
66  //
67  aNow = aP;
68  while(aNow && (rc = Get(aNow->Name, Buff, maxSz, iPath, iFD)) >= 0
69  && (rc = Set(aNow->Name, Buff, aNow->Vlen, oPath, oFD)) >= 0)
70  {aNow = aNow->Next;}
71 
72  // Free up resources and return
73  //
74  Free(aP);
75  free(Buff);
76  return rc;
77  }
78 
79 // First obtain the size of the attribute (if zero ignore it)
80 //
81  if ((sz = Get(Aname, 0, 0, iPath, iFD)) <= 0)
82  return (!sz || sz == -ENOTSUP ? 0 : sz);
83 
84 // Obtain storage
85 //
86  if (!(bP = (char *)malloc(sz)))
87  {if (Say)
88  {char eBuff[512];
89  snprintf(eBuff, sizeof(eBuff), "copy attr %s from", Aname);
90  Say->Emsg("XAttr", ENOMEM, eBuff, iPath);
91  }
92  return -ENOMEM;
93  }
94 
95 // Copy over any extended attributes
96 //
97  if ((rc = Get(Aname, bP, sz, iPath, iFD)) > 0)
98  {if ((rc = Set(Aname, bP, rc, oPath, oFD)) < 0 && rc == -ENOTSUP) rc = 0;}
99  else if (rc < 0 && rc == -ENOTSUP) rc = 0;
100 
101 // All done
102 //
103  free(bP);
104  return rc;
105 }
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
virtual int List(AList **aPL, const char *Path, int fd=-1, int getSz=0)=0
virtual int Get(const char *Aname, void *Aval, int Avsz, const char *Path, int fd=-1)=0
virtual int Set(const char *Aname, const void *Aval, int Avsz, const char *Path, int fd=-1, int isNew=0)=0
virtual void Free(AList *aPL)=0

References XrdSysError::Emsg(), Free(), Get(), List(), XrdSysXAttr::AList::Next, Say, and Set().

+ Here is the call graph for this function:

◆ Del()

virtual int XrdSysXAttr::Del ( const char *  Aname,
const char *  Path,
int  fd = -1 
)
pure virtual

Remove an extended attribute.

Parameters
Aname-> The attribute name.
Path-> Path of the file whose attribute is to be removed.
fdIf >=0 is the file descriptor of the opened subject file.
Returns
=0 Attribute was successfully removed.
<0 Attribute was not removed or does not exist. The return value is -errno that describes the reason for the failure.

Implemented in XrdCephXAttr.

Referenced by XrdOucXAttr< T >::Del(), and XrdCl::LocalFileHandler::DelXAttr().

+ Here is the caller graph for this function:

◆ Free()

virtual void XrdSysXAttr::Free ( AList aPL)
pure virtual

Release storage occupied by the Alist structure returned by List().

Parameters
aPL-> The first element of the AList structure.

Implemented in XrdCephXAttr.

Referenced by Copy(), XrdCksManager::List(), and XrdCl::LocalFileHandler::ListXAttr().

+ Here is the caller graph for this function:

◆ Get()

virtual int XrdSysXAttr::Get ( const char *  Aname,
void *  Aval,
int  Avsz,
const char *  Path,
int  fd = -1 
)
pure virtual

Get an attribute value and its size.

Parameters
Aname-> The attribute name.
Aval-> Buffer to receive the attribute value.
AvszLength of the buffer in bytes. Only up to this number of bytes should be returned. However, should Avsz be zero the the size of the attribute value should be returned and the Aval argument should be ignored.
Path-> Path of the file whose attribute is to be fetched.
fd-> If >=0 is the file descriptor of the opened subject file.
Returns
>0 The number of bytes placed in Aval. However, if avsz is zero then the value is the actual size of the attribute value.
=0 The attribute exists but has no associated value.
<0 The attribute value could not be returned. The returned value is -errno describing the reason.

Implemented in XrdCephXAttr.

Referenced by Copy(), XrdPfc::Cache::DetermineFullFileSize(), XrdCl::LocalFileHandler::GetXAttr(), and XrdCl::LocalFileHandler::ListXAttr().

+ Here is the caller graph for this function:

◆ List()

virtual int XrdSysXAttr::List ( AList **  aPL,
const char *  Path,
int  fd = -1,
int  getSz = 0 
)
pure virtual

Get all of the attributes associated with a file.

Parameters
aPL-> the pointer to hold the first element of AList. The storage occupied by the returned AList must be released by calling Free().
Path-> Path of the file whose attributes are t be returned.
fd-> If >=0 is the file descriptor of the opened subject file.
getSzWhen != 0 then the size of the maximum attribute value should be returned. Otherwise, upon success 0 is returned.
Returns
>0 Attributes were returned and aPL points to the first attribute value. The returned value is the largest size of an attribute value encountered (getSz != 0).
=0 Attributes were returned and aPL points to the first attribute value (getSz == 0).
<0 The attribute values could not be returned. The returned value is -errno describing the reason.

Implemented in XrdCephXAttr.

Referenced by Copy(), and XrdCl::LocalFileHandler::ListXAttr().

+ Here is the caller graph for this function:

◆ Set()

virtual int XrdSysXAttr::Set ( const char *  Aname,
const void *  Aval,
int  Avsz,
const char *  Path,
int  fd = -1,
int  isNew = 0 
)
pure virtual

Set an attribute.

Parameters
Aname-> The attribute name.
Aval-> Buffer holding the attribute value.
AvszLength of the buffer in bytes. This is the length of the attribute value which may contain binary data.
Path-> Path of the file whose attribute is to be set.
fd-> If >=0 is the file descriptor of the opened subject file.
isNewWhen !0 then the attribute must not exist (i.e. new). Otherwise, if it does exist, the value is replaced. In either case, if it does not exist it should be created.
Returns
=0 The attribute was successfully set.
<0 The attribute values could not be set. The returned value is -errno describing the reason.

Implemented in XrdCephXAttr.

Referenced by XrdOssSys::Alloc_Cache(), Copy(), XrdOssSys::RenameLink3(), XrdOucXAttr< T >::Set(), XrdCl::LocalFileHandler::SetXAttr(), and XrdPfc::Cache::WriteFileSizeXAttr().

+ Here is the caller graph for this function:

◆ SetMsgRoute()

XrdSysError * XrdSysXAttr::SetMsgRoute ( XrdSysError errP)
virtual

Establish the error message routing. Unless it's established, no messages should be produced. A default implementation is supplied.

Parameters
errP-> Pointer to the error message object. If it is a nil pointer, no error messages should be produced.
Returns
The previous setting.

Definition at line 111 of file XrdSysXAttr.cc.

112 {
113  XrdSysError *msgP = Say;
114  Say = errP;
115  return msgP;
116 }

References Say.

Referenced by XrdOfsConfigPI::Load().

+ Here is the caller graph for this function:

Member Data Documentation

◆ Say

XrdSysError* XrdSysXAttr::Say
protected

Definition at line 191 of file XrdSysXAttr.hh.

Referenced by Copy(), and SetMsgRoute().


The documentation for this class was generated from the following files: