xrootd
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
XrdCksManager Class Reference

#include <XrdCksManager.hh>

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

List of all members.

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 XrdCksCalc * Object (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)
 XrdCksManager (XrdSysError *erP, int iosz, XrdVersionInfo &vInfo, bool autoload=false)
virtual ~XrdCksManager ()
- Public Member Functions inherited from XrdCks
 XrdCks (XrdSysError *erP)
 Constructor.
virtual ~XrdCks ()
 Destructor.

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)
csInfo * Find (const char *Name)

Private Attributes

csInfo csTab [csMax]
int csLast
int segSize
XrdCksLoader * cksLoader
XrdVersionInfo & myVersion

Static Private Attributes

static const int csMax = 8

Additional Inherited Members

- Protected Attributes inherited from XrdCks
XrdSysError * eDest

Constructor & Destructor Documentation

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

References cksLoader, csLast, csTab, Name(), and segSize.

XrdCksManager::~XrdCksManager ( )
virtual

Member Function Documentation

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

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

Parameters:
PfnThe 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 Pfn's extended file attributes.
Returns:
Success: zero with Cks structure holding the checksum value. Failure: -errno (see significant error numbers below).

Implements XrdCks.

References XrdOucXAttr< T >::Attr, XrdCksXAttr::Cks, csLast, csTab, XrdCksData::csTime, XrdCksCalc::Final(), Find(), XrdCksData::fmTime, XrdCksManager::csInfo::Len, XrdCksData::Length, XrdCksData::Name, XrdCksManager::csInfo::Name, XrdCksCalc::New(), XrdCksManager::csInfo::Obj, XrdCksCalc::Recycle(), XrdCksData::Set(), XrdOucXAttr< T >::Set(), and XrdCksData::Value.

Referenced by Ver().

int XrdCksManager::Calc ( const char *  Pfn,
time_t &  MTime,
XrdCksCalc *  CksObj 
)
protectedvirtual
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.

References csLast, csMax, csTab, XrdCks::eDest, XrdSysError::Emsg(), XrdOucTokenizer::GetLine(), XrdOucTokenizer::GetToken(), Name(), XrdCksData::NameSize, XrdCksManager::csInfo::Parms, XrdCksManager::csInfo::Path, and Path.

Referenced by Init().

int XrdCksManager::Config ( const char *  cFN,
csInfo &  Info 
)
private
int XrdCksManager::Del ( const char *  Pfn,
XrdCksData &  Cks 
)
virtual

Delete the checksum from the Pfn's xattrs.

Returns:
Success: 0 Failure: -errno (see significant error numbers below).

Implements XrdCks.

References XrdOucXAttr< T >::Attr, XrdCksXAttr::Cks, XrdOucXAttr< T >::Del(), XrdCksData::Name, and XrdCksData::Set().

XrdCksManager::csInfo * XrdCksManager::Find ( const char *  Name)
private
int XrdCksManager::Get ( const char *  Pfn,
XrdCksData &  Cks 
)
virtual

Retreive the checksum from the Pfn'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:
PfnThe 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.

References XrdOucXAttr< T >::Attr, XrdCksXAttr::Cks, csLast, csTab, XrdCksData::fmTime, XrdOucXAttr< T >::Get(), XrdCksData::Length, ModTime(), XrdCksData::Name, Name(), XrdCksData::Set(), and XrdCksData::ValuSize.

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.

References Config(), csLast, csMax, csTab, XrdCks::eDest, XrdSysError::Emsg(), Name(), XrdCksManager::csInfo::Obj, Path, and XrdCksCalc::Type().

char * XrdCksManager::List ( const char *  Pfn,
char *  Buff,
int  Blen,
char  Sep = ' ' 
)
virtual

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

Parameters:
PfnThe name of the physical file whose checksum names are to be returned. When Pfn 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.

References csLast, csTab, XrdSysFAttr::Free(), XrdSysFAttr::List(), XrdSysFAttr::AList::Name, Name(), XrdSysFAttr::AList::Next, and XrdSysFAttr::AList::Nlen.

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

References stat().

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

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.

References csLast, and csTab.

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

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.

References csTab, Find(), XrdCksCalc::New(), and XrdCksManager::csInfo::Obj.

int XrdCksManager::Set ( const char *  Pfn,
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:
PfnThe 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.

References XrdOucXAttr< T >::Attr, XrdCksXAttr::Cks, csLast, csTab, XrdCksData::csTime, Find(), XrdCksData::fmTime, XrdCksManager::csInfo::Len, XrdCksData::Length, ModTime(), XrdCksData::Name, and XrdOucXAttr< T >::Set().

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

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

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

Implements XrdCks.

References csTab, Find(), and XrdCksManager::csInfo::Len.

int XrdCksManager::Ver ( const char *  Pfn,
XrdCksData &  Cks 
)
virtual

Retreive the checksum from the Pfn'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:
PfnThe physical name of the file to be verified.
CksSpecifies the checksum name and value.
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.

References XrdOucXAttr< T >::Attr, Calc(), XrdCksXAttr::Cks, csLast, csTab, Find(), XrdCksData::fmTime, XrdOucXAttr< T >::Get(), XrdCksManager::csInfo::Len, XrdCksData::Length, ModTime(), XrdCksData::Name, XrdCksManager::csInfo::Name, XrdCksData::Set(), and XrdCksData::Value.


Member Data Documentation

XrdCksLoader* XrdCksManager::cksLoader
private

Referenced by Find(), XrdCksManager(), and ~XrdCksManager().

int XrdCksManager::csLast
private
const int XrdCksManager::csMax = 8
staticprivate

Referenced by Config(), Find(), and Init().

csInfo XrdCksManager::csTab[csMax]
private
XrdVersionInfo& XrdCksManager::myVersion
private

Referenced by Config().

int XrdCksManager::segSize
private

Referenced by Calc(), and XrdCksManager().


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