xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <cerrno>
34 #include <unistd.h>
35 #include <sys/types.h>
36 #include <vector>
37 #include "XrdSys/XrdSysHeaders.hh"
38 #include "XrdOuc/XrdOucExport.hh"
40 #include "XrdOuc/XrdOucPList.hh"
41 #include "XrdOuc/XrdOucSid.hh"
42 #include "XrdOss/XrdOss.hh"
43 
44 /******************************************************************************/
45 /* X r d P s s D i r */
46 /******************************************************************************/
47 
48 class XrdPssDir : public XrdOssDF
49 {
50 public:
51 int Close(long long *retsz=0);
52 int Opendir(const char *, XrdOucEnv &);
53 int Readdir(char *buff, int blen);
54 
55  // Constructor and destructor
56  XrdPssDir(const char *tid)
58  myDir(0) {}
59 
60  ~XrdPssDir() {if (myDir) Close();}
61 private:
62  DIR *myDir;
63 };
64 
65 /******************************************************************************/
66 /* X r d P s s F i l e */
67 /******************************************************************************/
68 
69 struct XrdOucIOVec;
70 class XrdSecEntity;
71 class XrdSfsAio;
72 
73 class XrdPssFile : public XrdOssDF
74 {
75 public:
76 
77 // The following two are virtual functions to allow for upcasting derivations
78 // of this implementation
79 //
80 virtual int Close(long long *retsz=0);
81 virtual int Open(const char *, int, mode_t, XrdOucEnv &);
82 
83 int Fchmod(mode_t mode) {return XrdOssOK;}
84 int Fstat(struct stat *);
85 int Fsync();
86 int Fsync(XrdSfsAio *aiop);
87 int Ftruncate(unsigned long long);
88 ssize_t pgRead (void* buffer, off_t offset, size_t rdlen,
89  uint32_t* csvec, uint64_t opts);
90 int pgRead (XrdSfsAio* aioparm, uint64_t opts);
91 ssize_t pgWrite(void* buffer, off_t offset, size_t wrlen,
92  uint32_t* csvec, uint64_t opts);
93 int pgWrite(XrdSfsAio* aoiparm, uint64_t opts);
94 ssize_t Read( off_t, size_t);
95 ssize_t Read( void *, off_t, size_t);
96 int Read(XrdSfsAio *aiop);
97 ssize_t ReadV(XrdOucIOVec *readV, int n);
98 ssize_t ReadRaw( void *, off_t, size_t);
99 ssize_t Write(const void *, off_t, size_t);
100 int Write(XrdSfsAio *aiop);
101 
102  // Constructor and destructor
103  XrdPssFile(const char *tid)
105  rpInfo(0), tpcPath(0), entity(0) {}
106 
107 virtual ~XrdPssFile() {if (fd >= 0) Close();
108  if (rpInfo) delete(rpInfo);
109  if (tpcPath) free(tpcPath);
110  }
111 
112 private:
113 
114 struct tprInfo
115  {char *tprPath;
116  char *dstURL;
117  size_t fSize;
118 
119  tprInfo(const char *fn) : tprPath(strdup(fn)),dstURL(0),fSize(0)
120  {}
121  ~tprInfo() {if (tprPath) free(tprPath);
122  if (dstURL) free(dstURL);
123  }
124  } *rpInfo;
125 
126  char *tpcPath;
128 };
129 
130 /******************************************************************************/
131 /* X r d P s s S y s */
132 /******************************************************************************/
133 
134 class XrdNetSecurity;
135 class XrdOucEnv;
136 class XrdOucStream;
137 class XrdOucTList;
138 class XrdPssUrlInfo;
139 class XrdSecsssID;
140 class XrdSysError;
141 
142 struct XrdVersionInfo;
143 
144 class XrdPssSys : public XrdOss
145 {
146 public:
147 virtual XrdOssDF *newDir(const char *tident)
148  {return (XrdOssDF *)new XrdPssDir(tident);}
149 virtual XrdOssDF *newFile(const char *tident)
150  {return (XrdOssDF *)new XrdPssFile(tident);}
151 
152 virtual void Connect(XrdOucEnv &);
153 
154 virtual void Disc(XrdOucEnv &);
155 
156 int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
157 bool ConfigMapID();
158 virtual
159 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
160 void EnvInfo(XrdOucEnv *envP);
161 uint64_t Features() {return myFeatures;}
162 int Init(XrdSysLogger *, const char *) override {return -ENOTSUP;}
163 int Init(XrdSysLogger *, const char *, XrdOucEnv *envP) override;
164 int Lfn2Pfn(const char *Path, char *buff, int blen);
165 const
166 char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
167 int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
168 int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
169 int Rename(const char *, const char *,
170  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
171 int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0);
172 int Stats(char *bp, int bl);
173 int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0);
174 int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
175 
176 static const int PolNum = 2;
177 enum PolAct {PolPath = 0, PolObj = 1};
178 
179 static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType,
180  const char *path);
181 static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo);
182 static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo,
183  bool doN2N=true);
184 
185 static const char *ConfigFN; // -> Pointer to the config file name
186 static const char *myHost;
187 static const char *myName;
188 static
189 XrdOucPListAnchor XPList; // Exported path list
190 
193 static const char *protName;
194 static const char *hdrData;
195 static int hdrLen;
196 static int Streams;
197 static int Workers;
198 static int Trace;
199 static int dcaCTime;
200 
201 static bool xLfn2Pfn;
202 static bool dcaCheck;
203 static bool dcaWorld;
204 static bool deferID; // Defer ID mapping until needed
205 static bool reProxy; // TPC requires reproxing
206 
207  XrdPssSys();
208 virtual ~XrdPssSys() {}
209 
210 private:
211 
212 char *LocalRoot;// -> pss Local n2n root, if any
213 XrdOucName2Name *theN2N; // -> File mapper object
214 unsigned long long DirFlags; // Defaults for exports
215 XrdVersionInfo *myVersion;// -> Compilation version
216 XrdSecsssID *idMapper; // -> Auth ID mapper
217 uint64_t myFeatures;// Our feature set
218 
219 int Configure(const char *, XrdOucEnv *);
220 int ConfigProc(const char *ConfigFN);
221 int ConfigXeq(char*, XrdOucStream&);
222 int xconf(XrdSysError *Eroute, XrdOucStream &Config);
223 int xdef( XrdSysError *Eroute, XrdOucStream &Config);
224 int xdca( XrdSysError *errp, XrdOucStream &Config);
225 int xexp( XrdSysError *Eroute, XrdOucStream &Config);
226 int xperm(XrdSysError *errp, XrdOucStream &Config);
227 int xpers(XrdSysError *errp, XrdOucStream &Config);
228 int xorig(XrdSysError *errp, XrdOucStream &Config);
229 };
230 #endif
int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0)
virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0)
static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo)
static const int PolNum
Definition: XrdPss.hh:176
static const uint16_t DF_isDir
Object is for a directory.
Definition: XrdOss.hh:392
static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType, const char *path)
int Configure(const char *, XrdOucEnv *)
int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)
Definition: XrdPss.hh:48
virtual int Close(long long *retsz=0)
int xorig(XrdSysError *errp, XrdOucStream &Config)
static bool deferID
Definition: XrdPss.hh:204
ssize_t ReadV(XrdOucIOVec *readV, int n)
Definition: XrdOucPList.hh:88
int Init(XrdSysLogger *, const char *) override
Definition: XrdPss.hh:162
Definition: XrdPss.hh:144
virtual void Connect(XrdOucEnv &)
Definition: XrdPss.hh:114
const XrdSecEntity * entity
Definition: XrdPss.hh:127
ssize_t Write(const void *, off_t, size_t)
Definition: XrdOucStream.hh:46
static const uint16_t DF_isFile
Object is for a file.
Definition: XrdOss.hh:393
uint64_t Features()
Definition: XrdPss.hh:161
int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0)
int Opendir(const char *, XrdOucEnv &)
Definition: XrdOucName2Name.hh:48
virtual int Open(const char *, int, mode_t, XrdOucEnv &)
int xdca(XrdSysError *errp, XrdOucStream &Config)
unsigned long long DirFlags
Definition: XrdPss.hh:214
virtual XrdOssDF * newFile(const char *tident)
Definition: XrdPss.hh:149
int xconf(XrdSysError *Eroute, XrdOucStream &Config)
static const char * hdrData
Definition: XrdPss.hh:194
static const char * ConfigFN
Definition: XrdPss.hh:185
static XrdNetSecurity * Police[PolNum]
Definition: XrdPss.hh:191
virtual void Disc(XrdOucEnv &)
char * tpcPath
Definition: XrdPss.hh:126
static const char * myHost
Definition: XrdPss.hh:186
static XrdOucTList * ManList
Definition: XrdPss.hh:192
virtual ~XrdPssFile()
Definition: XrdPss.hh:107
ssize_t pgRead(void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
size_t fSize
Definition: XrdPss.hh:117
static const char * protName
Definition: XrdPss.hh:193
Definition: XrdPssUrlInfo.hh:37
int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)
Definition: XrdSysError.hh:89
bool ConfigMapID()
struct XrdPssFile::tprInfo * rpInfo
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
XrdPssDir(const char *tid)
Definition: XrdPss.hh:56
~tprInfo()
Definition: XrdPss.hh:121
int Readdir(char *buff, int blen)
XrdCmsConfig Config
uint64_t myFeatures
Definition: XrdPss.hh:217
int fd
Definition: XrdOss.hh:455
char * tprPath
Definition: XrdPss.hh:115
int xperm(XrdSysError *errp, XrdOucStream &Config)
static bool dcaWorld
Definition: XrdPss.hh:203
Definition: XrdSecsssID.hh:53
static bool xLfn2Pfn
Definition: XrdPss.hh:201
static XrdOucPListAnchor XPList
Definition: XrdPss.hh:189
int ConfigXeq(char *, XrdOucStream &)
void EnvInfo(XrdOucEnv *envP)
static const uint16_t DF_isProxy
Object is a proxy object.
Definition: XrdOss.hh:394
int Lfn2Pfn(const char *Path, char *buff, int blen)
Definition: XrdOucEnv.hh:41
XrdOucName2Name * theN2N
Definition: XrdPss.hh:213
char * dstURL
Definition: XrdPss.hh:116
Definition: XrdOucIOVec.hh:40
static int Trace
Definition: XrdPss.hh:198
char * LocalRoot
Definition: XrdPss.hh:212
XrdSecsssID * idMapper
Definition: XrdPss.hh:216
tprInfo(const char *fn)
Definition: XrdPss.hh:119
int xexp(XrdSysError *Eroute, XrdOucStream &Config)
#define XrdOssOK
Definition: XrdOss.hh:50
XrdVersionInfo * myVersion
Definition: XrdPss.hh:215
PolAct
Definition: XrdPss.hh:177
Definition: XrdOucTList.hh:41
virtual XrdOssDF * newDir(const char *tident)
Definition: XrdPss.hh:147
ssize_t pgWrite(void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
static int Streams
Definition: XrdPss.hh:196
int ConfigProc(const char *ConfigFN)
int Rename(const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)
XrdPssFile(const char *tid)
Definition: XrdPss.hh:103
Definition: XrdSysLogger.hh:52
ssize_t Read(off_t, size_t)
static bool reProxy
Definition: XrdPss.hh:205
int xdef(XrdSysError *Eroute, XrdOucStream &Config)
#define stat(a, b)
Definition: XrdPosix.hh:96
static bool dcaCheck
Definition: XrdPss.hh:202
Definition: XrdPss.hh:177
ssize_t ReadRaw(void *, off_t, size_t)
~XrdPssDir()
Definition: XrdPss.hh:60
Definition: XrdOss.hh:497
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)
Definition: XrdOss.hh:62
Definition: XrdNetSecurity.hh:43
Definition: XrdPss.hh:73
int Stats(char *bp, int bl)
Definition: XrdSecEntity.hh:63
int Ftruncate(unsigned long long)
Definition: XrdSfsAio.hh:58
DIR * myDir
Definition: XrdPss.hh:62
int Close(long long *retsz=0)
virtual ~XrdPssSys()
Definition: XrdPss.hh:208
static int hdrLen
Definition: XrdPss.hh:195
static const char * myName
Definition: XrdPss.hh:187
int xpers(XrdSysError *errp, XrdOucStream &Config)
static int Workers
Definition: XrdPss.hh:197
int Fstat(struct stat *)
static int dcaCTime
Definition: XrdPss.hh:199
Definition: XrdPss.hh:177
int Fchmod(mode_t mode)
Definition: XrdPss.hh:83
int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)