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

#include <XrdOssArcFile.hh>

Inheritance diagram for XrdOssArcFile:
Collaboration diagram for XrdOssArcFile:

Public Member Functions

 XrdOssArcFile (const char *tident, XrdOssDF *df)
virtual ~XrdOssArcFile ()
int Close (long long *retsz=0) override
int Fstat (struct stat *buf) override
bool getErrMsg (std::string &eText) override
int Open (const char *path, int Oflag, mode_t Mode, XrdOucEnv &env) override
ssize_t Read (off_t offset, size_t size) override
ssize_t Read (void *buffer, off_t offset, size_t size) override
ssize_t Write (const void *buffer, off_t offset, size_t size) override
Public Member Functions inherited from XrdOssWrapDF
 XrdOssWrapDF (XrdOssDF &df2Wrap)
virtual ~XrdOssWrapDF ()
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).
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 Opendir (const char *path, 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 (XrdOucRangeList &rlist)
virtual int Read (XrdSfsAio *aiop)
virtual int Readdir (char *buff, int blen)
virtual ssize_t ReadRaw (void *buffer, off_t offset, size_t size)
virtual ssize_t ReadV (XrdOucIOVec *readV, int rdvcnt)
virtual int StatRet (struct stat *Stat)
virtual int Write (XrdSfsAio *aiop)
virtual ssize_t WriteV (XrdOucIOVec *writeV, int wrvcnt)
Public Member Functions inherited from XrdOssDF
 XrdOssDF (const char *tid="", uint16_t dftype=0, int fdnum=-1)
virtual ~XrdOssDF ()
uint16_t DFType ()

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 XrdOssWrapDF
XrdOssDFwrapDF
Protected Attributes inherited from XrdOssDF
uint16_t dfType
int fd
off_t pgwEOF
short rsvd
const char * tident

Detailed Description

Definition at line 39 of file XrdOssArcFile.hh.

Constructor & Destructor Documentation

◆ XrdOssArcFile()

XrdOssArcFile::XrdOssArcFile ( const char * tident,
XrdOssDF * df )
inline

Definition at line 130 of file XrdOssArcFile.hh.

131 : XrdOssWrapDF(*df), ossDF(df) {}
XrdOssWrapDF(XrdOssDF &df2Wrap)

References XrdOssDF::XrdOssDF(), XrdOssWrapDF::XrdOssWrapDF(), and XrdOssDF::tident.

Here is the call graph for this function:

◆ ~XrdOssArcFile()

XrdOssArcFile::~XrdOssArcFile ( )
virtual

Definition at line 75 of file XrdOssArcFile.cc.

76{ delete ossDF;
77 if (zFile) delete zFile;
78}

Member Function Documentation

◆ Close()

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

Close 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).

Reimplemented from XrdOssWrapDF.

Definition at line 84 of file XrdOssArcFile.cc.

85{
86 int rc;
87
88// Issue close to possible zipfile appendage and delete it. The underlying
89// oss did not open the file, so we do not issue a close to that.
90//
91 if (zFile)
92 {rc = zFile->Close();
93 if (retsz) *retsz = 0;
94 delete zFile;
95 zFile = 0;
96 } else rc = ossDF->Close(retsz);
97
98// All done
99//
100 return rc;
101}

◆ Fstat()

int XrdOssArcFile::Fstat ( struct stat * buf)
overridevirtual

Return state information for this file.

Parameters
buf- Pointer to the structure where info it to be returned.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssWrapDF.

Definition at line 107 of file XrdOssArcFile.cc.

108{
109// Check if we should forward this call
110//
111 if (zFile == 0) return ossDF->Fstat(buf);
112
113// Obtain stat for the archive file member
114//
115 return zFile->Stat(*buf);
116}

References stat.

◆ getErrMsg()

bool XrdOssArcFile::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 XrdOssWrapDF.

Definition at line 122 of file XrdOssArcFile.cc.

123{
124// Return any extened error mesage associated with this thread
125//
126 if (ecMsg.hasMsg())
127 {std::string xMsg;
128 if (ossDF->getErrMsg(xMsg))
129 {ecMsg.Append();
130 ecMsg.Msg("oss", xMsg.c_str());
131 }
132 ecMsg.Get(eText);
133 return true;
134 }
135 return ossDF->getErrMsg(eText);
136}
bool hasMsg() const
std::string Msg()
XrdOucECMsg & Append(char dlm='\n')
int Get(std::string &ecm, bool rst=true)

References XrdOssArcGlobals::ecMsg.

◆ Open()

int XrdOssArcFile::Open ( const char * path,
int Oflag,
mode_t Mode,
XrdOucEnv & env )
overridevirtual

Open a file.

Parameters
path- Pointer to the path of the file to be opened.
Oflag- Standard open flags.
Mode- File open mode (ignored unless creating a file).
env- Reference to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssWrapDF.

Definition at line 142 of file XrdOssArcFile.cc.

