xrootd
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
XrdCksLoader Class Reference

#include <XrdCksLoad.hh>

Inheritance diagram for XrdCksLoader:
Inheritance graph
[legend]
Collaboration diagram for XrdCksLoader:
Collaboration graph
[legend]

Classes

struct  csInfo
 

Public Member Functions

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 Size (const char *Name=0)
 
virtual int Set (const char *Pfn, XrdCksData &Cks, int myTime=0)
 
virtual int Ver (const char *Pfn, XrdCksData &Cks)
 
 XrdCksLoader (XrdSysError *erP, int iosz, XrdVersionInfo *vInfo)
 
virtual ~XrdCksLoader ()
 
XrdCksCalcLoad (const char *csName, const char *csParms=0, char *eBuff=0, int eBlen=0, bool orig=false)
 
 XrdCksLoader (XrdVersionInfo &vInfo, const char *libPath=0)
 
 ~XrdCksLoader ()
 Destructor. More...
 
- Public Member Functions inherited from XrdCks
virtual int Calc (const char *Xfn, XrdCksData &Cks, XrdCksPCB *pcbP, int doSet=1)
 
virtual int Ver (const char *Xfn, XrdCksData &Cks, XrdCksPCB *pcbP)
 
 XrdCks (XrdSysError *erP)
 Constructor. More...
 
virtual ~XrdCks ()
 Destructor. More...
 

Protected Member Functions

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

Private Member Functions

int Config (const char *cFN, csInfo &Info)
 
csInfoFind (const char *Name)
 
csInfoFind (const char *Name)
 

Private Attributes

csInfo csTab [csMax]
 
int csLast
 
int segSize
 
XrdVersionInfo * myVersion
 
char * verMsg
 
XrdVersionInfo * urVersion
 
char * ldPath
 

Static Private Attributes

static const int csMax = 4
 

Additional Inherited Members

- Protected Attributes inherited from XrdCks
XrdSysErroreDest
 

Detailed Description

This class defines the checksum loader interface. It is intended to be used by xrootd clients to obtain an instance of a checksum calculation object. This object may be builtin or may come from a shared library.

Constructor & Destructor Documentation

◆ XrdCksLoader() [1/2]

XrdCksLoader::XrdCksLoader ( XrdSysError erP,
int  iosz,
XrdVersionInfo *  vInfo 
)

◆ ~XrdCksLoader() [1/2]

virtual XrdCksLoader::~XrdCksLoader ( )
virtual

◆ XrdCksLoader() [2/2]

XrdCksLoader::XrdCksLoader ( XrdVersionInfo &  vInfo,
const char *  libPath = 0 
)

Constructor

Parameters
vInfoIs the reference to the version information corresponding to the xrootd version you compiled with. You define this information using the XrdVERSIONINFODEF macro defined in XrdVersion.hh. You must supply your version information and it must be compatible with the loader and any shared libraries that it might load on your behalf.
libPathThe path where dynamic checksum calculators are to be found and dynamically loaded, if need be. If libPath is nil then the default loader search order is used. The name of the shared library must follow the naming convention "libXrdCksCalc<csName>.so" where <csName> is the checksum name. So, an sha256 checksum would try to load libXrdCksCalcsha256.so shared library.

◆ ~XrdCksLoader() [2/2]

XrdCksLoader::~XrdCksLoader ( )

Destructor.

Member Function Documentation

◆ Calc() [1/2]

virtual int XrdCksLoader::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.

◆ Calc() [2/2]

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

◆ Config() [1/2]

virtual int XrdCksLoader::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.

◆ Config() [2/2]

int XrdCksLoader::Config ( const char *  cFN,
csInfo Info 
)
private

◆ Del()

virtual int XrdCksLoader::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.

◆ Find() [1/2]

csInfo* XrdCksLoader::Find ( const char *  Name)
private

◆ Find() [2/2]

csInfo* XrdCksLoader::Find ( const char *  Name)
private

◆ Get()

virtual int XrdCksLoader::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.

◆ Init()

virtual int XrdCksLoader::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.

◆ List()

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

◆ Load()

XrdCksCalc* XrdCksLoader::Load ( const char *  csName,
const char *  csParms = 0,
char *  eBuff = 0,
int  eBlen = 0,
bool  orig = false 
)

Get a new XrdCksCalc object that can calculate the checksum corresponding to the specified name. The object can be used to compute checksums on the fly. The object's Recycle() method must be used to delete it. The adler32, crc32, and md5 checksums are natively supported. Up to five more checksum algorithms can be loaded from shared libraries.

Parameters
csNmeThe name of the checksum algorithm (e.g. md5).
csParmsAny parameters that might be needed by the checksum algorithm should it be loaded from a shared library.
eBuffOptional pointer to a buffer to receive the reason for a load failure as a null terminated string.
eBlenThe length of the buffer.
origReturns the original object not a new instance of it. This is usually used by CksManager during an autoload.
Returns
Success: A pointer to a new checksum calculation object. Failure: Zero if the corresponding checksum object could not be loaded. If eBuff was supplied, it holds the reason.

◆ ModTime()

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

◆ Name()

virtual const char* XrdCksLoader::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.

◆ Object()

virtual XrdCksCalc* XrdCksLoader::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.

◆ Set()

virtual int XrdCksLoader::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.

◆ Size()

virtual int XrdCksLoader::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.

◆ Ver()

virtual int XrdCksLoader::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.

Member Data Documentation

◆ csLast

int XrdCksLoader::csLast
private

◆ csMax

static const int XrdCksLoader::csMax = 4
staticprivate

◆ csTab

csInfo XrdCksLoader::csTab
private

◆ ldPath

char* XrdCksLoader::ldPath
private

◆ myVersion

XrdVersionInfo* XrdCksLoader::myVersion
private

◆ segSize

int XrdCksLoader::segSize
private

◆ urVersion

XrdVersionInfo* XrdCksLoader::urVersion
private

◆ verMsg

char* XrdCksLoader::verMsg
private

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