File indexing completed on 2026-01-08 10:33:33
0001 #ifndef __OFS_API_H__
0002 #define __OFS_API_H__
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #include <cstring>
0033 #include <dirent.h>
0034 #include <sys/types.h>
0035
0036 #include "XrdOfs/XrdOfsEvr.hh"
0037 #include "XrdOfs/XrdOfsHandle.hh"
0038 #include "XrdSys/XrdSysPthread.hh"
0039 #include "XrdSfs/XrdSfsInterface.hh"
0040 #include "XrdCms/XrdCmsClient.hh"
0041
0042 class XrdNetIF;
0043 class XrdOfsEvs;
0044 class XrdOfsPocq;
0045 class XrdOfsPrepare;
0046 class XrdOss;
0047 class XrdOssDF;
0048 class XrdOssDir;
0049 class XrdOucEnv;
0050 class XrdOucPListAnchor;
0051 class XrdSysError;
0052 class XrdSysLogger;
0053 class XrdOucStream;
0054 class XrdSfsAio;
0055
0056 struct XrdVersionInfo;
0057
0058
0059
0060
0061
0062 class XrdOfsDirectory : public XrdSfsDirectory
0063 {
0064 public:
0065
0066 int open(const char *dirName,
0067 const XrdSecEntity *client,
0068 const char *opaque = 0);
0069
0070 const char *nextEntry();
0071
0072 int close();
0073
0074 inline void copyError(XrdOucErrInfo &einfo) {einfo = error;}
0075
0076 const char *FName() {return (const char *)fname;}
0077
0078 int autoStat(struct stat *buf);
0079
0080 XrdOfsDirectory(XrdOucErrInfo &eInfo, const char *user)
0081 : XrdSfsDirectory(eInfo), tident(user ? user : ""),
0082 fname(0), dp(0), atEOF(0) {}
0083
0084 virtual ~XrdOfsDirectory() {if (dp) close();}
0085
0086 protected:
0087 const char *tident;
0088 char *fname;
0089 XrdOssDF *dp;
0090 int atEOF;
0091 char dname[MAXNAMLEN];
0092 };
0093
0094 class XrdOfsDirFull : public XrdOfsDirectory
0095 {
0096 public:
0097 XrdOfsDirFull(const char *user, int MonID)
0098 : XrdOfsDirectory(myEInfo, user), myEInfo(user, MonID)
0099 {}
0100
0101 virtual ~XrdOfsDirFull() {}
0102
0103 private:
0104 XrdOucErrInfo myEInfo;
0105 };
0106
0107
0108
0109
0110
0111 class XrdOfsTPC;
0112 class XrdOucChkPnt;
0113
0114 class XrdOfsFile : public XrdSfsFile
0115 {
0116 public:
0117
0118 int open(const char *fileName,
0119 XrdSfsFileOpenMode openMode,
0120 mode_t createMode,
0121 const XrdSecEntity *client,
0122 const char *opaque = 0);
0123
0124 int checkpoint(XrdSfsFile::cpAct act,
0125 struct iov *range=0, int n=0);
0126
0127 int close();
0128
0129 using XrdSfsFile::fctl;
0130
0131 int fctl(const int cmd,
0132 const char *args,
0133 XrdOucErrInfo &out_error);
0134
0135 int fctl(const int cmd,
0136 int alen,
0137 const char *args,
0138 const XrdSecEntity *client = 0);
0139
0140 const char *FName() {return (oh ? oh->Name() : "?");}
0141
0142 int getMmap(void **Addr, off_t &Size);
0143
0144 XrdSfsXferSize pgRead(XrdSfsFileOffset offset,
0145 char *buffer,
0146 XrdSfsXferSize rdlen,
0147 uint32_t *csvec,
0148 uint64_t opts=0);
0149
0150 int pgRead(XrdSfsAio *aioparm, uint64_t opts=0);
0151
0152
0153 XrdSfsXferSize pgWrite(XrdSfsFileOffset offset,
0154 char *buffer,
0155 XrdSfsXferSize wrlen,
0156 uint32_t *csvec,
0157 uint64_t opts=0);
0158
0159 int pgWrite(XrdSfsAio *aioparm, uint64_t opts=0);
0160
0161
0162 int read(XrdSfsFileOffset fileOffset,
0163 XrdSfsXferSize amount);
0164
0165 XrdSfsXferSize read(XrdSfsFileOffset fileOffset,
0166 char *buffer,
0167 XrdSfsXferSize buffer_size);
0168
0169 XrdSfsXferSize readv(XrdOucIOVec *readV,
0170 int readCount);
0171
0172 int read(XrdSfsAio *aioparm);
0173
0174 XrdSfsXferSize write(XrdSfsFileOffset fileOffset,
0175 const char *buffer,
0176 XrdSfsXferSize buffer_size);
0177
0178 int write(XrdSfsAio *aioparm);
0179
0180 int sync();
0181
0182 int sync(XrdSfsAio *aiop);
0183
0184 int stat(struct stat *buf);
0185
0186 int truncate(XrdSfsFileOffset fileOffset);
0187
0188 int getCXinfo(char cxtype[4], int &cxrsz);
0189
0190 XrdOfsFile(XrdOucErrInfo &eInfo, const char *user);
0191
0192 ~XrdOfsFile() {viaDel = 1; if (oh) close();}
0193
0194 protected:
0195
0196 const char *tident;
0197 XrdOfsHandle *oh;
0198 XrdOfsTPC *myTPC;
0199 XrdOucChkPnt *myCKP;
0200 int dorawio;
0201 char viaDel;
0202 bool ckpBad;
0203
0204 private:
0205
0206 void GenFWEvent();
0207 int CreateCKP();
0208 };
0209
0210 class XrdOfsFileFull : public XrdOfsFile
0211 {
0212 public:
0213 XrdOfsFileFull(const char *user, int MonID)
0214 : XrdOfsFile(myEInfo, user), myEInfo(user, MonID)
0215 {}
0216
0217 virtual ~XrdOfsFileFull() {}
0218
0219 private:
0220 XrdOucErrInfo myEInfo;
0221 };
0222
0223
0224
0225
0226
0227 class XrdAccAuthorize;
0228 class XrdCks;
0229 class XrdCmsClient;
0230 class XrdOfsConfigPI;
0231 class XrdOfsFSctl_PI;
0232 class XrdOfsPoscq;
0233 struct XrdSfsFACtl;
0234
0235 class XrdOfs : public XrdSfsFileSystem
0236 {
0237 friend class XrdOfsDirectory;
0238 friend class XrdOfsFile;
0239
0240 public:
0241
0242
0243
0244 XrdSfsDirectory *newDir(char *user=0, int MonID=0)
0245 {return new XrdOfsDirFull(user, MonID);}
0246
0247 XrdSfsDirectory *newDir(XrdOucErrInfo &eInfo)
0248 {return new XrdOfsDirectory(eInfo, eInfo.getErrUser());}
0249
0250 XrdSfsFile *newFile(char *user=0,int MonID=0)
0251 {return new XrdOfsFileFull(user, MonID);}
0252
0253 XrdSfsFile *newFile(XrdOucErrInfo &eInfo)
0254 {return new XrdOfsFile(eInfo, eInfo.getErrUser());}
0255
0256
0257
0258 int chksum( csFunc Func,
0259 const char *csName,
0260 const char *Path,
0261 XrdOucErrInfo &out_error,
0262 const XrdSecEntity *client = 0,
0263 const char *opaque = 0);
0264
0265 int chmod(const char *Name,
0266 XrdSfsMode Mode,
0267 XrdOucErrInfo &out_error,
0268 const XrdSecEntity *client,
0269 const char *opaque = 0);
0270
0271 void Connect(const XrdSecEntity *client = 0);
0272
0273 void Disc(const XrdSecEntity *client = 0);
0274
0275 int exists(const char *fileName,
0276 XrdSfsFileExistence &exists_flag,
0277 XrdOucErrInfo &out_error,
0278 const XrdSecEntity *client,
0279 const char *opaque = 0);
0280
0281 int FAttr( XrdSfsFACtl *faReq,
0282 XrdOucErrInfo &eInfo,
0283 const XrdSecEntity *client = 0);
0284
0285 int FSctl(const int cmd,
0286 XrdSfsFSctl &args,
0287 XrdOucErrInfo &eInfo,
0288 const XrdSecEntity *client = 0);
0289
0290 int fsctl(const int cmd,
0291 const char *args,
0292 XrdOucErrInfo &out_error,
0293 const XrdSecEntity *client = 0);
0294
0295 int getStats(char *buff, int blen);
0296
0297 const char *getVersion();
0298
0299 int mkdir(const char *dirName,
0300 XrdSfsMode Mode,
0301 XrdOucErrInfo &out_error,
0302 const XrdSecEntity *client,
0303 const char *opaque = 0);
0304
0305 int prepare( XrdSfsPrep &pargs,
0306 XrdOucErrInfo &out_error,
0307 const XrdSecEntity *client = 0);
0308
0309 int rem(const char *path,
0310 XrdOucErrInfo &out_error,
0311 const XrdSecEntity *client,
0312 const char *info = 0)
0313 {return remove('f', path, out_error, client, info);}
0314
0315 int remdir(const char *dirName,
0316 XrdOucErrInfo &out_error,
0317 const XrdSecEntity *client,
0318 const char *info = 0)
0319 {return remove('d',dirName,out_error,client,info);}
0320
0321 int rename(const char *oldFileName,
0322 const char *newFileName,
0323 XrdOucErrInfo &out_error,
0324 const XrdSecEntity *client,
0325 const char *infoO = 0,
0326 const char *infoN = 0);
0327
0328 int stat(const char *Name,
0329 struct stat *buf,
0330 XrdOucErrInfo &out_error,
0331 const XrdSecEntity *client,
0332 const char *opaque = 0);
0333
0334 int stat(const char *Name,
0335 mode_t &mode,
0336 XrdOucErrInfo &out_error,
0337 const XrdSecEntity *client,
0338 const char *opaque = 0);
0339
0340 int truncate(const char *Name,
0341 XrdSfsFileOffset fileOffset,
0342 XrdOucErrInfo &out_error,
0343 const XrdSecEntity *client = 0,
0344 const char *opaque = 0);
0345
0346
0347 virtual int Configure(XrdSysError &);
0348
0349 virtual int Configure(XrdSysError &, XrdOucEnv *);
0350
0351 void Config_Cluster(XrdOss *);
0352
0353 void Config_Display(XrdSysError &);
0354
0355 XrdOfs();
0356 virtual ~XrdOfs() {}
0357
0358
0359
0360
0361
0362
0363
0364 enum {Authorize = 0x0001,
0365 XAttrPlug = 0x0002,
0366 isPeer = 0x0050,
0367 isProxy = 0x0020,
0368 isManager = 0x0040,
0369 isServer = 0x0080,
0370 isSuper = 0x00C0,
0371 isMeta = 0x0100,
0372 haveRole = 0x01F0,
0373 Forwarding= 0x1000,
0374 ThirdPC = 0x2000,
0375 SubCluster= 0x4000,
0376 RdrTPC = 0x8000
0377 };
0378
0379 int Options;
0380 int myPort;
0381
0382
0383
0384 mode_t dMask[2];
0385 mode_t fMask[2];
0386
0387
0388
0389 char *tpcRdrHost[2];
0390 int tpcRdrPort[2];
0391
0392
0393
0394 XrdNetIF *myIF;
0395
0396
0397
0398 struct fwdOpt
0399 {const char *Cmd;
0400 char *Host;
0401 int Port;
0402 void Reset() {Cmd = 0; Port = 0;
0403 if (Host) {free(Host); Host = 0;}
0404 }
0405 fwdOpt() : Cmd(0), Host(0), Port(0) {}
0406 ~fwdOpt() {}
0407 };
0408
0409 struct fwdOpt fwdCHMOD;
0410 struct fwdOpt fwdMKDIR;
0411 struct fwdOpt fwdMKPATH;
0412 struct fwdOpt fwdMV;
0413 struct fwdOpt fwdRM;
0414 struct fwdOpt fwdRMDIR;
0415 struct fwdOpt fwdTRUNC;
0416
0417 static int MaxDelay;
0418 static int OSSDelay;
0419
0420 char *ConfigFN;
0421
0422
0423
0424
0425
0426 protected:
0427
0428 XrdOfsEvr evrObject;
0429 XrdCmsClient *Finder;
0430
0431 virtual int ConfigXeq(char *var, XrdOucStream &, XrdSysError &);
0432 static int Emsg(const char *, XrdOucErrInfo &, int, const char *x,
0433 XrdOfsHandle *hP);
0434 static int Emsg(const char *, XrdOucErrInfo &, int, const char *x,
0435 const char *y="");
0436 static int fsError(XrdOucErrInfo &myError, int rc);
0437 const char *Split(const char *Args, const char **Opq, char *Path, int Plen);
0438 int Stall(XrdOucErrInfo &, int, const char *);
0439 void Unpersist(XrdOfsHandle *hP, int xcev=1);
0440 char *WaitTime(int, char *, int);
0441
0442
0443
0444
0445
0446 private:
0447
0448 char *myRole;
0449 XrdOfsFSctl_PI *FSctl_PC;
0450 XrdOfsFSctl_PI *FSctl_PI;
0451 XrdAccAuthorize *Authorization;
0452 XrdCmsClient *Balancer;
0453 XrdOfsEvs *evsObject;
0454 XrdOucPListAnchor*ossRPList;
0455
0456 XrdOfsPoscq *poscQ;
0457 char *poscLog;
0458 int poscHold;
0459 short poscSync;
0460 signed char poscAuto;
0461
0462 char ossRW;
0463
0464 XrdOfsConfigPI *ofsConfig;
0465 XrdOfsPrepare *prepHandler;
0466 XrdCks *Cks;
0467 bool CksPfn;
0468 bool CksRdr;
0469 bool prepAuth;
0470 char OssIsProxy;
0471 char myRType[4];
0472
0473 uint64_t ossFeatures;
0474
0475 int usxMaxNsz;
0476 int usxMaxVsz;
0477
0478 static XrdOfsHandle *dummyHandle;
0479 XrdSysMutex ocMutex;
0480
0481 bool DirRdr;
0482 bool reProxy;
0483 bool OssHasPGrw;
0484
0485
0486
0487
0488
0489
0490
0491 int ctlFADel(XrdSfsFACtl &faCtl, XrdOucEnv &faEnv, XrdOucErrInfo &einfo);
0492 int ctlFAGet(XrdSfsFACtl &faCtl, XrdOucEnv &faEnv, XrdOucErrInfo &einfo);
0493 int ctlFALst(XrdSfsFACtl &faCtl, XrdOucEnv &faEnv, XrdOucErrInfo &einfo);
0494 int ctlFASet(XrdSfsFACtl &faCtl, XrdOucEnv &faEnv, XrdOucErrInfo &einfo);
0495
0496
0497
0498 int remove(const char type, const char *path, XrdOucErrInfo &out_error,
0499 const XrdSecEntity *client, const char *opaque);
0500
0501
0502
0503 int ConfigDispFwd(char *buff, struct fwdOpt &Fwd);
0504 int ConfigPosc(XrdSysError &Eroute);
0505 int ConfigRedir(XrdSysError &Eroute, XrdOucEnv *EnvInfo);
0506 int ConfigTPC(XrdSysError &Eroute, XrdOucEnv *EnvInfo);
0507 int ConfigTPC(XrdSysError &Eroute);
0508 char *ConfigTPCDir(XrdSysError &Eroute, const char *sfx,
0509 const char *xPath=0);
0510 const char *Fname(const char *);
0511 int Forward(int &Result, XrdOucErrInfo &Resp, struct fwdOpt &Fwd,
0512 const char *arg1=0, const char *arg2=0,
0513 XrdOucEnv *Env1=0, XrdOucEnv *Env2=0);
0514 int FSctl(XrdOfsFile &file, int cmd, int alen, const char *args,
0515 const XrdSecEntity *client);
0516 int Reformat(XrdOucErrInfo &);
0517 const char *theRole(int opts);
0518 int xcrds(XrdOucStream &, XrdSysError &);
0519 int xcrm(XrdOucStream &, XrdSysError &);
0520 int xdirl(XrdOucStream &, XrdSysError &);
0521 int xexp(XrdOucStream &, XrdSysError &, bool);
0522 int xforward(XrdOucStream &, XrdSysError &);
0523 int xmaxd(XrdOucStream &, XrdSysError &);
0524 int xnmsg(XrdOucStream &, XrdSysError &);
0525 int xnot(XrdOucStream &, XrdSysError &);
0526 int xpers(XrdOucStream &, XrdSysError &);
0527 int xrole(XrdOucStream &, XrdSysError &);
0528 int xtpc(XrdOucStream &, XrdSysError &);
0529 int xtpcal(XrdOucStream &, XrdSysError &);
0530 int xtpcr(XrdOucStream &, XrdSysError &);
0531 int xtrace(XrdOucStream &, XrdSysError &);
0532 int xatr(XrdOucStream &, XrdSysError &);
0533 };
0534 #endif