XRootD
XrdOfsConfigPI Class Reference

#include <XrdOfsConfigPI.hh>

+ Collaboration diagram for XrdOfsConfigPI:

Public Types

enum  TheLib {
  theAtrLib = 0x0100 ,
  theAutLib = 0x0201 ,
  theCksLib = 0x0402 ,
  theCmsLib = 0x0803 ,
  theCtlLib = 0x1004 ,
  theOssLib = 0x2005 ,
  thePrpLib = 0x4006 ,
  allXXXLib = 0x7f07 ,
  maxXXXLib = 0x0007 ,
  libIXMask = 0x00ff
}
 

Public Member Functions

 ~XrdOfsConfigPI ()
 Destructor. More...
 
bool ConfigCtl (XrdCmsClient *cmscP, XrdOucEnv *envP=0)
 
bool Configure (XrdCmsClient *cmscP, XrdOucEnv *envP)
 
void Default (TheLib what, const char *lpath, const char *lparm=0)
 
void DefaultCS (const char *alg)
 
void Display ()
 Display configuration settings. More...
 
bool LclCks ()
 
bool Load (int what, XrdOucEnv *envP=0)
 
bool OssCks ()
 
bool Parse (TheLib what)
 
bool Plugin (XrdAccAuthorize *&piP)
 Get Authorization plugin. More...
 
bool Plugin (XrdCks *&pip)
 Get Checksum manager plugin. More...
 
bool Plugin (XrdCmsClient_t &piP)
 Get Cms client object generator. More...
 
bool Plugin (XrdOfsFSctl_PI *&piP)
 Get Ctl plugin. More...
 
bool Plugin (XrdOfsPrepare *&piP)
 Get Prp plugin (prepare) More...
 
bool Plugin (XrdOss *&piP)
 Get Oss plugin. More...
 
bool PrepAuth ()
 
bool Push (TheLib what, const char *plugP, const char *parmP=0)
 
void SetCksRdSz (int rdsz)
 

Static Public Member Functions

static XrdOfsConfigPINew (const char *cfn, XrdOucStream *cfgP, XrdSysError *errP, XrdVersionInfo *verP=0, XrdSfsFileSystem *sfsP=0)
 

Detailed Description

The XrdOfsConfigPI is a helper class to handle ofs plugins. It is a safe class in that the invoker of this class may reside in a different shared library even though the implementation of this class may change. This is because nothing is this class depends on the invoker knowing the layout of thie class members nor the actual size of this class. Note that you must use the static New() method to obtain an instance of this class.

Definition at line 60 of file XrdOfsConfigPI.hh.

Member Enumeration Documentation

◆ TheLib

The following enum is passed either alone or in combination to various methods to indicate what plugin is being referenced.

Enumerator
theAtrLib 

Extended attribute plugin.

theAutLib 

Authorization plugin.

theCksLib 

Checksum manager plugin.

theCmsLib 

Cms client plugin.

theCtlLib 

Ctl plugin (FSCtl)

theOssLib 

Oss plugin.

thePrpLib 

Prp plugin (prepare)

allXXXLib 

All plugins (Load() only)

maxXXXLib 

Maximum different plugins.

libIXMask 

Definition at line 69 of file XrdOfsConfigPI.hh.

69  {theAtrLib = 0x0100,
70  theAutLib = 0x0201,
71  theCksLib = 0x0402,
72  theCmsLib = 0x0803,
73  theCtlLib = 0x1004,
74  theOssLib = 0x2005,
75  thePrpLib = 0x4006,
76  allXXXLib = 0x7f07,
77  maxXXXLib = 0x0007,
78  libIXMask = 0x00ff
79  };
@ theOssLib
Oss plugin.
@ allXXXLib
All plugins (Load() only)
@ maxXXXLib
Maximum different plugins.
@ theCksLib
Checksum manager plugin.
@ thePrpLib
Prp plugin (prepare)
@ theCmsLib
Cms client plugin.
@ theAtrLib
Extended attribute plugin.
@ theAutLib
Authorization plugin.
@ theCtlLib
Ctl plugin (FSCtl)

