38 #include <sys/param.h>
39 #include <sys/types.h>
73 const int ro_Mode = ~(S_IWUSR | S_IWGRP | S_IWOTH);
74 char actual_path[MAXPATHLEN+1], *local_path, *remote_path;
75 unsigned long long popts;
85 if ((retc =
lcl_N2N->
lfn2pfn(path, actual_path,
sizeof(actual_path))))
87 else local_path = actual_path;
88 else local_path = (
char *)path;
94 {retc = (
STT_V2 ? (*STT_Fund)(local_path, buff,
opts, EnvP, path)
95 : (*STT_Func)(local_path, buff,
opts, EnvP));
96 }
else retc =
stat(local_path, buff);
100 {
struct utimbuf times;
101 times.actime = time(0);
102 times.modtime = buff->st_mtime;
103 utime(local_path, ×);
106 }
else if (errno != ENOENT)
return (errno ? -errno : -ENOMSG);
111 || (EnvP && EnvP->
Get(
"oss.lcl")))
return -errno;
117 if ((retc =
rmt_N2N->
lfn2rfn(path, actual_path,
sizeof(actual_path))))
119 else remote_path = actual_path;
120 else remote_path = (
char *)path;
124 if ((retc =
MSS_Stat(remote_path, buff)))
return retc;
147 int sVal, wVal, Util;
148 long long fSpace, fSize;
149 unsigned long long Opt;
153 StatFS(path, Opt, fSize, fSpace);
159 if (fSpace <= 0) {fSize = fSpace = 0; Util = 0;}
160 else {Util = (fSize ? (fSize - fSpace)*100LL/fSize : 0);
161 fSpace = fSpace >> 20LL;
162 if ((fSpace >> 31LL)) fSpace = 0x7fffffff;
167 blen = snprintf(buff, blen,
"%d %lld %d %d %lld %d",
168 wVal, (wVal ? fSpace : 0LL), (wVal ? Util : 0),
169 sVal, (sVal ? fSpace : 0LL), (sVal ? Util : 0));
188 long long &fSize,
long long &fSpace)
199 {
char lcl_path[MAXPATHLEN+1];
206 else {fSpace = 0; fSize = 0;}
227 static const char *Resp=
"oss.cgroup=%s&oss.space=%lld&oss.free=%lld"
228 "&oss.maxf=%lld&oss.used=%lld&oss.quota=%lld";
237 {
unsigned long long Opt;
238 long long fSpace, fSize;
239 StatFS(path, Opt, fSize, fSpace);
240 if (fSpace < 0) fSpace = 0;
241 blen = snprintf(buff, blen, Resp,
"public", fSize, fSpace, fSpace,
249 {
if ((retc =
getCname(path, &sbuff, cgbuff)))
return retc;
256 ? snprintf(buff,blen,Resp,cgrp,CSpace.Total,CSpace.Free,CSpace.Maxfree,
257 CSpace.Usage,CSpace.Quota)
258 : snprintf(buff, blen, Resp, cgrp, 0LL, 0LL, 0LL, 0LL, -1LL));
278 char lcl_path[MAXPATHLEN+1];
307 if (
stat(path, buff))
return (errno ? -errno : -ENOMSG);
364 if (*sname !=
'+') vsP = 0;
405 long long Size, Mtime, Ctime, Atime;
410 if ((retc =
getCname(path, &sbuff, cgbuff)))
return retc;
411 if (S_ISREG(sbuff.st_mode)) fType =
'f';
412 else if (S_ISDIR(sbuff.st_mode)) fType =
'd';
417 Size = sbuff.st_size;
418 Mtime = sbuff.st_mtime; Ctime = sbuff.st_ctime; Atime = sbuff.st_atime;
419 blen = snprintf(buff, blen,
420 "oss.cgroup=%s&oss.type=%c&oss.used=%lld&oss.mt=%lld"
421 "&oss.ct=%lld&oss.at=%lld&oss.u=*&oss.g=*&oss.fs=%c",
422 cgbuff, fType, Size, Mtime, Ctime, Atime,
423 (sbuff.st_mode & S_IWUSR ?
'w':
'r'));
458 char actual_path[MAXPATHLEN+1];
464 if ((retc =
lcl_N2N->
lfn2pfn(path, actual_path,
sizeof(actual_path))))
466 else thePath = actual_path;
471 if ((retc =
stat(thePath, sbuff)))
return -errno;
476 if (S_ISDIR(sbuff->st_mode)) strcpy(cgbuff,
"public");
477 else if (S_ISBLK(sbuff->st_mode)) strcpy(cgbuff,
"*");
491 static const char ptag1[] =
"<paths>%d";
492 static const char ptag2[] =
"<stats id=\"%d\"><lp>\"%s\"</lp><rp>\"%s\"</rp>"
493 "<tot>%lld</tot><free>%lld</free><ino>%lld</ino><ifr>%lld</ifr></stats>";
494 static const char ptag3[] =
"</paths>";
496 static const int ptag1sz =
sizeof(ptag1);
497 static const int ptag2sz =
sizeof(ptag2) + (16*4);
498 static const int ptag3sz =
sizeof(ptag3);
500 static const char stag1[] =
"<space>%d";
501 static const char stag2[] =
"<stats id=\"%d\"><name>%s</name>"
502 "<tot>%lld</tot><free>%lld</free><maxf>%lld</maxf>"
503 "<fsn>%d</fsn><usg>%lld</usg>";
504 static const char stagq[] =
"<qta>%lld</qta>";
505 static const char stags[] =
"</stats>";
506 static const char stag3[] =
"</space>";
508 static const int stag1sz =
sizeof(stag1);
510 static const int stagqsz =
sizeof(stagq) + 16;
511 static const int stagssz =
sizeof(stags);
512 static const int stag3sz =
sizeof(stag3);
514 static const int stagsz = ptag1sz + ptag2sz + ptag3sz + 1024 +
515 + stag1sz + stag2sz + stag3sz
521 int dpNum = 0, spNum = 0, n, flen;
526 if (!buff)
return ptag1sz + (ptag2sz *
numDP) + stag3sz +
lenDP
527 + stag1sz + (stag2sz *
numCG) + stag3sz
532 if (blen <= stagsz)
return 0;
536 flen = sprintf(bp, ptag1,
numDP); bp += flen; blen -= flen;
540 while(dpP && blen > 0)
543 flen = snprintf(bp, blen, ptag2, dpNum, dpP->
Path1, dpP->
Path2,
546 dpP = dpP->
Next; bp += flen; blen -= flen; dpNum++;
551 if (blen <= ptag3sz)
return 0;
552 strcpy(bp, ptag3); bp += (ptag3sz-1); blen -= (ptag3sz-1);
557 if (blen <= stag1sz)
return (blen < 0 ? 0 : dpNum);
558 flen = snprintf(bp, blen, stag1,
numCG); bp += flen; blen -= flen;
559 if (blen <= stag1sz)
return dpNum;
563 while(fsg && blen > 0)
566 flen = snprintf(bp, blen, stag2, spNum, fsg->
group, CSpace.
Total>>10,
568 bp += flen; blen -= flen; spNum++;
569 if (CSpace.
Quota >= 0 && blen > stagqsz)
570 {flen = sprintf(bp, stagq, CSpace.
Quota); bp += flen; blen -= flen;}
571 if (blen < stagssz)
return dpNum;
572 strcpy(bp, stags); bp += (stagssz-1); blen -= (stagssz-1);
578 if (blen >= stag3sz) {strcpy(bp, stag3); bp += (stag3sz-1);}
int stat(const char *path, struct stat *buf)
static int getSpace(XrdOssCache_Space &Space, const char *sname, XrdOssVSPart **vsPart=0)
static long long freeSpace(long long &Size, const char *path=0)
static long long PubQuota
static XrdOssCache_Group * fsgroups
static void * Scan(int cscanint)
static void DevInfo(struct stat &buf, bool limits=false)
static int getCname(const char *path, char *Cache, char *lbuf=0, int lbsz=0)
static const int minSNbsz
static const int maxSNlen
int StatLS(XrdOucEnv &env, const char *path, char *buff, int &blen)
int StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
int IsRemote(const char *path)
int StatXP(const char *path, unsigned long long &attr, XrdOucEnv *Env=0)
int getStats(char *buff, int blen)
int getCname(const char *path, struct stat *sbuff, char *cgbuff)
int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *Env=0)
int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *Env=0)
unsigned long long PathOpts(const char *path)
XrdOucName2Name * lcl_N2N
int MSS_Stat(const char *, struct stat *buff=0)
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *Env=0)
int StatPF(const char *, struct stat *, int)
XrdOucName2Name * rmt_N2N
static const int PF_dStat
static const int PF_dNums
static const int PF_dInfo
static const int PF_isLFN
char * Get(const char *varname)
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0
virtual int lfn2rfn(const char *lfn, char *buff, int blen)=0