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

#include <XrdPosixMap.hh>

Collaboration diagram for XrdPosixMap:

Public Member Functions

 XrdPosixMap ()
 ~XrdPosixMap ()

Static Public Member Functions

static int Entry2Buf (const XrdCl::DirectoryList::ListEntry &dirEnt, struct stat &buf, XrdOucECMsg &ecMsg)
static mode_t Flags2Mode (dev_t *rdv, uint32_t flags)
static XrdCl::Access::Mode Mode2Access (mode_t mode)
static int Result (const XrdCl::XRootDStatus &Status, XrdOucECMsg &ecMsg, bool retneg1=false)
static void SetDebug (bool dbg)

Detailed Description

Definition at line 45 of file XrdPosixMap.hh.

Constructor & Destructor Documentation

◆ XrdPosixMap()

XrdPosixMap::XrdPosixMap ( )
inline

Definition at line 62 of file XrdPosixMap.hh.

62{}

◆ ~XrdPosixMap()

XrdPosixMap::~XrdPosixMap ( )
inline

Definition at line 63 of file XrdPosixMap.hh.

63{}

Member Function Documentation

◆ Entry2Buf()

int XrdPosixMap::Entry2Buf ( const XrdCl::DirectoryList::ListEntry & dirEnt,
struct stat & buf,
XrdOucECMsg & ecMsg )
static

Definition at line 88 of file XrdPosixMap.cc.

89{
90 auto statInfo = dirEnt.GetStatInfo();
91 if (!statInfo) {
92 ecMsg.Set(EIO, "Directory entry is missing expected stat information");
93 return EIO;
94 }
95
96 memset(&buf, '\0', sizeof(buf));
97 buf.st_mode = Flags2Mode(nullptr, statInfo->GetFlags());
98 if (statInfo->ExtendedFormat())
99 {// Flags2Mode only maps the simplified protocol flags to owner permission
100 // bits (S_IRUSR, S_IWUSR, S_IXUSR). The extended stat response carries
101 // the full POSIX permission mode as an octal string (e.g. "0644").
102 // Replace the permission bits while preserving the file type (S_IFMT).
103 mode_t realPerms = strtol(statInfo->GetModeAsString().c_str(), nullptr, 8);
104 buf.st_mode = (buf.st_mode & S_IFMT) | (realPerms & 07777);
105 buf.st_ctime = static_cast<time_t>(statInfo->GetChangeTime());
106 buf.st_atime = static_cast<time_t>(statInfo->GetAccessTime());
107 }
108 else
109 {// Since the UID/GID isn't known by the client, when these are translated by
110 // XrdXrootdProtocol::StatGen back to xroot protocol flags, they will get zero'd
111 // out if only the user access mode is set (e.g., S_IRUSR). Therefor, upgrade the
112 // access mode in the mapping to "other" as well (e.g., S_ROTH). This way, the
113 // computed mode is the same for both the origin and the cache
114 if (buf.st_mode & S_IRUSR) buf.st_mode |= S_IROTH;
115 if (buf.st_mode & S_IWUSR) buf.st_mode |= S_IWOTH;
116 if (buf.st_mode & S_IXUSR) buf.st_mode |= S_IXOTH;
117 }
118 buf.st_mtime = static_cast<time_t>(statInfo->GetModTime());
119 buf.st_ctime = buf.st_mtime;
120 buf.st_size = static_cast<size_t>(statInfo->GetSize());
121 buf.st_ino = static_cast<ino_t>(strtoll(statInfo->GetId().c_str(), 0, 10));
122 buf.st_blocks = buf.st_size/512 + buf.st_size%512;
123 // If the device is zero'd out, then the listing later is translated to being offline
124 buf.st_dev = 1;
125
126 return 0;
127}
StatInfo * GetStatInfo()
Get the stat info object.
void Set(int ecc, const char *ecm="")
static mode_t Flags2Mode(dev_t *rdv, uint32_t flags)

References Flags2Mode(), XrdCl::DirectoryList::ListEntry::GetStatInfo(), XrdOucECMsg::Set(), and stat.

Referenced by XrdPosixDir::nextEntry().

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

◆ Flags2Mode()

mode_t XrdPosixMap::Flags2Mode ( dev_t * rdv,
uint32_t flags )
static

Definition at line 62 of file XrdPosixMap.cc.

63{
64 mode_t newflags = 0;
65
66// Map the xroot flags to unix flags
67//
68 if (flags & XrdCl::StatInfo::XBitSet) newflags |= S_IXUSR;
69 if (flags & XrdCl::StatInfo::IsReadable) newflags |= S_IRUSR;
70 if (flags & XrdCl::StatInfo::IsWritable) newflags |= S_IWUSR;
71 if (flags & XrdCl::StatInfo::Other) newflags |= S_IFBLK;
72 else if (flags & XrdCl::StatInfo::IsDir) newflags |= S_IFDIR;
73 else newflags |= S_IFREG;
74 if (flags & XrdCl::StatInfo::POSCPending) newflags |= XRDSFS_POSCPEND;
75 if (rdv)
76 {*rdv = 0;
77 if (flags & XrdCl::StatInfo::Offline) *rdv |= XRDSFS_OFFLINE;
79 }
80
81 return newflags;
82}
static const dev_t XRDSFS_HASBKUP
#define XRDSFS_POSCPEND
static const dev_t XRDSFS_OFFLINE
@ IsReadable
Read access is allowed.
@ IsDir
This is a directory.
@ Other
Neither a file nor a directory.
@ BackUpExists
Back up copy exists.
@ XBitSet
Executable/searchable bit set.
@ Offline
File is not online (ie. on disk).
@ IsWritable
Write access is allowed.