Constructor & Destructor Documentation

◆ ~XrdOfsConfigPI()

XrdOfsConfigPI::~XrdOfsConfigPI ( )

Destructor.

Definition at line 129 of file XrdOfsConfigPI.cc.

130 {
131  if (CksConfig) delete CksConfig;
132  if (CksAlg) free(CksAlg);
133 }

Member Function Documentation

◆ ConfigCtl()

bool XrdOfsConfigPI::ConfigCtl ( XrdCmsClient cmscP,
XrdOucEnv envP = 0 
)

Configure the fsctl plugin.

Parameters
cmscPPointer to the cms plugin.
envPPointer to the environment.

Definition at line 297 of file XrdOfsConfigPI.cc.

298 {
299  struct XrdOfsFSctl_PI::Plugins thePI = {autPI, cmsP, ossPI, sfsPI};
300 
301 // If there is no fsctl plugin, we are done.
302 //
303  if (!ctlPI) return true;
304 
305 // Initialize all of the plugin in FIFO order.
306 //
307  if (!ctlPI->Configure(ConfigFN, LP[PIX(theCtlLib)].parms, envP, thePI))
308  return false;
309 
310  int n = ctlVec.size();
311 
312  for (int i = 0; i < n; i++)
313  {if (!ctlVec[i].ctlPI->Configure(ConfigFN,ctlVec[i].parms,envP,thePI))
314  return false;
315  }
316  return true;
317 }
#define PIX(x)
XrdOss * ossPI
-> Oss plugin
XrdAccAuthorize * autPI
-> Authorization plugin
virtual bool Configure(const char *CfgFN, const char *Parms, XrdOucEnv *envP, const Plugins &plugs)
XrdSfsFileSystem * sfsPI
-> Sfs plugin (a.k.a. ofs)
The Plugins struct is used to pass plugin pointers to configure.
XrdOucEnv * envP
Definition: XrdPss.cc:109

References XrdOfsFSctl_PI::Plugins::autPI, XrdOfsFSctl_PI::Configure(), XrdProxy::envP, XrdOfsFSctl_PI::Plugins::ossPI, PIX, XrdOfsFSctl_PI::Plugins::sfsPI, and theCtlLib.

Referenced by XrdOfs::Configure().

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

◆ Configure()

bool XrdOfsConfigPI::Configure ( XrdCmsClient cmscP,
XrdOucEnv envP 
)

Configure the cms client.

Parameters
cmscPPointer to the cms client instance.
envPPointer to the environment normally passed to the cms client istance.
Returns
true upon success and false upon failure.

Definition at line 288 of file XrdOfsConfigPI.cc.

289 {
290  return 0 != cmscP->Configure(ConfigFN, LP[PIX(theCmsLib)].parms, envP);
291 }
virtual int Configure(const char *cfn, char *Parms, XrdOucEnv *EnvInfo)=0

References XrdCmsClient::Configure(), XrdProxy::envP, PIX, and theCmsLib.

+ Here is the call graph for this function:

◆ Default()

void XrdOfsConfigPI::Default ( XrdOfsConfigPI::TheLib  what,
const char *  lpath,
const char *  lparm = 0 
)

Set the default plugin path and parms. This method may be called before or after the configuration file is parsed.

Parameters
whatThe enum that specified which plugin is being set.
lpathThe plugin library path
lparmThe plugin parameters (0 if none)

Definition at line 323 of file XrdOfsConfigPI.cc.

325 {
326  int n = PIX(what);
327 
328  if (n < maxXXXLib && !RepLib(what, lpath, (lparm ? lparm : nullParms)))
329  defLib[n] = true;
330 }

References maxXXXLib, and PIX.

Referenced by XrdOfs::Configure().

+ Here is the caller graph for this function:

