00001 #ifndef _XRDOSS_H 00002 #define _XRDOSS_H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d O s s . h h */ 00006 /* */ 00007 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include <dirent.h> 00034 #include <errno.h> 00035 #include <stdint.h> 00036 #include <strings.h> 00037 #include <sys/stat.h> 00038 #include <sys/types.h> 00039 #include <string.h> 00040 00041 #include "XrdOss/XrdOssVS.hh" 00042 #include "XrdOuc/XrdOucIOVec.hh" 00043 00044 class XrdOucEnv; 00045 class XrdSysLogger; 00046 class XrdSfsAio; 00047 00048 #ifndef XrdOssOK 00049 #define XrdOssOK 0 00050 #endif 00051 00052 /******************************************************************************/ 00053 /* C l a s s X r d O s s D F */ 00054 /******************************************************************************/ 00055 00060 00061 class XrdOssDF 00062 { 00063 public: 00064 00065 /******************************************************************************/ 00066 /* D i r e c t o r y O r i e n t e d M e t h o d s */ 00067 /******************************************************************************/ 00068 00069 //----------------------------------------------------------------------------- 00076 //----------------------------------------------------------------------------- 00077 00078 virtual int Opendir(const char *path, XrdOucEnv &env) {return -ENOTDIR;} 00079 00080 //----------------------------------------------------------------------------- 00089 //----------------------------------------------------------------------------- 00090 00091 virtual int Readdir(char *buff, int blen) {return -ENOTDIR;} 00092 00093 //----------------------------------------------------------------------------- 00102 //----------------------------------------------------------------------------- 00103 00104 virtual int StatRet(struct stat *) {return -ENOTSUP;} 00105 00106 /******************************************************************************/ 00107 /* F i l e O r i e n t e d M e t h o d s */ 00108 /******************************************************************************/ 00109 //----------------------------------------------------------------------------- 00115 //----------------------------------------------------------------------------- 00116 00117 virtual int Fchmod(mode_t mode) {return -EISDIR;} 00118 00119 //----------------------------------------------------------------------------- 00121 //----------------------------------------------------------------------------- 00122 00123 virtual void Flush() {} 00124 00125 //----------------------------------------------------------------------------- 00131 //----------------------------------------------------------------------------- 00132 00133 virtual int Fstat(struct stat *buf) {return -EISDIR;} 00134 00135 //----------------------------------------------------------------------------- 00139 //----------------------------------------------------------------------------- 00140 00141 virtual int Fsync() {return -EISDIR;} 00142 00143 //----------------------------------------------------------------------------- 00149 //----------------------------------------------------------------------------- 00150 00151 virtual int Fsync(XrdSfsAio *aiop) {return -EISDIR;} 00152 00153 //----------------------------------------------------------------------------- 00159 //----------------------------------------------------------------------------- 00160 00161 virtual int Ftruncate(unsigned long long) {return -EISDIR;} 00162 00163 //----------------------------------------------------------------------------- 00171 //----------------------------------------------------------------------------- 00172 00173 virtual off_t getMmap(void **addr) {*addr = 0; return 0;} 00174 00175 //----------------------------------------------------------------------------- 00182 //----------------------------------------------------------------------------- 00183 00184 virtual int isCompressed(char *cxidp=0) {(void)cxidp; return 0;} 00185 00186 //----------------------------------------------------------------------------- 00195 //----------------------------------------------------------------------------- 00196 00197 virtual int Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &env) 00198 {return -EISDIR;} 00199 00200 //----------------------------------------------------------------------------- 00215 //----------------------------------------------------------------------------- 00216 00217 // pgRead and pgWrite options as noted. 00218 // 00219 static const uint64_t 00220 Verify = 0x8000000000000000ULL; 00221 static const uint64_t 00222 doCalc = 0x4000000000000000ULL; 00223 00224 virtual ssize_t pgRead (void* buffer, off_t offset, size_t rdlen, 00225 uint32_t* csvec, uint64_t opts); 00226 00227 //----------------------------------------------------------------------------- 00235 //----------------------------------------------------------------------------- 00236 00237 virtual int pgRead (XrdSfsAio* aioparm, uint64_t opts); 00238 00239 //----------------------------------------------------------------------------- 00256 //----------------------------------------------------------------------------- 00257 00258 virtual ssize_t pgWrite(void* buffer, off_t offset, size_t wrlen, 00259 uint32_t* csvec, uint64_t opts); 00260 00261 //----------------------------------------------------------------------------- 00269 //----------------------------------------------------------------------------- 00270 00271 virtual int pgWrite(XrdSfsAio* aoiparm, uint64_t opts); 00272 00273 //----------------------------------------------------------------------------- 00280 //----------------------------------------------------------------------------- 00281 00282 virtual ssize_t Read(off_t offset, size_t size) {return (ssize_t)-EISDIR;} 00283 00284 //----------------------------------------------------------------------------- 00293 //----------------------------------------------------------------------------- 00294 00295 virtual ssize_t Read(void *buffer, off_t offset, size_t size) 00296 {return (ssize_t)-EISDIR;} 00297 00298 //----------------------------------------------------------------------------- 00305 //----------------------------------------------------------------------------- 00306 00307 virtual int Read(XrdSfsAio *aoip) {(void)aoip; return (ssize_t)-EISDIR;} 00308 00309 //----------------------------------------------------------------------------- 00318 //----------------------------------------------------------------------------- 00319 00320 virtual ssize_t ReadRaw(void *buffer, off_t offset, size_t size) 00321 {return (ssize_t)-EISDIR;} 00322 00323 //----------------------------------------------------------------------------- 00331 //----------------------------------------------------------------------------- 00332 00333 virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt); 00334 00335 //----------------------------------------------------------------------------- 00344 //----------------------------------------------------------------------------- 00345 00346 virtual ssize_t Write(const void *buffer, off_t offset, size_t size) 00347 {return (ssize_t)-EISDIR;} 00348 00349 //----------------------------------------------------------------------------- 00356 //----------------------------------------------------------------------------- 00357 00358 virtual int Write(XrdSfsAio *aiop) {(void)aiop; return (ssize_t)-EISDIR;} 00359 00360 //----------------------------------------------------------------------------- 00368 //----------------------------------------------------------------------------- 00369 00370 virtual ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt); 00371 00372 /******************************************************************************/ 00373 /* C o m m o n D i r e c t o r y a n d F i l e M e t h o d s */ 00374 /******************************************************************************/ 00375 //----------------------------------------------------------------------------- 00381 //----------------------------------------------------------------------------- 00382 00383 virtual int Close(long long *retsz=0)=0; 00384 00385 //----------------------------------------------------------------------------- 00389 //----------------------------------------------------------------------------- 00390 00391 // Returned value will have one or more bits set as below. 00392 // 00393 static const uint16_t DF_isDir = 0x0001; 00394 static const uint16_t DF_isFile = 0x0002; 00395 static const uint16_t DF_isProxy = 0x0010; 00396 00397 uint16_t DFType() {return dfType;} 00398 00399 //----------------------------------------------------------------------------- 00409 //----------------------------------------------------------------------------- 00410 00411 virtual int Fctl(int cmd, int alen, const char *args, char **resp=0); 00412 00413 //----------------------------------------------------------------------------- 00417 //----------------------------------------------------------------------------- 00418 00419 virtual int getFD() {return -1;} // Must override to support sendfile() 00420 00421 //----------------------------------------------------------------------------- 00425 //----------------------------------------------------------------------------- 00426 virtual 00427 const char *getTID() {return tident;} 00428 00429 //----------------------------------------------------------------------------- 00435 //----------------------------------------------------------------------------- 00436 00437 XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1) 00438 : tident(tid), pgwEOF(0), fd(fdnum), dfType(dftype), 00439 rsvd(0) {} 00440 00441 virtual ~XrdOssDF() {} 00442 00443 00444 protected: 00445 00446 const char *tident; // Trace identifier 00447 off_t pgwEOF; // Highest short offset on pgWrite (0 means none yet) 00448 int fd; // The associated file descriptor. 00449 uint16_t dfType; // Type of this object 00450 short rsvd; // Reserved 00451 }; 00452 00453 /******************************************************************************/ 00454 /* X r d O s s O p t i o n s */ 00455 /******************************************************************************/ 00456 00457 // Options that can be passed to Create() 00458 // 00459 #define XRDOSS_mkpath 0x01 00460 #define XRDOSS_new 0x02 00461 #define XRDOSS_Online 0x04 00462 #define XRDOSS_isPFN 0x10 00463 #define XRDOSS_isMIG 0x20 00464 #define XRDOSS_setnoxa 0x40 00465 00466 // Values returned by Features() 00467 // 00468 #define XRDOSS_HASPGRW 0x0000000000000001ULL 00469 #define XRDOSS_HASFSCS 0x0000000000000002ULL 00470 #define XRDOSS_HASPRXY 0x0000000000000004ULL 00471 #define XRDOSS_HASNOSF 0x0000000000000008ULL 00472 00473 // Options that can be passed to Stat() 00474 // 00475 #define XRDOSS_resonly 0x0001 00476 #define XRDOSS_updtatm 0x0002 00477 #define XRDOSS_preop 0x0004 00478 00479 // Commands that can be passed to FSctl 00480 // 00481 #define XRDOSS_FSCTLFA 0x0001 00482 00483 /******************************************************************************/ 00484 /* C l a s s X r d O s s */ 00485 /******************************************************************************/ 00486 00487 class XrdOss 00488 { 00489 public: 00490 00491 //----------------------------------------------------------------------------- 00498 //----------------------------------------------------------------------------- 00499 00500 virtual XrdOssDF *newDir(const char *tident)=0; 00501 00502 //----------------------------------------------------------------------------- 00509 //----------------------------------------------------------------------------- 00510 00511 virtual XrdOssDF *newFile(const char *tident)=0; 00512 00513 //----------------------------------------------------------------------------- 00521 //----------------------------------------------------------------------------- 00522 00523 virtual int Chmod(const char * path, mode_t mode, XrdOucEnv *envP=0)=0; 00524 00525 //----------------------------------------------------------------------------- 00529 //----------------------------------------------------------------------------- 00530 00531 virtual void Connect(XrdOucEnv &env); 00532 00533 //----------------------------------------------------------------------------- 00545 //----------------------------------------------------------------------------- 00546 00547 virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, 00548 int opts=0)=0; 00549 00550 //----------------------------------------------------------------------------- 00554 //----------------------------------------------------------------------------- 00555 00556 virtual void Disc(XrdOucEnv &env); 00557 00558 //----------------------------------------------------------------------------- 00562 //----------------------------------------------------------------------------- 00563 00564 virtual void EnvInfo(XrdOucEnv *envP); 00565 00566 //----------------------------------------------------------------------------- 00570 //----------------------------------------------------------------------------- 00571 00572 virtual uint64_t Features(); 00573 00574 //----------------------------------------------------------------------------- 00583 //----------------------------------------------------------------------------- 00584 00585 virtual int FSctl(int cms, int alen, const char *args, char **resp=0); 00586 00587 //----------------------------------------------------------------------------- 00594 //----------------------------------------------------------------------------- 00595 00596 virtual int Init(XrdSysLogger *lp, const char *cfn)=0; 00597 00598 //----------------------------------------------------------------------------- 00606 //----------------------------------------------------------------------------- 00607 00608 virtual int Init(XrdSysLogger *lp, const char *cfn, XrdOucEnv *envP) 00609 {return Init(lp, cfn);} 00610 00611 //----------------------------------------------------------------------------- 00620 //----------------------------------------------------------------------------- 00621 00622 virtual int Mkdir(const char *path, mode_t mode, int mkpath=0, 00623 XrdOucEnv *envP=0)=0; 00624 00625 //----------------------------------------------------------------------------- 00634 //----------------------------------------------------------------------------- 00635 00636 virtual int Reloc(const char *tident, const char *path, 00637 const char *cgName, const char *anchor=0); 00638 00639 //----------------------------------------------------------------------------- 00649 //----------------------------------------------------------------------------- 00650 00651 virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)=0; 00652 00653 //----------------------------------------------------------------------------- 00662 //----------------------------------------------------------------------------- 00663 00664 virtual int Rename(const char *oPath, const char *nPath, 00665 XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0)=0; 00666 00667 //----------------------------------------------------------------------------- 00679 //----------------------------------------------------------------------------- 00680 00681 virtual int Stat(const char *path, struct stat *buff, 00682 int opts=0, XrdOucEnv *envP=0)=0; 00683 00684 //----------------------------------------------------------------------------- 00691 //----------------------------------------------------------------------------- 00692 00693 virtual int Stats(char *buff, int blen) {(void)buff; (void)blen; return 0;} 00694 00695 //----------------------------------------------------------------------------- 00713 //----------------------------------------------------------------------------- 00714 00715 virtual int StatFS(const char *path, char *buff, int &blen, 00716 XrdOucEnv *envP=0); 00717 00718 //----------------------------------------------------------------------------- 00736 //----------------------------------------------------------------------------- 00737 00738 virtual int StatLS(XrdOucEnv &env, const char *path, 00739 char *buff, int &blen); 00740 00741 //----------------------------------------------------------------------------- 00756 //----------------------------------------------------------------------------- 00757 00758 static const int PF_dInfo = 0x00000001; 00759 static const int PF_dNums = 0x00000002; 00760 static const int PF_isLFN = 0x00000004; 00761 00762 virtual int StatPF(const char *path, struct stat *buff, int opts); 00763 00764 virtual int StatPF(const char *path, struct stat *buff) 00765 {return StatPF(path, buff, 0);} // Backward compat 00766 00767 //----------------------------------------------------------------------------- 00779 //----------------------------------------------------------------------------- 00780 00781 virtual int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0); 00782 00783 //----------------------------------------------------------------------------- 00796 //----------------------------------------------------------------------------- 00797 00798 virtual int StatXA(const char *path, char *buff, int &blen, 00799 XrdOucEnv *envP=0); 00800 00801 //----------------------------------------------------------------------------- 00809 //----------------------------------------------------------------------------- 00810 00811 virtual int StatXP(const char *path, unsigned long long &attr, 00812 XrdOucEnv *envP=0); 00813 00814 //----------------------------------------------------------------------------- 00822 //----------------------------------------------------------------------------- 00823 00824 virtual int Truncate(const char *path, unsigned long long fsize, 00825 XrdOucEnv *envP=0)=0; 00826 00827 //----------------------------------------------------------------------------- 00838 //----------------------------------------------------------------------------- 00839 00840 virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0; 00841 00842 // Default Name-to-Name Methods 00843 00844 //----------------------------------------------------------------------------- 00852 //----------------------------------------------------------------------------- 00853 00854 virtual int Lfn2Pfn(const char *Path, char *buff, int blen) 00855 {if ((int)strlen(Path) >= blen) return -ENAMETOOLONG; 00856 strcpy(buff, Path); return 0; 00857 } 00858 00859 //----------------------------------------------------------------------------- 00869 //----------------------------------------------------------------------------- 00870 virtual 00871 const char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc) 00872 { (void)buff; (void)blen; rc = 0; return Path;} 00873 00874 //----------------------------------------------------------------------------- 00876 //----------------------------------------------------------------------------- 00877 00878 XrdOss() {} 00879 virtual ~XrdOss() {} 00880 }; 00881 00882 /******************************************************************************/ 00883 /* S t o r a g e S y s t e m I n s t a n t i a t o r */ 00884 /******************************************************************************/ 00885 00886 //------------------------------------------------------------------------------ 00909 //------------------------------------------------------------------------------ 00910 00911 //------------------------------------------------------------------------------ 00913 //------------------------------------------------------------------------------ 00914 00915 typedef XrdOss *(*XrdOssGetStorageSystem_t) (XrdOss *native_oss, 00916 XrdSysLogger *Logger, 00917 const char *config_fn, 00918 const char *parms); 00919 00920 typedef XrdOss *(*XrdOssGetStorageSystem2_t)(XrdOss *native_oss, 00921 XrdSysLogger *Logger, 00922 const char *config_fn, 00923 const char *parms, 00924 XrdOucEnv *envP); 00925 00926 typedef XrdOssGetStorageSystem2_t XrdOssAddStorageSystem2_t; 00927 00959 //------------------------------------------------------------------------------ 00965 //------------------------------------------------------------------------------ 00966 00972 #endif