xrootd
XrdBwm.hh
Go to the documentation of this file.
1 #ifndef __BWM_API_H__
2 #define __BWM_API_H__
3 /******************************************************************************/
4 /* */
5 /* X r d B w m . h h */
6 /* */
7 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC03-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 #include <string.h>
14 #include <dirent.h>
15 #include <sys/types.h>
16 
17 #include "XrdBwm/XrdBwmHandle.hh"
18 #include "XrdSys/XrdSysPthread.hh"
20 
21 class XrdOucEnv;
22 class XrdSysError;
23 class XrdSysLogger;
24 class XrdOucStream;
25 class XrdSfsAio;
26 
27 /******************************************************************************/
28 /* X r d B w m D i r e c t o r y */
29 /******************************************************************************/
30 
32 {
33 public:
34 
35  int open(const char *dirName,
36  const XrdSecEntity *client,
37  const char *opaque = 0);
38 
39  const char *nextEntry();
40 
41  int close();
42 
43 inline void copyError(XrdOucErrInfo &einfo) {einfo = error;}
44 
45 const char *FName() {return "";}
46 
47  XrdBwmDirectory(const char *user, int monid)
48  : XrdSfsDirectory(user, monid),
49  tident(user ? user : "") {}
50 
51 virtual ~XrdBwmDirectory() {}
52 
53 protected:
54 const char *tident;
55 };
56 
57 /******************************************************************************/
58 /* X r d B w m F i l e */
59 /******************************************************************************/
60 
61 class XrdBwmFile : public XrdSfsFile
62 {
63 public:
64 
65  int open(const char *fileName,
66  XrdSfsFileOpenMode openMode,
67  mode_t createMode,
68  const XrdSecEntity *client,
69  const char *opaque = 0);
70 
71  int close();
72 
73  int fctl(const int cmd,
74  const char *args,
75  XrdOucErrInfo &out_error);
76 
77  const char *FName() {return (oh ? oh->Name() : "?");}
78 
79  int getMmap(void **Addr, off_t &Size);
80 
81  int read(XrdSfsFileOffset fileOffset, // Preread only
82  XrdSfsXferSize amount);
83 
85  char *buffer,
86  XrdSfsXferSize buffer_size);
87 
88  int read(XrdSfsAio *aioparm);
89 
91  const char *buffer,
92  XrdSfsXferSize buffer_size);
93 
94  int write(XrdSfsAio *aioparm);
95 
96  int sync();
97 
98  int sync(XrdSfsAio *aiop);
99 
100  int stat(struct stat *buf);
101 
102  int truncate(XrdSfsFileOffset fileOffset);
103 
104  int getCXinfo(char cxtype[4], int &cxrsz);
105 
106  XrdBwmFile(const char *user, int monid);
107 
108 virtual ~XrdBwmFile() {if (oh) close();}
109 
110 protected:
111  const char *tident;
112 
113 private:
114 
116 };
117 
118 /******************************************************************************/
119 /* C l a s s X r d B w m */
120 /******************************************************************************/
121 
122 class XrdAccAuthorize;
123 class XrdBwmLogger;
124 class XrdBwmPolicy;
125 
126 class XrdBwm : public XrdSfsFileSystem
127 {
128 friend class XrdBwmDirectory;
129 friend class XrdBwmFile;
130 
131 public:
132 
133 // Object allocation
134 //
135  XrdSfsDirectory *newDir(char *user=0, int monid=0)
136  {return (XrdSfsDirectory *)new XrdBwmDirectory(user,monid);}
137 
138  XrdSfsFile *newFile(char *user=0, int monid=0)
139  {return (XrdSfsFile *)new XrdBwmFile(user,monid);}
140 
141 // Other functions
142 //
143  int chmod(const char *Name,
145  XrdOucErrInfo &out_error,
146  const XrdSecEntity *client,
147  const char *opaque = 0);
148 
149  int exists(const char *fileName,
150  XrdSfsFileExistence &exists_flag,
151  XrdOucErrInfo &out_error,
152  const XrdSecEntity *client,
153  const char *opaque = 0);
154 
155  int fsctl(const int cmd,
156  const char *args,
157  XrdOucErrInfo &out_error,
158  const XrdSecEntity *client);
159 
160  int getStats(char *buff, int blen) {return 0;}
161 
162 const char *getVersion();
163 
164  int mkdir(const char *dirName,
166  XrdOucErrInfo &out_error,
167  const XrdSecEntity *client,
168  const char *opaque = 0);
169 
170  int prepare( XrdSfsPrep &pargs,
171  XrdOucErrInfo &out_error,
172  const XrdSecEntity *client = 0);
173 
174  int rem(const char *path,
175  XrdOucErrInfo &out_error,
176  const XrdSecEntity *client,
177  const char *info = 0)
178  {return remove('f', path, out_error, client, info);}
179 
180  int remdir(const char *dirName,
181  XrdOucErrInfo &out_error,
182  const XrdSecEntity *client,
183  const char *info = 0)
184  {return remove('d',dirName,out_error,client,info);}
185 
186  int rename(const char *oldFileName,
187  const char *newFileName,
188  XrdOucErrInfo &out_error,
189  const XrdSecEntity *client,
190  const char *infoO = 0,
191  const char *infoN = 0);
192 
193  int stat(const char *Name,
194  struct stat *buf,
195  XrdOucErrInfo &out_error,
196  const XrdSecEntity *client,
197  const char *opaque = 0);
198 
199  int stat(const char *Name,
200  mode_t &mode,
201  XrdOucErrInfo &out_error,
202  const XrdSecEntity *client,
203  const char *opaque = 0);
204 
205  int truncate(const char *Name,
206  XrdSfsFileOffset fileOffset,
207  XrdOucErrInfo &out_error,
208  const XrdSecEntity *client = 0,
209  const char *opaque = 0);
210 // Management functions
211 //
212 virtual int Configure(XrdSysError &);
213 
214  XrdBwm();
215 virtual ~XrdBwm() {} // Too complicate to delete :-)
216 
217 /******************************************************************************/
218 /* C o n f i g u r a t i o n V a l u e s */
219 /******************************************************************************/
220 
221 char *ConfigFN; // ->Configuration filename
222 char *HostName; // ->Our hostname
223 char *HostPref; // ->Our hostname with domain removed
224 char *myDomain; // ->Our domain name
225 int myDomLen; //
227 char Reserved[3];
228 
229 /******************************************************************************/
230 /* P r o t e c t e d I t e m s */
231 /******************************************************************************/
232 
233 protected:
234 
235 virtual int ConfigXeq(char *var, XrdOucStream &, XrdSysError &);
236  int Emsg(const char *, XrdOucErrInfo &, int,
237  const char *, const char *y="");
238  int Emsg(const char *, XrdOucErrInfo &, const char *,
239  const char *, const char *y="");
240  int Stall(XrdOucErrInfo &, int, const char *);
241 
242 /******************************************************************************/
243 /* P r i v a t e C o n f i g u r a t i o n */
244 /******************************************************************************/
245 
246 private:
247 
248 XrdAccAuthorize *Authorization; // ->Authorization Service
249 char *AuthLib; // ->Authorization Library
250 char *AuthParm; // ->Authorization Parameters
251 XrdBwmLogger *Logger; // ->Logger
252 XrdBwmPolicy *Policy; // ->Policy
253 char *PolLib;
254 char *PolParm;
255 char *locResp; // ->Locate Response
256 int locRlen; // Length of locResp;
259 
261 XrdSysMutex ocMutex; // Global mutex for open/close
262 
263 /******************************************************************************/
264 /* O t h e r D a t a */
265 /******************************************************************************/
266 
267 int remove(const char type, const char *path,
268  XrdOucErrInfo &out_error, const XrdSecEntity *client,
269  const char *opaque);
270 // Function used during Configuration
271 //
272 int setupAuth(XrdSysError &);
273 int setupPolicy(XrdSysError &);
274 int xalib(XrdOucStream &, XrdSysError &);
275 int xlog(XrdOucStream &, XrdSysError &);
276 int xpol(XrdOucStream &, XrdSysError &);
278 };
279 #endif