xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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) {fd = -1;}
96 
97 virtual ~XrdPssFile() {if (fd >= 0) Close();
98  if (tpcPath) free(tpcPath);
99  }
100 
101 private:
102 
103 const char *tident;
104  char *tpcPath;
105 };
106 
107 /******************************************************************************/
108 /* X r d P s s S y s */
109 /******************************************************************************/
110 
111 class XrdNetSecurity;
112 class XrdOucEnv;
113 class XrdOucStream;
114 class XrdOucTList;
115 class XrdPssUrlInfo;
116 class XrdSysError;
117 
118 struct XrdVersionInfo;
119 
120 class XrdPssSys : public XrdOss
121 {
122 public:
123 virtual XrdOssDF *newDir(const char *tident)
124  {return (XrdOssDF *)new XrdPssDir(tident);}
125 virtual XrdOssDF *newFile(const char *tident)
126  {return (XrdOssDF *)new XrdPssFile(tident);}
127 
128 int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
129 virtual
130 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
131 void EnvInfo(XrdOucEnv *envP);
132 int Init(XrdSysLogger *, const char *);
133 int Lfn2Pfn(const char *Path, char *buff, int blen);
134 const
135 char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
136 int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
137 int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
138 int Rename(const char *, const char *,
139  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
140 int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0);
141 int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0);
142 int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
143 
144 static const int PolNum = 2;
145 enum PolAct {PolPath = 0, PolObj = 1};
146 
147 static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType,
148  const char *path);
149 static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo);
150 static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo,
151  bool doN2N=true);
152 static
153 const char *valProt(const char *pname, int &plen, int adj=0);
154 
155 static const char *ConfigFN; // -> Pointer to the config file name
156 static const char *myHost;
157 static const char *myName;
158 static
159 XrdOucPListAnchor XPList; // Exported path list
160 
163 static const char *protName;
164 static const char *hdrData;
165 static int hdrLen;
166 static int Streams;
167 static int Workers;
168 static int Trace;
169 
170 static bool outProxy; // True means outgoing proxy
171 static bool pfxProxy; // True means outgoing proxy is prefixed
172 static bool xLfn2Pfn;
173 
174  XrdPssSys();
175 virtual ~XrdPssSys() {}
176 
177 private:
178 
179 char *LocalRoot;// -> pss Local n2n root, if any
180 XrdOucName2Name *theN2N; // -> File mapper object
181 unsigned long long DirFlags; // Defaults for exports
182 XrdVersionInfo *myVersion;// -> Compilation version
183 
184 int Configure(const char *);
185 int ConfigProc(const char *ConfigFN);
186 int ConfigXeq(char*, XrdOucStream&);
187 const
188 char *getDomain(const char *hName);
189 int xconf(XrdSysError *Eroute, XrdOucStream &Config);
190 int xdef( XrdSysError *Eroute, XrdOucStream &Config);
191 int xexp( XrdSysError *Eroute, XrdOucStream &Config);
192 int xperm(XrdSysError *errp, XrdOucStream &Config);
193 int xorig(XrdSysError *errp, XrdOucStream &Config);
194 };
195 #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:144
static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType, const char *path)
const char * tident
Definition: XrdPss.hh:58
int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)
Definition: XrdPss.hh:47
int isCompressed(char *cxidp=0)
virtual int Close(long long *retsz=0)
int xorig(XrdSysError *errp, XrdOucStream &Config)
ssize_t ReadV(XrdOucIOVec *readV, int n)
Definition: XrdOucPList.hh:88
Definition: XrdPss.hh:120
ssize_t Write(const void *, off_t, size_t)
Definition: XrdOucStream.hh:45
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 &)
unsigned long long DirFlags
Definition: XrdPss.hh:181
virtual XrdOssDF * newFile(const char *tident)
Definition: XrdPss.hh:125
int xconf(XrdSysError *Eroute, XrdOucStream &Config)
static const char * hdrData
Definition: XrdPss.hh:164
static const char * ConfigFN
Definition: XrdPss.hh:155
static XrdNetSecurity * Police[PolNum]
Definition: XrdPss.hh:161
char * tpcPath
Definition: XrdPss.hh:104
static const char * myHost
Definition: XrdPss.hh:156
static XrdOucTList * ManList
Definition: XrdPss.hh:162
virtual ~XrdPssFile()
Definition: XrdPss.hh:97
static const char * protName
Definition: XrdPss.hh:163
Definition: XrdPssUrlInfo.hh:37
int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)
Definition: XrdSysError.hh:89
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
XrdPssDir(const char *tid)
Definition: XrdPss.hh:55
int Readdir(char *buff, int blen)
XrdCmsConfig Config
int Configure(const char *)
int fd
Definition: XrdOss.hh:132
int xperm(XrdSysError *errp, XrdOucStream &Config)
static bool xLfn2Pfn
Definition: XrdPss.hh:172
static XrdOucPListAnchor XPList
Definition: XrdPss.hh:159
int ConfigXeq(char *, XrdOucStream &)
const char * getDomain(const char *hName)
void EnvInfo(XrdOucEnv *envP)
int Lfn2Pfn(const char *Path, char *buff, int blen)
Definition: XrdOucEnv.hh:41
XrdOucName2Name * theN2N
Definition: XrdPss.hh:180
Definition: XrdOucIOVec.hh:40
static int Trace
Definition: XrdPss.hh:168
static bool pfxProxy
Definition: XrdPss.hh:171
char * LocalRoot
Definition: XrdPss.hh:179
int xexp(XrdSysError *Eroute, XrdOucStream &Config)
#define XrdOssOK
Definition: XrdOss.hh:47
XrdVersionInfo * myVersion
Definition: XrdPss.hh:182
PolAct
Definition: XrdPss.hh:145
Definition: XrdOucTList.hh:41
virtual XrdOssDF * newDir(const char *tident)
Definition: XrdPss.hh:123
static int Streams
Definition: XrdPss.hh:166
int ConfigProc(const char *ConfigFN)
int Rename(const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)
XrdPssFile(const char *tid)
Definition: XrdPss.hh:95
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
Definition: XrdPss.hh:145
ssize_t ReadRaw(void *, off_t, size_t)
int Init(XrdSysLogger *, const char *)
~XrdPssDir()
Definition: XrdPss.hh:56
const char * tident
Definition: XrdPss.hh:103
Definition: XrdOss.hh:173
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)
Definition: XrdOss.hh:59
off_t getMmap(void **addr)
Definition: XrdNetSecurity.hh:43
Definition: XrdPss.hh:69
int Ftruncate(unsigned long long)
static const char * valProt(const char *pname, int &plen, int adj=0)
Definition: XrdSfsAio.hh:57
DIR * myDir
Definition: XrdPss.hh:59
int Close(long long *retsz=0)
virtual ~XrdPssSys()
Definition: XrdPss.hh:175
static int hdrLen
Definition: XrdPss.hh:165
static const char * myName
Definition: XrdPss.hh:157
static int Workers
Definition: XrdPss.hh:167
int Fstat(struct stat *)
static bool outProxy
Definition: XrdPss.hh:170
Definition: XrdPss.hh:145
int Fchmod(mode_t mode)
Definition: XrdPss.hh:79
int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)