XRootD
Loading...
Searching...
No Matches
XrdOfsConfigPI.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d O f s C o n f i g P I . c c */
4/* */
5/* (c) 2014 by the Board of Trustees of the Leland Stanford, Jr., University */
6/* All Rights Reserved */
7/* Produced by Andrew Hanushevsky for Stanford University under contract */
8/* DE-AC02-76-SFO0515 with the Department of Energy */
9/* */
10/* This file is part of the XRootD software suite. */
11/* */
12/* XRootD is free software: you can redistribute it and/or modify it under */
13/* the terms of the GNU Lesser General Public License as published by the */
14/* Free Software Foundation, either version 3 of the License, or (at your */
15/* option) any later version. */
16/* */
17/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20/* License for more details. */
21/* */
22/* You should have received a copy of the GNU Lesser General Public License */
23/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25/* */
26/* The copyright holder's institutional names and contributor's names may not */
27/* be used to endorse or promote products derived from this software without */
28/* specific prior written permission of the institution or contributor. */
29/******************************************************************************/
30
31#include <unistd.h>
32#include <cctype>
33#include <cstdlib>
34#include <cstring>
35#include <cstdio>
36#include <sys/param.h>
37
38#include "XrdVersion.hh"
39
41
42#include "XrdCks/XrdCks.hh"
44
46
47#include "XrdOfs/XrdOfs.hh"
51
52#include "XrdOss/XrdOss.hh"
53
54#include "XrdOuc/XrdOucEnv.hh"
57#include "XrdOuc/XrdOucUtils.hh"
58
59#include "XrdSys/XrdSysError.hh"
60#include "XrdSys/XrdSysFAttr.hh"
63
64/******************************************************************************/
65/* G l o b a l s & S t a t i c s */
66/******************************************************************************/
67
68namespace
69{
70const char *drctv[] = {"xattrlib", "authlib", "ckslib", "cmslib",
71 "ctllib", "osslib", "preplib"};
72
73const char *nullParms = 0;
74}
75
77
78/******************************************************************************/
79/* D e f i n e s */
80/******************************************************************************/
81
82#define DO_LOAD(x) loadLib & (x & ~libIXMask)
83
84#define PIX(x) x & libIXMask
85
86/******************************************************************************/
87/* C o n s t r u c t o r */
88/******************************************************************************/
89
90XrdOfsConfigPI::XrdOfsConfigPI(const char *cfn, XrdOucStream *cfgP,
91 XrdSysError *errP, XrdSfsFileSystem *sfsP,
92 XrdVersionInfo *verP)
93 : autPI(0), cksPI(0), cmsPI(0), ctlPI(0), prpPI(0), ossPI(0),
94 sfsPI(sfsP), urVer(verP),
95 Config(cfgP), Eroute(errP), CksConfig(0), ConfigFN(cfn),
96 CksAlg(0), CksRdsz(0), ossXAttr(false), ossCksio(0),
97 prpAuth(true), Loaded(false), LoadOK(false), cksLcl(false)
98{
99 int rc;
100
101// Clear the library table
102//
103 memset(defLib, 0, sizeof(defLib));
104
105// Set correct version
106//
107 if (!verP) urVer = &XrdVERSIONINFOVAR(XrdOfs);
108
109// Preallocate the checksum configurator
110//
111 CksConfig = new XrdCksConfig(ConfigFN, Eroute, rc, *urVer);
112 if (!rc) {delete CksConfig; CksConfig = 0;}
113
114// Set Pushable attributes
115//
116 pushOK[PIX(theAtrLib)] = true;
117 pushOK[PIX(theAutLib)] = true;
118 pushOK[PIX(theCksLib)] = false;
119 pushOK[PIX(theCmsLib)] = false;
120 pushOK[PIX(theCtlLib)] = true;
121 pushOK[PIX(theOssLib)] = true;
122 pushOK[PIX(thePrpLib)] = true;
123}
124
125/******************************************************************************/
126/* D e s t r u c t o r */
127/******************************************************************************/
128
130{
131 if (CksConfig) delete CksConfig;
132 if (CksAlg) free(CksAlg);
133}
134
135/******************************************************************************/
136/* Private: A d d L i b */
137/******************************************************************************/
138
139bool XrdOfsConfigPI::AddLib(XrdOfsConfigPI::TheLib what)
140{
141 struct xxxLP newALP;
142 char *val, *path;
143 char parms[2048];
144 int i, xLib = PIX(what);
145
146// Get the path
147//
148 if (!(val = Config->GetWord()) || !val[0])
149 {Eroute->Emsg("Config", drctv[PIX(what)],"not specified"); return false;}
150 path = strdup(val);
151
152// Get the parameters
153//
154 if (!Config->GetRest(parms, sizeof(parms)))
155 {Eroute->Emsg("Config", drctv[xLib], "parameters too long");
156 free(path);
157 return false;
158 }
159
160// Add this library
161//
162 i = ALP[xLib].size();
163 ALP[xLib].push_back(newALP);
164 ALP[xLib][i].lib = path;
165 if (*parms) ALP[xLib][i].parms = strdup(parms);
166 return true;
167}
168
169/******************************************************************************/
170/* Private: A d d L i b A t r */
171/******************************************************************************/
172
173bool XrdOfsConfigPI::AddLibAtr(XrdOucEnv *envP, XrdSysXAttr *&atrPI)
174{
175 const char *epName = "XrdSysAddXAttrObject";
177 int n = ALP[PIX(theAtrLib)].size();
178
179 for (int i = 0; i < n; i++)
180 {const char *path = ALP[PIX(theAtrLib)][i].lib;
181 const char *parms = ALP[PIX(theAtrLib)][i].parms;
182 XrdOucPinLoader myLib(Eroute, urVer, "xattrlib", path);
183 ep = (XrdSysAddXAttrObject_t)(myLib.Resolve(epName));
184 if (!ep) return false;
185 atrPI = ep(Eroute, ConfigFN, parms, envP, atrPI);
186 if (!atrPI) return false;
187 }
188 return true;
189}
190
191/******************************************************************************/
192/* Private: A d d L i b A u t */
193/******************************************************************************/
194
195bool XrdOfsConfigPI::AddLibAut(XrdOucEnv *envP)
196{
197 const char *epName = "XrdAccAuthorizeObjAdd";
198 int n = ALP[PIX(theAutLib)].size();
199
200 for (int i = 0; i < n; i++)
201 {const char *path = ALP[PIX(theAutLib)][i].lib;
202 const char *parms = ALP[PIX(theAutLib)][i].parms;
204 XrdOucPinLoader myLib(Eroute, urVer, "authlib", path);
205 addAut = (XrdAccAuthorizeObjAdd_t)myLib.Resolve(epName);
206 if (!addAut) return false;
207 autPI = addAut(Eroute->logger(), ConfigFN, parms, envP, autPI);
208 if (!autPI) return false;
209 }
210 return true;
211}
212
213
214/******************************************************************************/
215/* Private: A d d L i b C t l */
216/******************************************************************************/
217
218bool XrdOfsConfigPI::AddLibCtl(XrdOucEnv *envP)
219{
220 const char *objName = "XrdOfsFSctl";
221 XrdOfsFSctl_PI *ctlObj;
222 int n = ALP[PIX(theCtlLib)].size();
223
224 for (int i = 0; i < n; i++)
225 {const char *path = ALP[PIX(theCtlLib)][i].lib;
226 const char *parms = ALP[PIX(theCtlLib)][i].parms;
227 XrdOucPinLoader myLib(Eroute, urVer, "ctllib", path);
228 ctlObj = (XrdOfsFSctl_PI *)myLib.Resolve(objName);
229 if (!ctlObj) return false;
230 ctlObj->eDest = Eroute;
231 ctlObj->prvPI = ctlPI;
232 ctlPI = ctlObj;
233 ctlLP theCTL = {ctlObj, parms};
234 ctlVec.push_back(theCTL);
235 }
236 return true;
237}
238
239/******************************************************************************/
240/* Private: A d d L i b O s s */
241/******************************************************************************/
242
243bool XrdOfsConfigPI::AddLibOss(XrdOucEnv *envP)
244{
245 const char *epName = "XrdOssAddStorageSystem2";
246 int n = ALP[PIX(theOssLib)].size();
247
248 for (int i = 0; i < n; i++)
249 {const char *path = ALP[PIX(theOssLib)][i].lib;
250 const char *parms = ALP[PIX(theOssLib)][i].parms;
252 XrdOucPinLoader myLib(Eroute, urVer, "osslib", path);
253
254 addOss2 = (XrdOssGetStorageSystem2_t)myLib.Resolve(epName);
255 if (!addOss2) return false;
256 ossPI = addOss2(ossPI, Eroute->logger(), ConfigFN, parms, envP);
257 if (!ossPI) return false;
258 }
259 return true;
260}
261
262/******************************************************************************/
263/* Private: A d d L i b P r p */
264/******************************************************************************/
265
266bool XrdOfsConfigPI::AddLibPrp(XrdOucEnv *envP)
267{
268 const char *epName = "XrdOfsAddPrepare";
269 int n = ALP[PIX(thePrpLib)].size();
270
271 for (int i = 0; i < n; i++)
272 {const char *path = ALP[PIX(thePrpLib)][i].lib;
273 const char *parms = ALP[PIX(thePrpLib)][i].parms;
274 XrdOfsAddPrepare_t addPrp;
275 XrdOucPinLoader myLib(Eroute, urVer, "preplib", path);
276 addPrp = (XrdOfsAddPrepare_t)myLib.Resolve(epName);
277 if (!addPrp) return false;
278 prpPI = addPrp(Eroute, ConfigFN, parms, sfsPI, ossPI, envP, prpPI);
279 if (!prpPI) return false;
280 }
281 return true;
282}
283
284/******************************************************************************/
285/* C o n f i g u r e */
286/******************************************************************************/
287
289{
290 return 0 != cmscP->Configure(ConfigFN, LP[PIX(theCmsLib)].parms, envP);
291}
292
293/******************************************************************************/
294/* C o n f i g C t l */
295/******************************************************************************/
296
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}
318
319/******************************************************************************/
320/* D e f a u l t */
321/******************************************************************************/
322
324 const char *lparm)
325{
326 int n = PIX(what);
327
328 if (n < maxXXXLib && !RepLib(what, lpath, (lparm ? lparm : nullParms)))
329 defLib[n] = true;
330}
331
332/******************************************************************************/
333/* D e f a u l t C S */
334/******************************************************************************/
335
336void XrdOfsConfigPI::DefaultCS(const char *alg)
337{
338 if (CksAlg) free(CksAlg);
339 CksAlg = strdup(alg);
340 XrdOucUtils::toLower(CksAlg);
341}
342
343/******************************************************************************/
344/* D i s p l a y */
345/******************************************************************************/
346
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}
377
378/******************************************************************************/
379/* L o a d */
380/******************************************************************************/
381
382bool XrdOfsConfigPI::Load(int loadLib, XrdOucEnv *envP)
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 }
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}
461
462/******************************************************************************/
463/* N e w */
464/******************************************************************************/
465
467 XrdSysError *errP, XrdVersionInfo *verP,
468 XrdSfsFileSystem *sfsP)
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}
479
480/******************************************************************************/
481/* O s s C k s */
482/******************************************************************************/
483
484bool XrdOfsConfigPI::OssCks() {return ossCksio > 0;}
485
486/******************************************************************************/
487/* P a r s e */
488/******************************************************************************/
489
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}
542
543/******************************************************************************/
544/* Private: P a r s e A t r L i b */
545/******************************************************************************/
546
547/* Function: ParseAtrLib
548
549 Purpose: To parse the directive: xattrlib {osslib | [++] <path>} [<parms>]
550
551 ++ stack this plugin.
552 osslib The plugin resides in the osslib plugin.
553 <path> the path of the xattr library to be used.
554 <parms> optional parms to be passed
555
556 Output: true upon success or false upon failure.
557*/
558
559bool XrdOfsConfigPI::ParseAtrLib()
560{
561 char *val;
562
563// Get the path and parms
564//
565 if (!(val = Config->GetWord()) || !val[0])
566 {Eroute->Emsg("Config", "xattrlib not specified"); return false;}
567
568// Check for a push wrapper
569//
570 if (!strcmp("++", val)) return AddLib(theAtrLib);
571
572// Record the path and parms
573//
574 ossXAttr = !strcmp("osslib", val);
575 return RepLib(theAtrLib, (ossXAttr ? 0 : val));
576}
577
578/******************************************************************************/
579/* Private: P a r s e O s s L i b */
580/******************************************************************************/
581
582/* Function: ParseOssLib
583
584 Purpose: To parse the directive: osslib [++ | <opts>] <path> [<parms>]
585 <opts>: [+cksio] [+mmapio] [+xattr] [<opts>]
586
587 +cksio use the oss plugin for checkum I/O. This is now the
588 default for the native oss plugin unless +mmapio set.
589 +mmapio use memory mapping i/o (previously the default). This
590 is not documented but here just in case.
591 +xattr the library contains the xattr plugin.
592 <path> the path of the oss library to be used.
593 <parms> optional parms to be passed
594
595 Output: true upon success or false upon failure.
596*/
597
598bool XrdOfsConfigPI::ParseOssLib()
599{
600 char *val, oBuff[80];
601 int oI = PIX(theOssLib);
602
603// Check if we are pushing another library here
604//
605 if ((val = Config->GetWord()) && !strcmp("++",val)) return AddLib(theOssLib);
606
607// Reset to defaults
608//
609 ossCksio = 0;
610 ossXAttr = false;
611 if (LP[oI].opts) {free(LP[oI].opts); LP[oI].opts = 0;}
612 *oBuff = 0;
613
614// Get the path and parms, and process keywords
615//
616 while(val)
617 { if (!strcmp("+cksio", val))
618 {if (!ossCksio) strcat(oBuff, "+cksio "); ossCksio = 1;}
619 else if (!strcmp("+mmapio", val))
620 {if ( ossCksio) strcat(oBuff, "+mmapio "); ossCksio = -1;}
621 else if (!strcmp("+xattr", val))
622 {if (!ossXAttr) strcat(oBuff, "+xattr "); ossXAttr = true;}
623 else break;
624 val = Config->GetWord();
625 }
626
627// Check if we an osslib
628//
629 if (!val || !val[0])
630 {Eroute->Emsg("Config", "osslib not specified"); return false;}
631
632// Record the path and parameters
633//
634 if (*oBuff) LP[oI].opts = strdup(oBuff);
635 return RepLib(theOssLib, val);
636}
637
638/******************************************************************************/
639/* Private: P a r s e P r p L i b */
640/******************************************************************************/
641
642/* Function: ParsePrpLib
643
644 Purpose: To parse the directive: preplib [++ | [<opts>]} <path> [<parms>]
645 <opts>: [+noauth]
646
647 ++ Stack this plugin.
648 +noauth do not apply authorization to path list.
649 <path> the path of the prepare library to be used.
650 <parms> optional parms to be passed
651
652 Output: true upon success or false upon failure.
653*/
654
655bool XrdOfsConfigPI::ParsePrpLib()
656{
657 char *val, oBuff[80];
658 int oI = PIX(thePrpLib);
659
660// Check if we are pushing another library here
661//
662 if ((val = Config->GetWord()) && !strcmp("++",val)) return AddLib(thePrpLib);
663
664// Reset to defaults
665//
666 prpAuth = true;
667 if (LP[oI].opts) {free(LP[oI].opts); LP[oI].opts = 0;}
668 *oBuff = 0;
669
670// Get the path and parms, and process keywords
671//
672 while(val)
673 { if (!strcmp("+noauth", val))
674 {if (prpAuth) strcat(oBuff, "+noauth "); prpAuth = false;}
675 else break;
676 val = Config->GetWord();
677 }
678
679// Check if we a library path
680//
681 if (!val || !val[0])
682 {Eroute->Emsg("Config", "preplib not specified"); return false;}
683
684// Record the path and parameters
685//
686 if (*oBuff) LP[oI].opts = strdup(oBuff);
687 return RepLib(thePrpLib, val);
688}
689
690/******************************************************************************/
691/* P l u g i n */
692/******************************************************************************/
693
695{ return (piP = autPI) != 0;}
696
698{ return (piP = cksPI) != 0;}
699
701{ return (piP = cmsPI) != 0;}
702
704{ return (piP = ctlPI) != 0;}
705
707{ return (piP = prpPI) != 0;}
708
710{ return (piP = ossPI) != 0;}
711
712/******************************************************************************/
713/* P r e p A u t h */
714/******************************************************************************/
715
716bool XrdOfsConfigPI::PrepAuth() {return prpAuth;}
717
718/******************************************************************************/
719/* P u s h */
720/******************************************************************************/
721
722bool XrdOfsConfigPI::Push(TheLib what, const char *plugP, const char *parmP)
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}
739
740/******************************************************************************/
741/* Private: R e p L i b */
742/******************************************************************************/
743
744bool XrdOfsConfigPI::RepLib(XrdOfsConfigPI::TheLib what,
745 const char *newLib, const char *newParms, bool parseParms)
746{
747 const char *parmP;
748 char parms[2048];
749 int xLib = PIX(what);
750
751// Replace any existing library specification
752//
753 if (LP[xLib].lib && newLib)
754 {if (!strcmp(LP[xLib].lib, newLib) && defLib[xLib])
755 {const char *dfltLib = (newParms ? newLib : LP[xLib].lib);
756 Eroute->Say("Config warning: ", "specified ", drctv[xLib],
757 " overrides default ", dfltLib);
758 }
759 free(LP[xLib].lib);
760 defLib[xLib] = false;
761 }
762 LP[xLib].lib = (newLib ? strdup(newLib) : 0);
763
764// Get any parameters
765//
766 if (newParms) parmP = (newParms == nullParms ? 0 : newParms);
767 else {*parms = 0; parmP = parms;
768 if (parseParms && !Config->GetRest(parms, sizeof(parms)))
769 {Eroute->Emsg("Config", drctv[xLib], "parameters too long");
770 return false;
771 }
772 }
773
774// Record the parameters
775//
776 if (LP[xLib].parms) free(LP[xLib].parms);
777 LP[xLib].parms = (*parmP ? strdup(parmP) : 0);
778 return true;
779}
780
781/******************************************************************************/
782/* S e t C k s R d S z */
783/******************************************************************************/
784
785void XrdOfsConfigPI::SetCksRdSz(int rdsz) {CksRdsz = rdsz;}
786
787/******************************************************************************/
788/* Private: S e t u p A t t r */
789/******************************************************************************/
790
791bool XrdOfsConfigPI::SetupAttr(XrdOfsConfigPI::TheLib what, XrdOucEnv *envP)
792{
794 XrdSysXAttr *theObj;
795 char *AtrLib = LP[PIX(what)].lib;
796 char *AtrParms = LP[PIX(what)].parms;
797
798// Create a plugin object
799//
800 {XrdOucPinLoader myLib(Eroute, urVer, "xattrlib", AtrLib);
801 ep = (XrdSysGetXAttrObject_t)(myLib.Resolve("XrdSysGetXAttrObject"));
802 if (!ep) return false;
803 if (strcmp(AtrLib, myLib.Path()))
804 {free(AtrLib); AtrLib = LP[PIX(what)].lib = strdup(myLib.Path());}
805 }
806
807// Get the Object now
808//
809 if (!(theObj = ep(Eroute, ConfigFN, AtrParms))) return false;
810
811// Push any additional objects
812//
813 if (!AddLibAtr(envP, theObj)) return false;
814
815// Tell the interface to use this object instead of the default implementation
816//
818 return true;
819}
820
821/******************************************************************************/
822/* Private: S e t u p A u t h */
823/******************************************************************************/
824
825bool XrdOfsConfigPI::SetupAuth(XrdOucEnv *envP)
826{
828 (XrdSysLogger *lp, const char *cfn,
829 const char *parm, XrdVersionInfo &vInfo);
830
833 char *AuthLib = LP[PIX(theAutLib)].lib;
834 char *AuthParms = LP[PIX(theAutLib)].parms;
835
836// Authorization comes from the library or we use the default
837//
838 if (!AuthLib)
839 {if (!(autPI = XrdAccDefaultAuthorizeObject
840 (Eroute->logger(), ConfigFN, AuthParms, *urVer)))
841 return false;
842 return AddLibAut(envP);
843 }
844
845// Create a plugin object. It will be version 2 or version 1, in that order
846//
847 {XrdOucPinLoader myLib(Eroute, urVer, "authlib", AuthLib);
848 ep2 = (XrdAccAuthorizeObject2_t)(myLib.Resolve("XrdAccAuthorizeObject2"));
849 if (!ep2)
850 {ep1 = (XrdAccAuthorizeObject_t)(myLib.Resolve("XrdAccAuthorizeObject"));
851 if (!ep1) return false;
852 if (!(autPI = ep1(Eroute->logger(), ConfigFN, AuthParms))) return false;
853 } else {
854 if (!(autPI = ep2(Eroute->logger(), ConfigFN, AuthParms, envP)))
855 return false;
856 }
857 if (strcmp(AuthLib, myLib.Path()))
858 {free(AuthLib); AuthLib = LP[PIX(theAutLib)].lib = strdup(myLib.Path());}
859 }
860
861// Process additional wrapper objects now
862//
863 return AddLibAut(envP);
864}
865
866/******************************************************************************/
867/* Private: S e t u p C m s */
868/******************************************************************************/
869
870bool XrdOfsConfigPI::SetupCms()
871{
872 char *CmsLib = LP[PIX(theCmsLib)].lib;
873
874// Load the plugin if we have to
875//
876 if (LP[PIX(theCmsLib)].lib)
877 {XrdOucPinLoader myLib(Eroute, urVer, "cmslib", CmsLib);
878 cmsPI = (XrdCmsClient *(*)(XrdSysLogger *, int, int, XrdOss *))
879 (myLib.Resolve("XrdCmsGetClient"));
880 if (!cmsPI) return false;
881 if (strcmp(CmsLib, myLib.Path()))
882 {free(CmsLib);
883 CmsLib = LP[PIX(theCmsLib)].lib = strdup(myLib.Path());
884 }
885 }
886 return true;
887}
888
889/******************************************************************************/
890/* S e t u p C t l */
891/******************************************************************************/
892
893bool XrdOfsConfigPI::SetupCtl(XrdOucEnv *envP)
894{
895 XrdOfsFSctl_PI *obj = 0;
896 char *CtlLib = LP[PIX(theCtlLib)].lib;
897
898// Load the plugin if we have to
899//
900 if (LP[PIX(theCtlLib)].lib)
901 {XrdOucPinLoader myLib(Eroute, urVer, "ctllib", CtlLib);
902 obj = (XrdOfsFSctl_PI *)(myLib.Resolve("XrdOfsFSctl"));
903 if (!obj) return false;
904 if (strcmp(CtlLib, myLib.Path()))
905 {free(CtlLib);
906 CtlLib = LP[PIX(theCtlLib)].lib = strdup(myLib.Path());
907 }
908 } else return true;
909
910// Record the object (it will be fully initialized later_
911//
912 obj->eDest = Eroute;
913 obj->prvPI = 0;
914 ctlPI = obj;
915 return AddLibCtl(envP);
916}
917
918/******************************************************************************/
919/* S e t u p P r p */
920/******************************************************************************/
921
922bool XrdOfsConfigPI::SetupPrp(XrdOucEnv *envP)
923{
924 XrdOfsgetPrepare_t ep = 0;
925 char *PrpLib = LP[PIX(thePrpLib)].lib;
926 char *PrpParms = LP[PIX(thePrpLib)].parms;
927
928// Load the plugin if we have to
929//
930 if (LP[PIX(thePrpLib)].lib)
931 {XrdOucPinLoader myLib(Eroute, urVer, "preplib", PrpLib);
932 ep = (XrdOfsgetPrepare_t)(myLib.Resolve("XrdOfsgetPrepare"));
933 if (!ep) return false;
934 if (strcmp(PrpLib, myLib.Path()))
935 {free(PrpLib);
936 PrpLib = LP[PIX(thePrpLib)].lib = strdup(myLib.Path());
937 }
938 } else return true;
939
940// Get the Object now
941//
942 if (!(prpPI = ep(Eroute, ConfigFN, PrpParms, sfsPI, ossPI, envP)))
943 return false;
944 return AddLibPrp(envP);
945}
XrdAccAuthorize * XrdAccDefaultAuthorizeObject(XrdSysLogger *lp, const char *cfn, const char *parm, XrdVersionInfo &urVer)
XrdAccAuthorize *(* XrdAccAuthorizeObject2_t)(XrdSysLogger *lp, const char *cfn, const char *parm, XrdOucEnv *envP)
XrdAccAuthorize *(* XrdAccAuthorizeObjAdd_t)(XrdSysLogger *lp, const char *cfn, const char *parm, XrdOucEnv *envP, XrdAccAuthorize *accP)
XrdAccAuthorize *(* XrdAccAuthorizeObject_t)(XrdSysLogger *lp, const char *cfn, const char *parm)
XrdCmsClient *(* XrdCmsClient_t)(XrdSysLogger *, int, int, XrdOss *)
XrdVERSIONINFOREF(XrdOfs)
#define PIX(x)
#define DO_LOAD(x)
XrdOfsPrepare *(* XrdOfsAddPrepare_t)(XrdSysError *eDest, const char *confg, const char *parms, XrdSfsFileSystem *theSfs, XrdOss *theOss, XrdOucEnv *envP, XrdOfsPrepare *prepP)
XrdOfsPrepare *(* XrdOfsgetPrepare_t)(XrdSysError *eDest, const char *confg, const char *parms, XrdSfsFileSystem *theSfs, XrdOss *theOss, XrdOucEnv *envP)
XrdOss * XrdOssGetSS(XrdSysLogger *Logger, const char *config_fn, const char *OssLib, const char *OssParms, XrdOucEnv *envP, XrdVersionInfo &urVer)
Definition XrdOssApi.cc:98
XrdOssGetStorageSystem2_t XrdOssAddStorageSystem2_t
Definition XrdOss.hh:945
XrdOss *(* XrdOssGetStorageSystem2_t)(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms, XrdOucEnv *envP)
Definition XrdOss.hh:939
struct myOpts opts
XrdSysXAttr * XrdSysXAttrActive
XrdSysXAttr *(* XrdSysAddXAttrObject_t)(XrdSysError *errP, const char *config_fn, const char *parms, XrdOucEnv *envP, XrdSysXAttr *attrP)
XrdSysXAttr *(* XrdSysGetXAttrObject_t)(XrdSysError *errP, const char *config_fn, const char *parms)
XrdCks * Configure(const char *dfltCalc=0, int rdsz=0, XrdOss *ossP=0, XrdOucEnv *envP=0)
const char * ManLib()
int ParseLib(XrdOucStream &Config, int &libType)
virtual int Configure(const char *cfn, char *Parms, XrdOucEnv *EnvInfo)=0
bool Parse(TheLib what)
bool ConfigCtl(XrdCmsClient *cmscP, XrdOucEnv *envP=0)
void Default(TheLib what, const char *lpath, const char *lparm=0)
void SetCksRdSz(int rdsz)
bool Plugin(XrdAccAuthorize *&piP)
Get Authorization plugin.
static XrdOfsConfigPI * New(const char *cfn, XrdOucStream *cfgP, XrdSysError *errP, XrdVersionInfo *verP=0, XrdSfsFileSystem *sfsP=0)
~XrdOfsConfigPI()
Destructor.
void DefaultCS(const char *alg)
bool Load(int what, XrdOucEnv *envP=0)
bool Push(TheLib what, const char *plugP, const char *parmP=0)
bool Configure(XrdCmsClient *cmscP, XrdOucEnv *envP)
@ theOssLib
Oss plugin.
@ 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)
void Display()
Display configuration settings.
XrdOfsFSctl_PI * prvPI
virtual bool Configure(const char *CfgFN, const char *Parms, XrdOucEnv *envP, const Plugins &plugs)
XrdSysError * eDest
The Plugins struct is used to pass plugin pointers to configure.
char * Get(const char *varname)
Definition XrdOucEnv.hh:69
char * GetWord(int lowcase=0)
int GetRest(char *theBuf, int Blen, int lowcase=0)
static void toLower(char *str)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
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)
XrdSysLogger * logger(XrdSysLogger *lp=0)
static void SetPlugin(XrdSysXAttr *xaP, bool push=false)
static XrdSysXAttr * Xat
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)
virtual XrdSysError * SetMsgRoute(XrdSysError *errP)