◆ DefaultCS()

void XrdOfsConfigPI::DefaultCS ( const char *  alg)

Set the default checksum algorithm. This method must be called before Load() is called.

Parameters
algPointer to the default algorithm name, it is duplicated.

Definition at line 336 of file XrdOfsConfigPI.cc.

337 {
338  if (CksAlg) free(CksAlg);
339  CksAlg = strdup(alg);
340  XrdOucUtils::toLower(CksAlg);
341 }
static void toLower(char *str)

References XrdOucUtils::toLower().

+ Here is the call graph for this function:

◆ Display()

void XrdOfsConfigPI::Display ( )

Display configuration settings.

Definition at line 347 of file XrdOfsConfigPI.cc.

348 {
349  xxxLP *lP;
350  char *oP, buff[4096];
351  const char *theLib;
352  int n, aI = PIX(theAtrLib), oI = PIX(theOssLib);
353 
354 // Display what we have
355 //
356  for (int i = 0; i < maxXXXLib; i++)
357  {oP = LP[i].opts;
358  if (i != aI) lP = &LP[i];
359  else if (ossXAttr) {lP = &LP[oI]; oP = 0;}
360  else lP = &LP[i];
361  n = ALP[i].size();
362  if (n || lP->lib)
363  {theLib = (lP->lib ? lP->lib : "default");
364  snprintf(buff, sizeof(buff), "ofs.%s %s%s %s", drctv[i],
365  (oP ? oP : ""), theLib, (lP->parms ? lP->parms : ""));
366  Eroute->Say(" ", buff);
367  for (int k = 0; k < n; k++)
368  {lP = &(ALP[i][k]);
369  snprintf(buff, sizeof(buff), "ofs.%s ++ %s %s", drctv[i],
370  lP->lib, (lP->parms ? lP->parms : ""));
371  Eroute->Say(" ", buff);
372  }
373  }
374 
375  }
376 }
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
Definition: XrdSysError.cc:141

References maxXXXLib, PIX, XrdSysError::Say(), theAtrLib, and theOssLib.

Referenced by XrdOfs::Config_Display().

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

◆ LclCks()

bool XrdOfsConfigPI::LclCks ( )
inline

Check if the checksum plugin runs on tghe local node irrespective of type.

Returns
True if the plugin runs on the local node, false otherwise.

Definition at line 168 of file XrdOfsConfigPI.hh.

168 {return cksLcl;}

Referenced by XrdOfs::Configure().

+ Here is the caller graph for this function:

◆ Load()

bool XrdOfsConfigPI::Load ( int  what,
XrdOucEnv envP = 0 
)

Load required plugins. This is a one time call!

Parameters
whatA "or" combination of TheLib enums specifying which plugins need to be loaded.
envPPointer to the environment normally passed to the default oss plugin at load time.
Returns
true upon success and false upon failure.

Definition at line 382 of file XrdOfsConfigPI.cc.

