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 <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 Read( off_t, size_t);
89 ssize_t Read( void *, off_t, size_t);
90 int Read(XrdSfsAio *aiop);
91 ssize_t ReadV(XrdOucIOVec *readV, int n);
92 ssize_t ReadRaw( void *, off_t, size_t);
93 ssize_t Write(const void *, off_t, size_t);
94 int Write(XrdSfsAio *aiop);
95 
96  // Constructor and destructor
97  XrdPssFile(const char *tid)
99  tpcPath(0), entity(0) {}
100 
101 virtual ~XrdPssFile() {if (fd >= 0) Close();
102  if (tpcPath) free(tpcPath);
103  }
104 
105 private:
106 
107  char *tpcPath;
108 
110 };
111 
112 /******************************************************************************/
113 /* X r d P s s S y s */
114 /******************************************************************************/
115 
116 class XrdNetSecurity;
117 class XrdOucEnv;
118 class XrdOucStream;
119 class XrdOucTList;
120 class XrdPssUrlInfo;
121 class XrdSecsssID;
122 class XrdSysError;
123 
124 struct XrdVersionInfo;
125 
126 class XrdPssSys : public XrdOss
127 {
128 public:
129 virtual XrdOssDF *newDir(const char *tident)
130  {return (XrdOssDF *)new XrdPssDir(tident);}
131 virtual XrdOssDF *newFile(const char *tident)
132  {return (XrdOssDF *)new XrdPssFile(tident);}
133 
134 virtual void Connect(XrdOucEnv &);
135 
136 virtual void Disc(XrdOucEnv &);
137 
138 int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
139 bool ConfigMapID();
140 virtual
141 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
142 void EnvInfo(XrdOucEnv *envP);
143 uint64_t Features() {return myFeatures;}
144 int Init(XrdSysLogger *, const char *);
145 int Lfn2Pfn(const char *Path, char *buff, int blen);
146 const
147 char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
148 int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
149 int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
150 int Rename(const char *, const char *,
151  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
152 int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0);
153 int Stats(char *bp, int bl);
154 int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0);
155 int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
156 
157 static const int PolNum = 2;
158 enum PolAct {PolPath = 0, PolObj = 1};
159 
160 static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType,
161  const char *path);
162 static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo);
163 static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo,
164  bool doN2N=true);
165 
166 static const char *ConfigFN; // -> Pointer to the config file name
167 static const char *myHost;
168 static const char *myName;
169 static
170 XrdOucPListAnchor XPList; // Exported path list
171 
174 static const char *protName;
175 static const char *hdrData;
176 static int hdrLen;
177 static int Streams;
178 static int Workers;
179 static int Trace;
180 static int dcaCTime;
181 
182 static bool xLfn2Pfn;
183 static bool dcaCheck;
184 static bool dcaWorld;
185 static bool deferID; // Defer ID mapping until needed
186 
187  XrdPssSys();
188 virtual ~XrdPssSys() {}
189 
190 private:
191 
192 char *LocalRoot;// -> pss Local n2n root, if any
193 XrdOucName2Name *theN2N; // -> File mapper object
194 unsigned long long DirFlags; // Defaults for exports
195 XrdVersionInfo *myVersion;// -> Compilation version
196 XrdSecsssID *idMapper; // -> Auth ID mapper
197 uint64_t myFeatures;// Our feature set
198 
199 int Configure(const char *);
200 int ConfigProc(const char *ConfigFN);
201 int ConfigXeq(char*, XrdOucStream&);
202 int xconf(XrdSysError *Eroute, XrdOucStream &Config);
203 int xdef( XrdSysError *Eroute, XrdOucStream &Config);
204 int xdca( XrdSysError *errp, XrdOucStream &Config);
205 int xexp( XrdSysError *Eroute, XrdOucStream &Config);
206 int xperm(XrdSysError *errp, XrdOucStream &Config);
207 int xpers(XrdSysError *errp, XrdOucStream &Config);
208 int xorig(XrdSysError *errp, XrdOucStream &Config);
209 };
210 #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:157
static const uint16_t DF_isDir
Object is for a directory.
Definition: XrdOss.hh:396
static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType, const char *path)
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:185
ssize_t ReadV(XrdOucIOVec *readV, int n)
Definition: XrdOucPList.hh:88
Definition: XrdPss.hh:126
virtual void Connect(XrdOucEnv &)
const XrdSecEntity * entity
Definition: XrdPss.hh:109
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:397
uint64_t Features()
Definition: XrdPss.hh:143
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:194
virtual XrdOssDF * newFile(const char *tident)
Definition: XrdPss.hh:131
int xconf(XrdSysError *Eroute, XrdOucStream &Config)
static const char * hdrData
Definition: XrdPss.hh:175
static const char * ConfigFN
Definition: XrdPss.hh:166
static XrdNetSecurity * Police[PolNum]
Definition: XrdPss.hh:172
virtual void Disc(XrdOucEnv &)
char * tpcPath
Definition: XrdPss.hh:107
static const char * myHost
Definition: XrdPss.hh:167
static XrdOucTList * ManList
Definition: XrdPss.hh:173
virtual ~XrdPssFile()
Definition: XrdPss.hh:101
static const char * protName
Definition: XrdPss.hh:174
Definition: XrdPssUrlInfo.hh:37
int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)
Definition: XrdSysError.hh:89
bool ConfigMapID()
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
XrdPssDir(const char *tid)
Definition: XrdPss.hh:56
int Readdir(char *buff, int blen)
XrdCmsConfig Config
int Configure(const char *)
uint64_t myFeatures
Definition: XrdPss.hh:197
int fd
Definition: XrdOss.hh:459
int xperm(XrdSysError *errp, XrdOucStream &Config)
static bool dcaWorld
Definition: XrdPss.hh:184
Definition: XrdSecsssID.hh:53
static bool xLfn2Pfn
Definition: XrdPss.hh:182
static XrdOucPListAnchor XPList
Definition: XrdPss.hh:170
int ConfigXeq(char *, XrdOucStream &)
void EnvInfo(XrdOucEnv *envP)
static const uint16_t DF_isProxy
Object is a proxy object.
Definition: XrdOss.hh:398
int Lfn2Pfn(const char *Path, char *buff, int blen)
Definition: XrdOucEnv.hh:41
XrdOucName2Name * theN2N
Definition: XrdPss.hh:193
Definition: XrdOucIOVec.hh:40
static int Trace
Definition: XrdPss.hh:179
char * LocalRoot
Definition: XrdPss.hh:192
XrdSecsssID * idMapper
Definition: XrdPss.hh:196
int xexp(XrdSysError *Eroute, XrdOucStream &Config)
#define XrdOssOK
Definition: XrdOss.hh:50
XrdVersionInfo * myVersion
Definition: XrdPss.hh:195
PolAct
Definition: XrdPss.hh:158
Definition: XrdOucTList.hh:41
virtual XrdOssDF * newDir(const char *tident)
Definition: XrdPss.hh:129
static int Streams
Definition: XrdPss.hh:177
int ConfigProc(const char *ConfigFN)
int Rename(const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)
XrdPssFile(const char *tid)
Definition: XrdPss.hh:97
Definition: XrdSysLogger.hh:52
ssize_t Read(off_t, size_t)
int xdef(XrdSysError *Eroute, XrdOucStream &Config)
#define stat(a, b)
Definition: XrdPosix.hh:96
static bool dcaCheck
Definition: XrdPss.hh:183
Definition: XrdPss.hh:158
ssize_t ReadRaw(void *, off_t, size_t)
int Init(XrdSysLogger *, const char *)
~XrdPssDir()
Definition: XrdPss.hh:60
Definition: XrdOss.hh:498
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:188
static int hdrLen
Definition: XrdPss.hh:176
static const char * myName
Definition: XrdPss.hh:168
int xpers(XrdSysError *errp, XrdOucStream &Config)
static int Workers
Definition: XrdPss.hh:178
int Fstat(struct stat *)
static int dcaCTime
Definition: XrdPss.hh:180
Definition: XrdPss.hh:158
int Fchmod(mode_t mode)
Definition: XrdPss.hh:83
int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)