References XrdCl::StatInfo::BackUpExists, XrdCl::StatInfo::IsDir, XrdCl::StatInfo::IsReadable, XrdCl::StatInfo::IsWritable, XrdCl::StatInfo::Offline, XrdCl::StatInfo::Other, XrdCl::StatInfo::POSCPending, XrdCl::StatInfo::XBitSet, XRDSFS_HASBKUP, XRDSFS_OFFLINE, and XRDSFS_POSCPEND.

Referenced by Entry2Buf(), XrdPosixAdmin::Stat(), XrdPosixAdmin::Stat(), and XrdPosixFile::Stat().

Here is the caller graph for this function:

◆ Mode2Access()

XrdCl::Access::Mode XrdPosixMap::Mode2Access ( mode_t mode)
static

Definition at line 175 of file XrdPosixMap.cc.

177
178// Map the mode
179//
180 if (mode & S_IRUSR) XMode |= XrdCl::Access::UR;
181 if (mode & S_IWUSR) XMode |= XrdCl::Access::UW;
182 if (mode & S_IXUSR) XMode |= XrdCl::Access::UX;
183 if (mode & S_IRGRP) XMode |= XrdCl::Access::GR;
184 if (mode & S_IWGRP) XMode |= XrdCl::Access::GW;
185 if (mode & S_IXGRP) XMode |= XrdCl::Access::GX;
186 if (mode & S_IROTH) XMode |= XrdCl::Access::OR;
187 if (mode & S_IXOTH) XMode |= XrdCl::Access::OX;
188 return XMode;
189}
@ OX
world executable/browsable
@ UR
owner readable
@ GR
group readable
@ UW
owner writable
@ GX
group executable/browsable
@ GW
group writable
@ UX
owner executable/browsable
@ OR
world readable

References XrdCl::Access::GR, XrdCl::Access::GW, XrdCl::Access::GX, XrdCl::Access::None, XrdCl::Access::OR, XrdCl::Access::OX, XrdCl::Access::UR, XrdCl::Access::UW, and XrdCl::Access::UX.

Referenced by XrdPosixXrootd::Mkdir().

Here is the caller graph for this function:

◆ Result()

int XrdPosixMap::Result ( const XrdCl::XRootDStatus & Status,
XrdOucECMsg & ecMsg,
bool retneg1 = false )
static

Definition at line 195 of file XrdPosixMap.cc.

197{
198 int eNum;
199
200// If all went well, return success
201//
202 if (Status.IsOK()) return 0;
203
204// If this is an xrootd error then get the xrootd generated error
205//
206 if (Status.code == XrdCl::errErrorResponse)
207 {ecMsg = Status.GetErrorMessage();
208 eNum = XProtocol::toErrno(Status.errNo);
209 } else {
210 ecMsg = Status.ToStr();
211 eNum = (Status.errNo ? Status.errNo : mapCode(Status.code));
212 }
213
214// Trace this if need be (we supress this for as we really need more info to
215// make this messae useful like the opteration and path).
216//
217// if (eNum != ENOENT && !ecMsg.hasMsg() && Debug)
218// std::cerr <<"XrdPosix: " <<eText <<std::endl;
219
220// Return
221//
222 ecMsg = errno = eNum;
223 return (retneg1 ? -1 : -eNum);
224}
static int toErrno(int xerr)
const std::string & GetErrorMessage() const
Get error message.
std::string ToStr() const
Convert to string.
const uint16_t errErrorResponse
uint16_t code
Error type, or additional hints on what to do.
bool IsOK() const
We're fine.
uint32_t errNo
Errno, if any.

References XrdCl::Status::code, XrdCl::errErrorResponse, XrdCl::Status::errNo, XrdCl::XRootDStatus::GetErrorMessage(), XrdCl::Status::IsOK(), XProtocol::toErrno(), and XrdCl::XRootDStatus::ToStr().

Referenced by XrdPosixXrootd::Close(), XrdPosixAdmin::FanOut(), XrdPosixFile::Fcntl(), XrdPosixFile::HandleResponse(), XrdPosixFileRH::HandleResponse(), XrdPosixXrootd::Mkdir(), XrdPosixDir::Open(), XrdPosixFile::pgRead(), XrdPosixFile::pgWrite(), XrdPosixFile::pgWrite(), XrdPosixAdmin::Query(), XrdPosixAdmin::Query(), XrdPosixFile::Read(), XrdPosixFile::Read(), XrdPosixFile::ReadV(), XrdPosixFile::ReadV(), XrdPosixXrootd::Rename(), XrdPosixXrootd::Rmdir(), XrdPosixAdmin::Stat(), XrdPosixAdmin::Stat(), XrdPosixXrootd::Statvfs(), XrdPosixFile::Sync(), XrdPosixFile::Sync(), XrdPosixFile::Trunc(), XrdPosixXrootd::Truncate(), XrdPosixXrootd::Unlink(), XrdPosixFile::Write(), and XrdPosixFile::Write().

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

◆ SetDebug()

void XrdPosixMap::SetDebug ( bool dbg)
inlinestatic

Definition at line 60 of file XrdPosixMap.hh.

60{Debug = dbg;}

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