XRootD
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  // Since the UID/GID isn't known by the client, when these are translated by
99  // XrdXrootdProtocol::StatGen back to xroot protocol flags, they will get zero'd
100  // out if only the user access mode is set (e.g., S_IRUSR). Therefor, upgrade the
101  // access mode in the mapping to "other" as well (e.g., S_ROTH). This way, the
102  // computed mode is the same for both the origin and the cache
103  if (buf.st_mode & S_IRUSR) buf.st_mode |= S_IROTH;
104  if (buf.st_mode & S_IWUSR) buf.st_mode |= S_IWOTH;
105  if (buf.st_mode & S_IXUSR) buf.st_mode |= S_IXOTH;
106  buf.st_mtime = static_cast<time_t>(statInfo->GetModTime());
107  buf.st_ctime = buf.st_mtime;
108  buf.st_size = static_cast<size_t>(statInfo->GetSize());
109  buf.st_ino = static_cast<ino_t>(strtoll(statInfo->GetId().c_str(), 0, 10));
110  buf.st_blocks = buf.st_size/512 + buf.st_size%512;
111  // If the device is zero'd out, then the listing later is translated to being offline
112  buf.st_dev = 1;
113 
114  if (statInfo->ExtendedFormat())
115  {buf.st_ctime = static_cast<time_t>(statInfo->GetChangeTime());
116  buf.st_atime = static_cast<time_t>(statInfo->GetAccessTime());
117  }
118 
119  return 0;
120 }
StatInfo * GetStatInfo()
Get the stat info object.
void Set(int ecc, const char *ecm="")
Definition: XrdOucECMsg.hh:138
static mode_t Flags2Mode(dev_t *rdv, uint32_t flags)
Definition: XrdPosixMap.cc:62
thread_local XrdOucECMsg ecMsg

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

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;
78  if (flags & XrdCl::StatInfo::BackUpExists) *rdv |= XRDSFS_HASBKUP;
79  }
80 
81  return newflags;
82 }
static const dev_t XRDSFS_HASBKUP
Definition: XrdSfsFlags.hh:102
#define XRDSFS_POSCPEND
Definition: XrdSfsFlags.hh:89
static const dev_t XRDSFS_OFFLINE
Definition: XrdSfsFlags.hh:100
@ 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(), and XrdPosixFile::Stat().

+ Here is the caller graph for this function:

◆ Mode2Access()

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

Definition at line 168 of file XrdPosixMap.cc.

170 
171 // Map the mode
172 //
173  if (mode & S_IRUSR) XMode |= XrdCl::Access::UR;
174  if (mode & S_IWUSR) XMode |= XrdCl::Access::UW;
175  if (mode & S_IXUSR) XMode |= XrdCl::Access::UX;
176  if (mode & S_IRGRP) XMode |= XrdCl::Access::GR;
177  if (mode & S_IWGRP) XMode |= XrdCl::Access::GW;
178  if (mode & S_IXGRP) XMode |= XrdCl::Access::GX;
179  if (mode & S_IROTH) XMode |= XrdCl::Access::OR;
180  if (mode & S_IXOTH) XMode |= XrdCl::Access::OX;
181  return XMode;
182 }
Mode
Access mode.
@ 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 188 of file XrdPosixMap.cc.

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

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

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

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

◆ SetDebug()

static 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: