36 #include <sys/param.h>
38 #include <sys/types.h>
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];}
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;}
155 {strcpy(fnP, lP->
File);
157 {
Say.
Emsg(
"Refresh", errno,
"stat", pBuff);
return 0;}
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);
236 int 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;
276 if (!dInfo)
return fP->
Path;
280 strcpy(dInfo->
text+dInfo->ival[dLen], fP->
File);
288 void 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,
313 shareD(
opts & CompressD), getCPT(
opts & GetCpyTim)
332 while((fsetP = fsList))
333 {fsList = fsetP->
Next; fsetP->
Next = 0;
delete fsetP;}
348 do{
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));
378 void 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);
433 int fType, noDLKF = 1, runOldFault = 0;
440 {
int n = strlen(dPath);
441 char *dBuff = (
char *)malloc(n+264);
442 strcpy(dBuff, dPath);
445 dP->ival[XrdFrmFileset::dLen] = n;
446 dP->ival[XrdFrmFileset::dRef] = 0;
453 if (noDLKF && !strcmp(fP->
File,
Config.lockFN))
454 {oldFile(fP, dP, -1);
delete fP; noDLKF = 0;
continue;}
456 || !(dotP = rindex(fP->
File,
'.'))) dotP = 0;
458 {runOldFault |= oldFile(fP, dP, fType);
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;
int stat(const char *path, struct stat *buf)
int open(const char *path, int oflag,...)
int fcntl(int fd, int cmd,...)
int unlink(const char *path)
XrdFrmFiles(const char *dname, int opts=Recursive, XrdOucTList *XList=0, XrdOucNSWalk::CallBack *cbP=0)
XrdFrmFileset * Get(int &rc, int noBase=0)
int setCpyTime(int Refresh=0)
int Refresh(int isMig=0, int doLock=1)
XrdOucXAttr< XrdFrcXAttrCpy > cpyInfo
int dirPath(char *dBuff, int dBlen)
XrdOucXAttr< XrdFrcXAttrPin > pinInfo
XrdOucNSWalk::NSEnt * pinFile()
XrdOucNSWalk::NSEnt * baseFile()
XrdFrmFileset(XrdFrmFileset *sP=0, XrdOucTList *diP=0)
XrdOucNSWalk::NSEnt * lockFile()
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)
T * Find(const char *KeyVal, time_t *KeyTime=0)
void setCallBack(CallBack *cbP=0)
NSEnt * Index(int &rc, const char **dPath=0)
int Get(const char *Path, int fd=-1)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void * Refresh(void *parg)