383 {
385  extern XrdOss *XrdOssGetSS(XrdSysLogger *, const char *, const char *,
386  const char *, XrdOucEnv *, XrdVersionInfo &);
387  bool aOK;
388 
389 // Check if load was already called as we can only try once
390 //
391  if (Loaded) return LoadOK;
392  Loaded = true;
393 
394 // Load the osslib first if so wanted. Note that the default osslib always
395 // wants osscksio unless it was stealthly overriden.
396 //
397  if (DO_LOAD(theOssLib))
398  {const char *ossLib = LP[PIX(theOssLib)].lib;
399  if (!ossLib && !ossCksio) ossCksio = 1;
400  if (!(ossPI = XrdOssGetSS(Eroute->logger(), ConfigFN, ossLib,
401  LP[PIX(theOssLib)].parms, envP, *urVer))) return false;
402  if (ossLib && envP && (ossLib = envP->Get("oss.lib")))
403  {free(LP[PIX(theOssLib)].lib);
404  LP[PIX(theOssLib)].lib = strdup(ossLib);
405  }
406  if (!AddLibOss(envP)) return false;
407  }
408 
409 // Now setup the extended attribute plugin if so desired
410 //
411  if (DO_LOAD(theAtrLib))
412  { if (ossXAttr && LP[PIX(theOssLib)].lib)
413  aOK = SetupAttr(theOssLib, envP);
414  else if (LP[PIX(theAtrLib)].lib)
415  aOK = SetupAttr(theAtrLib, envP);
416  else {XrdSysXAttr *theObj = XrdSysXAttrActive;
417  if (!AddLibAtr(envP, theObj)) aOK = false;
418  else {if (theObj != XrdSysXAttrActive)
419  XrdSysFAttr::SetPlugin(theObj, true);
420  aOK = true;
421  }
422  }
423  if (!aOK) return false;
424  }
425  XrdSysFAttr::Xat->SetMsgRoute(Eroute);
426 
427 // Setup authorization if we need to
428 //
429  if (DO_LOAD(theAutLib) && !SetupAuth(envP)) return false;
430 
431 // Setup checksumming if we need to
432 //
433  if (DO_LOAD(theCksLib))
434  {if (!CksConfig)
435  {Eroute->Emsg("Config", "Unable to load checksum manager; "
436  "incompatible versions.");
437  return false;
438  }
439  cksPI = CksConfig->Configure(CksAlg, CksRdsz,
440  (ossCksio > 0 ? ossPI : 0), envP);
441  if (!cksPI) return false;
442  }
443 
444 // Setup the cms if we need to
445 //
446  if (DO_LOAD(theCmsLib) && !SetupCms()) return false;
447 
448 // Setup the fsctl plugin if need be
449 //
450  if (DO_LOAD(theCtlLib) && !SetupCtl(envP)) return false;
451 
452 // Setup the prepare plugin if need be
453 //
454  if (DO_LOAD(thePrpLib) && !SetupPrp(envP)) return false;
455 
456 // All done
457 //
458  LoadOK = true;
459  return true;
460 }
#define DO_LOAD(x)
XrdOss * XrdOssGetSS(XrdSysLogger *Logger, const char *config_fn, const char *OssLib, const char *OssParms, XrdOucEnv *envP, XrdVersionInfo &urVer)
Definition: XrdOssApi.cc:98
XrdSysXAttr * XrdSysXAttrActive
Definition: XrdSysFAttr.cc:61
XrdCks * Configure(const char *dfltCalc=0, int rdsz=0, XrdOss *ossP=0, XrdOucEnv *envP=0)
char * Get(const char *varname)
Definition: XrdOucEnv.hh:69
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
XrdSysLogger * logger(XrdSysLogger *lp=0)
Definition: XrdSysError.hh:141
static void SetPlugin(XrdSysXAttr *xaP, bool push=false)
Definition: XrdSysFAttr.cc:164
static XrdSysXAttr * Xat
Definition: XrdSysFAttr.hh:51
virtual XrdSysError * SetMsgRoute(XrdSysError *errP)
Definition: XrdSysXAttr.cc:111

References XrdCksConfig::Configure(), DO_LOAD, XrdSysError::Emsg(), XrdProxy::envP, XrdOucEnv::Get(), XrdSysError::logger(), XrdOfsFSctl_PI::Plugins::ossPI, PIX, XrdSysXAttr::SetMsgRoute(), XrdSysFAttr::SetPlugin(), theAtrLib, theAutLib, theCksLib, theCmsLib, theCtlLib, theOssLib, thePrpLib, XrdSysFAttr::Xat, XrdOssGetSS(), and XrdSysXAttrActive.

Referenced by XrdPfc::Cache::Config(), XrdFrmConfig::Configure(), XrdOfs::Configure(), and main().

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

◆ New()

XrdOfsConfigPI * XrdOfsConfigPI::New ( const char *  cfn,
XrdOucStream cfgP,
XrdSysError errP,
XrdVersionInfo *  verP = 0,
XrdSfsFileSystem sfsP = 0 
)
static

