XRootD
XrdPssDir Class Reference

#include <XrdPss.hh>

+ Inheritance diagram for XrdPssDir:
+ Collaboration diagram for XrdPssDir:

Public Member Functions

 XrdPssDir (const char *tid)
 
 ~XrdPssDir ()
 
int Close (long long *retsz=0) override
 
bool getErrMsg (std::string &eText) override
 
int Opendir (const char *, XrdOucEnv &) override
 
int Readdir (char *buff, int blen) override
 
int StatRet (struct stat *buf) override
 
- Public Member Functions inherited from XrdOssDF
 XrdOssDF (const char *tid="", uint16_t dftype=0, int fdnum=-1)
 
virtual ~XrdOssDF ()
 
virtual int Clone (const std::vector< XrdOucCloneSeg > &cVec)
 
virtual int Clone (XrdOssDF &srcFile)
 
uint16_t DFType ()
 
virtual int Fchmod (mode_t mode)
 
virtual int Fctl (int cmd, int alen, const char *args, char **resp=0)
 
virtual void Flush ()
 Flush filesystem cached pages for this file (used for checksums). More...
 
virtual int Fstat (struct stat *buf)
 
virtual int Fsync ()
 
virtual int Fsync (XrdSfsAio *aiop)
 
virtual int Ftruncate (unsigned long long flen)
 
virtual int getFD ()
 
virtual off_t getMmap (void **addr)
 
virtual const char * getTID ()
 
virtual int isCompressed (char *cxidp=0)
 
virtual int Open (const char *path, int Oflag, mode_t Mode, XrdOucEnv &env)
 
