 |
ewmscp
..
|
Go to the documentation of this file.
14 #include WithXattrUgly
17 #define ENOATTR ENODATA
23 auto result = stat(path.c_str(), &statBuf);
24 if (result && (errno == ENOENT || errno == ENOTDIR)) {
33 for (
int retries = 100; retries; --retries) {
36 auto result = stat(path.c_str(), &statBuf);
37 if (result && errno == ENOENT) {
39 }
else if (result && errno == ENOTDIR) {
41 path,
"stat",
"found @#$%@ gpfs err ", errno);
47 auto result = lstat(path.c_str(), &statBuf);
48 if (result && errno == ENOENT) {
50 }
else if (result && errno == ENOTDIR) {
52 path,
"lstat",
"found @#$%@ gpfs err", errno);
59 return std::unique_ptr<const genericStat>(
new genericStat(statBuf, std::chrono::nanoseconds(1)));
64 const std::string& name) {
65 #if defined(WithXattr) || defined(WithXattrUgly)
68 for (
int i = 0; i < 100; i++) {
70 auto retval = lgetxattr(path.c_str(), name.c_str(), buffer,
sizeof(buffer));
73 if (errno == ENOENT || errno ==
ENOATTR) {
75 }
else if (errno == ENOTDIR) {
78 "got a f*^%$&^%$ GPFS bug", errno);
83 buffer[retval] =
'\0';
120 return std::unique_ptr<const genericStat>(
new genericStat(statBuf, std::chrono::nanoseconds(1)));
123 #if defined(WithXattr) || defined(WithXattrUgly)
126 "can't set xattr '", name,
"' to '", value,
"' on ",
path);
133 #if defined(WithXattr) || defined(WithXattrUgly)
136 auto retval = fgetxattr(
fd, name.c_str(), buffer,
sizeof(buffer));
143 buffer[retval] =
'\0';
154 #if defined(WithXattr) || defined(WithXattrUgly)
156 auto result = fremovexattr(
fd, name.c_str());
157 if (result && errno ==
ENOATTR) {
161 "can't remove xattr ", name,
" from ",
path);
169 xattrs.emplace_front(name, value);
172 for (
const auto& item : xattrs) {
173 handle->
setXattr(item.first, item.second);
177 #if defined(WithXattr) || defined(WithXattrUgly)
183 "can't get xattrs for ", handler.
path);
185 for (
auto readPtr = &buf[0]; readPtr < &buf[bufSize];) {
186 add(readPtr, handler.
getXattr(readPtr));
191 auto attrData = std::unique_ptr<attrDataType>(
new attrDataType());
192 attrData->fill(*
this);
193 if (attrData->xattrs.empty()) {
199 return std::move(attrData);
virtual void setXattr(const std::string &, const std::string &)
class for defining the location of a error message in the source code.
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure
std::string getXattr(const std::string &path, const std::string &name) override
generic stat abstraction class Used to abstract the variants of the stat structure.
std::unique_ptr< const genericStat > getStat() override
void fill(posixFileIoCommon &handler)
class for exceptions that result from unimplemented functions Exceptions of this kind are to be throw...
virtual std::unique_ptr< attrDataType > getAttrData(const outputHandler::base *)
get attributes in the optimal way for setting with aOutputHandler
std::forward_list< std::pair< std::string, std::string > > xattrs
void setXattr(const std::string &name, const std::string &value) override
void add(const std::string &name, const std::string &value)
void set(ioHandle *handle) override
set this set of attributes on the file described by handle
void removeXattr(const std::string &name) override
std::unique_ptr< const genericStat > getStat(const std::string &path, bool followLink) override
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!
#define timerInst(subfunc)
base class for posixFile reader and writer class with the common stuff like fd, path and xattr handli...
bool pathExists(const std::string &path) override
class as base for inputHandler::base::reader and outputHandler::base::writer containing the common pa...
void good0(T call, const Args &... args)
template function to wrap system calls that return 0 on success
std::unique_ptr< ioHandle::attrDataType > getAttrData(const outputHandler::base *aOutputHandler) override
get attributes in the optimal way for setting with aOutputHandler
posixFileIoCommon(const std::string &aPath)
std::string getXattr(const std::string &name) override
get one extended attribute value