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

#include <XrdCksManager.hh>

+ Inheritance diagram for XrdCksManager:
+ Collaboration diagram for XrdCksManager:

Public Types

enum  { Cks_nomtchk = 0x00000001 }
 

Public Member Functions

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

Protected Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from XrdCks
XrdSysErroreDest
 

Detailed Description

Definition at line 48 of file XrdCksManager.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Cks_nomtchk 

Definition at line 73 of file XrdCksManager.hh.

73{Cks_nomtchk = 0x00000001};

Constructor & Destructor Documentation

◆ XrdCksManager()

XrdCksManager::XrdCksManager ( XrdSysError erP,
int  iosz,
XrdVersionInfo &  vInfo,
bool  autoload = false 
)

Definition at line 75 of file XrdCksManager.cc.

77 : XrdCks(erP), myVersion(vInfo)
78{
79
80// Get a dynamic loader if so wanted
81//
82 if (autoload) cksLoader = new XrdCksLoader(vInfo);
83 else cksLoader = 0;
84
85// Prefill the native digests we support
86//
87 strcpy(csTab[0].Name, "adler32");
88 strcpy(csTab[1].Name, "crc32");
89 strcpy(csTab[2].Name, "crc32c");
90 strcpy(csTab[3].Name, "md5");
91 csLast = 3;
92
93// Compute the i/o size
94//
95 if (rdsz <= 65536) segSize = 67108864;
96 else segSize = ((rdsz/65536) + (rdsz%65536 != 0)) * 65536;
97}
virtual const char * Name(int seqNum=0)

References Name().

+ Here is the call graph for this function:

◆ ~XrdCksManager()

XrdCksManager::~XrdCksManager ( )
virtual

Definition at line 103 of file XrdCksManager.cc.

104{
105 int i;
106 for (i = 0; i <= csLast; i++)
107 {if (csTab[i].Obj && csTab[i].doDel) csTab[i].Obj->Recycle();
108 if (csTab[i].Path) free( csTab[i].Path);
109 if (csTab[i].Parms) free( csTab[i].Parms);
110 if (csTab[i].Plugin) delete csTab[i].Plugin;
111 }
112 if (cksLoader) delete cksLoader;
113}
XrdOucString Path

References Path.

Member Function Documentation

◆ Calc() [1/2]

int XrdCksManager::Calc ( const char *  Pfn,
time_t &  MTime,
XrdCksCalc CksObj 
)
protectedvirtual

Reimplemented in XrdCksManOss.

Definition at line 161 of file XrdCksManager.cc.

162{
163 class ioFD
164 {public:
165 int FD;
166 ioFD() : FD(-1) {}
167 ~ioFD() {if (FD >= 0) close(FD);}
168 } In;
169 struct stat Stat;
170 char *inBuff;
171 off_t Offset=0, fileSize;
172 size_t ioSize, calcSize;
173 int rc;
174
175// Open the input file
176//
177 if ((In.FD = open(Pfn, O_RDONLY)) < 0) return -errno;
178
179// Get the file characteristics
180//
181 if (fstat(In.FD, &Stat)) return -errno;
182 if (!(Stat.st_mode & S_IFREG)) return -EPERM;
183 calcSize = fileSize = Stat.st_size;
184 MTime = Stat.st_mtime;
185
186// We now compute checksum 64MB at a time using mmap I/O
187//
188 ioSize = (fileSize < (off_t)segSize ? fileSize : segSize); rc = 0;
189 while(calcSize)
190 {if ((inBuff = (char *)mmap(0, ioSize, PROT_READ,
191#if defined(__FreeBSD__)
192 MAP_RESERVED0040|MAP_PRIVATE, In.FD, Offset)) == MAP_FAILED)
193#elif defined(__GNU__)
194 MAP_PRIVATE, In.FD, Offset)) == MAP_FAILED)
195#else
196 MAP_NORESERVE|MAP_PRIVATE, In.FD, Offset)) == MAP_FAILED)
197#endif
198 {rc = errno; eDest->Emsg("Cks", rc, "memory map", Pfn); break;}
199 madvise(inBuff, ioSize, MADV_SEQUENTIAL);
200 csP->Update(inBuff, ioSize);
201 calcSize -= ioSize; Offset += ioSize;
202 if (munmap(inBuff, ioSize) < 0)
203 {rc = errno; eDest->Emsg("Cks",rc,"unmap memory for",Pfn); break;}
204 if (calcSize < (size_t)segSize) ioSize = calcSize;
205 }
206
207// Return if we failed
208//
209 if (calcSize) return (rc ? -rc : -EIO);
210 return 0;
211}
struct stat Stat
Definition XrdCks.cc:49
#define close(a)
Definition XrdPosix.hh:48
#define fstat(a, b)
Definition XrdPosix.hh:62
#define open
Definition XrdPosix.hh:76
#define stat(a, b)
Definition XrdPosix.hh:101
XrdSysError * eDest
Definition XrdCks.hh:289
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

