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)
 
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 43 of file XrdPosixMap.hh.

Constructor & Destructor Documentation

◆ XrdPosixMap()

XrdPosixMap::XrdPosixMap ( )
inline

Definition at line 60 of file XrdPosixMap.hh.

60 {}

◆ ~XrdPosixMap()

XrdPosixMap::~XrdPosixMap ( )
inline

Definition at line 61 of file XrdPosixMap.hh.

61 {}

Member Function Documentation

◆ Entry2Buf()

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

Definition at line 88 of file XrdPosixMap.cc.

89 {
90  auto statInfo = dirEnt.GetStatInfo();
91  if (!statInfo) return EIO;
92 
93  memset(&buf, '\0', sizeof(buf));
94  buf.st_mode = XrdPosixMap::Flags2Mode(nullptr, statInfo->GetFlags());
95  // Since the UID/GID isn't known by the client, when these are translated by
96  // XrdXrootdProtocol::StatGen back to xrootd protocol flags, they will get zero'd
97  // out if only the user access mode is set (e.g., S_IRUSR). Therefor, upgrade the
98  // access mode in the mapping to "other" as well (e.g., S_ROTH). This way, the
99  // computed mode is the same for both the origin and the cache
100  if (buf.st_mode & S_IRUSR) buf.st_mode |= S_IROTH;
101  if (buf.st_mode & S_IWUSR) buf.st_mode |= S_IWOTH;
102  if (buf.st_mode & S_IXUSR) buf.st_mode |= S_IXOTH;
103  buf.st_mtime = static_cast<time_t>(statInfo->GetModTime());
104  buf.st_ctime = buf.st_mtime;
105  buf.st_size = static_cast<size_t>(statInfo->GetSize());
106  buf.st_ino = static_cast<ino_t>(strtoll(statInfo->GetId().c_str(), 0, 10));
107  buf.st_blocks = buf.st_size/512 + buf.st_size%512;
108  // If the device is zero'd out, then the listing later is translated to being offline
109  buf.st_dev = 1;
110 
111  if (statInfo->ExtendedFormat())
112  {buf.st_ctime = static_cast<time_t>(statInfo->GetChangeTime());
113  buf.st_atime = static_cast<time_t>(statInfo->GetAccessTime());
114  }
115 
116  return 0;
117 }
StatInfo * GetStatInfo()
Get the stat info object.
static mode_t Flags2Mode(dev_t *rdv, uint32_t flags)
Definition: XrdPosixMap.cc:62

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

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 165 of file XrdPosixMap.cc.

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

187 {
188  int eNum;
189 
190 // If all went well, return success
191 //
192  if (Status.IsOK()) return 0;
193 
194 // If this is an xrootd error then get the xrootd generated error
195 //
196  if (Status.code == XrdCl::errErrorResponse)
197  {ecMsg = Status.GetErrorMessage();
198  eNum = XProtocol::toErrno(Status.errNo);
199  } else {
200  ecMsg = Status.ToStr();
201  eNum = (Status.errNo ? Status.errNo : mapCode(Status.code));
202  }
203 
204 // Trace this if need be (we supress this for as we really need more info to
205 // make this messae useful like the opteration and path).
206 //
207 // if (eNum != ENOENT && !ecMsg.hasMsg() && Debug)
208 // std::cerr <<"XrdPosix: " <<eText <<std::endl;
209 
210 // Return
211 //
212  ecMsg = errno = eNum;
213  return (retneg1 ? -1 : -eNum);
214 }
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
thread_local XrdOucECMsg ecMsg
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 58 of file XrdPosixMap.hh.

58 {Debug = dbg;}

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