00001 #ifndef __BWM_API_H__
00002 #define __BWM_API_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <string.h>
00033 #include <dirent.h>
00034 #include <sys/types.h>
00035
00036 #include "XrdBwm/XrdBwmHandle.hh"
00037 #include "XrdSys/XrdSysPthread.hh"
00038 #include "XrdSfs/XrdSfsInterface.hh"
00039
00040 class XrdOucEnv;
00041 class XrdSysError;
00042 class XrdSysLogger;
00043 class XrdOucStream;
00044 class XrdSfsAio;
00045
00046 struct XrdVersionInfo;
00047
00048
00049
00050
00051
00052 class XrdBwmDirectory : public XrdSfsDirectory
00053 {
00054 public:
00055
00056 int open(const char *dirName,
00057 const XrdSecEntity *client,
00058 const char *opaque = 0);
00059
00060 const char *nextEntry();
00061
00062 int close();
00063
00064 inline void copyError(XrdOucErrInfo &einfo) {einfo = error;}
00065
00066 const char *FName() {return "";}
00067
00068 XrdBwmDirectory(const char *user, int monid)
00069 : XrdSfsDirectory(user, monid),
00070 tident(user ? user : "") {}
00071
00072 virtual ~XrdBwmDirectory() {}
00073
00074 protected:
00075 const char *tident;
00076 };
00077
00078
00079
00080
00081
00082 class XrdBwmFile : public XrdSfsFile
00083 {
00084 public:
00085
00086 int open(const char *fileName,
00087 XrdSfsFileOpenMode openMode,
00088 mode_t createMode,
00089 const XrdSecEntity *client,
00090 const char *opaque = 0);
00091
00092 int close();
00093
00094 using XrdSfsFile::fctl;
00095
00096 int fctl(const int cmd,
00097 const char *args,
00098 XrdOucErrInfo &out_error);
00099
00100 const char *FName() {return (oh ? oh->Name() : "?");}
00101
00102 int getMmap(void **Addr, off_t &Size);
00103
00104 int read(XrdSfsFileOffset fileOffset,
00105 XrdSfsXferSize amount);
00106
00107 XrdSfsXferSize read(XrdSfsFileOffset fileOffset,
00108 char *buffer,
00109 XrdSfsXferSize buffer_size);
00110
00111 int read(XrdSfsAio *aioparm);
00112
00113 XrdSfsXferSize write(XrdSfsFileOffset fileOffset,
00114 const char *buffer,
00115 XrdSfsXferSize buffer_size);
00116
00117 int write(XrdSfsAio *aioparm);
00118
00119 int sync();
00120
00121 int sync(XrdSfsAio *aiop);
00122
00123 int stat(struct stat *buf);
00124
00125 int truncate(XrdSfsFileOffset fileOffset);
00126
00127 int getCXinfo(char cxtype[4], int &cxrsz);
00128
00129 XrdBwmFile(const char *user, int monid);
00130
00131 virtual ~XrdBwmFile() {if (oh) close();}
00132
00133 protected:
00134 const char *tident;
00135
00136 private:
00137
00138 XrdBwmHandle *oh;
00139 };
00140
00141
00142
00143
00144
00145 class XrdAccAuthorize;
00146 class XrdBwmLogger;
00147 class XrdBwmPolicy;
00148
00149 class XrdBwm : public XrdSfsFileSystem
00150 {
00151 friend class XrdBwmDirectory;
00152 friend class XrdBwmFile;
00153
00154 public:
00155
00156
00157
00158 XrdSfsDirectory *newDir(char *user=0, int monid=0)
00159 {return (XrdSfsDirectory *)new XrdBwmDirectory(user,monid);}
00160
00161 XrdSfsFile *newFile(char *user=0, int monid=0)
00162 {return (XrdSfsFile *)new XrdBwmFile(user,monid);}
00163
00164
00165
00166 int chmod(const char *Name,
00167 XrdSfsMode Mode,
00168 XrdOucErrInfo &out_error,
00169 const XrdSecEntity *client,
00170 const char *opaque = 0);
00171
00172 int exists(const char *fileName,
00173 XrdSfsFileExistence &exists_flag,
00174 XrdOucErrInfo &out_error,
00175 const XrdSecEntity *client,
00176 const char *opaque = 0);
00177
00178 int fsctl(const int cmd,
00179 const char *args,
00180 XrdOucErrInfo &out_error,
00181 const XrdSecEntity *client);
00182
00183 int getStats(char *buff, int blen) {return 0;}
00184
00185 const char *getVersion();
00186
00187 int mkdir(const char *dirName,
00188 XrdSfsMode Mode,
00189 XrdOucErrInfo &out_error,
00190 const XrdSecEntity *client,
00191 const char *opaque = 0);
00192
00193 int prepare( XrdSfsPrep &pargs,
00194 XrdOucErrInfo &out_error,
00195 const XrdSecEntity *client = 0);
00196
00197 int rem(const char *path,
00198 XrdOucErrInfo &out_error,
00199 const XrdSecEntity *client,
00200 const char *info = 0)
00201 {return remove('f', path, out_error, client, info);}
00202
00203 int remdir(const char *dirName,
00204 XrdOucErrInfo &out_error,
00205 const XrdSecEntity *client,
00206 const char *info = 0)
00207 {return remove('d',dirName,out_error,client,info);}
00208
00209 int rename(const char *oldFileName,
00210 const char *newFileName,
00211 XrdOucErrInfo &out_error,
00212 const XrdSecEntity *client,
00213 const char *infoO = 0,
00214 const char *infoN = 0);
00215
00216 int stat(const char *Name,
00217 struct stat *buf,
00218 XrdOucErrInfo &out_error,
00219 const XrdSecEntity *client,
00220 const char *opaque = 0);
00221
00222 int stat(const char *Name,
00223 mode_t &mode,
00224 XrdOucErrInfo &out_error,
00225 const XrdSecEntity *client,
00226 const char *opaque = 0);
00227
00228 int truncate(const char *Name,
00229 XrdSfsFileOffset fileOffset,
00230 XrdOucErrInfo &out_error,
00231 const XrdSecEntity *client = 0,
00232 const char *opaque = 0);
00233
00234
00235 virtual int Configure(XrdSysError &);
00236
00237 XrdBwm();
00238 virtual ~XrdBwm() {}
00239
00240
00241
00242
00243
00244 XrdVersionInfo *myVersion;
00245
00246 char *ConfigFN;
00247 char *HostName;
00248 char *HostPref;
00249 char *myDomain;
00250 int myDomLen;
00251 char Authorize;
00252 char Reserved[7];
00253
00254
00255
00256
00257
00258 protected:
00259
00260 virtual int ConfigXeq(char *var, XrdOucStream &, XrdSysError &);
00261 int Emsg(const char *, XrdOucErrInfo &, int,
00262 const char *, const char *y="");
00263 int Emsg(const char *, XrdOucErrInfo &, const char *,
00264 const char *, const char *y="");
00265 int Stall(XrdOucErrInfo &, int, const char *);
00266
00267
00268
00269
00270
00271 private:
00272
00273 XrdAccAuthorize *Authorization;
00274 char *AuthLib;
00275 char *AuthParm;
00276 XrdBwmLogger *Logger;
00277 XrdBwmPolicy *Policy;
00278 char *PolLib;
00279 char *PolParm;
00280 char *locResp;
00281 int locRlen;
00282 int PolSlotsIn;
00283 int PolSlotsOut;
00284
00285 static XrdBwmHandle *dummyHandle;
00286 XrdSysMutex ocMutex;
00287
00288
00289
00290
00291
00292 int remove(const char type, const char *path,
00293 XrdOucErrInfo &out_error, const XrdSecEntity *client,
00294 const char *opaque);
00295
00296
00297 int setupAuth(XrdSysError &);
00298 int setupPolicy(XrdSysError &);
00299 int xalib(XrdOucStream &, XrdSysError &);
00300 int xlog(XrdOucStream &, XrdSysError &);
00301 int xpol(XrdOucStream &, XrdSysError &);
00302 int xtrace(XrdOucStream &, XrdSysError &);
00303 };
00304 #endif