References close, XrdCks::eDest, XrdSysError::Emsg(), fstat, open, Stat, stat, and XrdCksCalc::Update().

+ Here is the call graph for this function:

◆ Calc() [2/2]

int XrdCksManager::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).

Implements XrdCks.

Reimplemented in XrdCksManOss.

Definition at line 119 of file XrdCksManager.cc.

120{
121 XrdCksCalc *csP;
122 csInfo *csIP = &csTab[0];
123 time_t MTime;
124 int rc;
125
126// Determine which checksum to get
127//
128 if (csLast < 0) return -ENOTSUP;
129 if (!(*Cks.Name)) Cks.Set(csIP->Name);
130 else if (!(csIP = Find(Cks.Name))) return -ENOTSUP;
131
132// If we need not set the checksum then see if we can get it from the
133// extended attributes.
134
135// Obtain a new checksum object
136//
137 if (!(csP = csIP->Obj->New())) return -ENOMEM;
138
139// Use the calculator to get and possibly set the checksum
140//
141 if (!(rc = Calc(Pfn, MTime, csP)))
142 {memcpy(Cks.Value, csP->Final(), csIP->Len);
143 Cks.fmTime = static_cast<long long>(MTime);
144 Cks.csTime = static_cast<int>(time(0) - MTime);
145 Cks.Length = csIP->Len;
146 csP->Recycle();
147 if (doSet)
149 memcpy(&xCS.Attr.Cks, &Cks, sizeof(xCS.Attr.Cks));
150 if ((rc = xCS.Set(Pfn))) return -rc;
151 }
152 }
153
154// All done
155//
156 return rc;
157}
XrdOucXAttr< XrdCksXAttr > xCS
Definition XrdCks.cc:48
virtual void Recycle()
Recycle the checksum object as it is no longer needed. A default is given.
Definition XrdCksCalc.hh:95
virtual char * Final()=0
char Value[ValuSize]
Definition XrdCksData.hh:53
int Set(const char *csName)
Definition XrdCksData.hh:81
char Name[NameSize]
Definition XrdCksData.hh:44
virtual int Calc(const char *Pfn, XrdCksData &Cks, int doSet=1)

References Calc(), XrdCksData::csTime, XrdCksCalc::Final(), XrdCksData::Length, XrdCksData::Name, XrdCksCalc::New(), XrdCksCalc::Recycle(), XrdCksData::Set(), XrdCksData::Value, and xCS.

Referenced by XrdCksManOss::Calc(), Calc(), and Ver().

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

◆ Config()

int XrdCksManager::Config ( const char *  Token,
char *  Line 
)
virtual

Parse a configuration directives specific to the checksum manager.

Parameters
TokenPoints to the directive that triggered the call.
LineAll the characters after the directive.
Returns
Success: 1 Failure: 0

Implements XrdCks.

Definition at line 225 of file XrdCksManager.cc.

226{
227 XrdOucTokenizer Cfg(Line);
228 char *val, *path = 0, name[XrdCksData::NameSize], *parms;
229 int i;
230
231// Get the the checksum name
232//
233 Cfg.GetLine();
234 if (!(val = Cfg.GetToken()) || !val[0])
235 {eDest->Emsg("Config", "checksum name not specified"); return 1;}
236 if (int(strlen(val)) >= XrdCksData::NameSize)
237 {eDest->Emsg("Config", "checksum name too long"); return 1;}
238 strcpy(name, val); XrdOucUtils::toLower(name);
239
240// Get the path and optional parameters
241//
242 val = Cfg.GetToken(&parms);
243 if (val && val[0]) path = strdup(val);
244 else {eDest->Emsg("Config","library path missing for ckslib digest",name);
245 return 1;
246 }
247
248// Check if this replaces an existing checksum
249//
250 for (i = 0; i < csMax; i++)
251 if (!(*csTab[i].Name) || !strcmp(csTab[i].Name, name)) break;
252
253// See if we can insert a new checksum (or replace one)
254//
255 if (i >= csMax)
256 {eDest->Emsg("Config", "too many checksums specified");
257 if (path) free(path);
258 return 1;
259 } else if (!(*csTab[i].Name)) csLast = i;
260
261// Insert the new checksum
262//
263 strcpy(csTab[i].Name, name);
264 if (csTab[i].Path) free(csTab[i].Path);
265 csTab[i].Path = path;
266 if (csTab[i].Parms) free(csTab[i].Parms);
267 csTab[i].Parms = (parms && *parms ? strdup(parms) : 0);
268
269// All done
270//
271 return 0;
272}
static const int NameSize
Definition XrdCksData.hh:41
static void toLower(char *str)

