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