Obtain an instance of this class (note that the constructor is private).

Parameters
cfnPointer to the configuration file name.
cfgPPointer to the stream that reads the configuration file.
errPPointer to the error message object that routes messages.
verPPointer to the version information of the object creator. If zero, the version information of this object is used. Generally, if the creator resides in a different shared library, the creator's version should be supplied.
sfsPPointer to file system doing the loading, if applicable.
Returns
Pointer to an instance of this class. If the pointer is nil, either the caller's version is incompatible or there is not enough memory (unlikely).

Definition at line 466 of file XrdOfsConfigPI.cc.

469 {
470 // Handle caller's version if so indicated
471 //
472  if (verP && !XrdSysPlugin::VerCmp(*verP, XrdVERSIONINFOVAR(XrdOfs)))
473  return 0;
474 
475 // Return an actual instance
476 //
477  return new XrdOfsConfigPI(cfn, cfgP, errP, sfsP, verP);
478 }
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)

References XrdSysPlugin::VerCmp(), and XrdOfsFSctl_PI::XrdOfsConfigPI.

Referenced by XrdPfc::Cache::Config(), XrdOfs::Configure(), and main().

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

◆ OssCks()

bool XrdOfsConfigPI::OssCks ( )

Check if the checksum plugin uses the oss plugin.

Returns
True if the plugin uses the oss plugin, false otherwise.

Definition at line 484 of file XrdOfsConfigPI.cc.

484 {return ossCksio > 0;}

Referenced by XrdOfs::Configure().

+ Here is the caller graph for this function:

◆ Parse()

bool XrdOfsConfigPI::Parse ( TheLib  what)

Parse a plugin directive.

Parameters
whatThe enum specifying which plugin directive to parse.
Returns
true upon success and false upon failure.

Definition at line 490 of file XrdOfsConfigPI.cc.

491 {
492  char *val;
493 
494 // Fan out based on what was specified
495 //
496  switch(what)
497  {case theAtrLib: return ParseAtrLib();
498  break;
499  case theAutLib: break;
500  case theCksLib: if (CksConfig)
501  {int libType;
502  if (CksConfig->ParseLib(*Config, libType))
503  return false;
504  if (libType) cksLcl = libType == 1;
505  RepLib(theCksLib, CksConfig->ManLib(), nullParms, false);
506  return true;
507  }
508  Eroute->Emsg("Config", "Checksum version error!");
509  return false;
510  break;
511  case theCmsLib: break;
512  break;
513  case theCtlLib: break;
514  break;
515  case theOssLib: return ParseOssLib();
516  break;
517  case thePrpLib: return ParsePrpLib();
518  break;
519  default: Eroute->Emsg("Config", "Invalid plugin Parse() call");
520  return false;
521  break;
522  }
523 
524 // Get the path
525 //
526  if (!(val = Config->GetWord()) || !val[0])
527  {Eroute->Emsg("Config", drctv[PIX(what)],"not specified"); return false;}
528 
529 // If this may be a pushable library, then see if the pushable tag is present
530 //
531  if (!strcmp("++", val))
532  {if (pushOK[PIX(what)]) return AddLib(what);
533  Eroute->Emsg("Config", "'++' option not supported for",
534  drctv[PIX(what)], "directive.");
535  return false;
536  }
537 
538 // Set the lib and parameters
539 //
540  return RepLib(what, val);
541 }
const char * ManLib()
Definition: XrdCksConfig.hh:55
int ParseLib(XrdOucStream &Config, int &libType)
char * GetWord(int lowcase=0)

References XrdCms::Config, XrdSysError::Emsg(), XrdCksConfig::ManLib(), XrdCksConfig::ParseLib(), PIX, theAtrLib, theAutLib, theCksLib, theCmsLib, theCtlLib, theOssLib, and thePrpLib.

