63 :
Next(sP), dInfo(diP)
64{ memset(File, 0,
sizeof(File));
65 if (diP) diP->ival[dRef]++;
82 if (dInfo && ((dInfo->ival[dRef] -= 1) <= 0))
delete dInfo;
97 if (dInfo) {dP = dInfo->text; dN = dInfo->ival[dLen];}
101 dN = File[i]->File - File[i]->Path;
108 if (dBlen > dN && dP) strncpy(dBuff, dP, dN);
123 fdClose() : Num(-1) {}
124 ~fdClose() {
if (Num >= 0)
close(Num);}
127 char pBuff[MAXPATHLEN+1], *fnP, *pnP = pBuff;
132 if (!(n =
dirPath(pBuff,
sizeof(pBuff)-1)))
return 0;
139 if (!(lkFD = chkLock(pBuff)))
return 0;
147 else strcpy(fnP, bP->
File);
149 {
Say.Emsg(
"Refresh", errno,
"stat", pnP);
return 0;}
152 if (!isMig)
pinInfo.Get(pnP, lkFD);
155 {strcpy(fnP, lP->
File);
157 {
Say.Emsg(
"Refresh", errno,
"stat", pBuff);
return 0;}
158 cpyInfo.Attr.cpyTime =
static_cast<long long>(lP->
Stat.st_mtime);
172 const char *What = 0, *badFN = 0;
185 What =
"No base file for";
192 What =
Config.runNew ?
"no copy time xattr for" :
"no lock file for";
199 Say.Emsg(
"Screen", What, badFN);
222 {
Say.Emsg(
"setCpyTime", errno,
"stat",
lockPath());
return 0;}
223 cpyInfo.Attr.cpyTime =
static_cast<long long>(lP->
Stat.st_mtime);
236int XrdFrmFileset::chkLock(
const char *
Path)
243 if ((lokFD =
open(
Path, O_RDONLY)) < 0)
244 {
Say.Emsg(
"chkLock", errno,
"open",
Path);
return 0;}
248 bzero(&lock_args,
sizeof(lock_args));
249 lock_args.l_type = F_WRLCK;
253 do {rc =
fcntl(lokFD, F_GETLK, &lock_args);}
while(rc < 0 && errno == EINTR);
257 if (!rc)
return lokFD;
258 Say.Emsg(
"chkLock", errno,
"lock",
Path);
276 if (!dInfo)
return fP->
Path;
280 strcpy(dInfo->text+dInfo->ival[dLen], fP->
File);
288void XrdFrmFileset::Remfix(
const char *fType,
const char *fPath)
293 if (
unlink(fPath))
Say.Emsg(
"Remfix", errno,
"remove orphan", fPath);
294 Say.Emsg(
"Remfix", fType,
"file orphan fixed; removed", fPath);
306 : nsObj(&
Say, dname, 0,
318 nsObj.setCallBack(cbP);
332 while((fsetP = fsList))
333 {fsList = fsetP->
Next; fsetP->
Next = 0;
delete fsetP;}
348do{
while ((fsetP = fsList))
349 {fsList = fsetP->
Next; fsetP->
Next = 0;
352 rc = 0;
return fsetP;
354 else if (noBase) {rc = 0;
return fsetP;}
355 else if (manMem)
delete fsetP;
360 do {
if (!(nP = nsObj.Index(rc, &dPath)))
return 0;
361 fsTab.Purge(); fsList = 0;
362 }
while(!Process(nP, dPath));
378void XrdFrmFiles::Complain(
const char *dPath)
380 static const int OneDay = 24*60*60;
389 Say.Emsg(
"Complain",
"Found old-style files in directory", dPath);
390 Say.Emsg(
"Complain",
"In new run mode, migrate & purge will skip them.");
399 char pBuff[MAXPATHLEN+8], *pnP = pBuff, *fnP;
409 if (fType >= 0)
return 1;
413 if (!dP) pnP = fP->
Path;
414 else {strcpy(pBuff, dP->
text);
415 fnP = pBuff + dP->ival[XrdFrmFileset::dLen];
417 strcpy(fnP, fP->
File);
429 XrdOucNSWalk::NSEnt *fP;
433 int fType, noDLKF = 1, runOldFault = 0;
440 {
int n = strlen(dPath);
441 char *dBuff = (
char *)malloc(n+264);
442 strcpy(dBuff, dPath);
443 dP =
new XrdOucTList;
445 dP->ival[XrdFrmFileset::dLen] = n;
446 dP->ival[XrdFrmFileset::dRef] = 0;
454 {oldFile(fP, dP, -1);
delete fP; noDLKF = 0;
continue;}
456 || !(dotP = rindex(fP->
File,
'.'))) dotP = 0;
458 {runOldFault |= oldFile(fP, dP, fType);
463 if (!(sP = fsTab.Find(fP->
File)))
464 {sP = fsList =
new XrdFrmFileset(fsList, dP);
465 fsTab.Add(fP->
File, sP, 0, manMem);
467 if (dotP) *dotP =
'.';
468 sP->File[fType] = fP;
473 if (runOldFault) Complain(dPath);
477 if (fsList)
return 1;
XrdOucPup XrdCmsParser::Pup & Say
int fcntl(int fd, int cmd,...)
static const int CompressD
static const int NoAutoDel
XrdFrmFiles(const char *dname, int opts=Recursive, XrdOucTList *XList=0, XrdOucNSWalk::CallBack *cbP=0)
static const int GetCpyTim
XrdFrmFileset * Get(int &rc, int noBase=0)
static const int Recursive
int setCpyTime(int Refresh=0)
int Refresh(int isMig=0, int doLock=1)
XrdOucNSWalk::NSEnt * baseFile()
XrdOucXAttr< XrdFrcXAttrCpy > cpyInfo
XrdOucNSWalk::NSEnt * lockFile()
int dirPath(char *dBuff, int dBlen)
XrdOucXAttr< XrdFrcXAttrPin > pinInfo
XrdOucNSWalk::NSEnt * pinFile()
XrdFrmFileset(XrdFrmFileset *sP=0, XrdOucTList *diP=0)
static theSfx pathType(const char *Path, int chkWhat=chkAll)
T * Add(const char *KeyVal, T *KeyData, const int LifeTime=0, XrdOucHash_Options opt=Hash_default)