ewmscp  ..
Classes | Public Member Functions | Static Private Attributes | List of all members
outputHandler::Gpfs Class Reference

#include <outputHandlerGpfs.h>

Inheritance diagram for outputHandler::Gpfs:
[legend]
Collaboration diagram for outputHandler::Gpfs:
[legend]

Classes

class  writerGpfs
 

Public Member Functions

 Gpfs ()=default
 
 ~Gpfs () override=default
 
std::unique_ptr< writernewWriter (const std::string &path, bool mightAppend, size_t sourceSize, size_t readBlockSize, copyRequest::stateType &state, bool noWrite, std::unique_ptr< ioHandle::attrDataType >, std::unique_ptr< acl::list > aclData) override
 
std::unique_ptr< writernewTmpWriter (std::string &path, size_t, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData) override
 
base::renameRetvalType rename (const std::string &fromPath, const std::unique_ptr< const genericStat > &readInitialStat, const std::string &toPath, copyRequest::stateType &state) override
 
- Public Member Functions inherited from outputHandler::posixFile
 posixFile ()=default
 
 ~posixFile () override=default
 
std::unique_ptr< writernewWriter (const std::string &path, bool mightAppend, size_t sourceSize, size_t readBlockSize, copyRequest::stateType &state, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData) override
 
std::unique_ptr< writernewTmpWriter (std::string &path, size_t sourceSize, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData) override
 
void ensureParentDirs (const std::string &path, const std::string &srcPath, inputHandler::base *InputHandler) override
 
void remove (const std::string &path, copyRequest::stateType &state) override
 
bool renameSimple (const std::string &fromPath, const std::string &toPath) override
 
base::renameRetvalType rename (const std::string &fromPath, const std::unique_ptr< const genericStat > &readInitialStat, const std::string &toPath, copyRequest::stateType &state) override
 
void createSymlink (const std::vector< char > &target, const std::string &path, uid_t uid, gid_t gid) override
 
void doAttributePreservations (const std::string &path, const genericStat &stat) override
 
size_t getMaxNameLength (const std::string &dirPath) override
 
- Public Member Functions inherited from outputHandler::base
 ~base () override=default
 
template<class C >
void shortenNameToMax (const std::string &path, C &pathBuf, const std::string &suffix)
 
- Public Member Functions inherited from pathHandler
virtual ~pathHandler ()=default
 
- Public Member Functions inherited from posixFileCommon
bool pathExists (const std::string &path) override
 
std::unique_ptr< const genericStatgetStat (const std::string &path, bool followLink) override
 
std::string getXattr (const std::string &path, const std::string &name) override
 

Static Private Attributes

static factoryTemplate< Gpfsfactory
 

Additional Inherited Members

- Public Types inherited from outputHandler::base
enum  renameRetvalType { renameRetvalType::ok, renameRetvalType::fileChanged, renameRetvalType::fileVanished, renameRetvalType::cantHappen }
 
- Static Public Member Functions inherited from outputHandler::base
static basenewHandler (const std::string &name)
 
template<class T >
static void addAllowedNamesToOption (T &option)
 
- Protected Member Functions inherited from outputHandler::base
 base ()=default
 
- Static Protected Member Functions inherited from outputHandler::base
static std::map< std::string, factoryClass * > & getFactoryMap ()
 

Detailed Description

Definition at line 9 of file outputHandlerGpfs.h.

Constructor & Destructor Documentation

◆ Gpfs()

outputHandler::Gpfs::Gpfs ( )
default

◆ ~Gpfs()

outputHandler::Gpfs::~Gpfs ( )
overridedefault

Member Function Documentation

◆ newTmpWriter()

std::unique_ptr< base::writer > outputHandler::Gpfs::newTmpWriter ( std::string &  path,
size_t  sourceSize,
bool  noWrite,
std::unique_ptr< ioHandle::attrDataType attrData,
std::unique_ptr< acl::list aclData 
)
overridevirtual

Reimplemented from outputHandler::base.

Definition at line 34 of file outputHandlerGpfs.cpp.

38  {
39  return std::unique_ptr<base::writer>(new writerGpfs(path,
40  sourceSize,
41  noWrite,
42  std::move(attrData),
43  std::move(aclData),
44  *this));
45  }

◆ newWriter()

std::unique_ptr< base::writer > outputHandler::Gpfs::newWriter ( const std::string &  path,
bool  mightAppend,
size_t  sourceSize,
size_t  readBlockSize,
copyRequest::stateType state,
bool  noWrite,
std::unique_ptr< ioHandle::attrDataType attrData,
std::unique_ptr< acl::list aclData 
)
overridevirtual

