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 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 ()
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).
virtual int Fstat (struct stat *buf)
virtual int Fsync ()
virtual int Fsync (XrdSfsAio *aiop)
virtual int Ftruncate (unsigned long long flen)
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 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_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 61 of file XrdOssApi.hh.

62 : XrdOssDF(tid, DF_isDir),
63 lclfd(dP), mssfd(0), Stat(0), ateof(false),
64 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:444
int fd
Definition XrdOss.hh:455
static const uint16_t DF_isDir
Object is for a directory.
Definition XrdOss.hh:392

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 66 of file XrdOssApi.hh.

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

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

672{
673 int retc;
674
675// We do not support returing a size
676//
677 if (retsz) *retsz = 0;
678
679// Make sure this object is open
680//
681 if (!isopen) return -XRDOSS_E8002;
682
683// Close whichever handle is open
684//
685 if (lclfd)
686 {if (!(retc = closedir(lclfd)))
687 {lclfd = 0;
688 isopen = false;
689 }
690 } else {
691 if (mssfd) { if (!(retc = XrdOssSS->MSS_Closedir(mssfd))) mssfd = 0;}
692 else retc = 0;
693 }
694
695// Indicate whether or not we really closed this object
696//
697 return retc;
698}
XrdOssSys * XrdOssSS
Definition XrdOssApi.cc:77
#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:

◆ 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 58 of file XrdOssApi.hh.

58{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 497 of file XrdOssApi.cc.

498{
499 EPNAME("Opendir");
500 char actual_path[MAXPATHLEN+1], *local_path, *remote_path;
501 int retc;
502
503// Return an error if this object is already open
504//
505 if (isopen) return -XRDOSS_E8001;
506
507// Get the processing flags for this directory
508//
509 unsigned long long pflags = XrdOssSS->PathOpts(dir_path);
510 if (pflags & XRDEXP_STAGE) dOpts |= isStage;
511 if (pflags & XRDEXP_NODREAD) dOpts |= noDread;
512 if (pflags & XRDEXP_NOCHECK) dOpts |= noCheck;
513 ateof = false;
514
515// Generate local path
516//
517 if (XrdOssSS->lcl_N2N)
518 if ((retc = XrdOssSS->lcl_N2N->lfn2pfn(dir_path, actual_path, sizeof(actual_path))))
519 return retc;
520 else local_path = actual_path;
521 else local_path = (char *)dir_path;
522
523// If this is a local filesystem request, open locally. We also obtian the
524// underlying file descriptor.
525//
526 if (!(dOpts & isStage) || (dOpts & noDread))
527 {TRACE(Opendir, "lcl path " <<local_path <<" (" <<dir_path <<")");
528 if (!(lclfd = XrdSysFD_OpenDir(local_path))) return -errno;
529 fd = dirfd(lclfd);
530 isopen = true;
531 return XrdOssOK;
532 }
533
534// Generate remote path
535//
536 if (XrdOssSS->rmt_N2N)
537 if ((retc = XrdOssSS->rmt_N2N->lfn2rfn(dir_path, actual_path, sizeof(actual_path))))
538 return retc;
539 else remote_path = actual_path;
540 else remote_path = (char *)dir_path;
541
542 TRACE(Opendir, "rmt path " << remote_path <<" (" << dir_path <<")");
543
544// Originally, if MSS directories were not to be read, we ould simply check
545// if the path was a directory and return an error if not. That was superceeded
546// by making NODREAD mean to read the local directory only (which is not always
547// ideal). So, we keep the code below but comment it out for now.
548//
549// if ((dOpts & noDread) && !(dOpts & noCheck))
550// {struct stat fstat;
551// if ((retc = XrdOssSS->MSS_Stat(remote_path,&fstat))) return retc;
552// if (!(S_ISDIR(fstat.st_mode))) return -ENOTDIR;
553// isopen = true;
554// return XrdOssOK;
555// }
556
557// Open the directory at the remote location.
558//
559 if (!(mssfd = XrdOssSS->MSS_Opendir(remote_path, retc))) return retc;
560 isopen = true;
561 return XrdOssOK;
562}
#define EPNAME(x)
#define XRDOSS_E8001
#define XrdOssOK
Definition XrdOss.hh:50
#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:497
unsigned long long PathOpts(const char *path)
Definition XrdOssApi.hh:177
XrdOucName2Name * lcl_N2N
Definition XrdOssApi.hh:254
void * MSS_Opendir(const char *, int &rc)
Definition XrdOssMSS.cc:102
XrdOucName2Name * rmt_N2N
Definition XrdOssApi.hh:255
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 583 of file XrdOssApi.cc.

584{
585 struct dirent *rp;
586
587// Check if this object is actually open
588//
589 if (!isopen) return -XRDOSS_E8002;
590
591// Perform local reads if this is a local directory
592//
593 if (lclfd)
594 {errno = 0;
595 while((rp = readdir(lclfd)))
596 {strlcpy(buff, rp->d_name, blen);
597#ifdef HAVE_FSTATAT
598 if (Stat && fstatat(fd, rp->d_name, Stat, 0))
599 {if (errno != ENOENT) return -errno;
600 errno = 0;
601 continue;
602 }
603#endif
604 return XrdOssOK;
605 }
606 *buff = '\0'; ateof = true;
607 return -errno;
608 }
609
610// Simulate the read operation, if need be.
611//
612 if (dOpts & noDread)
613 {if (ateof) *buff = '\0';
614 else {*buff = '.'; ateof = true;}
615 return XrdOssOK;
616 }
617
618// Perform a remote read
619//
620 return XrdOssSS->MSS_Readdir(mssfd, buff, blen);
621}
#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 637 of file XrdOssApi.cc.

638{
639
640// Check if this object is actually open
641//
642 if (!isopen) return -XRDOSS_E8002;
643
644// We only support autostat for local directories
645//
646 if (!lclfd) return -ENOTSUP;
647
648// We do not support autostat unless we have the fstatat function
649//
650#ifndef HAVE_FSTATAT
651 return -ENOTSUP;
652#endif
653
654// All is well
655//
656 Stat = buff;
657 return 0;
658}

References stat, and XRDOSS_E8002.


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