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

#include <XrdOssApi.hh>

Inheritance diagram for XrdOssDir:
Collaboration diagram for XrdOssDir:

Public Member Functions

 XrdOssDir (const char *tid, DIR *dP=0)
 ~XrdOssDir ()
int Close (long long *retsz=0)
int Fctl (int cmd, int alen, const char *args, char **resp=0)
int getFD ()
int Opendir (const char *, XrdOucEnv &)
int Readdir (char *buff, int blen)
int StatRet (struct stat *buff)
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 void Flush ()
 Flush filesystem cached pages for this file (used for checksums).
virtual int Fstat (struct stat *buf)
virtual int Fsync ()
virtual int Fsync (XrdSfsAio *aiop)
virtual int Ftruncate (unsigned long long flen)
virtual bool getErrMsg (std::string &eText)
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.
static const uint16_t DF_isFile = 0x0002
 Object is for a file.
static const uint16_t DF_isProxy = 0x0010
 Object is a proxy object.
static const uint64_t doCalc = 0x4000000000000000ULL
 pgw: Calculate checksums
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
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 XrdOssApi.hh.

Constructor & Destructor Documentation

◆ XrdOssDir()

XrdOssDir::XrdOssDir ( const char * tid,
DIR * dP = 0 )
inline

Definition at line 62 of file XrdOssApi.hh.

63 : XrdOssDF(tid, DF_isDir),
64 lclfd(dP), mssfd(0), Stat(0), ateof(false),
65 isopen(dP != 0), dOpts(0) {if (dP) fd = dirfd(dP);}
struct stat Stat
Definition XrdCks.cc:49
#define dirfd(x)
XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1)
Definition XrdOss.hh:504
int fd
Definition XrdOss.hh:515
static const uint16_t DF_isDir
Object is for a directory.
Definition XrdOss.hh:432

References XrdOssDF::XrdOssDF(), XrdOssDF::DF_isDir, dirfd, and XrdOssDF::fd.

Here is the call graph for this function:

◆ ~XrdOssDir()

XrdOssDir::~XrdOssDir ( )
inline

Definition at line 67 of file XrdOssApi.hh.

67{if (isopen) Close();}
int Close(long long *retsz=0)
Definition XrdOssApi.cc:731

References Close().

Here is the call graph for this function:

Member Function Documentation

◆ Close()

int XrdOssDir::Close ( long long * retsz = 0)
virtual

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 731 of file XrdOssApi.cc.

732{
733 int retc;
734
735// We do not support returing a size
736//
737 if (retsz) *retsz = 0;
738
739// Make sure this object is open
740//
741 if (!isopen) return -XRDOSS_E8002;
742
743// Close whichever handle is open
744//
745 if (lclfd)
746 {if (!(retc = closedir(lclfd)))
747 {lclfd = 0;
748 isopen = false;
749 }
750 } else {
751 if (mssfd) { if (!(retc = XrdOssSS->MSS_Closedir(mssfd))) mssfd = 0;}
752 else retc = 0;
753 }
754
755// Indicate whether or not we really closed this object
756//
757 return retc;
758}
XrdOssSys * XrdOssSS
Definition XrdOssApi.cc:82
#define XRDOSS_E8002
#define closedir(a)
Definition XrdPosix.hh:50
int MSS_Closedir(void *)
Definition XrdOssMSS.cc:185

References closedir, XRDOSS_E8002, and XrdOssSS.

Referenced by ~XrdOssDir().

Here is the caller graph for this function:

◆ Fctl()

int XrdOssDir::Fctl ( int cmd,
int alen,
const char * args,
char ** resp = 0 )
virtual

Reimplemented from XrdOssDF.

Definition at line 774 of file XrdOssApi.cc.

775{
776
777 switch(cmd)
778 {case XrdOssDF::Fctl_utimes: break; // Unsupported
780 if (dfType != DF_isDir) return -ENOTBLK;
781 if (lclfd) return -EALREADY;
782 if (alen != (int)sizeof(int)) return -EINVAL;
783 int retc, newFD;
784 memcpy(&newFD, args, sizeof(int));
785 struct stat buf;
786 do {retc = fstat(newFD, &buf);} while(retc && errno == EINTR);
787 if (retc) return -errno;
788 fd = newFD;
789 if (!(lclfd = fdopendir(newFD))) return -errno;
790 isopen = true;
791 return XrdOssOK;
792 break;
793 default: break;
794 }
795 return -ENOTSUP;
796}
#define XrdOssOK
Definition XrdOss.hh:54
#define fstat(a, b)
Definition XrdPosix.hh:62
#define stat(a, b)
Definition XrdPosix.hh:101
uint16_t dfType
Definition XrdOss.hh:516
static const int Fctl_utimes
Definition XrdOss.hh:459
static const int Fctl_setFD
Definition XrdOss.hh:460

References XrdOssDF::DF_isDir, XrdOssDF::dfType, XrdOssDF::Fctl_setFD, XrdOssDF::Fctl_utimes, XrdOssDF::fd, fstat, stat, and XrdOssOK.

◆ getFD()

int XrdOssDir::getFD ( )
inlinevirtual

Return the underlying file descriptor.

Returns
-1 if there is no file descriptor or a non-negative FD number.

Reimplemented from XrdOssDF.

Definition at line 59 of file XrdOssApi.hh.

59{return fd;}

References XrdOssDF::fd.

◆ Opendir()

int XrdOssDir::Opendir ( const char * path,
XrdOucEnv & env )
virtual

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 557 of file XrdOssApi.cc.