virtual ssize_t pgRead (void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
 
virtual int pgRead (XrdSfsAio *aioparm, uint64_t opts)
 
virtual ssize_t pgWrite (void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
 
virtual int pgWrite (XrdSfsAio *aioparm, uint64_t opts)
 
virtual ssize_t Read (off_t offset, size_t size)
 
virtual ssize_t Read (void *buffer, off_t offset, size_t size)
 
virtual ssize_t Read (XrdOucRangeList &rlist)
 
virtual int Read (XrdSfsAio *aiop)
 
virtual ssize_t ReadRaw (void *buffer, off_t offset, size_t size)
 
virtual ssize_t ReadV (XrdOucIOVec *readV, int rdvcnt)
 
virtual ssize_t Write (const void *buffer, off_t offset, size_t size)
 
virtual int Write (XrdSfsAio *aiop)
 
virtual ssize_t WriteV (XrdOucIOVec *writeV, int wrvcnt)
 

Additional Inherited Members

- Static Public Attributes inherited from XrdOssDF
static const uint16_t DF_isDir = 0x0001
 Object is for a directory. More...
 
static const uint16_t DF_isFile = 0x0002
 Object is for a file. More...
 
static const uint16_t DF_isProxy = 0x0010
 Object is a proxy object. More...
 
static const uint64_t doCalc = 0x4000000000000000ULL
 pgw: Calculate checksums More...
 
static const int Fctl_ckpObj = 0
 
static const int Fctl_QFinfo = 3
 
static const int Fctl_setFD = 2
 
static const int Fctl_utimes = 1
 
static const uint64_t Verify = 0x8000000000000000ULL
 all: Verify checksums More...
 
- Protected Attributes inherited from XrdOssDF
uint16_t dfType
 
int fd
 
off_t pgwEOF
 
short rsvd
 
const char * tident
 

Detailed Description

Definition at line 51 of file XrdPss.hh.

Constructor & Destructor Documentation

◆ XrdPssDir()

XrdPssDir::XrdPssDir ( const char *  tid)
inline

Definition at line 67 of file XrdPss.hh.

69  myDir(0), lastEtrc(0) {}
XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1)
Definition: XrdOss.hh:504
static const uint16_t DF_isDir
Object is for a directory.
Definition: XrdOss.hh:432
static const uint16_t DF_isProxy
Object is a proxy object.
Definition: XrdOss.hh:434

◆ ~XrdPssDir()

XrdPssDir::~XrdPssDir ( )
inline

Definition at line 71 of file XrdPss.hh.

71 {if (myDir) Close();}
int Close(long long *retsz=0) override
Definition: XrdPss.cc:824

References Close().

+ Here is the call graph for this function:

Member Function Documentation

◆ Close()

int XrdPssDir::Close ( long long *  retsz = 0)
overridevirtual

Close a directory or file.

Parameters
retszIf not nil, where the size of the file is to be returned.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOssDF.

Definition at line 824 of file XrdPss.cc.

825 {
826  DIR *theDir;
827 
828 // Close the directory proper if it exists. POSIX specified that directory
829 // stream is no longer available after closedir() regardless if return value.
830 //
831  if ((theDir = myDir))
832  {myDir = 0;
833  if (XrdPosixXrootd::Closedir(theDir))
834  {int rc = errno;
835  lastEtrc = XrdPosixXrootd::QueryError(lastEtext);
836  return -rc;
837  }
838  return XrdOssOK;
839  }
840 
841 // Directory is not open
842 //
843  return -XRDOSS_E8002;
844 }
#define XRDOSS_E8002
Definition: XrdOssError.hh:36
#define XrdOssOK
Definition: XrdOss.hh:54
static int Closedir(DIR *dirp)
Closedir() conforms to POSIX.1-2001 closedir()
static int QueryError(std::string &emsg, int fd=-1, bool reset=true)

References XrdPosixXrootd::Closedir(), XrdPosixXrootd::QueryError(), XRDOSS_E8002, and XrdOssOK.

Referenced by ~XrdPssDir().

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

◆ getErrMsg()

bool XrdPssDir::getErrMsg ( std::string &  eText)
overridevirtual

Obtain detailed error message text for the immediately preceeding directory or file error (see also XrdOss::getErrMsg()).

Parameters
eText- Where the message text is to be returned.
Returns
True if message text is available, false otherwise.
Note
This method should be called using the same thread that encountered the error; otherwise, missleading error text may be returned.
Upon return, the internal error message text is cleared.

Reimplemented from XrdOssDF.

Definition at line 850 of file XrdPss.cc.

851 {
852 // Return what we have but make sure to reset whatever we have
853 //
854  if (lastEtrc <= 0 || lastEtext.empty()) return false;
855  eText = lastEtext;
856  lastEtext.clear();
857  lastEtrc = 0;
858  return true;
859 }

◆ Opendir()

int XrdPssDir::Opendir ( const char *  path,
XrdOucEnv env 
)
overridevirtual

Open a directory.

Parameters
path- Pointer to the path of the directory to be opened.
env- Reference to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 719 of file XrdPss.cc.

720 {
721  EPNAME("Opendir");
722  int rc;
723  char pbuff[PBsz];
724 
725 // Return an error if this object is already open
726 //
727  if (myDir) return -XRDOSS_E8001;
728 
729 // Open directories are not supported for object id's
730 //
731  if (*dir_path != '/') return -ENOTSUP;
732 
733 // Setup url info
734 //
735  XrdPssUrlInfo uInfo(&Env, dir_path);
736  uInfo.setID();
737 
738 // Convert path to URL
739 //
740  if ((rc = XrdPssSys::P2URL(pbuff, PBsz, uInfo, XrdPssSys::xLfn2Pfn)))
741  return rc;
742 
743 // Do some tracing
744 //
745  if(DEBUGON) {
746  auto urlObf = obfuscateAuth(pbuff);
747  DEBUG(uInfo.Tident(),"url="<<urlObf);
748  }
749 
750 // Open the directory
751 //
752  myDir = XrdPosixXrootd::Opendir(pbuff);
753  if (!myDir)
754  {rc = -errno;
755  lastEtrc = XrdPosixXrootd::QueryError(lastEtext);
756  return rc;
757  }
758  return XrdOssOK;
759 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
#define XRDOSS_E8001
Definition: XrdOssError.hh:35
std::string obfuscateAuth(const std::string &input)
#define DEBUGON
static DIR * Opendir(const char *path)
Opendir() conforms to POSIX.1-2001 opendir()
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
Definition: XrdPss.cc:1621
static bool xLfn2Pfn
Definition: XrdPss.hh:222
static const int PBsz
Definition: XrdPss.cc:120

References DEBUG, DEBUGON, EPNAME, obfuscateAuth(), XrdPosixXrootd::Opendir(), XrdPssSys::P2URL(), XrdProxy::PBsz, XrdPosixXrootd::QueryError(), XrdPssUrlInfo::setID(), XrdPssUrlInfo::Tident(), XrdPssSys::xLfn2Pfn, XRDOSS_E8001, and XrdOssOK.

+ Here is the call graph for this function:

◆ Readdir()

int XrdPssDir::Readdir ( char *  buff,
int  blen 
)
overridevirtual

Get the next directory entry.

Parameters
buff- Pointer to buffer where a null terminated string of the entry name is to be returned. If no more entries exist, a null string is returned.
blen- Length of the buffer.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 780 of file XrdPss.cc.

781 {
782 // Check if we are directly reading the directory
783 //
784  if (myDir)
785  {dirent *entP, myEnt;
786  int rc = XrdPosixXrootd::Readdir_r(myDir, &myEnt, &entP);
787  if (rc)
788  {lastEtrc = XrdPosixXrootd::QueryError(lastEtext, myDir);
789  return -rc;
790  }
791  if (!entP) *buff = 0;
792  else strlcpy(buff, myEnt.d_name, blen);
793  return XrdOssOK;
794  }
795 
796 // The directory is not open
797 //
798  return -XRDOSS_E8002;
799 }
size_t strlcpy(char *dst, const char *src, size_t sz)
static int Readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)

References XrdPosixXrootd::QueryError(), XrdPosixXrootd::Readdir_r(), strlcpy(), XRDOSS_E8002, and XrdOssOK.

+ Here is the call graph for this function:

◆ StatRet()

int XrdPssDir::StatRet ( struct stat buff)
overridevirtual

Set the stat() buffer where stat information is to be placed corresponding to the directory entry returned by Readdir().

Parameters
buff- Pointer to stat structure to be used.
Returns
0 upon success or -ENOTSUP if not supported.
Note
This is a one-time call as stat structure is reused for each Readdir.
When StatRet() is in effect, directory entries that have been deleted from the target directory are quietly skipped.

Reimplemented from XrdOssDF.

Definition at line 804 of file XrdPss.cc.

805 {
806  if (!myDir) return -XRDOSS_E8002;
807 
808  auto rc = XrdPosixXrootd::StatRet(myDir, buff);
809  if (rc) return -rc;
810  return XrdOssOK;
811 }
static int StatRet(DIR *dirp, struct stat *buf)

References XrdPosixXrootd::StatRet(), XRDOSS_E8002, and XrdOssOK.

+ Here is the call graph for this function:

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