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

#include <XrdCksManOss.hh>

+ Inheritance diagram for XrdCksManOss:
+ Collaboration diagram for XrdCksManOss:

Public Member Functions

 XrdCksManOss (XrdOss *ossX, XrdSysError *erP, int iosz, XrdVersionInfo &vInfo, bool autoload=false)
 
virtual ~XrdCksManOss ()
 
virtual int Calc (const char *Lfn, XrdCksData &Cks, int doSet=1)
 
virtual int Del (const char *Lfn, XrdCksData &Cks)
 
virtual int Get (const char *Lfn, XrdCksData &Cks)
 
virtual char * List (const char *Lfn, char *Buff, int Blen, char Sep=' ')
 
virtual int Set (const char *Lfn, XrdCksData &Cks, int myTime=0)
 
virtual int Ver (const char *Lfn, XrdCksData &Cks)
 
- Public Member Functions inherited from XrdCksManager
 XrdCksManager (XrdSysError *erP, int iosz, XrdVersionInfo &vInfo, bool autoload=false)
 
virtual ~XrdCksManager ()
 
virtual int Config (const char *Token, char *Line)
 
virtual int Init (const char *ConfigFN, const char *AddCalc=0)
 
virtual const char * Name (int seqNum=0)
 
virtual XrdCksCalcObject (const char *name)
 
void SetOpts (int opt)
 
virtual int Size (const char *Name=0)
 
- Public Member Functions inherited from XrdCks
 XrdCks (XrdSysError *erP)
 Constructor.
 
virtual ~XrdCks ()
 Destructor.
 
virtual int Ver (const char *Xfn, XrdCksData &Cks, XrdCksPCB *pcbP)
 

Protected Member Functions

virtual int Calc (const char *Lfn, time_t &MTime, XrdCksCalc *CksObj)
 
virtual int ModTime (const char *Pfn, time_t &MTime)
 

Additional Inherited Members

- Public Types inherited from XrdCksManager
enum  { Cks_nomtchk = 0x00000001 }
 
- Protected Attributes inherited from XrdCks
XrdSysErroreDest
 

Detailed Description

Definition at line 43 of file XrdCksManOss.hh.

Constructor & Destructor Documentation

◆ XrdCksManOss()

XrdCksManOss::XrdCksManOss ( XrdOss * ossX,
XrdSysError * erP,
int iosz,
XrdVersionInfo & vInfo,
bool autoload = false )

Definition at line 86 of file XrdCksManOss.cc.

88 : XrdCksManager(erP, rdSz, vInfo, autoload)
89 {if (rdSz <= 65536) rdSz = 67108864;
90 else rdSz = ((rdSz/65536) + (rdSz%65536 != 0)) * 65536;
91 eDest = erP;
92 ossP = ossX;
93 }
XrdCksManager(XrdSysError *erP, int iosz, XrdVersionInfo &vInfo, bool autoload=false)
XrdSysError * eDest
Definition XrdCks.hh:289

References XrdCks::eDest.

◆ ~XrdCksManOss()

virtual XrdCksManOss::~XrdCksManOss ( )
inlinevirtual

Definition at line 61 of file XrdCksManOss.hh.

61{}

Member Function Documentation

◆ Calc() [1/2]

int XrdCksManOss::Calc ( const char * Lfn,
time_t & MTime,
XrdCksCalc * CksObj )
protectedvirtual

Reimplemented from XrdCksManager.

Definition at line 115 of file XrdCksManOss.cc.