Implements outputHandler::base.

Definition at line 20 of file outputHandlerGpfs.cpp.

27  {
28  return std::unique_ptr<base::writer>(new writerGpfs(path, mightAppend,
29  sourceSize, readBlockSize,
30  state, noWrite,
31  std::move(attrData),
32  std::move(aclData)));
33  }

◆ rename()

base::renameRetvalType outputHandler::Gpfs::rename ( const std::string &  fromPath,
const std::unique_ptr< const genericStat > &  readInitialStat,
const std::string &  toPath,
copyRequest::stateType state 
)
overridevirtual

Implements outputHandler::base.

Definition at line 171 of file outputHandlerGpfs.cpp.

174  {
175  auto retval = posixFile::rename(fromPath, readInitialStat, toPath, state);
177  auto lastSlash = fromPath.find_last_of('/');
178  auto fromDir = lastSlash == std::string::npos ? "." : fromPath.substr(0, lastSlash);
179  lastSlash = toPath.find_last_of('/');
180  auto toDir = lastSlash == std::string::npos ? "." : toPath.substr(0, lastSlash);
181  if (fromDir != toDir) { // we move from one dir to another with possibly different acls
182  char aclBufferSpace[0x10000];
183  auto aclBuffer = reinterpret_cast<gpfs_opaque_acl_t*>(aclBufferSpace);
184  aclBuffer->acl_buffer_len = sizeof(aclBufferSpace);
185  aclBuffer->acl_version = 0;
186  aclBuffer->acl_type = GPFS_ACL_TYPE_ACCESS;
187  static const std::string pattern("/.aclgetXXXXXX");
188  std::vector<char> tmpName;
189  tmpName.reserve(toDir.size() + pattern.size());
190  tmpName.insert(tmpName.end(), toDir.cbegin(), toDir.cend());
191  tmpName.insert(tmpName.end(), pattern.cbegin(), pattern.cend());
192  tmpName.push_back('\0');
193  if (readInitialStat->isDir()) {
194  timerInst(mkdtemp);
195  throwcall::badval(mkdtemp(tmpName.data()), nullptr, "can't create tmp dir '", tmpName.data(), "'");
196  } else {
197  static timer::anchor a("mkstemp");
199  auto fd = throwcall::badval(mkstemp(tmpName.data()), -1, "can't create tmp file '", tmpName.data(), "'");
200  i.stop();
201  timerInst(close);
202  throwcall::good0(close(fd), "can't close ", tmpName.data());
203  }
204  {
205  timerInst(gpfs_getacl);
206  throwcall::good0(gpfs_getacl(tmpName.data(), 0, aclBuffer), "can't get acl for '", tmpName.data(), "'");
207  }
208  if (readInitialStat->isDir()) {
209  timerInst(rmdir);
210  throwcall::good0(rmdir(tmpName.data()), "can't remove '", tmpName.data(), "'");
211  } else {
212  timerInst(unlink);
213  throwcall::good0(unlink(tmpName.data()), "can't remove '", tmpName.data(), "'");
214  }
215  if (aclBuffer->acl_buffer_len > 0) {
216  timerInst(gpfs_putacl);
217  throwcall::good0(gpfs_putacl(toPath.c_str(), 0, aclBuffer), "can't set acl for '", toPath, "'");
218  }
219  }
220  }
221  return retval;
222  }

References throwcall::badval(), copyRequest::done, throwcall::good0(), genericStat::isDir(), outputHandler::base::ok, outputHandler::posixFile::rename(), timer::instanceUnscoped::stop(), and timerInst.

Here is the call graph for this function:

Member Data Documentation

◆ factory

factoryTemplate<Gpfs> outputHandler::Gpfs::factory
staticprivate

Definition at line 10 of file outputHandlerGpfs.h.


The documentation for this class was generated from the following files:
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
copyRequest::stateBitType::done
@ done
aclBuffer
Definition: fixGpfsAcls.cpp:24
genericStat::isDir
bool isDir() const
Definition: genericStat.cpp:92
outputHandler::base::renameRetvalType::ok
@ ok
timer::instanceUnscoped
Definition: timer.h:95
timer::anchor
Definition: timer.h:22
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
outputHandler::posixFile::rename
base::renameRetvalType rename(const std::string &fromPath, const std::unique_ptr< const genericStat > &readInitialStat, const std::string &toPath, copyRequest::stateType &state) override
Definition: outputHandlerPosixFile.cpp:153