00001 #ifndef __OFS_API_H__
00002 #define __OFS_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 "XrdOfs/XrdOfsEvr.hh"
00037 #include "XrdOfs/XrdOfsHandle.hh"
00038 #include "XrdSys/XrdSysPthread.hh"
00039 #include "XrdSfs/XrdSfsInterface.hh"
00040 #include "XrdCms/XrdCmsClient.hh"
00041
00042 class XrdNetIF;
00043 class XrdOfsEvs;
00044 class XrdOfsPocq;
00045 class XrdOfsPrepare;
00046 class XrdOss;
00047 class XrdOssDF;
00048 class XrdOssDir;
00049 class XrdOucEnv;
00050 class XrdSysError;
00051 class XrdSysLogger;
00052 class XrdOucStream;
00053 class XrdSfsAio;
00054
00055 struct XrdVersionInfo;
00056
00057
00058
00059
00060
00061 class XrdOfsDirectory : public XrdSfsDirectory
00062 {
00063 public:
00064
00065 int open(const char *dirName,
00066 const XrdSecEntity *client,
00067 const char *opaque = 0);
00068
00069 const char *nextEntry();
00070
00071 int close();
00072
00073 inline void copyError(XrdOucErrInfo &einfo) {einfo = error;}
00074
00075 const char *FName() {return (const char *)fname;}
00076
00077 int autoStat(struct stat *buf);
00078
00079 XrdOfsDirectory(const char *user, int MonID)
00080 : XrdSfsDirectory(user, MonID)
00081 {dp = 0;
00082 tident = (user ? user : "");
00083 fname=0; atEOF=0;
00084 }
00085 virtual ~XrdOfsDirectory() {if (dp) close();}
00086
00087 protected:
00088 const char *tident;
00089 char *fname;
00090
00091 private:
00092 XrdOssDF *dp;
00093 int atEOF;
00094 char dname[MAXNAMLEN];
00095 };
00096
00097
00098
00099
00100
00101 class XrdOfsTPC;
00102
00103 class XrdOfsFile : public XrdSfsFile
00104 {
00105 public:
00106
00107 int open(const char *fileName,
00108 XrdSfsFileOpenMode openMode,
00109 mode_t createMode,
00110 const XrdSecEntity *client,
00111 const char *opaque = 0);
00112
00113 int close();
00114
00115 using XrdSfsFile::fctl;
00116
00117 int fctl(const int cmd,
00118 const char *args,
00119 XrdOucErrInfo &out_error);
00120
00121 int fctl(const int cmd,
00122 int alen,
00123 const char *args,
00124 const XrdSecEntity *client = 0);
00125
00126 const char *FName() {return (oh ? oh->Name() : "?");}
00127
00128 int getMmap(void **Addr, off_t &Size);
00129
00130 int read(XrdSfsFileOffset fileOffset,
00131 XrdSfsXferSize amount);
00132
00133 XrdSfsXferSize read(XrdSfsFileOffset fileOffset,
00134 char *buffer,
00135 XrdSfsXferSize buffer_size);
00136
00137 XrdSfsXferSize readv(XrdOucIOVec *readV,
00138 int readCount);
00139
00140 int read(XrdSfsAio *aioparm);
00141
00142 XrdSfsXferSize write(XrdSfsFileOffset fileOffset,
00143 const char *buffer,
00144 XrdSfsXferSize buffer_size);
00145
00146 int write(XrdSfsAio *aioparm);
00147
00148 int sync();
00149
00150 int sync(XrdSfsAio *aiop);
00151
00152 int stat(struct stat *buf);
00153
00154 int truncate(XrdSfsFileOffset fileOffset);
00155
00156 int getCXinfo(char cxtype[4], int &cxrsz);
00157
00158 XrdOfsFile(const char *user, int MonID);
00159
00160 ~XrdOfsFile() {viaDel = 1; if (oh) close();}
00161
00162 protected:
00163 const char *tident;
00164
00165 private:
00166
00167 void GenFWEvent();
00168
00169 XrdOfsHandle *oh;
00170 XrdOfsTPC *myTPC;
00171 int dorawio;
00172 char viaDel;
00173 };
00174
00175
00176
00177
00178
00179 class XrdAccAuthorize;
00180 class XrdCks;
00181 class XrdCmsClient;
00182 class XrdOfsConfigPI;
00183 class XrdOfsPoscq;
00184
00185 class XrdOfs : public XrdSfsFileSystem
00186 {
00187 friend class XrdOfsDirectory;
00188 friend class XrdOfsFile;
00189
00190 public:
00191
00192
00193
00194 XrdSfsDirectory *newDir(char *user=0, int MonID=0)
00195 {return (XrdSfsDirectory *)new XrdOfsDirectory(user,MonID);}
00196
00197 XrdSfsFile *newFile(char *user=0,int MonID=0)
00198 {return (XrdSfsFile *)new XrdOfsFile(user, MonID);}
00199
00200
00201
00202 int chksum( csFunc Func,
00203 const char *csName,
00204 const char *Path,
00205 XrdOucErrInfo &out_error,
00206 const XrdSecEntity *client = 0,
00207 const char *opaque = 0);
00208
00209 int chmod(const char *Name,
00210 XrdSfsMode Mode,
00211 XrdOucErrInfo &out_error,
00212 const XrdSecEntity *client,
00213 const char *opaque = 0);
00214
00215 int exists(const char *fileName,
00216 XrdSfsFileExistence &exists_flag,
00217 XrdOucErrInfo &out_error,
00218 const XrdSecEntity *client,
00219 const char *opaque = 0);
00220
00221 int fsctl(const int cmd,
00222 const char *args,
00223 XrdOucErrInfo &out_error,
00224 const XrdSecEntity *client);
00225
00226 int getStats(char *buff, int blen);
00227
00228 const char *getVersion();
00229
00230 int mkdir(const char *dirName,
00231 XrdSfsMode Mode,
00232 XrdOucErrInfo &out_error,
00233 const XrdSecEntity *client,
00234 const char *opaque = 0);
00235
00236 int prepare( XrdSfsPrep &pargs,
00237 XrdOucErrInfo &out_error,
00238 const XrdSecEntity *client = 0);
00239
00240 int rem(const char *path,
00241 XrdOucErrInfo &out_error,
00242 const XrdSecEntity *client,
00243 const char *info = 0)
00244 {return remove('f', path, out_error, client, info);}
00245
00246 int remdir(const char *dirName,
00247 XrdOucErrInfo &out_error,
00248 const XrdSecEntity *client,
00249 const char *info = 0)
00250 {return remove('d',dirName,out_error,client,info);}
00251
00252 int rename(const char *oldFileName,
00253 const char *newFileName,
00254 XrdOucErrInfo &out_error,
00255 const XrdSecEntity *client,
00256 const char *infoO = 0,
00257 const char *infoN = 0);
00258
00259 int stat(const char *Name,
00260 struct stat *buf,
00261 XrdOucErrInfo &out_error,
00262 const XrdSecEntity *client,
00263 const char *opaque = 0);
00264
00265 int stat(const char *Name,
00266 mode_t &mode,
00267 XrdOucErrInfo &out_error,
00268 const XrdSecEntity *client,
00269 const char *opaque = 0);
00270
00271 int truncate(const char *Name,
00272 XrdSfsFileOffset fileOffset,
00273 XrdOucErrInfo &out_error,
00274 const XrdSecEntity *client = 0,
00275 const char *opaque = 0);
00276
00277
00278 virtual int Configure(XrdSysError &);
00279
00280 virtual int Configure(XrdSysError &, XrdOucEnv *);
00281
00282 void Config_Cluster(XrdOss *);
00283
00284 void Config_Display(XrdSysError &);
00285
00286 XrdOfs();
00287 virtual ~XrdOfs() {}
00288
00289
00290
00291
00292
00293
00294
00295 enum {Authorize = 0x0001,
00296 XAttrPlug = 0x0002,
00297 isPeer = 0x0050,
00298 isProxy = 0x0020,
00299 isManager = 0x0040,
00300 isServer = 0x0080,
00301 isSuper = 0x00C0,
00302 isMeta = 0x0100,
00303 haveRole = 0x01F0,
00304 Forwarding= 0x1000,
00305 ThirdPC = 0x2000,
00306 SubCluster= 0x4000
00307 };
00308
00309 int Options;
00310 int myPort;
00311
00312
00313
00314 char *tpcRdrHost[2];
00315 int tpcRdrPort[2];
00316
00317
00318
00319 XrdNetIF *myIF;
00320
00321
00322
00323 struct fwdOpt
00324 {const char *Cmd;
00325 char *Host;
00326 int Port;
00327 void Reset() {Cmd = 0; Port = 0;
00328 if (Host) {free(Host); Host = 0;}
00329 }
00330 fwdOpt() : Cmd(0), Host(0), Port(0) {}
00331 ~fwdOpt() {}
00332 };
00333
00334 struct fwdOpt fwdCHMOD;
00335 struct fwdOpt fwdMKDIR;
00336 struct fwdOpt fwdMKPATH;
00337 struct fwdOpt fwdMV;
00338 struct fwdOpt fwdRM;
00339 struct fwdOpt fwdRMDIR;
00340 struct fwdOpt fwdTRUNC;
00341
00342 static int MaxDelay;
00343 static int OSSDelay;
00344
00345 char *ConfigFN;
00346
00347
00348
00349
00350
00351 protected:
00352
00353 XrdOfsEvr evrObject;
00354 XrdCmsClient *Finder;
00355
00356 virtual int ConfigXeq(char *var, XrdOucStream &, XrdSysError &);
00357 static int Emsg(const char *, XrdOucErrInfo &, int, const char *x,
00358 XrdOfsHandle *hP);
00359 static int Emsg(const char *, XrdOucErrInfo &, int, const char *x,
00360 const char *y="");
00361 static int fsError(XrdOucErrInfo &myError, int rc);
00362 const char *Split(const char *Args, const char **Opq, char *Path, int Plen);
00363 int Stall(XrdOucErrInfo &, int, const char *);
00364 void Unpersist(XrdOfsHandle *hP, int xcev=1);
00365 char *WaitTime(int, char *, int);
00366
00367
00368
00369
00370
00371 private:
00372
00373 char *myRole;
00374 XrdAccAuthorize *Authorization;
00375 XrdCmsClient *Balancer;
00376 XrdOfsEvs *evsObject;
00377
00378 XrdOfsPoscq *poscQ;
00379 char *poscLog;
00380 int poscHold;
00381 short poscSync;
00382 signed char poscAuto;
00383
00384 char ossRW;
00385
00386 XrdOfsConfigPI *ofsConfig;
00387 XrdOfsPrepare *prepHandler;
00388 XrdCks *Cks;
00389 bool CksPfn;
00390 bool CksRdr;
00391 bool prepAuth;
00392 char OssIsProxy;
00393 char myRType[4];
00394
00395 XrdVersionInfo *myVersion;
00396
00397 static XrdOfsHandle *dummyHandle;
00398 XrdSysMutex ocMutex;
00399
00400
00401
00402
00403
00404
00405
00406 int remove(const char type, const char *path,
00407 XrdOucErrInfo &out_error, const XrdSecEntity *client,
00408 const char *opaque);
00409
00410
00411
00412 int ConfigDispFwd(char *buff, struct fwdOpt &Fwd);
00413 int ConfigPosc(XrdSysError &Eroute);
00414 int ConfigRedir(XrdSysError &Eroute, XrdOucEnv *EnvInfo);
00415 int ConfigTPC(XrdSysError &Eroute);
00416 char *ConfigTPCDir(XrdSysError &Eroute, const char *xPath);
00417 const char *Fname(const char *);
00418 int Forward(int &Result, XrdOucErrInfo &Resp, struct fwdOpt &Fwd,
00419 const char *arg1=0, const char *arg2=0,
00420 XrdOucEnv *Env1=0, XrdOucEnv *Env2=0);
00421 int Reformat(XrdOucErrInfo &);
00422 const char *theRole(int opts);
00423 int xcrds(XrdOucStream &, XrdSysError &);
00424 int xexp(XrdOucStream &, XrdSysError &, bool);
00425 int xforward(XrdOucStream &, XrdSysError &);
00426 int xmaxd(XrdOucStream &, XrdSysError &);
00427 int xnmsg(XrdOucStream &, XrdSysError &);
00428 int xnot(XrdOucStream &, XrdSysError &);
00429 int xpers(XrdOucStream &, XrdSysError &);
00430 int xrole(XrdOucStream &, XrdSysError &);
00431 int xtpc(XrdOucStream &, XrdSysError &);
00432 int xtpcal(XrdOucStream &, XrdSysError &);
00433 int xtpcr(XrdOucStream &, XrdSysError &);
00434 int xtrace(XrdOucStream &, XrdSysError &);
00435 };
00436 #endif