116{
117 class inFile
118 {public:
119 XrdOssDF *fP;
120 inFile() {fP = ossP->newFile("ckscalc");}
121 ~inFile() {if (fP) delete fP;}
122 } In;
123 XrdOucEnv openEnv;
124 const char *Lfn = Pfn2Lfn(Pfn);
125 struct stat Stat;
126 char *buffP;
127 off_t Offset=0, fileSize;
128 size_t ioSize, calcSize;
129 int rc;
130
131// Open the input file
132//
133 if ((rc = In.fP->Open(Lfn,O_RDONLY,0,openEnv))) return (rc > 0 ? -rc : rc);
134
135// Get the file characteristics
136//
137 if ((rc = In.fP->Fstat(&Stat))) return (rc > 0 ? -rc : rc);
138 if (!(Stat.st_mode & S_IFREG)) return -EPERM;
139 calcSize = fileSize = Stat.st_size;
140 MTime = Stat.st_mtime;
141
142// Compute read size and allocate a buffer
143//
144 ioSize = (fileSize < (off_t)rdSz ? fileSize : rdSz); rc = 0;
145 buffP = (char *)malloc(ioSize);
146 if (!buffP) return -ENOMEM;
147
148// We now compute checksum 64MB at a time using mmap I/O
149//
150 while(calcSize)
151 {if ((rc= In.fP->Read(buffP, Offset, ioSize)) < 0) break;
152 csP->Update(buffP, ioSize);
153 calcSize -= ioSize; Offset += ioSize;
154 if (calcSize < (size_t)ioSize) ioSize = calcSize;
155 }
156 free(buffP);
157
158// Issue error message if we have an error
159//
160 if (rc < 0) eDest->Emsg("Cks", rc, "read", Pfn);
161
162// Return
163//
164 return (rc < 0 ? rc : 0);
165}
struct stat Stat
Definition XrdCks.cc:49
#define stat(a, b)
Definition XrdPosix.hh:101
virtual XrdOssDF * newFile(const char *tident)=0
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

References XrdCks::eDest, XrdSysError::Emsg(), XrdOss::newFile(), Stat, stat, and XrdCksCalc::Update().

+ Here is the call graph for this function:

◆ Calc() [2/2]

int XrdCksManOss::Calc ( const char * Xfn,
XrdCksData & Cks,
int doSet = 1 )
virtual

Calculate a new checksum for a physical file using the checksum algorithm named in the Cks parameter.

Parameters
XfnThe logical or physical name of the file to be checksumed.
CksFor input, it specifies the checksum algorithm to be used. For output, the checksum value is returned upon success.
doSetWhen true, the new value must replace any existing value in the Xfn's extended file attributes.
pcbPIn the second form, the pointer to the callback object. A nil pointer does not invoke any callback.
Returns
Success: zero with Cks structure holding the checksum value. Failure: -errno (see significant error numbers below).

Reimplemented from XrdCksManager.

Definition at line 99 of file XrdCksManOss.cc.

100{
101 int rc;
102 LfnPfn Xfn(Lfn, rc);
103
104// If lfn conversion failed, bail out
105//
106 if (rc) return rc;
107
108// Return the result
109//
110 return XrdCksManager::Calc(Xfn.Pfn, Cks, doSet);
111}
virtual int Calc(const char *Pfn, XrdCksData &Cks, int doSet=1)

References XrdCksManager::Calc(), and LfnPfn::Pfn.

+ Here is the call graph for this function:

◆ Del()

int XrdCksManOss::Del ( const char * Xfn,
XrdCksData & Cks )
virtual

Delete the checksum from the Xfn's xattrs.

Parameters
XfnThe logical or physical name of the file to be checksumed.
CksSpecifies the checksum type to delete.
Returns
Success: 0 Failure: -errno (see significant error numbers below).

Reimplemented from XrdCksManager.

Definition at line 171 of file XrdCksManOss.cc.

172{
173 int rc;
174 LfnPfn Xfn(Lfn, rc);
175
176// If lfn conversion failed, bail out
177//
178 if (rc) return rc;
179
180// Delete the attribute and return the result
181//
182 return XrdCksManager::Del(Xfn.Pfn, Cks);
183}
virtual int Del(const char *Pfn, XrdCksData &Cks)

References XrdCksManager::Del(), and LfnPfn::Pfn.

+ Here is the call graph for this function:

◆ Get()

int XrdCksManOss::Get ( const char * Xfn,
XrdCksData & Cks )
virtual

Retreive the checksum from the Xfn's xattrs and return it and indicate whether or not it is stale (i.e. the file modification has changed or the name and length are not the expected values).

Parameters
XfnThe logical or physical name of the file to be checksumed.
CksFor input, it specifies the checksum type to return. For output, the checksum value is returned upon success.
Returns
Success: The length of the binary checksum in the Cks structure. Failure: -errno (see significant error numbers below).

Reimplemented from XrdCksManager.

Definition at line 189 of file XrdCksManOss.cc.

190{
191 int rc;
192 LfnPfn Xfn(Lfn, rc);
193
194// If lfn conversion failed, bail out
195//
196 if (rc) return rc;
197
198// Return result
199//
200 return XrdCksManager::Get(Xfn.Pfn, Cks);
201}
virtual int Get(const char *Pfn, XrdCksData &Cks)

