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 
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&);
209 };
210 #endif
XrdPssSys::Remdir
int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)
XrdOss
Definition: XrdOss.hh:488
XrdPssFile::Close
virtual int Close(long long *retsz=0)
XrdPssDir
Definition: XrdPss.hh:49
XrdPssDir::Close
int Close(long long *retsz=0)
XrdPssSys::myVersion
XrdVersionInfo * myVersion
Definition: XrdPss.hh:195
XrdPssFile::Write
ssize_t Write(const void *, off_t, size_t)
XrdPssSys::newFile
virtual XrdOssDF * newFile(const char *tident)
Definition: XrdPss.hh:131
XrdPssFile::Fstat
int Fstat(struct stat *)
XrdPssSys::Init
int Init(XrdSysLogger *, const char *)
XrdPssSys::PolPath
@ PolPath
Definition: XrdPss.hh:158
XrdPssSys::P2DST
static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType, const char *path)
XrdPssFile::Fchmod
int Fchmod(mode_t mode)
Definition: XrdPss.hh:83
XrdPssSys::Police
static XrdNetSecurity * Police[PolNum]
Definition: XrdPss.hh:172
XrdPssSys::LocalRoot
char * LocalRoot
Definition: XrdPss.hh:192
XrdOucName2Name.hh
XrdPssSys::ConfigXeq
int ConfigXeq(char *, XrdOucStream &)
XrdOssDF::DF_isProxy
static const uint16_t DF_isProxy
Object is a proxy object.
Definition: XrdOss.hh:395
XrdOssDF::DF_isDir
static const uint16_t DF_isDir
Object is for a directory.
Definition: XrdOss.hh:393
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:127
XrdPssSys::Stats
int Stats(char *bp, int bl)
XrdPssSys::myFeatures
uint64_t myFeatures
Definition: XrdPss.hh:197
XrdPssSys::Create
virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0)
XrdOssDF
Definition: XrdOss.hh:62
XrdPssFile
Definition: XrdPss.hh:74
XrdOucPListAnchor
Definition: XrdOucPList.hh:89
XrdPssFile::Read
ssize_t Read(void *, off_t, size_t)
XrdNetSecurity
Definition: XrdNetSecurity.hh:44
XrdPssSys::dcaWorld
static bool dcaWorld
Definition: XrdPss.hh:184
XrdPssSys::P2OUT
static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo)
XrdPssSys::newDir
virtual XrdOssDF * newDir(const char *tident)
Definition: XrdPss.hh:129
XrdPssSys::Lfn2Pfn
const char * Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
XrdPssSys::ConfigFN
static const char * ConfigFN
Definition: XrdPss.hh:166
XrdPssSys::dcaCTime
static int dcaCTime
Definition: XrdPss.hh:180
XrdOucIOVec
Definition: XrdOucIOVec.hh:41
XrdOucStream
Definition: XrdOucStream.hh:47
XrdPssSys::ManList
static XrdOucTList * ManList
Definition: XrdPss.hh:173
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:183
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:448
XrdOssDF::DF_isFile
static const uint16_t DF_isFile
Object is for a file.
Definition: XrdOss.hh:394
XrdPssSys::Streams
static int Streams
Definition: XrdPss.hh:177
XrdPssSys::Features
uint64_t Features()
Definition: XrdPss.hh:143
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:62
XrdPssSys::xLfn2Pfn
static bool xLfn2Pfn
Definition: XrdPss.hh:182
XrdPssSys::ConfigProc
int ConfigProc(const char *ConfigFN)
XrdPssSys::PolNum
static const int PolNum
Definition: XrdPss.hh:157
XrdPssFile::tpcPath
char * tpcPath
Definition: XrdPss.hh:107
XrdPssSys::xdca
int xdca(XrdSysError *errp, XrdOucStream &Config)
XrdPssSys::XPList
static XrdOucPListAnchor XPList
Definition: XrdPss.hh:170
XrdPssSys::hdrLen
static int hdrLen
Definition: XrdPss.hh:176
XrdOucEnv
Definition: XrdOucEnv.hh:42
XrdPssSys::deferID
static bool deferID
Definition: XrdPss.hh:185
XrdPssFile::~XrdPssFile
virtual ~XrdPssFile()
Definition: XrdPss.hh:101
XrdPssSys::Connect
virtual void Connect(XrdOucEnv &)
XrdPssSys::Stat
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)
XrdPssSys::ConfigMapID
bool ConfigMapID()
XrdPssSys::protName
static const char * protName
Definition: XrdPss.hh:174
XrdPssSys::xpers
int xpers(XrdSysError *errp, XrdOucStream &Config)
XrdPssSys::Workers
static int Workers
Definition: XrdPss.hh:178
XrdPssSys::EnvInfo
void EnvInfo(XrdOucEnv *envP)
XrdPssDir::XrdPssDir
XrdPssDir(const char *tid)
Definition: XrdPss.hh:56
XrdSysLogger
Definition: XrdSysLogger.hh:53
XrdPssDir::~XrdPssDir
~XrdPssDir()
Definition: XrdPss.hh:60
XrdCms::Config
XrdCmsConfig Config
XrdSecsssID
Definition: XrdSecsssID.hh:54
XrdOucSid.hh
XrdPssSys::DirFlags
unsigned long long DirFlags
Definition: XrdPss.hh:194
XrdPssSys::Unlink
int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)
XrdPssSys::~XrdPssSys
virtual ~XrdPssSys()
Definition: XrdPss.hh:188
XrdPssSys::Rename
int Rename(const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)
XrdPssSys::Disc
virtual void Disc(XrdOucEnv &)
XrdPssSys::XrdPssSys
XrdPssSys()
XrdPssFile::Read
ssize_t Read(off_t, size_t)
XrdPssFile::XrdPssFile
XrdPssFile(const char *tid)
Definition: XrdPss.hh:97
XrdPssSys::myName
static const char * myName
Definition: XrdPss.hh:168
XrdPssFile::ReadRaw
ssize_t ReadRaw(void *, off_t, size_t)
XrdOucName2Name
Definition: XrdOucName2Name.hh:49
XrdOssOK
#define XrdOssOK
Definition: XrdOss.hh:49
XrdPssFile::ReadV
ssize_t ReadV(XrdOucIOVec *readV, int n)
XrdSecEntity
Definition: XrdSecEntity.hh:64
XrdSfsAio
Definition: XrdSfsAio.hh:59
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:175
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:158
XrdSysError
Definition: XrdSysError.hh:90
XrdPssSys::xorig
int xorig(XrdSysError *errp, XrdOucStream &Config)
XrdOucPList.hh
XrdPssSys::myHost
static const char * myHost
Definition: XrdPss.hh:167
XrdPssFile::entity
const XrdSecEntity * entity
Definition: XrdPss.hh:109
XrdPssSys::PolObj
@ PolObj
Definition: XrdPss.hh:158
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:193
XrdOucTList
Definition: XrdOucTList.hh:42
XrdPssSys::Trace
static int Trace
Definition: XrdPss.hh:179
XrdOucExport.hh
XrdPssFile::Fsync
int Fsync()
XrdPssSys::idMapper
XrdSecsssID * idMapper
Definition: XrdPss.hh:196
XrdSysHeaders.hh