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