References XrdCks::eDest, XrdSysError::Emsg(), Name(), XrdCksData::NameSize, Path, and XrdOucUtils::toLower().

Referenced by Init().

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

◆ Del()

int XrdCksManager::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).

Implements XrdCks.

Reimplemented in XrdCksManOss.

Definition at line 446 of file XrdCksManager.cc.

447{
449
450// Set the checksum name
451//
452 xCS.Attr.Cks.Set(Cks.Name);
453
454// Delete the attribute and return the result
455//
456 return xCS.Del(Pfn);
457}

References XrdOucXAttr< T >::Attr, XrdCksData::Name, and xCS.

Referenced by XrdCksManOss::Del().

+ Here is the caller graph for this function:

◆ Get()

int XrdCksManager::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).

Implements XrdCks.

Reimplemented in XrdCksManOss.

Definition at line 463 of file XrdCksManager.cc.

464{
466 time_t MTime;
467 int rc, nFault;
468
469// Determine which checksum to get (we will accept unsupported ones as well)
470//
471 if (csLast < 0) return -ENOTSUP;
472 if (!*Cks.Name) Cks.Set(csTab[0].Name);
473 if (!xCS.Attr.Cks.Set(Cks.Name)) return -ENOTSUP;
474
475// Retreive the attribute
476//
477 if ((rc = xCS.Get(Pfn)) <= 0) return (rc && rc != -ENOATTR ? rc : -ESRCH);
478
479// Mark state of the name and copy the attribute over
480//
481 nFault = strcmp(xCS.Attr.Cks.Name, Cks.Name);
482 Cks = xCS.Attr.Cks;
483
484// Verify the file. We do this with modification time unless that check
485// has been turned off.
486//
487 if (CksOpts & Cks_nomtchk) MTime = Cks.fmTime;
488 else if ((rc = ModTime(Pfn, MTime))) return rc;
489
490// Return result
491//
492 return (Cks.fmTime != MTime || nFault
493 || Cks.Length > XrdCksData::ValuSize || Cks.Length <= 0
494 ? -ESTALE : int(Cks.Length));
495}
#define ENOATTR
static const int ValuSize
Definition XrdCksData.hh:42
virtual int ModTime(const char *Pfn, time_t &MTime)

References Cks_nomtchk, ENOATTR, XrdCksData::Length, ModTime(), Name(), XrdCksData::Name, XrdCksData::Set(), XrdCksData::ValuSize, and xCS.

Referenced by XrdCksManOss::Get().

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

◆ Init()

int XrdCksManager::Init ( const char *  ConfigFN,
const char *  DfltCalc = 0 
)
virtual

Fully initialize the manager which includes loading any plugins.

Parameters
ConfigFNPoints to the configuration file path.
DfltCalcIs the default checksum and should be defaulted if NULL. The default implementation defaults this to adler32. A default is only needed should the checksum name in the XrdCksData object be omitted.
Returns
Success: 1 Failure: 0

Implements XrdCks.

Definition at line 278 of file XrdCksManager.cc.