Referenced by XrdPfc::Cache::Config().

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

◆ Plugin() [1/6]

bool XrdOfsConfigPI::Plugin ( XrdAccAuthorize *&  piP)

Get Authorization plugin.

Obtain a pointer to a plugin handled by this class.

Parameters
piPRefererence to the pointer to receive the plugin pointer.
Returns
true Plugin pointer has been returned.
false The plugin was not oaded and the pointer is nil.

Definition at line 694 of file XrdOfsConfigPI.cc.

695 { return (piP = autPI) != 0;}

References XrdOfsFSctl_PI::Plugins::autPI.

Referenced by XrdPfc::Cache::Config(), XrdFrmConfig::Configure(), XrdOfs::Configure(), and main().

+ Here is the caller graph for this function:

◆ Plugin() [2/6]

bool XrdOfsConfigPI::Plugin ( XrdCks *&  pip)

Get Checksum manager plugin.

Definition at line 697 of file XrdOfsConfigPI.cc.

698 { return (piP = cksPI) != 0;}

◆ Plugin() [3/6]

bool XrdOfsConfigPI::Plugin ( XrdCmsClient_t piP)

Get Cms client object generator.

Definition at line 700 of file XrdOfsConfigPI.cc.

701 { return (piP = cmsPI) != 0;}

References XrdOfsFSctl_PI::Plugins::cmsPI.

◆ Plugin() [4/6]

bool XrdOfsConfigPI::Plugin ( XrdOfsFSctl_PI *&  piP)

Get Ctl plugin.

Definition at line 703 of file XrdOfsConfigPI.cc.

704 { return (piP = ctlPI) != 0;}

◆ Plugin() [5/6]

bool XrdOfsConfigPI::Plugin ( XrdOfsPrepare *&  piP)

Get Prp plugin (prepare)

Definition at line 706 of file XrdOfsConfigPI.cc.

707 { return (piP = prpPI) != 0;}

◆ Plugin() [6/6]

bool XrdOfsConfigPI::Plugin ( XrdOss *&  piP)

Get Oss plugin.

Definition at line 709 of file XrdOfsConfigPI.cc.

710 { return (piP = ossPI) != 0;}

References XrdOfsFSctl_PI::Plugins::ossPI.

◆ PrepAuth()

bool XrdOfsConfigPI::PrepAuth ( )

Check if the prepare plugin wants authorization.

Returns
True if the plugin wants authorization, false otherwise.

Definition at line 716 of file XrdOfsConfigPI.cc.

716 {return prpAuth;}

Referenced by XrdOfs::Configure().

+ Here is the caller graph for this function:

◆ Push()

bool XrdOfsConfigPI::Push ( TheLib  what,
const char *  plugP,
const char *  parmP = 0 
)

Push a plugin on top of eixsting plugins to be loaded.

Parameters
whatThe enum specifying which plugin to push.
plugPPointer to the name or path of the shared library
parmPPointer to library parameters, if any.
Returns
True upon success, false if plugin is not pushable.

Definition at line 722 of file XrdOfsConfigPI.cc.

723 {
724  struct xxxLP newALP;
725  int i, xLib = PIX(what);
726 
727 // Make sure this library is pushable
728 //
729  if (!pushOK[xLib]) return false;
730 
731 // Add this library
732 //
733  i = ALP[xLib].size();
734  ALP[xLib].push_back(newALP);
735  ALP[xLib][i].lib = strdup(plugP);
736  if (parmP && *parmP) ALP[xLib][i].parms = strdup(parmP);
737  return true;
738 }

References PIX.

Referenced by XrdPfc::Cache::Config().

+ Here is the caller graph for this function:

◆ SetCksRdSz()

void XrdOfsConfigPI::SetCksRdSz ( int  rdsz)

Set the checksum read size

Parameters
rdszThe chesum read size buffer.

Definition at line 785 of file XrdOfsConfigPI.cc.

785 {CksRdsz = rdsz;}

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