xrootd
XrdPss.hh
Go to the documentation of this file.
1 #ifndef _XRDPSS_API_H
2 #define _XRDPSS_API_H
3 /******************************************************************************/
4 /* */
5 /* X r d P s s . h h */
6 /* */
7 /* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <errno.h>
34 #include <unistd.h>
35 #include <sys/types.h>
36 #include "XrdSys/XrdSysHeaders.hh"
37 #include "XrdOuc/XrdOucExport.hh"
39 #include "XrdOuc/XrdOucPList.hh"
40 #include "XrdOuc/XrdOucSid.hh"
41 #include "XrdOss/XrdOss.hh"
42 
43 /******************************************************************************/
44 /* X r d P s s D i r */
45 /******************************************************************************/
46 
47 class XrdPssDir : public XrdOssDF
48 {
49 public:
50 int Close(long long *retsz=0);
51 int Opendir(const char *, XrdOucEnv &);
52 int Readdir(char *buff, int blen);
53 
54  // Constructor and destructor
55  XrdPssDir(const char *tid) : tident(tid), myDir(0) {}
56  ~XrdPssDir() {if (myDir) Close();}
57 private:
58 const char *tident;
59  DIR *myDir;
60 };
61 
62 /******************************************************************************/
63 /* X r d P s s F i l e */
64 /******************************************************************************/
65 
66 struct XrdOucIOVec;
67 class XrdSfsAio;
68 
69 class XrdPssFile : public XrdOssDF
70 {
71 public:
72 
73 // The following two are virtual functions to allow for upcasting derivations
74 // of this implementation
75 //
76 virtual int Close(long long *retsz=0);
77 virtual int Open(const char *, int, mode_t, XrdOucEnv &);
78 
79 int Fchmod(mode_t mode) {return XrdOssOK;}
80 int Fstat(struct stat *);
81 int Fsync();
82 int Fsync(XrdSfsAio *aiop);
83 int Ftruncate(unsigned long long);
84 off_t getMmap(void **addr);
85 int isCompressed(char *cxidp=0);
86 ssize_t Read( off_t, size_t);
87 ssize_t Read( void *, off_t, size_t);
88 int Read(XrdSfsAio *aiop);
89 ssize_t ReadV(XrdOucIOVec *readV, int n);
90 ssize_t ReadRaw( void *, off_t, size_t);
91 ssize_t Write(const void *, off_t, size_t);
92 int Write(XrdSfsAio *aiop);
93 
94  // Constructor and destructor
95  XrdPssFile(const char *tid) : tident(tid), tpcPath(0)
96  {fd = -1;}
97 
98 virtual ~XrdPssFile() {if (fd >= 0) Close();
99  if (tpcPath) free(tpcPath);
100  }
101 
102 private:
103 
104 const char *tident;
105  char *tpcPath;
106 };
107 
108 /******************************************************************************/
109 /* X r d P s s S y s */
110 /******************************************************************************/
111 
112 class XrdNetSecurity;
113 class XrdOucEnv;
114 class XrdOucStream;
115 class XrdOucTList;
116 class XrdPssUrlInfo;
117 class XrdSysError;
118 
119 struct XrdVersionInfo;
120 
121 class XrdPssSys : public XrdOss
122 {
123 public:
124 virtual XrdOssDF *newDir(const char *tident)
125  {return (XrdOssDF *)new XrdPssDir(tident);}
126 virtual XrdOssDF *newFile(const char *tident)
127  {return (XrdOssDF *)new XrdPssFile(tident);}
128 
129 int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
130 virtual
131 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
132 void EnvInfo(XrdOucEnv *envP);
133 int Init(XrdSysLogger *, const char *);
134 int Lfn2Pfn(const char *Path, char *buff, int blen);
135 const
136 char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
137 int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
138 int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
139 int Rename(const char *, const char *,
140  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
141 int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0);
142 int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0);
143 int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
144 
145 static const int PolNum = 2;
146 enum PolAct {PolPath = 0, PolObj = 1};
147 
148 static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType,
149  const char *path);
150 static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo);
151 static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo,
152  bool doN2N=true);
153 static
154 const char *valProt(const char *pname, int &plen, int adj=0);
155 
156 static const char *ConfigFN; // -> Pointer to the config file name
157 static const char *myHost;
158 static const char *myName;
159 static
160 XrdOucPListAnchor XPList; // Exported path list
161 
164 static const char *protName;
165 static const char *hdrData;
166 static int hdrLen;
167 static int Streams;
168 static int Workers;
169 static int Trace;
170 static int dcaCTime;
171 
172 static bool outProxy; // True means outgoing proxy
173 static bool pfxProxy; // True means outgoing proxy is prefixed
174 static bool xLfn2Pfn;
175 static bool dcaCheck;
176 static bool dcaWorld;
177 
179 virtual ~XrdPssSys() {}
180 
181 private:
182 
183 char *LocalRoot;// -> pss Local n2n root, if any
184 XrdOucName2Name *theN2N; // -> File mapper object
185 unsigned long long DirFlags; // Defaults for exports
186 XrdVersionInfo *myVersion;// -> Compilation version
187 
188 int Configure(const char *);
189 int ConfigProc(const char *ConfigFN);
190 int ConfigXeq(char*, XrdOucStream&);
191 const
192 char *getDomain(const char *hName);
199 };
200 #endif
XrdPssSys::Remdir
int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)
XrdOss
Definition: XrdOss.hh:174
XrdPssFile::Close
virtual int Close(long long *retsz=0)
XrdPssFile::tident
const char * tident
Definition: XrdPss.hh:104
XrdPssDir
Definition: XrdPss.hh:48
XrdPssDir::Close
int Close(long long *retsz=0)
XrdPssSys::myVersion
XrdVersionInfo * myVersion
Definition: XrdPss.hh:186
XrdPssFile::Write
ssize_t Write(const void *, off_t, size_t)
XrdPssSys::newFile
virtual XrdOssDF * newFile(const char *tident)
Definition: XrdPss.hh:126
XrdPssFile::Fstat
int Fstat(struct stat *)
XrdPssSys::Init
int Init(XrdSysLogger *, const char *)
XrdPssSys::PolPath
@ PolPath
Definition: XrdPss.hh:146
XrdPssSys::P2DST
static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType, const char *path)
XrdPssDir::tident
const char * tident
Definition: XrdPss.hh:58
XrdPssFile::Fchmod
int Fchmod(mode_t mode)
Definition: XrdPss.hh:79
XrdPssSys::Police
static XrdNetSecurity * Police[PolNum]
Definition: XrdPss.hh:162
XrdPssSys::LocalRoot
char * LocalRoot
Definition: XrdPss.hh:183
XrdOucName2Name.hh
XrdPssSys::ConfigXeq
int ConfigXeq(char *, XrdOucStream &)
XrdPssSys::P2URL
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
XrdPssSys::Lfn2Pfn
int Lfn2Pfn(const char *Path, char *buff, int blen)
XrdPssSys
Definition: XrdPss.hh:122
XrdPssSys::Create
virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0)
XrdOssDF
Definition: XrdOss.hh:60
XrdPssFile
Definition: XrdPss.hh:70
XrdOucPListAnchor
Definition: XrdOucPList.hh:89
XrdPssFile::Read
ssize_t Read(void *, off_t, size_t)
XrdNetSecurity
Definition: XrdNetSecurity.hh:44
XrdPssSys::valProt
static const char * valProt(const char *pname, int &plen, int adj=0)
XrdPssSys::dcaWorld
static bool dcaWorld
Definition: XrdPss.hh:176
XrdPssSys::P2OUT
static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo)
XrdPssSys::newDir
virtual XrdOssDF * newDir(const char *tident)
Definition: XrdPss.hh:124
XrdPssSys::getDomain
const char * getDomain(const char *hName)
XrdPssSys::Lfn2Pfn
const char * Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
XrdPssSys::ConfigFN
static const char * ConfigFN
Definition: XrdPss.hh:156
XrdPssSys::dcaCTime
static int dcaCTime
Definition: XrdPss.hh:170
XrdOucIOVec
Definition: XrdOucIOVec.hh:41
XrdOucStream
Definition: XrdOucStream.hh:46
XrdPssSys::pfxProxy
static bool pfxProxy
Definition: XrdPss.hh:173
XrdPssFile::getMmap
off_t getMmap(void **addr)
XrdPssSys::ManList
static XrdOucTList * ManList
Definition: XrdPss.hh:163
XrdPssFile::Read
int Read(XrdSfsAio *aiop)
XrdPssFile::Open
virtual int Open(const char *, int, mode_t, XrdOucEnv &)
XrdPssSys::dcaCheck
static bool dcaCheck
Definition: XrdPss.hh:175
XrdPssSys::xexp
int xexp(XrdSysError *Eroute, XrdOucStream &Config)
XrdPssDir::Opendir
int Opendir(const char *, XrdOucEnv &)
XrdOss.hh
XrdPssFile::Fsync
int Fsync(XrdSfsAio *aiop)
XrdPssSys::xconf
int xconf(XrdSysError *Eroute, XrdOucStream &Config)
XrdOssDF::fd
int fd
Definition: XrdOss.hh:132
XrdPssSys::Streams
static int Streams
Definition: XrdPss.hh:167
XrdPssSys::Mkdir
int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0)
XrdPssUrlInfo
Definition: XrdPssUrlInfo.hh:38
XrdPssDir::myDir
DIR * myDir
Definition: XrdPss.hh:59
XrdPssSys::xLfn2Pfn
static bool xLfn2Pfn
Definition: XrdPss.hh:174
XrdPssSys::ConfigProc
int ConfigProc(const char *ConfigFN)
XrdPssSys::PolNum
static const int PolNum
Definition: XrdPss.hh:145
XrdPssFile::tpcPath
char * tpcPath
Definition: XrdPss.hh:105
XrdPssSys::xdca
int xdca(XrdSysError *errp, XrdOucStream &Config)
XrdPssSys::XPList
static XrdOucPListAnchor XPList
Definition: XrdPss.hh:160
XrdPssSys::hdrLen
static int hdrLen
Definition: XrdPss.hh:166
XrdOucEnv
Definition: XrdOucEnv.hh:42
XrdPssSys::outProxy
static bool outProxy
Definition: XrdPss.hh:172
XrdPssFile::~XrdPssFile
virtual ~XrdPssFile()
Definition: XrdPss.hh:98
XrdPssSys::Stat
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)
XrdPssSys::protName
static const char * protName
Definition: XrdPss.hh:164
XrdPssSys::Workers
static int Workers
Definition: XrdPss.hh:168
XrdPssSys::EnvInfo
void EnvInfo(XrdOucEnv *envP)
XrdPssDir::XrdPssDir
XrdPssDir(const char *tid)
Definition: XrdPss.hh:55
XrdSysLogger
Definition: XrdSysLogger.hh:53
XrdPssDir::~XrdPssDir
~XrdPssDir()
Definition: XrdPss.hh:56
XrdCms::Config
XrdCmsConfig Config
XrdOucSid.hh
XrdPssSys::DirFlags
unsigned long long DirFlags
Definition: XrdPss.hh:185
XrdPssSys::Unlink
int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)
XrdPssSys::~XrdPssSys
virtual ~XrdPssSys()
Definition: XrdPss.hh:179
XrdPssSys::Rename
int Rename(const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)
XrdPssSys::XrdPssSys
XrdPssSys()
XrdPssFile::Read
ssize_t Read(off_t, size_t)
XrdPssFile::XrdPssFile
XrdPssFile(const char *tid)
Definition: XrdPss.hh:95
XrdPssSys::myName
static const char * myName
Definition: XrdPss.hh:158
XrdPssFile::ReadRaw
ssize_t ReadRaw(void *, off_t, size_t)
XrdOucName2Name
Definition: XrdOucName2Name.hh:49
XrdOssOK
#define XrdOssOK
Definition: XrdOss.hh:47
XrdPssFile::ReadV
ssize_t ReadV(XrdOucIOVec *readV, int n)
XrdSfsAio
Definition: XrdSfsAio.hh:58
XrdPssSys::Truncate
int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0)
stat
#define stat(a, b)
Definition: XrdPosix.hh:96
XrdPssSys::hdrData
static const char * hdrData
Definition: XrdPss.hh:165
XrdPssDir::Readdir
int Readdir(char *buff, int blen)
XrdPssSys::Configure
int Configure(const char *)
XrdPssSys::xperm
int xperm(XrdSysError *errp, XrdOucStream &Config)
XrdPssFile::Write
int Write(XrdSfsAio *aiop)
XrdPssSys::xdef
int xdef(XrdSysError *Eroute, XrdOucStream &Config)
XrdPssSys::PolAct
PolAct
Definition: XrdPss.hh:146
XrdSysError
Definition: XrdSysError.hh:90
XrdPssSys::xorig
int xorig(XrdSysError *errp, XrdOucStream &Config)
XrdOucPList.hh
XrdPssSys::myHost
static const char * myHost
Definition: XrdPss.hh:157
XrdPssFile::isCompressed
int isCompressed(char *cxidp=0)
XrdPssSys::PolObj
@ PolObj
Definition: XrdPss.hh:146
XrdPssFile::Ftruncate
int Ftruncate(unsigned long long)
XrdPssSys::Chmod
int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)
XrdPssSys::theN2N
XrdOucName2Name * theN2N
Definition: XrdPss.hh:184
XrdOucTList
Definition: XrdOucTList.hh:42
XrdPssSys::Trace
static int Trace
Definition: XrdPss.hh:169
XrdOucExport.hh
XrdPssFile::Fsync
int Fsync()
XrdSysHeaders.hh