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

#include <XrdCksManager.hh>

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

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

Constructor & Destructor Documentation

◆ XrdCksManager()

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

Definition at line 66 of file XrdCksManager.cc.

68 : XrdCks(erP), myVersion(vInfo)
69{
70
71// Get a dynamic loader if so wanted
72//
73 if (autoload) cksLoader = new XrdCksLoader(vInfo);
74 else cksLoader = 0;
75
76// Prefill the native digests we support
77//
78 strcpy(csTab[0].Name, "adler32");
79 strcpy(csTab[1].Name, "crc32");
80 strcpy(csTab[2].Name, "crc32c");
81 strcpy(csTab[3].Name, "md5");
82 csLast = 3;
83
84// Compute the i/o size
85//
86 if (rdsz <= 65536) segSize = 67108864;
87 else segSize = ((rdsz/65536) + (rdsz%65536 != 0)) * 65536;
88}
virtual const char * Name(int seqNum=0)
XrdCks(XrdSysError *erP)
Constructor.
Definition XrdCks.hh:272

References Name().

+ Here is the call graph for this function:

◆ ~XrdCksManager()

XrdCksManager::~XrdCksManager ( )
virtual

Definition at line 94 of file XrdCksManager.cc.

95{
96 int i;
97 for (i = 0; i <= csLast; i++)
98 {if (csTab[i].Obj && csTab[i].doDel) csTab[i].Obj->Recycle();
99 if (csTab[i].Path) free( csTab[i].Path);
100 if (csTab[i].Parms) free( csTab[i].Parms);
101 if (csTab[i].Plugin) delete csTab[i].Plugin;
102 }
103 if (cksLoader) delete cksLoader;
104}
XrdOucString Path
virtual void Recycle()
Recycle the checksum object as it is no longer needed. A default is given.
Definition XrdCksCalc.hh:95

References Path, and XrdCksCalc::Recycle().

+ Here is the call graph for this function:

Member Function Documentation

◆ Calc() [1/2]

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

Reimplemented in XrdCksManOss.

Definition at line 152 of file XrdCksManager.cc.

153{
154 class ioFD
155 {public:
156 int FD;
157 ioFD() : FD(-1) {}
158 ~ioFD() {if (FD >= 0) close(FD);}
159 } In;
160 struct stat Stat;
161 char *inBuff;
162 off_t Offset=0, fileSize;
163 size_t ioSize, calcSize;
164 int rc;
165
166// Open the input file
167//
168 if ((In.FD = open(Pfn, O_RDONLY)) < 0) return -errno;
169
170// Get the file characteristics
171//
172 if (fstat(In.FD, &Stat)) return -errno;
173 if (!(Stat.st_mode & S_IFREG)) return -EPERM;
174 calcSize = fileSize = Stat.st_size;
175 MTime = Stat.st_mtime;
176
177// We now compute checksum 64MB at a time using mmap I/O
178//
179 ioSize = (fileSize < (off_t)segSize ? fileSize : segSize); rc = 0;
180 while(calcSize)
181 {if ((inBuff = (char *)mmap(0, ioSize, PROT_READ,
182#if defined(__FreeBSD__)
183 MAP_RESERVED0040|MAP_PRIVATE, In.FD, Offset)) == MAP_FAILED)
184#elif defined(__GNU__)
185 MAP_PRIVATE, In.FD, Offset)) == MAP_FAILED)
186#else
187 MAP_NORESERVE|MAP_PRIVATE, In.FD, Offset)) == MAP_FAILED)
188#endif
189 {rc = errno; eDest->Emsg("Cks", rc, "memory map", Pfn); break;}
190 madvise(inBuff, ioSize, MADV_SEQUENTIAL);
191 csP->Update(inBuff, ioSize);
192 calcSize -= ioSize; Offset += ioSize;
193 if (munmap(inBuff, ioSize) < 0)
194 {rc = errno; eDest->Emsg("Cks",rc,"unmap memory for",Pfn); break;}
195 if (calcSize < (size_t)segSize) ioSize = calcSize;
196 }
197
198// Return if we failed
199//
200 if (calcSize) return (rc ? -rc : -EIO);
201 return 0;
202}
struct stat Stat
Definition XrdCks.cc:49
#define close(a)
Definition XrdPosix.hh:43
#define fstat(a, b)
Definition XrdPosix.hh:57
#define open
Definition XrdPosix.hh:71
#define stat(a, b)
Definition XrdPosix.hh:96
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 110 of file XrdCksManager.cc.

