42 #include <sys/param.h>
44 #include <sys/types.h>
46 #include <sys/vnode.h>
50 #include "XrdVersion.hh"
80 #define ENOATTR ENODATA
87 #define isNOSTAGE(_x_) !(XRDEXP_STAGE & XrdPssSys::XPList.Find(_x_))
89 #define isREADONLY(_x_) (XRDEXP_NOTRW & XrdPssSys::XPList.Find(_x_))
190 eDest.
Say(
"Copr. 2019, Stanford University, Pss Version " XrdVSTRING);
194 tmp = ((NoGo = Configure(cFN,
envP)) ?
"failed." :
"completed.");
195 eDest.
Say(
"------ Proxy storage system initialization ", tmp);
241 if (idMapper && client)
242 {
const char *fmt = (client->
ueid & 0xf0000000 ?
"%x" :
"U%x");
244 snprintf(uName,
sizeof(uName), fmt, client->
ueid);
290 if (idMapper && client)
291 {
const char *fmt = (client->
ueid & 0xf0000000 ?
"%x" :
"U%x");
293 snprintf(uName,
sizeof(uName), fmt, client->
ueid);
294 DEBUG(client->
tident,
"Unregistering as ID "<<uName);
320 if (theN2N)
return -(theN2N->
lfn2pfn(oldp, newp, blen));
321 if ((
int)strlen(oldp) >= blen)
return -ENAMETOOLONG;
328 if (!theN2N) {rc = 0;
return oldp;}
329 if ((rc = -(theN2N->
lfn2pfn(oldp, newp, blen))))
return 0;
392 const char *Cgi =
"";
463 DEBUG(uInfoOld.
Tident(),
"old url="<<oldNameObf <<
" new url=" <<newNameObf);
493 const char *Cgi =
"";
603 const char *Cgi =
"";
662 if (*dir_path !=
'/')
return -ENOTSUP;
684 if (!myDir)
return -errno;
712 {dirent *entP, myEnt;
715 if (!entP) *buff = 0;
716 else strlcpy(buff, myEnt.d_name, blen);
743 if ((theDir = myDir))
775 const char *Cgi =
"";
778 bool tpcMode = (Oflag & O_NOFOLLOW) != 0;
779 bool rwMode = (Oflag & (O_WRONLY | O_RDWR | O_APPEND)) != 0;
809 char *envcgi = (
char *)Env.
Env(elen);
811 if (envcgi && strstr(envcgi,
"only-if-cached"))
815 myData.
Arg1 =
"cached";
818 const char *myArgs[1];
820 myData.ArgP = myArgs;
836 {Oflag &= ~O_NOFOLLOW;
839 {tpcPath = strdup(path);
841 {
const char *rPath = Env.
Get(
"tpc.reproxy");
842 if (!rPath || *rPath !=
'/')
return -
ENOATTR;
843 if (!(rPath = rindex(rPath,
'/')) || *(rPath+1) == 0)
845 rpInfo =
new tprInfo(rPath+1);
884 {Env.
Put(
"FileURL",
Info.cacheURL);
885 return -EDESTADDRREQ;
888 if (
fd < 0)
return -errno;
912 if (retsz) *retsz = 0;
927 return (rc == 0 ?
XrdOssOK : -errno);
954 std::vector<uint32_t> vecCS;
969 return (ssize_t)-errno;
973 if (vecCS.size() && csvec)
974 memcpy(csvec, vecCS.data(), vecCS.size()*
sizeof(uint32_t));
1007 std::vector<uint32_t> vecCS;
1027 if (csvec) memcpy(csvec, vecCS.data(), vecCS.size()*
sizeof(uint32_t));
1032 memcpy(vecCS.data(), csvec, n*
sizeof(uint32_t));
1041 return (bytes < 0 ? (ssize_t)-errno : bytes);
1088 ? (ssize_t)-errno : retval;
1135 return Read(buff, offset, blen);
1160 ? (ssize_t)-errno : retval;
1198 if (rpInfo->dstURL == 0
1199 || !fstatat(
rpFD, rpInfo->tprPath, &
Stat, AT_SYMLINK_NOFOLLOW))
1200 {
char lnkbuff[2048];
int lnklen;
1201 lnklen = readlinkat(
rpFD, rpInfo->tprPath, lnkbuff,
sizeof(lnkbuff)-1);
1204 if (lnklen < 0) {
if (errno != ENOENT) rc = -errno;}
1207 {unlinkat(
rpFD, rpInfo->tprPath, 0);
1211 unlinkat(
rpFD, rpInfo->tprPath, 0);
1212 lnkbuff[lnklen] = 0;
1213 if (rpInfo->dstURL) free(rpInfo->dstURL);
1214 rpInfo->dstURL = strdup(lnkbuff);
1216 DEBUG(
tident,rpInfo->tprPath<<
" maps "<<tpcPath<<
" -> "<<lnkbuff);
1225 {
if (!(rpInfo->fSize = buff->st_size)) rpInfo->fSize = 1;
1228 free(rpInfo->dstURL);
1235 {memset(buff, 0,
sizeof(
struct stat));
1236 buff->st_size = rpInfo->fSize;
1246 memset(buff, 0,
sizeof(
struct stat));
1319 Slash = index(path,
'/');
1320 if (!Slash || (n = (Slash - path)) == 0) {retc = -EINVAL;
return 0;}
1321 if (n >= hBlen) {retc = -ENAMETOOLONG;
return 0;}
1322 strncpy(hBuff, path, n); hBuff[n] = 0;
1327 {retc = -EACCES;
return 0;}
1339 {
const char *theID = uInfo.
getID();
1340 const char *pname, *path, *thePath;
1346 thePath = path = uInfo.
thePath();
1350 if (*path ==
'/') path++;
1352 else {
if (!
hdrLen)
return -ENOTSUP;
1353 n = snprintf(pbuff, pblen,
hdrData, theID, thePath);
1354 if (n >= pblen || !uInfo.
addCGI(pbuff, pbuff+n, pblen-n))
1355 return -ENAMETOOLONG;
1361 if (*thePath !=
'/')
1364 if (*path ==
'/') theID =
"";
1367 path+(*path ==
'/' ? 1:0)))
return 0;
1368 n = snprintf(pbuff, pblen,
"%s%s%s", pname, theID, path);
1369 if (n >= pblen || !uInfo.
addCGI(pbuff, pbuff+n, pblen-n))
1370 return -ENAMETOOLONG;
1378 if (!(n =
P2DST(retc, hBuff,
sizeof(hBuff),
PolPath, path)))
return 0;
1385 if (index(hBuff,
'@')) theID=
"";
1386 n = snprintf(pbuff,pblen,
"%s%s%s/%s",pname,theID,hBuff,path);
1390 if (n >= pblen || !uInfo.
addCGI(pbuff, pbuff+n, pblen-n))
1391 return -ENAMETOOLONG;
1411 const char *path = uInfo.
thePath();
1413 char Apath[MAXPATHLEN+1];
1424 {
if (retc > 0)
return -retc;}
1432 else pfxLen = snprintf(pbuff, pblen,
hdrData, uInfo.
getID(), path);
1433 if (pfxLen >= pblen)
return -ENAMETOOLONG;
1438 {
if (!uInfo.
addCGI(pbuff, pbuff+pfxLen, pblen-pfxLen))
1439 return -ENAMETOOLONG;
XrdAccAuthorize * Authorize
std::string obfuscateAuth(const std::string &input)
int stat(const char *path, struct stat *buf)
XrdVERSIONINFO(XrdOssGetStorageSystem2, XrdPss)
XrdOss * XrdOssGetStorageSystem2(XrdOss *native_oss, XrdSysLogger *Logger, const char *cFN, const char *parms, XrdOucEnv *envp)
const char * Arg1
PLUGINO, PLUGION, PLUGXC.
int Arg2Len
Length or -count of args in extension.
< SFS_FSCTL_PLUGIN/PLUGIO/PLUGXC parms
virtual int FSctl(const int cmd, int alen, const char *args, XrdSfsFile &file, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)=0
static const uint64_t doCalc
pgw: Calculate checksums
static const uint64_t Verify
all: Verify checksums
void * GetPtr(const char *varname)
char * Get(const char *varname)
const XrdSecEntity * secEnv() const
void Put(const char *varname, const char *value)
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0
unsigned long long Find(const char *pathname)
static void csCalc(const char *data, off_t offs, size_t count, uint32_t *csval)
static bool csVer(dataInfo &dInfo, off_t &bado, int &badc)
static int csNum(off_t offs, int count)
Compute the required size of a checksum vector based on offset & length.
static bool OpenFC(const char *path, int oflag, mode_t mode, XrdPosixInfo &Info)
static int Stats(const char *theID, char *buff, int blen)
static void EnvInfo(XrdOucEnv &theEnv)
static ssize_t Pread(int fildes, void *buf, size_t nbyte, off_t offset)
Pread() conforms to POSIX.1-2001 pread()
static int Closedir(DIR *dirp)
Closedir() conforms to POSIX.1-2001 closedir()
static int Stat(const char *path, struct stat *buf)
Stat() conforms to POSIX.1-2001 stat()
static int Mkdir(const char *path, mode_t mode)
Mkdir() conforms to POSIX.1-2001 mkdir()
static int Unlink(const char *path)
Unlink() conforms to POSIX.1-2001 unlink()
static int Rmdir(const char *path)
Rmdir() conforms to POSIX.1-2001 rmdir()
static void VRead(int fildes, const XrdOucIOVec *readV, int n, XrdPosixCallBackIO *cbp)
static int Rename(const char *oldpath, const char *newpath)
Rename() conforms to POSIX.1-2001 rename()
static int Close(int fildes)
Close() conforms to POSIX.1-2001 close()
static int Readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
static int QueryError(std::string &emsg, int fd=-1, bool reset=true)
static int Ftruncate(int fildes, off_t offset)
Ftruncate() conforms to POSIX.1-2001 ftruncate()
static DIR * Opendir(const char *path)
Opendir() conforms to POSIX.1-2001 opendir()
static int Fsync(int fildes)
Fsync() conforms to POSIX.1-2001 fsync()
static int Fstat(int fildes, struct stat *buf)
Fstat() conforms to POSIX.1-2001 fstat()
static int Open(const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)
static ssize_t Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
Pwrite() conforms to POSIX.1-2001 pwrite()
static int Truncate(const char *path, off_t offset)
Telldir() conforms to POSIX.1-2001 telldir()
int Close(long long *retsz=0)
int Opendir(const char *, XrdOucEnv &)
int Readdir(char *buff, int blen)
ssize_t ReadRaw(void *, off_t, size_t)
virtual int Close(long long *retsz=0)
virtual int Open(const char *, int, mode_t, XrdOucEnv &)
ssize_t Read(off_t, size_t)
ssize_t Write(const void *, off_t, size_t)
ssize_t ReadV(XrdOucIOVec *readV, int n)
ssize_t pgRead(void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
int Ftruncate(unsigned long long)
ssize_t pgWrite(void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0) override
static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo)
int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0) override
virtual void Connect(XrdOucEnv &) override
int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0) override
int Stats(char *bp, int bl) override
static const char * hdrData
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0) override
int Init(XrdSysLogger *, const char *) override
static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType, const char *path)
int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0) override
void EnvInfo(XrdOucEnv *envP) override
static XrdNetSecurity * Police[PolNum]
static XrdOucPListAnchor XPList
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0) override
int Lfn2Pfn(const char *Path, char *buff, int blen) override
virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0) override
virtual void Disc(XrdOucEnv &) override
int Rename(const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0) override
void setID(const char *tid=0)
bool addCGI(const char *prot, char *buff, int blen)
static const char * valProt(const char *pname, int &plen, int adj=0)
const char * tident
Trace identifier always preset.
unsigned int ueid
Unique ID of entity instance.
bool Register(const char *lgnid, const XrdSecEntity *Ident, bool doReplace=false, bool defer=false)
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)
void SetLogger(XrdSysLogger *logp)
XrdOfsFSctl_PI * cacheFSctl
XrdSysTrace SysTrace("Pss", 0)
XrdSysError eDest(0, "pss_")
static const char * osslclCGI
thread_local XrdOucECMsg ecMsg("[pss]")
static XrdPssSys XrdProxySS
static const char * ofslclCGI