143{
144 int rc, arcFD;
145 bool isRW = (Oflag & (O_APPEND|O_CREAT|O_TRUNC|O_WRONLY|O_RDWR)) != 0;
146
147// Check what we should be doing here. Options are:
148// a) Forward open to underlying storage system (not our path),
149// b) Handle and error,
150// c) Open an actual arvhive, or
151// d) Open a file inside an archive.
152//
153 XrdOssArcCompose dsInfo(path, &env, rc, isRW);
154
155 if (rc == EDOM) return ossDF->Open(path, Oflag, Mode, env);
156 if (rc != 0) return -rc;
157
158// We will be doing a MSS orinted restore. This is subject to pausing.
159// So, we must run under the control of the stop monitor.
160//
161 XrdOssArcStopMon stopMon(Config.stopMon);
162
163// Whether this is a request for an archve or a file in the archive, we
164// need to bring the archive file online. We do this first.
165//
166 char arcPath[MAXPATHLEN];
167 if ((rc = dsInfo.ArcPath(arcPath, sizeof(arcPath), true))) return -rc;
168 if ((rc = XrdOssArcStage::Stage(arcPath, arcPath+Config.tapePathLEN)))
169 {if (rc == EINPROGRESS) return Config.wtpStage;
170 return -rc;
171 }
172
173// If this was a request for the actual archive file, then open it and promote
174// the open to the underlying file system as it will handle all I/O.
175//
176 if (dsInfo.didType == XrdOssArcCompose::isARC)
177 {if ((arcFD = XrdSysFD_Open(arcPath, O_RDONLY, Mode)) < 0)
178 {rc = errno;
179 Elog.Emsg("open", rc, "open", arcPath);
180 return -rc;
181 }
182 rc = ossDF->Fctl(XrdOssDF::Fctl_setFD,sizeof(int),(const char*)&arcFD);
183 if (rc)
184 {Elog.Emsg("open", rc, "promote open", arcPath);
185 close(arcFD);
186 return Neg(rc);
187 }
188 return XrdOssOK;
189 }
190
191// Create the name of the archive member in the archive file
192//
193 char arcMember[MAXPATHLEN];
194 if ((rc = dsInfo.ArcMember(arcMember, sizeof(arcMember)))) return -rc;
195
196// This is a request for a particular file. Get a zip file object and open it.
197//
198 zFile = new XrdOssArcZipFile(arcPath, rc);
199
200// Open the member in the archive if possibe
201//
202 if (!rc) rc = zFile->Open(arcMember);
203
204// Diagnose any errors
205//
206 if (rc)
207 {Elog.Emsg("open", rc, "open archive", path);
208 ecMsg.Msg("open", "Unable to access member", arcMember, "in archive",
209 arcPath);
210 delete zFile; zFile = 0;
211 return Neg(rc);
212 }
213 return 0;
214}
#define Neg(x)
Definition XrdOssArc.cc:78
#define XrdOssOK
Definition XrdOss.hh:54
#define close(a)
Definition XrdPosix.hh:48
int Mode
XrdOssArcStopMon * stopMon
static int Stage(const char *path, const char *mssPath)
static const int Fctl_setFD
Definition XrdOss.hh:460
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdOssArcConfig Config
Definition XrdOssArc.cc:68
XrdSysError Elog(0, "OssArc_")

References XrdOssArcCompose::ArcMember(), XrdOssArcCompose::ArcPath(), close, XrdOssArcGlobals::Config, XrdOssArcCompose::didType, XrdOssArcGlobals::ecMsg, XrdOssArcGlobals::Elog, XrdOssDF::Fctl_setFD, XrdOssArcCompose::isARC, Mode, Neg, XrdOssArcStage::Stage(), and XrdOssOK.

Here is the call graph for this function:

◆ Read() [1/2]

ssize_t XrdOssArcFile::Read ( off_t offset,
size_t size )
inlineoverridevirtual

Preread file blocks into the file system cache.

Parameters
offset- The offset where the read is to start.
size- The number of bytes to pre-read.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssWrapDF.

Definition at line 102 of file XrdOssArcFile.hh.

102{return 0;}

◆ Read() [2/2]

ssize_t XrdOssArcFile::Read ( void * buffer,
off_t offset,
size_t size )
overridevirtual

Read file bytes into a buffer.

Parameters
buffer- pointer to buffer where the bytes are to be placed.
offset- The offset where the read is to start.
size- The number of bytes to read.
Returns
>= 0 The number of bytes that placed in buffer.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssWrapDF.

Definition at line 220 of file XrdOssArcFile.cc.

221{
222// Execute read based on what kind of file we currently have
223//
224 if (zFile) return zFile->Read(buffer, offset, size);
225 return ossDF->Read(buffer, offset, size);
226}

◆ Write()

ssize_t XrdOssArcFile::Write ( const void * buffer,
off_t offset,
size_t size )
overridevirtual

Write file bytes from a buffer.

Parameters
buffer- pointer to buffer where the bytes reside.
offset- The offset where the write is to start.
size- The number of bytes to write.
Returns
>= 0 The number of bytes that were written.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssWrapDF.

Definition at line 234 of file XrdOssArcFile.cc.

235{
236// Execute read based on what kind of file we currently have
237//
238 if (zFile) return -EBADF;
239 return ossDF->Write(buffer, offset, size);
240}

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