111{
112 XrdCksCalc *csP;
113 csInfo *csIP = &csTab[0];
114 time_t MTime;
115 int rc;
116
117// Determine which checksum to get
118//
119 if (csLast < 0) return -ENOTSUP;
120 if (!(*Cks.Name)) Cks.Set(csIP->Name);
121 else if (!(csIP = Find(Cks.Name))) return -ENOTSUP;
122
123// If we need not set the checksum then see if we can get it from the
124// extended attributes.
125
126// Obtain a new checksum object
127//
128 if (!(csP = csIP->Obj->New())) return -ENOMEM;
129
130// Use the calculator to get and possibly set the checksum
131//
132 if (!(rc = Calc(Pfn, MTime, csP)))
133 {memcpy(Cks.Value, csP->Final(), csIP->Len);
134 Cks.fmTime = static_cast<long long>(MTime);
135 Cks.csTime = static_cast<int>(time(0) - MTime);
136 Cks.Length = csIP->Len;
137 csP->Recycle();
138 if (doSet)
140 memcpy(&xCS.Attr.Cks, &Cks, sizeof(xCS.Attr.Cks));
141 if ((rc = xCS.Set(Pfn))) return -rc;
142 }
143 }
144
145// All done
146//
147 return rc;
148}
XrdOucXAttr< XrdCksXAttr > xCS
Definition XrdCks.cc:48
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 Calc(), XrdCksManOss::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 216 of file XrdCksManager.cc.

217{
218 XrdOucTokenizer Cfg(Line);
219 char *val, *path = 0, name[XrdCksData::NameSize], *parms;
220 int i;
221
222// Get the the checksum name
223//
224 Cfg.GetLine();
225 if (!(val = Cfg.GetToken()) || !val[0])
226 {eDest->Emsg("Config", "checksum name not specified"); return 1;}
227 if (int(strlen(val)) >= XrdCksData::NameSize)
228 {eDest->Emsg("Config", "checksum name too long"); return 1;}
229 strcpy(name, val); XrdOucUtils::toLower(name);
230
231// Get the path and optional parameters
232//
233 val = Cfg.GetToken(&parms);
234 if (val && val[0]) path = strdup(val);
235 else {eDest->Emsg("Config","library path missing for ckslib digest",name);
236 return 1;
237 }
238
239// Check if this replaces an existing checksum
240//
241 for (i = 0; i < csMax; i++)
242 if (!(*csTab[i].Name) || !strcmp(csTab[i].Name, name)) break;
243
244// See if we can insert a new checksum (or replace one)
245//
246 if (i >= csMax)
247 {eDest->Emsg("Config", "too many checksums specified");
248 if (path) free(path);
249 return 1;
250 } else if (!(*csTab[i].Name)) csLast = i;
251
252// Insert the new checksum
253//
254 strcpy(csTab[i].Name, name);
255 if (csTab[i].Path) free(csTab[i].Path);
256 csTab[i].Path = path;
257 if (csTab[i].Parms) free(csTab[i].Parms);
258 csTab[i].Parms = (parms && *parms ? strdup(parms) : 0);
259
260// All done
261//
262 return 0;
263}
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 437 of file XrdCksManager.cc.

438{
440
441// Set the checksum name
442//
443 xCS.Attr.Cks.Set(Cks.Name);
444
445// Delete the attribute and return the result
446//
447 return xCS.Del(Pfn);
448}

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 454 of file XrdCksManager.cc.

455{
457 time_t MTime;
458 int rc, nFault;
459
460// Determine which checksum to get (we will accept unsupported ones as well)
461//
462 if (csLast < 0) return -ENOTSUP;
463 if (!*Cks.Name) Cks.Set(csTab[0].Name);
464 if (!xCS.Attr.Cks.Set(Cks.Name)) return -ENOTSUP;
465
466// Retreive the attribute
467//
468 if ((rc = xCS.Get(Pfn)) <= 0) return (rc && rc != -ENOATTR ? rc : -ESRCH);
469
470// Mark state of the name and copy the attribute over
471//
472 nFault = strcmp(xCS.Attr.Cks.Name, Cks.Name);
473 Cks = xCS.Attr.Cks;
474
475// Verify the file
476//
477 if ((rc = ModTime(Pfn, MTime))) return rc;
478
479// Return result
480//
481 return (Cks.fmTime != MTime || nFault
482 || Cks.Length > XrdCksData::ValuSize || Cks.Length <= 0
483 ? -ESTALE : int(Cks.Length));
484}
#define ENOATTR
static const int ValuSize
Definition XrdCksData.hh:42
virtual int ModTime(const char *Pfn, time_t &MTime)

References ENOATTR, XrdCksData::Length, ModTime(), XrdCksData::Name, 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 269 of file XrdCksManager.cc.

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

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

+ 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 490 of file XrdCksManager.cc.