279{
280 int i;
281
282// See if we need to set the default calculation
283//
284 if (DfltCalc)
285 {for (i = 0; i < csLast; i++) if (!strcmp(csTab[i].Name, DfltCalc)) break;
286 if (i >= csMax)
287 {eDest->Emsg("Config", DfltCalc, "cannot be made the default; "
288 "not supported.");
289 return 0;
290 }
291 if (i) {csInfo Temp = csTab[i]; csTab[i] = csTab[0]; csTab[0] = Temp;}
292 }
293
294// See if there are any checksums to configure
295//
296 if (csLast < 0)
297 {eDest->Emsg("Config", "No checksums defined; cannot configure!");
298 return 0;
299 }
300
301// Complete the checksum table
302//
303 for (i = 0; i <= csLast; i++)
304 {if (csTab[i].Path) {if (!(Config(ConfigFN, csTab[i]))) return 0;}
305 else { if (!strcmp("adler32", csTab[i].Name))
306 csTab[i].Obj = new XrdCksCalcadler32;
307 else if (!strcmp("crc32", csTab[i].Name))
308 csTab[i].Obj = new XrdCksCalccrc32;
309 else if (!strcmp("crc32c", csTab[i].Name))
310 csTab[i].Obj = new XrdCksCalccrc32C;
311 else if (!strcmp("md5", csTab[i].Name))
312 csTab[i].Obj = new XrdCksCalcmd5;
313 else {eDest->Emsg("Config", "Invalid native checksum -",
314 csTab[i].Name);
315 return 0;
316 }
317 csTab[i].Obj->Type(csTab[i].Len);
318 }
319 }
320
321// All done
322//
323 return 1;
324}
virtual int Config(const char *Token, char *Line)

References Config(), XrdCks::eDest, XrdSysError::Emsg(), Name(), and Path.

+ Here is the call graph for this function:

◆ List()

char * XrdCksManager::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.

Implements XrdCks.

Reimplemented in XrdCksManOss.

Definition at line 501 of file XrdCksManager.cc.

502{
503 static const char *vPfx = "XrdCks.";
504 static const int vPln = strlen(vPfx);
505 XrdSysFAttr::AList *vP, *axP = 0;
506 char *bP = Buff;
507 int i, n;
508
509// Verify that the buffer is large enough
510//
511 if (Blen < 2) return 0;
512
513// Check if the default list is wanted
514//
515 if (!Pfn)
516 {if (csLast < 0) return 0;
517 i = 0;
518 while(i <= csLast && Blen > 1)
519 {n = strlen(csTab[i].Name);
520 if (n >= Blen) break;
521 if (bP != Buff) *bP++ = Sep;
522 strcpy(bP, csTab[i].Name); bP += n; *bP = 0;
523 }
524 return (bP == Buff ? 0 : Buff);
525 }
526
527// Get a list of attributes for this file
528//
529 if (XrdSysFAttr::Xat->List(&axP, Pfn) < 0 || !axP) return 0;
530
531// Go through the list extracting what we are looking for
532//
533 vP = axP;
534 while(vP)
535 {if (vP->Nlen > vPln && !strncmp(vP->Name, vPfx, vPln))
536 {n = vP->Nlen - vPln;
537 if (n >= Blen) break;
538 if (bP != Buff) *bP++ = Sep;
539 strcpy(bP, vP->Name + vPln); bP += n; *bP = 0;
540 }
541 vP = vP->Next;
542 }
543
544// All done
545//
547 return (bP == Buff ? 0 : Buff);
548}
virtual char * List(const char *Pfn, char *Buff, int Blen, char Sep=' ')
static XrdSysXAttr * Xat
char Name[1]
Start of the name (size of struct is dynamic)
int Nlen
The length of the attribute name that follows.
virtual void Free(AList *aPL)=0
AList * Next
-> next element.

References XrdSysXAttr::Free(), List(), Name(), XrdSysXAttr::AList::Name, XrdSysXAttr::AList::Next, XrdSysXAttr::AList::Nlen, and XrdSysFAttr::Xat.

Referenced by XrdCksManOss::List(), and List().

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

◆ ModTime()

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

Reimplemented in XrdCksManOss.

Definition at line 554 of file XrdCksManager.cc.

555{
556 struct stat Stat;
557
558 if (stat(Pfn, &Stat)) return -errno;
559
560 MTime = Stat.st_mtime;
561 return 0;
562}

References Stat, and stat.

Referenced by Get(), Set(), and Ver().

+ Here is the caller graph for this function:

◆ Name()

const char * XrdCksManager::Name ( int  seqNum = 0)
virtual

Get the name of the checksums associated with a sequence number. Note that Name() may be called prior to final config to see if there are any chksums to configure and avoid unintended errors.

Parameters
seqNumThe sequence number. Zero signifies the default name. Higher numbers are alternates.
Returns
Success: Pointer to the name. Failure: A nil pointer is returned (no more alternates exist).

Implements XrdCks.

Definition at line 568 of file XrdCksManager.cc.

569{
570
571 return (seqNum < 0 || seqNum > csLast ? 0 : csTab[seqNum].Name);
572}