References XrdCksManager::Get(), and LfnPfn::Pfn.

+ Here is the call graph for this function:

◆ List()

char * XrdCksManOss::List ( const char * Xfn,
char * Buff,
int Blen,
char Sep = ' ' )
virtual

List names of the checksums associated with a Xfn or all supported ones.

Parameters
XfnThe logical or physical file name whose checksum names are to be returned. When Xfn is null, return all supported checksum algorithm names.
BuffPoints to a buffer, at least 64 bytes in length, to hold a "Sep" separated list of checksum names.
BlenThe length of the buffer.
SepThe separation character to be used between adjacent names.
Returns
Success: Pointer to Buff holding at least one checksum name. Failure: A nil pointer is returned.

Reimplemented from XrdCksManager.

Definition at line 207 of file XrdCksManOss.cc.

208{
209 int rc;
210 LfnPfn Xfn(Lfn, rc);
211
212// If lfn conversion failed, bail out
213//
214 if (rc) return 0;
215
216// Simply invoke the base class list
217//
218 return XrdCksManager::List(Xfn.Pfn, Buff, Blen,Sep);
219}
virtual char * List(const char *Pfn, char *Buff, int Blen, char Sep=' ')

References XrdCksManager::List(), and LfnPfn::Pfn.

+ Here is the call graph for this function:

◆ ModTime()

int XrdCksManOss::ModTime ( const char * Pfn,
time_t & MTime )
protectedvirtual

Reimplemented from XrdCksManager.

Definition at line 225 of file XrdCksManOss.cc.

226{
227 const char *Lfn = Pfn2Lfn(Pfn);
228 struct stat Stat;
229 int rc;
230
231 if (!(rc = ossP->Stat(Lfn, &Stat))) MTime = Stat.st_mtime;
232
233 return (rc > 0 ? -rc : 0);
234}
virtual int Stat(const char *path, struct stat *buff, int opts=0, XrdOucEnv *envP=0)=0

References Stat, stat, and XrdOss::Stat().

+ Here is the call graph for this function:

◆ Set()

int XrdCksManOss::Set ( const char * Xfn,
XrdCksData & Cks,
int myTime = 0 )
virtual

Set a file's checksum in the extended attributes along with the file's mtime and the time of setting.

Parameters
XfnThe logical or physical name of the file to be set.
CksSpecifies the checksum name and value.
myTimeWhen true then the fmTime and gmTime in the Cks structure are to be used; as opposed to the current time.
Returns
Success: zero is returned. Failure: -errno (see significant error numbers below).

Reimplemented from XrdCksManager.

Definition at line 240 of file XrdCksManOss.cc.

241{
242 int rc;
243 LfnPfn Xfn(Lfn, rc);
244
245// If lfn conversion failed, bail out
246//
247 if (rc) return rc;
248
249// Now set the checksum information in the extended attribute object
250//
251 return XrdCksManager::Set(Xfn.Pfn, Cks, myTime);
252}
virtual int Set(const char *Pfn, XrdCksData &Cks, int myTime=0)

References LfnPfn::Pfn, and XrdCksManager::Set().

+ Here is the call graph for this function:

◆ Ver()

int XrdCksManOss::Ver ( const char * Xfn,
XrdCksData & Cks )
virtual

Retreive the checksum from the Xfn's xattrs and compare it to the supplied checksum. If the checksum is not available or is stale, a new checksum is calculated and written to the extended attributes.

Parameters
XfnThe logical or physical name of the file to be verified.
CksSpecifies the checksum name and value.
pcbPIn the second form, the pointer to the callback object. A nil pointer does not invoke any callback.
Returns
Success: True Failure: False (the checksums do not match) or -errno indicating that verification could not be performed (see significant error numbers below).

Reimplemented from XrdCksManager.

Definition at line 258 of file XrdCksManOss.cc.

259{
260 int rc;
261 LfnPfn Xfn(Lfn, rc);
262
263// If lfn conversion failed, bail out
264//
265 if (rc) return rc;
266
267// Return result invoking the base class
268//
269 return XrdCksManager::Ver(Lfn, Cks);
270}
virtual int Ver(const char *Pfn, XrdCksData &Cks)

References XrdCksManager::Ver().

+ Here is the call graph for this function:

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