491{
492 static const char *vPfx = "XrdCks.";
493 static const int vPln = strlen(vPfx);
494 XrdSysFAttr::AList *vP, *axP = 0;
495 char *bP = Buff;
496 int i, n;
497
498// Verify that the buffer is large enough
499//
500 if (Blen < 2) return 0;
501
502// Check if the default list is wanted
503//
504 if (!Pfn)
505 {if (csLast < 0) return 0;
506 i = 0;
507 while(i <= csLast && Blen > 1)
508 {n = strlen(csTab[i].Name);
509 if (n >= Blen) break;
510 if (bP != Buff) *bP++ = Sep;
511 strcpy(bP, csTab[i].Name); bP += n; *bP = 0;
512 }
513 return (bP == Buff ? 0 : Buff);
514 }
515
516// Get a list of attributes for this file
517//
518 if (XrdSysFAttr::Xat->List(&axP, Pfn) < 0 || !axP) return 0;
519
520// Go through the list extracting what we are looking for
521//
522 vP = axP;
523 while(vP)
524 {if (vP->Nlen > vPln && !strncmp(vP->Name, vPfx, vPln))
525 {n = vP->Nlen - vPln;
526 if (n >= Blen) break;
527 if (bP != Buff) *bP++ = Sep;
528 strcpy(bP, vP->Name + vPln); bP += n; *bP = 0;
529 }
530 vP = vP->Next;
531 }
532
533// All done
534//
536 return (bP == Buff ? 0 : Buff);
537}
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 List(), and XrdCksManOss::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 543 of file XrdCksManager.cc.

544{
545 struct stat Stat;
546
547 if (stat(Pfn, &Stat)) return -errno;
548
549 MTime = Stat.st_mtime;
550 return 0;
551}

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

558{
559
560 return (seqNum < 0 || seqNum > csLast ? 0 : csTab[seqNum].Name);
561}

References Name().

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

+ Here is the call graph for this function:
+ 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 567 of file XrdCksManager.cc.

568{
569 csInfo *csIP = &csTab[0];
570
571// Return an object it at all possible
572//
573 if (name && !(csIP = Find(name))) return 0;
574 return csIP->Obj->New();
575}
virtual XrdCksCalc * New()=0

References XrdCksCalc::New().

+ Here is the call graph for this function:

◆ 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 591 of file XrdCksManager.cc.

592{
594 csInfo *csIP = &csTab[0];
595
596// Verify the incoming checksum for correctness
597//
598 if (csLast < 0 || (*Cks.Name && !(csIP = Find(Cks.Name)))) return -ENOTSUP;
599 if (Cks.Length != csIP->Len) return -EDOM;
600 memcpy(&xCS.Attr.Cks, &Cks, sizeof(xCS.Attr.Cks));
601
602// Set correct times if need be
603//
604 if (!myTime)
605 {time_t MTime;
606 int rc = ModTime(Pfn, MTime);
607 if (rc) return rc;
608 xCS.Attr.Cks.fmTime = static_cast<long long>(MTime);
609 xCS.Attr.Cks.csTime = static_cast<int>(time(0) - MTime);
610 }
611
612// Now set the checksum information in the extended attribute object
613//
614 return xCS.Set(Pfn);
615}

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:

◆ 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 581 of file XrdCksManager.cc.

582{
583 csInfo *iP = (Name != 0 ? Find(Name) : &csTab[0]);
584 return (iP != 0 ? iP->Len : 0);
585}

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 621 of file XrdCksManager.cc.

622{
624 time_t MTime;
625 csInfo *csIP = &csTab[0];
626 int rc;
627
628// Determine which checksum to get
629//
630 if (csLast < 0 || (*Cks.Name && !(csIP = Find(Cks.Name)))) return -ENOTSUP;
631 xCS.Attr.Cks.Set(csIP->Name);
632
633// Verify the file
634//
635 if ((rc = ModTime(Pfn, MTime))) return rc;
636
637// Retreive the attribute. Return upon fatal error.
638//
639 if ((rc = xCS.Get(Pfn)) < 0) return rc;
640
641// Verify the checksum and see if we need to recalculate it
642//
643 if (!rc || xCS.Attr.Cks.fmTime != MTime
644 || strcmp(xCS.Attr.Cks.Name, csIP->Name)
645 || xCS.Attr.Cks.Length != csIP->Len)
646 {strcpy(xCS.Attr.Cks.Name, Cks.Name);
647 if ((rc = Calc(Pfn, xCS.Attr.Cks, 1)) < 0) return rc;
648 }
649
650// Compare the checksums
651//
652 return (xCS.Attr.Cks.Length == Cks.Length
653 && !memcmp(xCS.Attr.Cks.Value, Cks.Value, csIP->Len));
654}

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: