XRootD
Loading...
Searching...
No Matches
XrdOssMirageXAttr Class Reference

#include <XrdOssMirageXAttr.hh>

Inheritance diagram for XrdOssMirageXAttr:
Collaboration diagram for XrdOssMirageXAttr:

Public Member Functions

 XrdOssMirageXAttr ()=default
virtual ~XrdOssMirageXAttr ()=default
virtual int Del (const char *Aname, const char *Path, int fd=-1) override
virtual void Free (AList *aPL) override
virtual int Get (const char *Aname, void *Aval, int Avsz, const char *Path, int fd=-1) override
virtual int List (AList **aPL, const char *Path, int fd=-1, int getSz=0) override
virtual int Set (const char *Aname, const void *Aval, int Avsz, const char *Path, int fd=-1, int isNew=0) override
void setOss (XrdOssMirage &oss)
Public Member Functions inherited from XrdSysXAttr
 XrdSysXAttr ()
 Constructor and Destructor.
virtual ~XrdSysXAttr ()
virtual int Copy (const char *iPath, int iFD, const char *oPath, int oFD, const char *Aname=0)
virtual XrdSysErrorSetMsgRoute (XrdSysError *errP)

Additional Inherited Members

Protected Attributes inherited from XrdSysXAttr
XrdSysErrorSay

Detailed Description

Definition at line 10 of file XrdOssMirageXAttr.hh.

Constructor & Destructor Documentation

◆ XrdOssMirageXAttr()

XrdOssMirageXAttr::XrdOssMirageXAttr ( )
default

◆ ~XrdOssMirageXAttr()

virtual XrdOssMirageXAttr::~XrdOssMirageXAttr ( )
virtualdefault

References Path.

Member Function Documentation

◆ Del()

int XrdOssMirageXAttr::Del ( const char * Aname,
const char * Path,
int fd = -1 )
overridevirtual

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.

Implements XrdSysXAttr.

Definition at line 20 of file XrdOssMirageXAttr.cc.

21{
22 if (this->oss == nullptr)
23 return -ENOTSUP;
24
25 const auto opt = oss->get_entry_write(Path);
26 if (!opt.has_value())
27 return -EINVAL;
28
29 auto entry = opt.value();
30
31 const std::string_view name{Aname};
32
33 if (name == "U.open.return_code"sv)
34 entry->open.return_code = {};
35 else if (name == "U.read.return_code"sv)
36 entry->read.return_code = {};
37 else if (name == "U.read.return_position"sv)
38 entry->read.return_position = {};
39 else if (name == "U.write.return_code"sv)
40 entry->write.return_code = {};
41 else if (name == "U.write.return_position"sv)
42 entry->write.return_position = {};
43 else if (name == "U.pattern"sv)
44 entry->pattern = {};
45 else
46 return -EINVAL;
47
48 return 0;
49}
XrdOucString Path

References Path.

◆ Free()

void XrdOssMirageXAttr::Free ( AList * aPL)
overridevirtual

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

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

Implements XrdSysXAttr.

Definition at line 51 of file XrdOssMirageXAttr.cc.

52{
53}

◆ Get()

int XrdOssMirageXAttr::Get ( const char * Aname,
void * Aval,
int Avsz,
const char * Path,
int fd = -1 )
overridevirtual

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.

Implements XrdSysXAttr.

Definition at line 55 of file XrdOssMirageXAttr.cc.

56{
57 if (this->oss == nullptr)
58 return -ENOTSUP;
59
60 const auto opt = oss->get_entry_read(Path);
61 if (!opt.has_value())
62 return -EINVAL;
63
64 const auto entry = opt.value();
65
66 const std::string_view name{Aname};
67 std::string value{};
68
69 if (name == "U.open.return_code"sv)
70 value = std::to_string(entry.open.return_code);
71 else if (name == "U.read.return_code"sv)
72 value = std::to_string(entry.read.return_code);
73 else if (name == "U.read.return_position"sv)
74 value = std::to_string(entry.read.return_position);
75 else if (name == "U.write.return_code"sv)
76 value = std::to_string(entry.write.return_code);
77 else if (name == "U.write.return_position"sv)
78 value = std::to_string(entry.write.return_position);
79 else if (name == "U.pattern"sv)
80 value = entry.pattern;
81 else
82 return -EINVAL;
83
84 const int num_bytes = std::min(static_cast<std::size_t>(Avsz), value.size());
85 std::copy_n(value.begin(), num_bytes, static_cast<char *>(Aval));
86
87 return num_bytes;
88}

References Path.

◆ List()

int XrdOssMirageXAttr::List ( AList ** aPL,
const char * Path,
int fd = -1,
int getSz = 0 )
overridevirtual

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.

Implements XrdSysXAttr.

Definition at line 90 of file XrdOssMirageXAttr.cc.

91{
92 return -ENOTSUP;
93}

References Path.

◆ Set()

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

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.

Implements XrdSysXAttr.

Definition at line 95 of file XrdOssMirageXAttr.cc.

96{
97 if (this->oss == nullptr)
98 return -ENOTSUP;
99
100 const auto opt = oss->get_entry_write(Path);
101 if (!opt.has_value())
102 return -EINVAL;
103
104 auto entry = opt.value();
105
106 const std::string_view name{Aname};
107 const std::string value(static_cast<const char *>(Aval), Avsz);
108
109 try
110 {
111 if (name == "U.open.return_code"sv)
112 entry->open.return_code = std::stoi(value);
113 else if (name == "U.read.return_code"sv)
114 entry->read.return_code = std::stoi(value);
115 else if (name == "U.read.return_position"sv)
116 entry->read.return_position = std::stoll(value);
117 else if (name == "U.write.return_code"sv)
118 entry->write.return_code = std::stoi(value);
119 else if (name == "U.write.return_position"sv)
120 entry->write.return_position = std::stoll(value);
121 else if (name == "U.pattern"sv)
122 entry->pattern = value;
123 else
124 return -EINVAL;
125 }
126 catch(std::out_of_range &)
127 {
128 return -EINVAL;
129 }
130
131 return 0;
132}

References Path.

◆ setOss()

void XrdOssMirageXAttr::setOss ( XrdOssMirage & oss)

Definition at line 134 of file XrdOssMirageXAttr.cc.

135{
136 if (this->oss == nullptr)
137 this->oss = &oss;
138}

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