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