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 "XrdSys/XrdSysHeaders.hh"
37 #include "XrdOuc/XrdOucExport.hh"
39 #include "XrdOuc/XrdOucPList.hh"
40 #include "XrdOss/XrdOss.hh"
41 
42 /******************************************************************************/
43 /* X r d P s s D i r */
44 /******************************************************************************/
45 
46 class XrdPssDir : public XrdOssDF
47 {
48 public:
49 int Close(long long *retsz=0);
50 int Opendir(const char *, XrdOucEnv &);
51 int Readdir(char *buff, int blen);
52 
53  // Constructor and destructor
54  XrdPssDir(const char *tid) : tident(tid), dirVec(0) {}
55  ~XrdPssDir() {if (dirVec) Close();}
56 private:
57 const char *tident;
58  char **dirVec;
59  int curEnt;
60  int numEnt;
61 };
62 
63 /******************************************************************************/
64 /* X r d P s s F i l e */
65 /******************************************************************************/
66 
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 Fstat(struct stat *);
80 int Fsync();
81 int Fsync(XrdSfsAio *aiop);
82 int Ftruncate(unsigned long long);
83 off_t getMmap(void **addr);
84 int isCompressed(char *cxidp=0);
85 ssize_t Read( off_t, size_t);
86 ssize_t Read( void *, off_t, size_t);
87 int Read(XrdSfsAio *aiop);
88 ssize_t ReadRaw( void *, off_t, size_t);
89 ssize_t Write(const void *, off_t, size_t);
90 int Write(XrdSfsAio *aiop);
91 
92  // Constructor and destructor
93  XrdPssFile(const char *tid) : tident(tid) {fd = -1;}
94 
95 virtual ~XrdPssFile() {if (fd >= 0) Close();}
96 
97 private:
98 
99 const char *tident;
100  int crOpts;
101 };
102 
103 /******************************************************************************/
104 /* X r d P s s S y s */
105 /******************************************************************************/
106 
107 class XrdOucEnv;
108 class XrdSysError;
109 class XrdOucStream;
110 class XrdOucTList;
111 
112 struct XrdVersionInfo;
113 
114 class XrdPssSys : public XrdOss
115 {
116 public:
117 virtual XrdOssDF *newDir(const char *tident)
118  {return (XrdOssDF *)new XrdPssDir(tident);}
119 virtual XrdOssDF *newFile(const char *tident)
120  {return (XrdOssDF *)new XrdPssFile(tident);}
121 
122 int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
123 virtual
124 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
125 int Init(XrdSysLogger *, const char *);
126 int Lfn2Pfn(const char *Path, char *buff, int blen);
127 const
128 char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
129 int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
130 int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
131 int Rename(const char *, const char *,
132  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
133 int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0);
134 int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0);
135 int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
136 
137 static char *P2URL(int &retc, char *pbuff, int pblen,
138  const char *path, int Split=0,
139  const char *Cgi=0, int CgiLn=0,
140  const char *tIdent=0, int doN2N=1);
141 static int T2UID(const char *Ident);
142 
143 static const char *ConfigFN; // -> Pointer to the config file name
144 static const char *myHost;
145 static const char *myName;
146 static uid_t myUid;
147 static gid_t myGid;
148 static
149 XrdOucPListAnchor XPList; // Exported path list
150 
152 static const char *urlPlain;
153 static int urlPlen;
154 static int hdrLen;
155 static const char *hdrData;
156 static const char *urlRdr;
157 static int Workers;
158 static int Trace;
159 
160 static char allChmod;
161 static char allMkdir;
162 static char allMv;
163 static char allRmdir;
164 static char allRm;
165 static char allTrunc;
166 
167 static char cfgDone; // Configuration completed
168 
169  XrdPssSys();
170 virtual ~XrdPssSys() {}
171 
172 private:
173 
174 char *LocalRoot;// -> Local n2n root, if any
175 char *N2NLib; // -> Name2Name Library Path
176 char *N2NParms; // -> Name2Name Object Parameters
177 XrdOucName2Name *theN2N; // -> File mapper object
178 unsigned long long DirFlags; // Defaults for exports
179 char *cPath; // -> Cache path
180 char *cParm; // -> Cache parameters
181 XrdVersionInfo *myVersion;// -> Compilation version
182 int TraceLvl; // Tracing options
183 
184 int buildHdr();
185 int Configure(const char *);
186 int ConfigProc(const char *ConfigFN);
187 int ConfigXeq(char*, XrdOucStream&);
188 int ConfigN2N();
189 int getCache();
190 int xcach(XrdSysError *Eroute, XrdOucStream &Config);
191 int xcacl(XrdSysError *Eroute, XrdOucStream &Config);
192 char *xcapr(XrdSysError *Eroute, XrdOucStream &Config, char *pBuff);
193 int xconf(XrdSysError *Eroute, XrdOucStream &Config);
194 int xdef( XrdSysError *Eroute, XrdOucStream &Config);
195 int xexp( XrdSysError *Eroute, XrdOucStream &Config);
196 int xorig(XrdSysError *errp, XrdOucStream &Config);
197 int xsopt(XrdSysError *Eroute, XrdOucStream &Config);
198 int xtrac(XrdSysError *Eroute, XrdOucStream &Config);
199 int xnml (XrdSysError *Eroute, XrdOucStream &Config);
200 };
201 #endif