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 
13 #include <errno.h>
14 #include <unistd.h>
15 #include <sys/types.h>
16 #include "XrdSys/XrdSysHeaders.hh"
17 #include "XrdOuc/XrdOucExport.hh"
19 #include "XrdOuc/XrdOucPList.hh"
20 #include "XrdOss/XrdOss.hh"
21 
22 /******************************************************************************/
23 /* X r d P s s D i r */
24 /******************************************************************************/
25 
26 class XrdPssDir : public XrdOssDF
27 {
28 public:
29 int Close(long long *retsz=0);
30 int Opendir(const char *, XrdOucEnv &);
31 int Readdir(char *buff, int blen);
32 
33  // Constructor and destructor
34  XrdPssDir(const char *tid) : tident(tid), dirVec(0) {}
35  ~XrdPssDir() {if (dirVec) Close();}
36 private:
37 const char *tident;
38  char **dirVec;
39  int curEnt;
40  int numEnt;
41 };
42 
43 /******************************************************************************/
44 /* X r d P s s F i l e */
45 /******************************************************************************/
46 
47 class XrdSfsAio;
48 
49 class XrdPssFile : public XrdOssDF
50 {
51 public:
52 
53 // The following two are virtual functions to allow for upcasting derivations
54 // of this implementation
55 //
56 virtual int Close(long long *retsz=0);
57 virtual int Open(const char *, int, mode_t, XrdOucEnv &);
58 
59 int Fstat(struct stat *);
60 int Fsync();
61 int Fsync(XrdSfsAio *aiop);
62 int Ftruncate(unsigned long long);
63 off_t getMmap(void **addr);
64 int isCompressed(char *cxidp=0);
65 ssize_t Read( off_t, size_t);
66 ssize_t Read( void *, off_t, size_t);
67 int Read(XrdSfsAio *aiop);
68 ssize_t ReadRaw( void *, off_t, size_t);
69 ssize_t Write(const void *, off_t, size_t);
70 int Write(XrdSfsAio *aiop);
71 
72  // Constructor and destructor
73  XrdPssFile(const char *tid) : tident(tid) {fd = -1;}
74 
75 virtual ~XrdPssFile() {if (fd >= 0) Close();}
76 
77 private:
78 
79 const char *tident;
80 const char *crPath;
81  int crOpts;
82 };
83 
84 /******************************************************************************/
85 /* X r d P s s S y s */
86 /******************************************************************************/
87 
88 class XrdOucEnv;
89 class XrdSysError;
90 class XrdOucStream;
91 class XrdOucTList;
92 
93 class XrdPssSys : public XrdOss
94 {
95 public:
96 virtual XrdOssDF *newDir(const char *tident)
97  {return (XrdOssDF *)new XrdPssDir(tident);}
98 virtual XrdOssDF *newFile(const char *tident)
99  {return (XrdOssDF *)new XrdPssFile(tident);}
100 
101 int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
102 virtual
103 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
104 int Init(XrdSysLogger *, const char *);
105 int Lfn2Pfn(const char *Path, char *buff, int blen);
106 const
107 char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
108 int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
109 int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
110 int Rename(const char *, const char *,
111  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
112 int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0);
113 int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0);
114 int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
115 
116 static char *P2URL(int &retc, char *pbuff, int pblen,
117  const char *path, int Split=0,
118  const char *Cgi=0, int CgiLn=0,
119  const char *tIdent=0, int doN2N=1);
120 static int T2UID(const char *Ident);
121 
122 static const char *ConfigFN; // -> Pointer to the config file name
123 static const char *myHost;
124 static const char *myName;
125 static uid_t myUid;
126 static gid_t myGid;
127 static
128 XrdOucPListAnchor XPList; // Exported path list
129 
131 static const char *urlPlain;
132 static int urlPlen;
133 static int hdrLen;
134 static const char *hdrData;
135 static const char *urlRdr;
136 static int Workers;
137 
138 static char allChmod;
139 static char allMkdir;
140 static char allMv;
141 static char allRmdir;
142 static char allRm;
143 static char allTrunc;
144 
145 static char cfgDone; // Configuration completed
146 
148  DirFlags(0), cPath(0), cParm(0) {}
149 virtual ~XrdPssSys() {}
150 
151 private:
152 
153 char *LocalRoot;// -> Local n2n root, if any
154 char *N2NLib; // -> Name2Name Library Path
155 char *N2NParms; // -> Name2Name Object Parameters
156 XrdOucName2Name *theN2N; // -> File mapper object
157 unsigned long long DirFlags; // Defaults for exports
158 char *cPath; // -> Cache path
159 char *cParm; // -> Cache parameters
160 
161 int buildHdr();
162 int Configure(const char *);
163 int ConfigProc(const char *ConfigFN);
164 int ConfigXeq(char*, XrdOucStream&);
165 int ConfigN2N();
166 int getCache();
167 int xcach(XrdSysError *Eroute, XrdOucStream &Config);
168 int xcacl(XrdSysError *Eroute, XrdOucStream &Config);
169 char *xcapr(XrdSysError *Eroute, XrdOucStream &Config, char *pBuff);
170 int xconf(XrdSysError *Eroute, XrdOucStream &Config);
171 int xdef( XrdSysError *Eroute, XrdOucStream &Config);
172 int xexp( XrdSysError *Eroute, XrdOucStream &Config);
173 int xorig(XrdSysError *errp, XrdOucStream &Config);
174 int xsopt(XrdSysError *Eroute, XrdOucStream &Config);
175 int xtrac(XrdSysError *Eroute, XrdOucStream &Config);
176 int xnml (XrdSysError *Eroute, XrdOucStream &Config);
177 };
178 #endif