558{
559 EPNAME("Opendir");
560 char actual_path[MAXPATHLEN+1], *local_path, *remote_path;
561 int retc;
562
563// Return an error if this object is already open
564//
565 if (isopen) return -XRDOSS_E8001;
566
567// Get the processing flags for this directory
568//
569 unsigned long long pflags = XrdOssSS->PathOpts(dir_path);
570 if (pflags & XRDEXP_STAGE) dOpts |= isStage;
571 if (pflags & XRDEXP_NODREAD) dOpts |= noDread;
572 if (pflags & XRDEXP_NOCHECK) dOpts |= noCheck;
573 ateof = false;
574
575// Generate local path
576//
577 if (XrdOssSS->lcl_N2N)
578 if ((retc = XrdOssSS->lcl_N2N->lfn2pfn(dir_path, actual_path, sizeof(actual_path))))
579 return retc;
580 else local_path = actual_path;
581 else local_path = (char *)dir_path;
582
583// If this is a local filesystem request, open locally. We also obtian the
584// underlying file descriptor.
585//
586 if (!(dOpts & isStage) || (dOpts & noDread))
587 {TRACE(Opendir, "lcl path " <<local_path <<" (" <<dir_path <<")");
588 if (!(lclfd = XrdSysFD_OpenDir(local_path))) return -errno;
589 fd = dirfd(lclfd);
590 isopen = true;
591 return XrdOssOK;
592 }
593
594// Generate remote path
595//
596 if (XrdOssSS->rmt_N2N)
597 if ((retc = XrdOssSS->rmt_N2N->lfn2rfn(dir_path, actual_path, sizeof(actual_path))))
598 return retc;
599 else remote_path = actual_path;
600 else remote_path = (char *)dir_path;
601
602 TRACE(Opendir, "rmt path " << remote_path <<" (" << dir_path <<")");
603
604// Originally, if MSS directories were not to be read, we ould simply check
605// if the path was a directory and return an error if not. That was superceeded
606// by making NODREAD mean to read the local directory only (which is not always
607// ideal). So, we keep the code below but comment it out for now.
608//
609// if ((dOpts & noDread) && !(dOpts & noCheck))
610// {struct stat fstat;
611// if ((retc = XrdOssSS->MSS_Stat(remote_path,&fstat))) return retc;
612// if (!(S_ISDIR(fstat.st_mode))) return -ENOTDIR;
613// isopen = true;
614// return XrdOssOK;
615// }
616
617// Open the directory at the remote location.
618//
619 if (!(mssfd = XrdOssSS->MSS_Opendir(remote_path, retc))) return retc;
620 isopen = true;
621 return XrdOssOK;
622}
#define EPNAME(x)
#define XRDOSS_E8001
#define XRDEXP_NODREAD
#define XRDEXP_NOCHECK
#define XRDEXP_STAGE
#define TRACE(act, x)
Definition XrdTrace.hh:63
int Opendir(const char *, XrdOucEnv &)
Definition XrdOssApi.cc:557
unsigned long long PathOpts(const char *path)
Definition XrdOssApi.hh:184
XrdOucName2Name * lcl_N2N
Definition XrdOssApi.hh:261
void * MSS_Opendir(const char *, int &rc)
Definition XrdOssMSS.cc:102
XrdOucName2Name * rmt_N2N
Definition XrdOssApi.hh:262
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0
virtual int lfn2rfn(const char *lfn, char *buff, int blen)=0

References dirfd, EPNAME, XrdOssDF::fd, Opendir(), TRACE, XRDEXP_NOCHECK, XRDEXP_NODREAD, XRDEXP_STAGE, XRDOSS_E8001, XrdOssOK, and XrdOssSS.

Referenced by Opendir().

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

◆ Readdir()

int XrdOssDir::Readdir ( char * buff,
int blen )
virtual

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 643 of file XrdOssApi.cc.

644{
645 struct dirent *rp;
646
647// Check if this object is actually open
648//
649 if (!isopen) return -XRDOSS_E8002;
650
651// Perform local reads if this is a local directory
652//
653 if (lclfd)
654 {errno = 0;
655 while((rp = readdir(lclfd)))
656 {strlcpy(buff, rp->d_name, blen);
657#ifdef HAVE_FSTATAT
658 if (Stat && fstatat(fd, rp->d_name, Stat, 0))
659 {if (errno != ENOENT) return -errno;
660 errno = 0;
661 continue;
662 }
663#endif
664 return XrdOssOK;
665 }
666 *buff = '\0'; ateof = true;
667 return -errno;
668 }
669
670// Simulate the read operation, if need be.
671//
672 if (dOpts & noDread)
673 {if (ateof) *buff = '\0';
674 else {*buff = '.'; ateof = true;}
675 return XrdOssOK;
676 }
677
678// Perform a remote read
679//
680 return XrdOssSS->MSS_Readdir(mssfd, buff, blen);
681}
#define readdir(a)
Definition XrdPosix.hh:86
size_t strlcpy(char *dst, const char *src, size_t sz)
int MSS_Readdir(void *fd, char *buff, int blen)
Definition XrdOssMSS.cc:140

References XrdOssDF::fd, readdir, strlcpy(), XRDOSS_E8002, XrdOssOK, and XrdOssSS.

Here is the call graph for this function:

◆ StatRet()

int XrdOssDir::StatRet ( struct stat * buff)
virtual

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 697 of file XrdOssApi.cc.

698{
699
700// Check if this object is actually open
701//
702 if (!isopen) return -XRDOSS_E8002;
703
704// We only support autostat for local directories
705//
706 if (!lclfd) return -ENOTSUP;
707
708// We do not support autostat unless we have the fstatat function
709//
710#ifndef HAVE_FSTATAT
711 return -ENOTSUP;
712#endif
713
714// All is well
715//
716 Stat = buff;
717 return 0;
718}

References stat, and XRDOSS_E8002.


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