Referenced by XrdCksManager(), Config(), Get(), Init(), List(), and Size().

+ Here is the caller graph for this function:

◆ Object()

XrdCksCalc * XrdCksManager::Object ( const char *  name)
virtual

Get a new XrdCksCalc object that can calculate the checksum corresponding to the specified name or the default object if name is a null pointer. The object can be used to compute checksums on the fly. The object's Recycle() method must be used to delete it.

Parameters
nameThe name of the checksum algorithm. If null, use the default one.
Returns
Success: A pointer to the object is returned. Failure: Zero if no corresponding object exists.

Reimplemented from XrdCks.

Definition at line 578 of file XrdCksManager.cc.

579{
580 csInfo *csIP = &csTab[0];
581
582// Return an object it at all possible
583//
584 if (name && !(csIP = Find(name))) return 0;
585 return csIP->Obj->New();
586}

◆ Set()

int XrdCksManager::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).

Implements XrdCks.

Reimplemented in XrdCksManOss.

Definition at line 602 of file XrdCksManager.cc.

603{
605 csInfo *csIP = &csTab[0];
606
607// Verify the incoming checksum for correctness
608//
609 if (csLast < 0 || (*Cks.Name && !(csIP = Find(Cks.Name)))) return -ENOTSUP;
610 if (Cks.Length != csIP->Len) return -EDOM;
611 memcpy(&xCS.Attr.Cks, &Cks, sizeof(xCS.Attr.Cks));
612
613// Set correct times if need be
614//
615 if (!myTime)
616 {time_t MTime;
617 int rc = ModTime(Pfn, MTime);
618 if (rc) return rc;
619 xCS.Attr.Cks.fmTime = static_cast<long long>(MTime);
620 xCS.Attr.Cks.csTime = static_cast<int>(time(0) - MTime);
621 }
622
623// Now set the checksum information in the extended attribute object
624//
625 return xCS.Set(Pfn);
626}

References XrdCksData::Length, ModTime(), XrdCksData::Name, and xCS.

Referenced by XrdCksManOss::Set().

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

◆ SetOpts()

void XrdCksManager::SetOpts ( int  opt)

Definition at line 632 of file XrdCksManager.cc.

632{CksOpts = opt;}

◆ Size()

int XrdCksManager::Size ( const char *  Name = 0)
virtual

Get the binary length of the checksum with the corresponding name.

Parameters
NameThe checksum algorithm name. If null, use the default name.
Returns
Success: checksum length. Failure: Zero if the checksum name does not exist.

Implements XrdCks.

Definition at line 592 of file XrdCksManager.cc.

593{
594 csInfo *iP = (Name != 0 ? Find(Name) : &csTab[0]);
595 return (iP != 0 ? iP->Len : 0);
596}

References Name().

+ Here is the call graph for this function:

◆ Ver()

int XrdCksManager::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).

Implements XrdCks.

Reimplemented in XrdCksManOss.

Definition at line 638 of file XrdCksManager.cc.

639{
641 time_t MTime;
642 csInfo *csIP = &csTab[0];
643 int rc;
644
645// Determine which checksum to get
646//
647 if (csLast < 0 || (*Cks.Name && !(csIP = Find(Cks.Name)))) return -ENOTSUP;
648 xCS.Attr.Cks.Set(csIP->Name);
649
650// Verify the file
651//
652 if ((rc = ModTime(Pfn, MTime))) return rc;
653
654// Retreive the attribute. Return upon fatal error.
655//
656 if ((rc = xCS.Get(Pfn)) < 0) return rc;
657
658// Verify the checksum and see if we need to recalculate it
659//
660 if (!rc || xCS.Attr.Cks.fmTime != MTime
661 || strcmp(xCS.Attr.Cks.Name, csIP->Name)
662 || xCS.Attr.Cks.Length != csIP->Len)
663 {strcpy(xCS.Attr.Cks.Name, Cks.Name);
664 if ((rc = Calc(Pfn, xCS.Attr.Cks, 1)) < 0) return rc;
665 }
666
667// Compare the checksums
668//
669 return (xCS.Attr.Cks.Length == Cks.Length
670 && !memcmp(xCS.Attr.Cks.Value, Cks.Value, csIP->Len));
671}

References Calc(), XrdCksData::Length, ModTime(), XrdCksData::Name, XrdCksData::Value, and xCS.

Referenced by XrdCksManOss::Ver().

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

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