ewmscp  ..
Public Member Functions | List of all members
posixFileCommon Class Reference

#include <posixFileCommon.h>

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

Public Member Functions

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
 
- Public Member Functions inherited from pathHandler
virtual ~pathHandler ()=default
 

Detailed Description

Definition at line 6 of file posixFileCommon.h.

Member Function Documentation

◆ getStat()

std::unique_ptr< const genericStat > posixFileCommon::getStat ( const std::string &  path,
bool  followLink 
)
overridevirtual

Implements pathHandler.

Definition at line 30 of file posixFileCommon.cpp.

31  {
32  struct stat statBuf;
33  for (int retries = 100; retries; --retries) {
34  if (followLink) {
35  timerInst(stat);
36  auto result = stat(path.c_str(), &statBuf);
37  if (result && errno == ENOENT) {
38  return nullptr;
39  } else if (result && errno == ENOTDIR) {
41  path, "stat", "found @#$%@ gpfs err ", errno);
42  continue;
43  }
44  throwcall::good0(result, "can't stat", path);
45  } else {
46  timerInst(lstat);
47  auto result = lstat(path.c_str(), &statBuf);
48  if (result && errno == ENOENT) {
49  return nullptr;
50  } else if (result && errno == ENOTDIR) {
52  path, "lstat", "found @#$%@ gpfs err", errno);
53  continue;
54  }
55  throwcall::good0(result, "can't lstat", path);
56  }
57  break;
58  }
59  return std::unique_ptr<const genericStat>(new genericStat(statBuf, std::chrono::nanoseconds(1)));
60 };

References errMsg::emit(), throwcall::good0(), errMsg::info, and timerInst.

Referenced by inputHandler::dummy::getStat().

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

◆ getXattr()

std::string posixFileCommon::getXattr ( const std::string &  path,
const std::string &  name 
)
overridevirtual

Reimplemented from pathHandler.

Definition at line 63 of file posixFileCommon.cpp.

64  {
65  #if defined(WithXattr) || defined(WithXattrUgly)
66  char buffer[512];
67 
68  for (int i = 0; i < 100; i++) {
69  timerInst(lgetxattr);
70  auto retval = lgetxattr(path.c_str(), name.c_str(), buffer, sizeof(buffer));
71 
72  if (retval == -1) {
73  if (errno == ENOENT || errno == ENOATTR) {
74  return "";
75  } else if (errno == ENOTDIR) { // we ran against a GPFS bug
77  path, "lgetxattr",
78  "got a f*^%$&^%$ GPFS bug", errno);
79  continue; // try again
80  }
81  throwcall::badval(retval, -1, "can't get xattr on ", path);
82  }
83  buffer[retval] = '\0';
84  break;
85  }
86  return buffer;
87  #else
88  throw unimplementedActionError("no xattr support");
89  #endif
90 };

References throwcall::badval(), errMsg::emit(), ENOATTR, errMsg::info, and timerInst.

Here is the call graph for this function:

◆ pathExists()

bool posixFileCommon::pathExists ( const std::string &  path)
overridevirtual

Implements pathHandler.

Definition at line 20 of file posixFileCommon.cpp.

20  {
21  struct stat statBuf;
22  timerInst(stat);
23  auto result = stat(path.c_str(), &statBuf);
24  if (result && (errno == ENOENT || errno == ENOTDIR)) {
25  return false;
26  }
27  throwcall::good0(result, "can't stat ", path);
28  return true;
29 };

References throwcall::good0(), and timerInst.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
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
errMsg::level::info
@ info
unimplementedActionError
class for exceptions that result from unimplemented functions Exceptions of this kind are to be throw...
Definition: copyRequestTypes.h:32
ENOATTR
#define ENOATTR
Definition: posixFileCommon.cpp:17
errMsg::emit
void emit(level aLogLevel, const location &loc, const std::string &aObject, const std::string &aAction, const Args &... args)
function to create and enqueue a message, this is the only way that messages should be created!
Definition: errMsgQueue.h:148
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