36 #include <sys/param.h>
37 #include <sys/types.h>
40 #include "XrdVersion.hh"
101 char *bp = theSE->
Buff;
102 int n, bleft =
sizeof(theSE->
Buff)-2;
110 do {
if ((n =
read(theSE->
myFD, bp, bleft)) <= 0)
111 {
if (!n || (n < 0 && errno != EINTR))
break;}
113 }
while ((bleft -= n));
117 dup2(theSE->
seFD, STDERR_FILENO);
122 if (theSE->
Buff[bp-(theSE->
Buff)-1L] !=
'\n') *bp++ =
'\n';
137 : dfltPolicy(
"*", -2, -3, 72000, 0)
165 isAgent = (getenv(
"XRDADMINPATH") ? 1 : 0);
189 LocalRoot= RemoteRoot = 0;
190 lcl_N2N = rmt_N2N =
the_N2N = 0;
191 N2N_Lib = N2N_Parms = 0;
203 if (!(sP = getenv(
"XRDCONFIGFN")) || !*sP)
205 else {ConfigFN = strdup(sP);
isAgent = 1;}
222 strcpy(buff,
"frm.");
225 pfxDTS = strdup(buff); plnDTS = strlen(buff);
235 const char *,
XrdOucEnv *, XrdVersionInfo &);
238 int retc, isMum = 0, myXfrMax = -1, NoGo = 0, optBG = 0;
240 char c, buff[1024], *logfn = 0;
242 extern int opterr,
optopt;
243 int pipeFD[2] = {-1, -1}, bindArg = -1, pureLFN = 0;
244 const char *pidFN = 0;
248 retc = strlen(argv[0]);
249 while(retc--)
if (argv[0][retc] ==
'/')
break;
250 myProg = &argv[0][retc+1];
257 && (c=getopt(argc,argv,vOpts)) && (c != (
char)-1))
262 case 'c':
if (ConfigFN) free(ConfigFN);
263 ConfigFN = strdup(optarg);
273 {
Say.
Emsg(
"Config",
"Invalid -k argument -",optarg);
277 case 'l':
if ((pureLFN = *optarg ==
'=')) optarg++;
279 {
Say.
Emsg(
"Config",
"Logfile name not specified.");
282 if (logfn) free(logfn);
283 logfn = strdup(optarg);
288 case 'n':
myInst = (!strcmp(optarg,
"anon")||!strcmp(optarg,
"default")
292 if (!ConfigOTO(optarg)) Usage(1);
301 case 's': pidFN = optarg;
307 default: sprintf(buff,
"'%c'",
optopt);
308 if (c ==
':')
Say.
Emsg(
"Config", buff,
"value not specified.");
309 else Say.
Emsg(
"Config", buff,
"option is invalid");
324 {
if (
isAgent && (logfn = getenv(
"XRDLOGDIR")))
325 {snprintf(buff,
sizeof(buff),
"%s%s%clog", logfn,
myFrmid,
327 logfn = strdup(buff);
339 if (pipe( pipeFD ) == -1)
340 {
Say.
Emsg(
"Config", errno,
"create a pipe"); exit(17);}
356 {
Say.
Emsg(
"Config",
"Unable to determine host name; execution terminated.");
363 snprintf(buff,
sizeof(buff),
"XRDINSTANCE=%s %s@%s",
myProg,
365 putenv(strdup(buff));
374 isMum = ConfigMum(theSE);
380 strcpy(msgBuff,
myInstance); strcat(msgBuff,
" running.");
386 sprintf(buff,
"File Residency Manager %s is starting. . .",
myProg);
393 if (!ConfigFN || !*ConfigFN) ConfigFN = strdup(
"/opt/xrootd/etc/xrootd.cf");
394 Say.
Say(
"Config using configuration file ", ConfigFN);
399 if (!NoGo) NoGo = ConfigPaths();
425 if (!NoGo)
switch(ssID)
426 {
case ssAdmin: NoGo = (ConfigN2N() || ConfigMss());
428 case ssPurg:
if (!(NoGo = (ConfigMon(0) || ConfigMP(
"purgeable"))))
429 ConfigPF(
"frm_purged");
431 case ssXfr:
if (!
isAgent && !(NoGo = (ConfigMon(1) || ConfigXfr())))
432 ConfigPF(
"frm_xfrd");
439 if (!NoGo && ppf) NoGo = ppf();
449 int status = NoGo ? 1 : 0;
450 if(
write( pipeFD[1], &status,
sizeof( status ) )) {};
457 temp = (NoGo ?
" initialization failed." :
" initialization completed.");
463 {
close(STDERR_FILENO);
482 if (lcl_N2N) rc = lcl_N2N->
lfn2pfn(oldp, newp, newpsz);
483 else if (((
int)strlen(oldp)) >= newpsz) rc = ENAMETOOLONG;
484 else strcpy(newp, oldp);
485 if (rc) {
Say.
Emsg(
"Config", rc,
"generate local path from", oldp);
499 if (lcl_N2N) rc = lcl_N2N->
pfn2lfn(oldp, newp, newpsz);
500 else if (((
int)strlen(oldp)) >= newpsz) rc = ENAMETOOLONG;
501 else strcpy(newp, oldp);
502 if (rc) {
Say.
Emsg(
"Config", rc,
"generate logical path from", oldp);
538 if (rmt_N2N) rc = rmt_N2N->
lfn2rfn(oldp, newp, newpsz);
539 else if (((
int)strlen(oldp)) >= newpsz) rc = ENAMETOOLONG;
540 else strcpy(newp, oldp);
541 if (rc) {
Say.
Emsg(
"Config", rc,
"generate rmote path from", oldp);
561 while(vP && strcmp(vP->
Name, Name)) vP = vP->
Next;
572 {
if (n >= (
int)
sizeof(buff)-2)
return &nullEnt;
573 strcpy(buff,
Path); buff[n+1] =
'/'; buff[n+2] =
'\0';
581 return (tP ? tP : &nullEnt);
601 XrdOucMsubs *XrdFrmConfig::ConfigCmd(
const char *cname,
char *cdata)
606 if (!cdata) {
Say.
Emsg(
"Config", cname,
"not specified.");
return 0;}
608 if ((cP = index(cdata,
' '))) *cP =
'\0';
611 {
Say.
Emsg(
"Config", errno,
"set up", cdata);
617 if (msubs->
Parse(cname, cdata))
return msubs;
626 int XrdFrmConfig::ConfigMon(
int isXfr)
630 if (ConfigN2N())
return 1;
653 int XrdFrmConfig::ConfigMP(
const char *pType)
658 char pDir[MAXPATHLEN+1];
665 {
Say.
Emsg(
"Config",
"Cannot determine", pType,
"paths.");
return 1;}
671 int psLen = strlen(psVal);
674 if (pOpts & xOpt) mypList = InsertPL(mypList, psVal, psLen,
676 else {
Say.
Say(
"Config", psVal,
"not marked", pType); NoGo = 1;}
679 while(vP && strcmp(psVal, vP->Name)) vP = vP->
Next;
681 else {
Say.
Emsg(
"Config",
"Space", psVal,
"not defined.");
698 sval[1] = fP->
Plen();
699 if (fP->
Flag() & xOpt)
712 while((tP = mypList))
715 DEBUG(
"Will scan " <<(tP->sval[0]?
"r/w: ":
"r/o: ") <<pDir);
718 {
if (!strncmp(tP->
text, nP->
text, tP->sval[1]))
722 mypList = tP->
next;
delete tP;
728 while((tP = expList)) {expList = tP->
next;
delete tP;}
733 {
Say.
Emsg(
"Config",
"No purgeable paths specified!");
760 int XrdFrmConfig::ConfigMss()
779 Recover() : stdErr(-1) {fdvec[0] = -1; fdvec[1] = -1;}
780 ~Recover() {
if (fdvec[0] >= 0)
close(fdvec[0]);
781 if (fdvec[1] >= 0)
close(fdvec[1]);
782 if (stdErr >= 0) {dup2(stdErr, STDERR_FILENO);
793 if (pipe(FD.fdvec) < 0)
return 0;
794 fcntl(FD.fdvec[0], F_SETFD, FD_CLOEXEC);
798 if ((FD.stdErr = dup(STDERR_FILENO)) < 0)
return 0;
802 if (dup2(FD.fdvec[1], STDERR_FILENO) < 0)
return 0;
803 close(FD.fdvec[1]); FD.fdvec[1] = -1;
807 theSE.
myFD = FD.fdvec[0];
808 theSE.
seFD = FD.stdErr;
827 int XrdFrmConfig::ConfigN2N()
833 if (!N2N_Lib && !LocalRoot && !RemoteRoot)
return 0;
837 if (!(
the_N2N = n2nLoader.Load(N2N_Lib, *myVersion)))
return 1;
841 if (N2N_Lib) rmt_N2N = lcl_N2N =
the_N2N;
842 else {
if (LocalRoot) lcl_N2N =
the_N2N;
843 if (RemoteRoot) rmt_N2N =
the_N2N;
855 int XrdFrmConfig::ConfigOTO(
char *Parms)
861 if ((Comma = index(Parms,
','))) *Comma =
'\0';
866 if (!Comma || !(*(Comma+1)))
return 1;
867 if (*(Comma+1) ==
',') Comma++;
868 else {Parms = Comma+1;
869 if ((Comma = index(Parms,
','))) *Comma =
'\0';
882 int XrdFrmConfig::ConfigPaths()
884 char *xPath, buff[MAXPATHLEN];
894 else if ((xPath = getenv(
"XRDADMINPATH"))) insName = 0;
895 else {xPath = (
char *)
"/tmp/"; insName =
myInst;}
899 if (XrdFrmCns::Init(
myFrmid, xPath, insName))
return 1;
916 strcpy(buff,
Config.AdminPath); strcat(buff,
"STOPPURGE");
928 void XrdFrmConfig::ConfigPF(
const char *pFN)
930 static const int Mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
932 char buff[1032], data[24];
937 if (
myInst) snprintf(buff,
sizeof(buff),
"%s/%s/%s.pid", ppP,
myInst, pFN);
938 else sprintf(buff,
"%s/%s.pid", ppP, pFN);
942 if ((pfFD =
open(buff, O_WRONLY|O_CREAT|O_TRUNC,
Mode)) < 0)
943 {
Say.
Emsg(
"Config",errno,
"open",buff);
return;}
947 n = sprintf(data,
"%lld",
static_cast<long long>(getpid()));
948 if (
write(pfFD, data, n) < 0)
Say.
Emsg(
"Config",errno,
"writing",buff);
956 int XrdFrmConfig::ConfigProc()
959 int cfgFD, retc, mbok, NoGo = 0;
970 if ( (cfgFD =
open(ConfigFN, O_RDONLY, 0)) < 0)
971 {
Say.
Emsg(
"Config", errno,
"open config file", ConfigFN);
974 cfgFile.Attach(cfgFD); cFile = &cfgFile;
975 static const char *cvec[] = {
"*** frm server config:", 0 };
982 if (!strncmp(var, pfxDTS, plnDTS)) {var += plnDTS; mbok = 1;}
983 if(ConfigXeq(var, mbok)) {cfgFile.Echo(); NoGo = 1;}
988 if ((retc = cfgFile.LastError()))
989 NoGo =
Say.
Emsg(
"Config", retc,
"read config file", ConfigFN);
990 cfgFile.Close(); cFile = 0;
1001 #define PARSEPI(x) return !OfsCfg->Parse(XrdOfsConfigPI:: x);
1003 int XrdFrmConfig::ConfigXeq(
char *var,
int mbok)
1008 if (!strcmp(var,
"all.adminpath" ))
return xapath();
1009 if (!strcmp(var,
"all.pidpath" ))
return Grab(var, &
PidPath, 0);
1010 if (!strcmp(var,
"all.manager" )) {
haveCMS = 1;
return 0;}
1011 if (!strcmp(var,
"frm.all.cnsd" ))
return xcnsd();
1017 if (!strcmp(var,
"frm.xfr.qcheck"))
return xqchk();
1018 if (!strcmp(var,
"ofs.ckslib" ))
PARSEPI(theCksLib);
1019 if (!strcmp(var,
"ofs.osslib" ))
PARSEPI(theOssLib);
1020 if (!strcmp(var,
"ofs.xattrlib" ))
PARSEPI(theAtrLib);
1024 if (!strcmp(var,
"oss.localroot" ))
return Grab(var, &LocalRoot, 0);
1025 if (!strcmp(var,
"oss.namelib" ))
return xnml();
1026 if (!strcmp(var,
"oss.remoteroot"))
return Grab(var, &RemoteRoot, 0);
1027 if (!strcmp(var,
"oss.space" ))
return xspace();
1028 if (!strcmp(var,
"xrootd.chksum" ))
return xcks();
1031 if (!strcmp(var,
"oss.xfr" ))
return xxfr();
1036 if (!strcmp(var,
"qcheck" ))
return xqchk();
1039 if (!strcmp(var,
"all.sitename" ))
return xsit();
1040 if (!strcmp(var,
"ofs.osslib" ))
PARSEPI(theOssLib);
1041 if (!strcmp(var,
"ofs.xattrlib" ))
PARSEPI(theAtrLib);
1042 if (!strcmp(var,
"oss.cache" ))
return xspace(0,0);
1043 if (!strcmp(var,
"oss.localroot" ))
return Grab(var, &LocalRoot, 0);
1044 if (!strcmp(var,
"oss.namelib" ))
return xnml();
1045 if (!strcmp(var,
"oss.remoteroot"))
return Grab(var, &RemoteRoot, 0);
1046 if (!strcmp(var,
"oss.xfr" ))
return xxfr();
1047 if (!strcmp(var,
"frm.all.monitor"))
return xmon();
1049 if (!strcmp(var,
"copycmd" ))
return xcopy();
1050 if (!strcmp(var,
"copymax" ))
return xcmax();
1051 if (!strcmp(var,
"oss.space" ))
return xspace();
1053 if (!strncmp(var,
"migr.", 5))
1055 if (!strcmp(vas,
"idlehold" ))
return xitm(
"idle time",
IdleHold);
1056 if (!strcmp(vas,
"waittime" ))
return xitm(
"migr wait",
WaitMigr);
1062 if (!strcmp(var,
"all.sitename" ))
return xsit();
1063 if (!strcmp(var,
"dirhold" ))
return xdpol();
1064 if (!strcmp(var,
"oss.cache" ))
return xspace(1,0);
1065 if (!strcmp(var,
"oss.localroot" ))
return Grab(var, &LocalRoot, 0);
1066 if (!strcmp(var,
"ofs.osslib" ))
PARSEPI(theOssLib);
1067 if (!strcmp(var,
"ofs.xattrlib" ))
PARSEPI(theAtrLib);
1068 if (!strcmp(var,
"policy" ))
return xpol();
1069 if (!strcmp(var,
"polprog" ))
return xpolprog();
1070 if (!strcmp(var,
"oss.space" ))
return xspace(1);
1071 if (!strcmp(var,
"waittime" ))
return xitm(
"purge wait",
WaitPurge);
1072 if (!strcmp(var,
"frm.all.monitor"))
return xmon();
1077 if (!mbok) cFile->
noEcho();
1078 else {
Say.
Say(
"Config warning: ignoring unknown frm directive '",var,
"'.");
1088 int XrdFrmConfig::ConfigXfr()
1090 int i, isBad, ioOK[2] = {0};
1094 isBad = ConfigMP(
"migratable") || ConfigMss();
1100 for (i = 0; i < 4; i++)
1110 if (!(ioOK[0] | ioOK[1]))
1112 "No copy commands specified; execution is meaningless!");
1118 if (!(
xfrIN = ioOK[0]))
1119 Say.
Emsg(
"Config",
"Input copy command not specified; "
1120 "incoming transfers prohibited!");
1125 Say.
Emsg(
"Config",
"Output copy command not specified; "
1126 "outgoing transfers prohibited!");
1137 int XrdFrmConfig::getTime(
const char *
emsg,
const char *item,
int *val,
1140 if (strcmp(item,
"forever"))
1150 int XrdFrmConfig::Grab(
const char *var,
char **Dest,
int nosubs)
1152 char myVar[1024], buff[2048], *val;
1158 strlcpy(myVar, var,
sizeof(myVar));
1164 if (!nosubs) val = cFile->
GetWord();
1165 else {myEnv = cFile->
SetEnv(0);
1166 if (!cFile->
GetRest(buff,
sizeof(buff)))
1167 {
Say.
Emsg(
"Config",
"arguments too long for", var);
1177 if (!val || !(*val))
1178 {
if (nosubs < 0)
Say.
Emsg(
"Config",
"no arguments for", var);
1179 else Say.
Emsg(
"Config",
"no value for directive", var);
1185 if (*Dest) {free(*Dest); Dest = 0;}
1188 int n = strlen(myVar);
1189 if (n + strlen(val) >
sizeof(fBuff)-1)
1190 {
Say.
Emsg(
"Config",
"arguments too long for", var);
return 1;}
1191 strcpy(fBuff, myVar); *(fBuff+n) =
' '; strcpy(fBuff+n+1, val);
1192 *Dest = strdup(fBuff);
1193 }
else *Dest = strdup(val);
1207 short sval[4] = {
static_cast<short>(isRW),
static_cast<short>(Plen)};
1212 while(tP && tP->sval[1] < Plen) {pP = tP; tP = tP->
next;}
1228 void XrdFrmConfig::InsertXD(
const char *
Path)
1231 char pBuff[MAXPATHLEN], *pP;
1232 int n = strlen(
Path);
1236 strcpy(pBuff,
Path);
1238 while(*pP ==
'/' && pP != pBuff) {*pP-- =
'\0'; n--;}
1243 DEBUG(
"Excluding '" <<pBuff <<
"'");
1250 void XrdFrmConfig::Usage(
int rc)
1252 std::cerr <<
"\nUsage: " <<
myProg <<
" " <<uInfo <<std::endl;
1271 int XrdFrmConfig::xapath()
1274 mode_t mode = S_IRWXU;
1279 if (!pval || !pval[0])
1280 {
Say.
Emsg(
"Config",
"adminpath not specified");
return 1;}
1285 {
Say.
Emsg(
"Config",
"adminpath not absolute");
return 1;}
1294 if ((val = cFile->
GetWord()) && val[0])
1295 {
if (!strcmp(
"group", val)) mode |= S_IRWXG;
1296 else {
Say.
Emsg(
"Config",
"invalid admin path modifier -", val);
1319 int XrdFrmConfig::xcks()
1325 while ((palg = cFile->
GetWord()) && *palg !=
'/')
1326 {
if (strcmp(palg,
"max"))
break;
1327 if (!(palg = cFile->
GetWord()))
1328 {
Say.
Emsg(
"Config",
"chksum max not specified");
return 1;}
1333 if (!palg || *palg ==
'/')
1334 {
Say.
Emsg(
"Config",
"chksum algorithm not specified");
return 1;}
1359 int XrdFrmConfig::xcnsd()
1362 char *val, *cnsPath = 0;
1363 struct cnsdopts {
const char *opname;
int opval;} cnsopt[] =
1369 int i, numopts =
sizeof(cnsopt)/
sizeof(
struct cnsdopts);
1373 if (!(val = cFile->
GetWord()))
1374 {
Say.
Emsg(
"Config",
"cnsd mode not specified");
return 1;}
1378 for (i = 0; i < numopts; i++)
1379 if (!strcmp(val,cnsopt[i].opname)) {cnsMode = cnsopt[i].opval;
break;}
1381 {
Say.
Emsg(
"Config",
"invalid cnsd mode '",val,
"'.");
return 1;}
1386 {
if (strcmp(
"apath", val))
1387 {
Say.
Emsg(
"Config",
"invalid cnsd option '",val,
"'.");
return 1;}
1388 if (!(cnsPath = cFile->
GetWord()))
1389 {
Say.
Emsg(
"Config",
"cnsd apath not specified");
return 1;}
1419 int XrdFrmConfig::xcopy()
1420 {
int cmdIO[2] = {0,0}, TLim=0,
Stats=0, hasMDP=0, cmdUrl=0, noAlo=0, rmErr=0;
1422 char *val, *theCmd = 0;
1423 struct copyopts {
const char *opname;
int *oploc;} cpopts[] =
1434 int i, n, numopts =
sizeof(cpopts)/
sizeof(
struct copyopts);
1439 while(val && *val !=
'/')
1440 {
for (i = 0; i < numopts; i++)
1441 {
if (!strcmp(val,cpopts[i].opname))
1442 {
if (strcmp(
"timeout", val)) {*cpopts[i].oploc = 1;
break;}
1443 else if (!xcopy(TLim))
return 1;
1447 Say.
Say(
"Config warning: ignoring invalid copycmd option '",val,
"'.");
1454 {
Say.
Emsg(
"Config",
"copy command not specified");
return 1;}
1455 if (Grab(val, &theCmd, -1))
return 1;
1459 if (!cmdIO[0] && !cmdIO[1]) cmdIO[0] = cmdIO[1] = 1;
1460 if (cmdIO[1]) hasMDP = (strstr(theCmd,
"$MDP") != 0);
1464 n = (cmdUrl ? 3 : 1);
1488 int XrdFrmConfig::xcopy(
int &TLim)
1492 if (!(val = cFile->
GetWord()) || !*val)
1493 {
Say.
Emsg(
"Config",
"copy command timeout not specified");
return 0;}
1512 int XrdFrmConfig::xcmax()
1515 if (!(val = cFile->
GetWord()))
1516 {
Say.
Emsg(
"Config",
"copymax value not specified");
return 1;}
1518 if (!strcmp(val,
"split"))
1519 {
if (!(val = cFile->
GetWord()))
1520 {
Say.
Emsg(
"Config",
"copymax in value not specified");
return 1;}
1522 if (!(val = cFile->
GetWord()))
1523 {
Say.
Emsg(
"Config",
"copymax out value not specified");
return 1;}
1548 int XrdFrmConfig::xdpol()
1552 if (!(val = cFile->
GetWord()))
1553 {
Say.
Emsg(
"Config",
"dirpolicy hold time not specified");
return 1;}
1571 int XrdFrmConfig::xitm(
const char *What,
int &tDest)
1575 if (!(val = cFile->
GetWord()))
1576 {
Say.
Emsg(
"Config", What,
"not specified");
return 1;}
1602 int XrdFrmConfig::xmon()
1603 {
char *val, *cp, *monDest[2] = {0, 0};
1604 int i, monIdent=3600, monMode[2] = {0, 0};
1606 while((val = cFile->
GetWord()))
1608 {
if (!strcmp(
"ident", val))
1609 {
if (!(val = cFile->
GetWord()))
1610 {
Say.
Emsg(
"Config",
"monitor ident value not specified");
1614 &monIdent,0))
return 1;
1619 if (!val) {
Say.
Emsg(
"Config",
"monitor dest not specified");
return 1;}
1621 for (i = 0; i < 2; i++)
1622 {
if (strcmp(
"dest", val))
break;
1623 while((val = cFile->
GetWord()))
1628 if (!val) {
Say.
Emsg(
"Config",
"monitor dest value not specified");
1631 if (!(cp = index(val, (
int)
':')) || !atoi(cp+1))
1632 {
Say.
Emsg(
"Config",
"monitor dest port missing or invalid in",val);
1635 monDest[i] = strdup(val);
1636 if (!(val = cFile->
GetWord()))
break;
1640 {
if (!strcmp(
"dest", val))
1641 Say.
Emsg(
"Config",
"Warning, a maximum of two dest values allowed.");
1642 else Say.
Emsg(
"Config",
"Warning, invalid monitor option", val);
1647 if (monDest[0] && monDest[1] && !strcmp(monDest[0], monDest[1]))
1648 {
Say.
Emsg(
"Config",
"Warning, monitor dests are identical.");
1649 monMode[0] |= monMode[1]; monMode[1] = 0;
1650 free(monDest[1]); monDest[1] = 0;
1655 if (!monMode[0] && !monMode[1])
return 0;
1677 int XrdFrmConfig::xnml()
1679 char *val, parms[1024];
1683 if (!(val = cFile->
GetWord()) || !val[0])
1684 {
Say.
Emsg(
"Config",
"namelib not specified");
return 1;}
1688 if (N2N_Lib) free(N2N_Lib);
1689 N2N_Lib = strdup(val);
1693 if (!cFile->
GetRest(parms,
sizeof(parms)))
1694 {
Say.
Emsg(
"Config",
"namelib parameters too long");
return 1;}
1695 if (N2N_Parms) free(N2N_Parms);
1696 N2N_Parms = (*parms ? strdup(parms) : 0);
1735 int XrdFrmConfig::xpol()
1741 struct purgeopts {
const char *opname;
int isTime;
int *oploc;} pgopts[] =
1743 {
"polprog", -1, &Ext},
1746 int i, rc, numopts =
sizeof(pgopts)/
sizeof(
struct purgeopts);
1750 if (!(val = cFile->
GetWord()))
1751 {
Say.
Emsg(
"Config",
"space name not specified");
return 1;}
1752 if (strlen(val) >=
sizeof(sname))
1753 {
Say.
Emsg(
"Config",
"space name '", val,
"' too long");
return 1;}
1757 if (!strcmp(
"=", val))
return xpolprog();
1763 if ( (val = cFile->
GetWord()) && isdigit(*val))
1765 if ((val = cFile->
GetWord()) && isdigit(*val))
1767 if ((minP < 0 && maxP >= 0) || (minP >= 0 && maxP < 0))
1768 {
Say.
Emsg(
"Config",
"purge min/max may not differ in type.");
1772 {
Say.
Emsg(
"Config",
"purge min must be < max value.");
return 1;}
1775 if (minP < 0) maxP = (minP < -99 ? -100 : minP - 1);
1776 else maxP = (minP * 120LL)/100LL;
1778 }
else if (val && !strcmp(val,
"nopurge"))
1781 {
Say.
Say(
"Config warning: ignoring extraneous policy option '",val,
"'.");
1789 {
for (i = 0; i < numopts; i++)
if (!strcmp(val,pgopts[i].opname))
break;
1791 {
Say.
Say(
"Config warning: ignoring invalid policy option '",val,
"'.");
1795 if (pgopts[i].isTime < 0) *(pgopts[i].oploc) = 1;
1796 else {
if (!(val = cFile->
GetWord()))
1797 {
Say.
Emsg(
"Config",
"policy", pgopts[i].opname,
1798 "argument not specified.");
1801 rc = (pgopts[i].isTime
1802 ? getTime(
"purge value",val,pgopts[i].oploc,0)
1803 :
XrdOuca2x::a2i (
Say,
"purge value",val,pgopts[i].oploc,0));
1812 {
Say.
Emsg(
"Config",
"External policy has not been pre-defined.");
1818 while(pP && strcmp(pP->Sname, sname)) pP = pP->Next;
1819 if (pP) {pP->minFree=minP; pP->maxFree=maxP; pP->Hold=Hold; pP->Ext=Ext;}
1820 else {pP =
new Policy(sname, minP, maxP, Hold, Ext);
1854 int XrdFrmConfig::xpolprog()
1856 char *val, pBuff[4096], *pbP = pBuff;
1857 struct polopts {
const char *opname;
int opval;} plopts[] =
1870 int i, n, numopts =
sizeof(plopts)/
sizeof(
struct polopts);
1874 if (!(val = cFile->
GetWord()))
1875 {
Say.
Emsg(
"Config",
"policy program not specified");
return 1;}
1880 while(val && *val !=
'|')
1881 {
for (i = 0; i < numopts; i++)
if (!strcmp(val,plopts[i].opname))
break;
1883 {
Say.
Say(
"Config warning: ignoring invalid policy option '",val,
"'.");
1888 {
Say.
Emsg(
"Config",
"To many policy program variables specified.");
1891 pVec[
pVecNum++] =
static_cast<char>(plopts[i].opval);
1898 if (val && !(*val)) val = cFile->
GetWord();
1900 {
Say.
Emsg(
"Config",
"policy program not specified.");
return 1;}
1902 if (i >= (
int)
sizeof(pBuff)-8)
1903 {
Say.
Emsg(
"Config",
"policy program name is too long.");
return 1;}
1904 strcpy(pBuff, val); pbP = pBuff+i; *(pbP+1) =
'\0';
1908 n =
sizeof(pBuff) - i - 1;
1909 if (!cFile->
GetRest(pbP+1, n))
1910 {
Say.
Emsg(
"Config",
"policy program args are too long.");
return 1;}
1911 if (*(pbP+1)) *pbP =
' ';
1916 pProg = strdup(pBuff);
1934 int XrdFrmConfig::xqchk()
1940 if (!(val = cFile->
GetWord()))
1941 {
Say.
Emsg(
"Config",
"qcheck time not specified");
return 1;}
1948 if (!(val = cFile->
GetWord()))
return 0;
1954 {
Say.
Emsg(
"Config",
"qcheck path not absolute");
return 1;}
1956 QPath = strdup(val);
1975 int XrdFrmConfig::xsit()
1979 if (!(val = cFile->
GetWord()))
1980 {
Say.
Emsg(
"Config",
"sitename value not specified");
return 1;}
1982 if (
mySite)
Say.
Emsg(
"Config",
"sitename already specified, using '",
2002 int XrdFrmConfig::xspace(
int isPrg,
int isXA)
2004 char *val, *pfxdir, *sfxdir;
2006 int i, k, rc, pfxln, cnum = 0;
2011 if (!(val = cFile->
GetWord()))
2012 {
Say.
Emsg(
"Config",
"space name not specified");
return 1;}
2013 if (strlen(val) >= (
int)
sizeof(grp))
2014 {
Say.
Emsg(
"Config",
"excessively long space name - ",val);
return 1;}
2017 if (!(val = cFile->
GetWord()))
2018 {
Say.
Emsg(
"Config",
"path to space not specified");
return 1;}
2022 if (!strcmp(val,
"assign") || !strcmp(val,
"default"))
return 0;
2025 if (k >= (
int)(
sizeof(fn)-1) || val[0] !=
'/' || k < 2)
2026 {
Say.
Emsg(
"Config",
"invalid space path - ", val);
return 1;}
2029 if (!isXA && (val = cFile->
GetWord()))
2030 {
if (strcmp(
"xa", val))
2031 {
Say.
Emsg(
"Config",
"invalid cache option - ",val);
return 1;}
2038 {
Say.
Emsg(
"Config",
"old-style spaces using oss.cache are no longer "
2044 {
for (i = k-1; i; i--)
if (fn[i] !=
'/')
break;
2045 fn[i+1] =
'/'; fn[i+2] =
'\0';
2046 xspaceBuild(grp, fn, isXA);
2050 for (i = k-1; i; i--)
if (fn[i] ==
'/')
break;
2051 i++; strcpy(dn, &fn[i]); fn[i] =
'\0';
2052 sfxdir = &fn[i]; pfxdir = dn; pfxln = strlen(dn)-1;
2054 {
Say.
Emsg(
"Config", errno,
"open space directory", fn);
return 1;}
2058 {
if (!strcmp(dp->d_name,
".") || !strcmp(dp->d_name,
"..")
2059 || (pfxln && strncmp(dp->d_name, pfxdir, pfxln)))
2061 strcpy(sfxdir, dp->d_name);
2062 if (
stat(fn, &buff))
break;
2063 if ((buff.st_mode & S_IFMT) == S_IFDIR)
2064 {val = sfxdir + strlen(sfxdir) - 1;
2065 if (*val++ !=
'/') {*val++ =
'/'; *val =
'\0';}
2066 xspaceBuild(grp, fn, isXA);
2073 Say.
Emsg(
"Config", errno,
"process space directory", fn);
2074 else if (!cnum)
Say.
Say(
"Config warning: no space directories found in ",val);
2080 void XrdFrmConfig::xspaceBuild(
char *grp,
char *fn,
int isxa)
2082 struct VPInfo *nP =
VPList;
2085 while(nP && strcmp(nP->Name, grp)) nP = nP->Next;
2090 while(tP && strcmp(tP->
text, fn)) tP = tP->
next;
2091 if (!tP) nP->Dir =
new XrdOucTList(fn, isxa, nP->Dir);
2093 if (!isxa)
nonXA = 1;
2111 int XrdFrmConfig::xxfr()
2113 static const int maxfdln = 256;
2114 const char *wantParm = 0;
2116 int htime = 3*60*60;
2118 while((val = cFile->
GetWord()))
2119 {
if (!strcmp(
"deny", val))
2120 {wantParm =
"xfr deny";
2126 else if (!strcmp(
"fdir", val))
2127 {wantParm =
"xfr fdir";
2132 {
Say.
Emsg(
"Config",
"xfr fdir path too long");
2139 else if (!strcmp(
"keep", val))
2140 {wantParm =
"xfr keep";
2149 if (!val && wantParm)
2150 {
Say.
Emsg(
"Config", wantParm,
"value not specified");
return 1;}
void * XrdFrmConfigMum(void *parg)
XrdOss * XrdOssGetSS(XrdSysLogger *Logger, const char *config_fn, const char *OssLib, const char *OssParms, XrdOucEnv *envP, XrdVersionInfo &urVer)
XrdOucPListAnchor * XrdOssRPList
int stat(const char *path, struct stat *buf)
struct dirent * readdir(DIR *dirp)
int open(const char *path, int oflag,...)
int fcntl(int fd, int cmd,...)
ssize_t write(int fildes, const void *buf, size_t nbyte)
int access(const char *path, int amode)
ssize_t read(int fildes, void *buf, size_t nbyte)
DIR * opendir(const char *path)
int emsg(int rc, char *msg)
#define XRDSYSTHREAD_BIND
static char * makePath(const char *iName, const char *Path, int Mode)
static const int cnsIgnore
static const int cnsRequire
static int Init(const char *aPath, int Opts)
struct XrdFrmConfig::Cmd xfrCmd[4]
XrdOucTList * Space(const char *Name, const char *Path=0)
int LogicalPath(const char *oldp, char *newp, int newpsz)
int NeedsCTA(const char *Lfn)
XrdNetCmsNotify * cmsPath
static const int cmdStats
static const int cmdAlloc
struct XrdFrmConfig::VPInfo * VPList
int RemotePath(const char *oldp, char *newp, int newpsz)
unsigned long long PathOpts(const char *Lfn)
XrdFrmConfig(SubSys ss, const char *vopts, const char *uinfo)
int Stat(const char *xLfn, const char *xPfn, struct stat *buff)
XrdOucName2Name * the_N2N
int LocalPath(const char *oldp, char *newp, int newpsz)
int Configure(int argc, char **argv, int(*ppf)())
static int Init(const char *iHost, const char *iProg, const char *iName)
static void Defaults(char *dest1, int m1, char *dest2, int m2, int iTime)
const char * Name(const char *eName=0, const char **eText=0)
bool Plugin(XrdAccAuthorize *&piP)
Get Authorization plugin.
static XrdOfsConfigPI * New(const char *cfn, XrdOucStream *cfgP, XrdSysError *errP, XrdVersionInfo *verP=0, XrdSfsFileSystem *sfsP=0)
void DefaultCS(const char *alg)
bool Load(int what, XrdOucEnv *envP=0)
@ theCksLib
Checksum manager plugin.
@ theAtrLib
Extended attribute plugin.
static const int minSNbsz
virtual int StatPF(const char *path, struct stat *buff, int opts)
virtual int Stat(const char *path, struct stat *buff, int opts=0, XrdOucEnv *envP=0)=0
static int Export(const char *Var, const char *Val)
int Parse(const char *oname, char *msg)
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0
virtual int pfn2lfn(const char *pfn, char *buff, int blen)=0
virtual int lfn2rfn(const char *lfn, char *buff, int blen)=0
unsigned long long Find(const char *pathname)
unsigned long long Flag()
int Setup(const char *prog, XrdSysError *errP=0, int(*Proc)(XrdOucStream *, char **, int)=0)
static const char * Set(const char *name, int maxlen=15)
char * GetMyFirstWord(int lowcase=0)
char * GetWord(int lowcase=0)
XrdOucEnv * SetEnv(XrdOucEnv *newEnv)
int GetRest(char *theBuf, int Blen, int lowcase=0)
static void Capture(const char **cVec=0, bool linefeed=true)
static const char * InstName(int TranOpt=0)
static bool PidFile(XrdSysError &eDest, const char *path)
static void makeHome(XrdSysError &eDest, const char *inst)
static void Undercover(XrdSysError &eDest, int noLog, int *pipeFD=0)
static char * subLogfn(XrdSysError &eDest, const char *inst, char *logfn)
static int a2sp(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
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)
const char * SetPrefix(const char *prefix)
void setHiRes()
Set log file timstamp to high resolution (hh:mm:ss.uuuu).
void AddMsg(const char *msg)
int Bind(const char *path, int lfh=0)
int ParseKeep(const char *arg)
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
XrdVERSIONINFODEF(myVersion, cmsclient, XrdVNUMBER, XrdVERSION)