ewmscp  ..
Classes | Public Member Functions | Protected Attributes | List of all members
daosFsIoCommon Class Reference

base class for daosFs reader and writer class with the common stuff like fd, path and xattr handling More...

#include <daosFsCommon.h>

Inheritance diagram for daosFsIoCommon:
[legend]
Collaboration diagram for daosFsIoCommon:
[legend]

Classes

class  attrDataType
 

Public Member Functions

 daosFsIoCommon (const std::string &aPath, daosFsCommon &aHandler)
 
void setXattr (const std::string &name, const std::string &value) override
 
std::string getXattr (const std::string &name) override
 get one extended attribute value More...
 
void removeXattr (const std::string &name) override
 
std::unique_ptr< const genericStatgetStat () override
 
std::unique_ptr< ioHandle::attrDataTypegetAttrData (const outputHandler::base *aOutputHandler) override
 get attributes in the optimal way for setting with aOutputHandler More...
 
- Public Member Functions inherited from ioHandle
 ioHandle ()
 
virtual ~ioHandle () noexcept(false)
 
virtual bool parallelizable () const
 tell if this handler is capable of parallel IO. Unsually not the case More...
 
virtual size_t getBlockSize () const
 
virtual void setBlockSize (size_t newSize)
 
virtual std::unique_ptr< acl::listgetAclData ()
 get acls More...
 

Protected Attributes

const std::string & path
 
dfs_obj_t * obj
 
daosFsCommonhandler
 
- Protected Attributes inherited from ioHandle
size_t blockSize
 in bytes, block size to be used when reading or writing More...
 

Detailed Description

base class for daosFs reader and writer class with the common stuff like fd, path and xattr handling

Definition at line 50 of file daosFsCommon.h.

Constructor & Destructor Documentation

◆ daosFsIoCommon()

daosFsIoCommon::daosFsIoCommon ( const std::string &  aPath,
daosFsCommon aHandler 
)

Definition at line 115 of file daosFsCommon.cpp.

115  :
116  path(aPath),
117  obj(nullptr),
118  handler(aHandler){
119 }

Member Function Documentation

◆ getAttrData()

std::unique_ptr< ioHandle::attrDataType > daosFsIoCommon::getAttrData ( const outputHandler::base )
overridevirtual

get attributes in the optimal way for setting with aOutputHandler

Returns
std::unique_ptr to the attribute data or nullptr if none available
Exceptions
std::system_errorwhen reading of attributes fails

Reimplemented from ioHandle.

Definition at line 184 of file daosFsCommon.cpp.

184  {
185  auto attrData = std::unique_ptr<attrDataType>(new attrDataType());
186  attrData->fill(*this);
187  if (attrData->xattrs.empty()) {
188  return nullptr;
189  }
190  #if __GNUC__ >= 8
191  return attrData;
192  #else
193  return std::move(attrData);
194  #endif
195 }

◆ getStat()

std::unique_ptr< const genericStat > daosFsIoCommon::getStat ( )
overridevirtual

Implements ioHandle.

Definition at line 123 of file daosFsCommon.cpp.

123  {
124  struct stat statBuf;
125  timerInst(stat);
126  throwcall::good0(dfs_ostat(handler.dfs, obj, &statBuf), "can't stat", path);
127  return std::unique_ptr<const genericStat>(new genericStat(statBuf, std::chrono::nanoseconds(1)));
128 }

References daosFsCommon::dfs, throwcall::good0(), handler, obj, path, and timerInst.

Here is the call graph for this function:

◆ getXattr()

std::string daosFsIoCommon::getXattr ( const std::string &  )
overridevirtual

get one extended attribute value

Returns
value or empty string if attribute not present
Exceptions
std::system_errorif attribute setting fails
unimplementedActionErrorif not implemented (most handlers)

Reimplemented from ioHandle.

Definition at line 135 of file daosFsCommon.cpp.

135  {
136  char buffer[512];
138  daos_size_t size = sizeof(buffer);
139  auto retval = dfs_getxattr(handler.dfs, obj, name.c_str(), buffer, &size);
140  if (retval != 0) {
141  if (errno != ENOATTR) {
142  throwcall::badval(retval, -1, "can't read xattr '", name, "' from ", path);
143  }
144  return "";
145  } else {
146  buffer[size] = '\0';
147  }
148  return buffer;
149 }

References throwcall::badval(), daosFsCommon::dfs, ENOATTR, handler, obj, path, and timerInst.

Referenced by daosFsIoCommon::attrDataType::fill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeXattr()

void daosFsIoCommon::removeXattr ( const std::string &  name)
overridevirtual

Reimplemented from ioHandle.

Definition at line 151 of file daosFsCommon.cpp.

151  {
152  timerInst(removexattr);
153  auto result = dfs_removexattr(handler.dfs, obj, name.c_str());
154  if (result && errno == ENOATTR) {
155  return; // be silent about this
156  }
157  throwcall::good0(result,
158  "can't remove xattr ", name, " from ", path);
159 }

References daosFsCommon::dfs, ENOATTR, throwcall::good0(), handler, obj, path, and timerInst.

Here is the call graph for this function:

◆ setXattr()

void daosFsIoCommon::setXattr ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Reimplemented from ioHandle.

Definition at line 129 of file daosFsCommon.cpp.

129  {
130  timerInst(setxattr);
131  throwcall::good0(dfs_setxattr(handler.dfs, obj, name.c_str(), value.data(), value.size(), 0),
132  "can't set xattr '", name, "' to '", value, "' on ", path);
133 }

References daosFsCommon::dfs, throwcall::good0(), handler, obj, path, and timerInst.

Here is the call graph for this function:

Member Data Documentation

◆ handler

daosFsCommon& daosFsIoCommon::handler
protected

◆ obj

dfs_obj_t* daosFsIoCommon::obj
protected

◆ path

const std::string& daosFsIoCommon::path
protected

The documentation for this class was generated from the following files:
daosFsIoCommon::obj
dfs_obj_t * obj
Definition: daosFsCommon.h:53
ENOATTR
#define ENOATTR
Definition: daosFsCommon.cpp:10
throwcall::badval
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure
Definition: throwcall.h:54
genericStat
generic stat abstraction class Used to abstract the variants of the stat structure.
Definition: genericStat.h:12
daosFsIoCommon::getXattr
std::string getXattr(const std::string &name) override
get one extended attribute value
Definition: daosFsCommon.cpp:135
daosFsCommon::dfs
dfs_t * dfs
Definition: daosFsCommon.h:15
timerInst
#define timerInst(subfunc)
Definition: timer.h:157
throwcall::good0
void good0(T call, const Args &... args)
template function to wrap system calls that return 0 on success
Definition: throwcall.h:40
daosFsIoCommon::path
const std::string & path
Definition: daosFsCommon.h:52
daosFsIoCommon::handler
daosFsCommon & handler
Definition: daosFsCommon.h:54