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