|
xrootd
|
00001 #ifndef __SFS_INTERFACE_H__ 00002 #define __SFS_INTERFACE_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S f s I n t e r f a c e . h h */ 00006 /* */ 00007 /* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00010 /* */ 00011 /* This file is part of the XRootD software suite. */ 00012 /* */ 00013 /* XRootD is free software: you can redistribute it and/or modify it under */ 00014 /* the terms of the GNU Lesser General Public License as published by the */ 00015 /* Free Software Foundation, either version 3 of the License, or (at your */ 00016 /* option) any later version. */ 00017 /* */ 00018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00021 /* License for more details. */ 00022 /* */ 00023 /* You should have received a copy of the GNU Lesser General Public License */ 00024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00026 /* */ 00027 /* The copyright holder's institutional names and contributor's names may not */ 00028 /* be used to endorse or promote products derived from this software without */ 00029 /* specific prior written permission of the institution or contributor. */ 00030 /******************************************************************************/ 00031 00032 #include <string.h> // For strlcpy() 00033 #include <sys/errno.h> 00034 #include <sys/types.h> 00035 #include <sys/stat.h> 00036 #include <sys/socket.h> // for sockaddr 00037 00038 #include "XrdOuc/XrdOucErrInfo.hh" 00039 00040 /******************************************************************************/ 00041 /* O p e n M o d e s */ 00042 /******************************************************************************/ 00043 00044 #define SFS_O_RDONLY 0 // open read/only 00045 #define SFS_O_WRONLY 1 // open write/only 00046 #define SFS_O_RDWR 2 // open read/write 00047 #define SFS_O_CREAT 0x100 // used for file creation 00048 #define SFS_O_TRUNC 0x200 // used for file truncation 00049 #define SFS_O_POSC 0x0100000 // persist on successful close 00050 #define SFS_O_NOWAIT 0x01000000 // do not impose operational delays 00051 #define SFS_O_RAWIO 0x02000000 // allow client-side decompression 00052 #define SFS_O_RESET 0x04000000 // Reset any cached information 00053 #define SFS_O_REPLICA 0x08000000 // Open for replication 00054 00055 // The following flag may be set in the access mode arg for open() & mkdir() 00056 // Note that on some systems mode_t is 16-bits so we use a careful value! 00057 // 00058 #define SFS_O_MKPTH 0x00004000 // Make directory path if missing 00059 00060 // The following options are here to provide a uniform clustering interface. 00061 // They may be passed through open/locate/stat, as applicable. 00062 // 00063 #define SFS_O_LOCATE 0x10000000 // This request generated by locate() 00064 #define SFS_O_STAT 0x20000000 // This request generated by stat() 00065 #define SFS_O_META 0x40000000 // This request generated by metaop 00066 00067 /******************************************************************************/ 00068 /* D e f i n e s */ 00069 /******************************************************************************/ 00070 00071 // Common fctl command values (0 to 255) 00072 // 00073 #define SFS_FCTL_GETFD 1 // Return file descriptor if possible 00074 #define SFS_FCTL_STATV 2 // Return visa information 00075 00076 // Common fsctl command values (0 to 255) 00077 // 00078 #define SFS_FSCTL_CMD 255 00079 00080 #define SFS_FSCTL_LOCATE 1 // Locate a file 00081 #define SFS_FSCTL_STATFS 2 // Return FS data 00082 #define SFS_FSCTL_STATLS 3 // Return LS data 00083 #define SFS_FSCTL_STATXA 4 // Return XA data 00084 #define SFS_FSCTL_PLUGIN 8 // Return Implementation Dependent Data 00085 #define SFS_FSCTL_PLUGIO 16 // Return Implementation Dependent Data 00086 00087 // Return Values for Integer Returning XrdSfs Interface 00088 // 00089 #define SFS_STALL 1 // ErrInfo code -> Seconds to stall client 00090 #define SFS_OK 0 // ErrInfo code -> All is well 00091 #define SFS_ERROR -1 // ErrInfo code -> Error occurred 00092 #define SFS_REDIRECT -256 // ErrInfo code -> Port number to redirect to 00093 #define SFS_STARTED -512 // ErrInfo code -> Estimated seconds to completion 00094 #define SFS_DATA -1024 // ErrInfo code -> Length of data 00095 00096 /******************************************************************************/ 00097 /* S t r u c t u r e s & T y p e d e f s */ 00098 /******************************************************************************/ 00099 00100 typedef long long XrdSfsFileOffset; 00101 typedef int XrdSfsFileOpenMode; 00102 typedef int XrdSfsMode; 00103 typedef int XrdSfsXferSize; 00104 00105 enum XrdSfsFileExistence 00106 { 00107 XrdSfsFileExistNo, 00108 XrdSfsFileExistIsFile, 00109 XrdSfsFileExistIsDirectory 00110 }; 00111 //------------------------------------------------ 00112 00113 #define Prep_PRTY0 0 00114 #define Prep_PRTY1 1 00115 #define Prep_PRTY2 2 00116 #define Prep_PRTY3 3 00117 #define Prep_PMASK 3 00118 #define Prep_SENDAOK 4 00119 #define Prep_SENDERR 8 00120 #define Prep_SENDACK 12 00121 #define Prep_WMODE 16 00122 #define Prep_STAGE 32 00123 #define Prep_COLOC 64 00124 #define Prep_FRESH 128 00125 00126 class XrdOucTList; 00127 00128 struct XrdSfsFSctl // SFS_FSCTL_PLUGIN/PLUGIO parameters 00129 { 00130 const char *Arg1; // PLUGIO & PLUGIN 00131 int Arg1Len; 00132 int Arg2Len; 00133 const char *Arg2; // PLUGIN opaque string 00134 }; 00135 00136 struct XrdSfsPrep // Prepare parameters 00137 { 00138 char *reqid; // Request ID 00139 char *notify; // Notification path or 0 00140 int opts; // Prep_xxx 00141 XrdOucTList *paths; // List of paths 00142 XrdOucTList *oinfo; // 1-to-1 correspondence of opaque info 00143 }; 00144 00145 /******************************************************************************/ 00146 /* A b s t r a c t C l a s s e s */ 00147 /******************************************************************************/ 00148 00149 class XrdSfsFile; 00150 class XrdSfsDirectory; 00151 class XrdOucTList; 00152 class XrdSecEntity; 00153 00154 /******************************************************************************/ 00155 /* X r d S f s F i l e S y s t e m */ 00156 /******************************************************************************/ 00157 00158 class XrdSfsFileSystem 00159 { 00160 public: 00161 00162 // The following two methods allocate a directory or file object 00163 // 00164 virtual XrdSfsDirectory *newDir(char *user=0, int MonID=0) = 0; 00165 00166 virtual XrdSfsFile *newFile(char *user=0, int MonID=0) = 0; 00167 00168 // The following are filesystem related methods 00169 // 00170 00171 enum csFunc {csCalc = 0, csGet, csSize}; 00172 00173 virtual int chksum( csFunc Func, 00174 const char *csName, 00175 const char *Path, 00176 XrdOucErrInfo &out_error, 00177 const XrdSecEntity *client = 0, 00178 const char *opaque = 0) 00179 {out_error.setErrInfo(ENOTSUP, "Not supported."); 00180 return SFS_ERROR; 00181 } 00182 00183 virtual int chmod(const char *Name, 00184 XrdSfsMode Mode, 00185 XrdOucErrInfo &out_error, 00186 const XrdSecEntity *client = 0, 00187 const char *opaque = 0) = 0; 00188 00189 virtual int FSctl(const int cmd, 00190 XrdSfsFSctl &args, 00191 XrdOucErrInfo &out_error, 00192 const XrdSecEntity *client = 0) {return SFS_OK;} 00193 00194 virtual int fsctl(const int cmd, 00195 const char *args, 00196 XrdOucErrInfo &out_error, 00197 const XrdSecEntity *client = 0) = 0; 00198 00199 virtual int getStats(char *buff, int blen) = 0; 00200 00201 virtual const char *getVersion() = 0; 00202 00203 virtual int exists(const char *fileName, 00204 XrdSfsFileExistence &exists_flag, 00205 XrdOucErrInfo &out_error, 00206 const XrdSecEntity *client = 0, 00207 const char *opaque = 0) = 0; 00208 00209 virtual int mkdir(const char *dirName, 00210 XrdSfsMode Mode, 00211 XrdOucErrInfo &out_error, 00212 const XrdSecEntity *client = 0, 00213 const char *opaque = 0) = 0; 00214 00215 virtual int prepare( XrdSfsPrep &pargs, 00216 XrdOucErrInfo &out_error, 00217 const XrdSecEntity *client = 0) = 0; 00218 00219 virtual int rem(const char *path, 00220 XrdOucErrInfo &out_error, 00221 const XrdSecEntity *client = 0, 00222 const char *opaque = 0) = 0; 00223 00224 virtual int remdir(const char *dirName, 00225 XrdOucErrInfo &out_error, 00226 const XrdSecEntity *client = 0, 00227 const char *opaque = 0) = 0; 00228 00229 virtual int rename(const char *oldFileName, 00230 const char *newFileName, 00231 XrdOucErrInfo &out_error, 00232 const XrdSecEntity *client = 0, 00233 const char *opaqueO = 0, 00234 const char *opaqueN = 0) = 0; 00235 00236 virtual int stat(const char *Name, 00237 struct stat *buf, 00238 XrdOucErrInfo &out_error, 00239 const XrdSecEntity *client = 0, 00240 const char *opaque = 0) = 0; 00241 00242 virtual int stat(const char *Name, 00243 mode_t &mode, 00244 XrdOucErrInfo &out_error, 00245 const XrdSecEntity *client = 0, 00246 const char *opaque = 0) = 0; 00247 00248 virtual int truncate(const char *Name, 00249 XrdSfsFileOffset fileOffset, 00250 XrdOucErrInfo &out_error, 00251 const XrdSecEntity *client = 0, 00252 const char *opaque = 0) = 0; 00253 00254 XrdSfsFileSystem() {} 00255 virtual ~XrdSfsFileSystem() {} 00256 00257 protected: 00258 }; 00259 00260 /******************************************************************************/ 00261 /* F i l e S y s t e m I n s t a n t i a t o r */ 00262 /******************************************************************************/ 00263 00264 /* When building a shared library plugin, the following "C" entry point must 00265 exist in the library: 00266 00267 extern "C" 00268 {XrdSfsFileSystem *XrdSfsGetFileSystem(XrdSfsFileSystem *nativeFS, 00269 XrdSysLogger *Logger, 00270 const char *configFn); 00271 } 00272 00273 */ 00274 00275 //------------------------------------------------------------------------------ 00281 //------------------------------------------------------------------------------ 00282 00289 /******************************************************************************/ 00290 /* X r d S f s F i l e */ 00291 /******************************************************************************/ 00292 00293 class XrdSfsAio; 00294 00295 class XrdSfsFile 00296 { 00297 public: 00298 XrdOucErrInfo error; 00299 00300 virtual int open(const char *fileName, 00301 XrdSfsFileOpenMode openMode, 00302 mode_t createMode, 00303 const XrdSecEntity *client = 0, 00304 const char *opaque = 0) = 0; 00305 00306 virtual int close() = 0; 00307 00308 virtual int fctl(const int cmd, 00309 const char *args, 00310 XrdOucErrInfo &out_error) = 0; 00311 00312 virtual const char *FName() = 0; 00313 00314 virtual int getMmap(void **Addr, off_t &Size) = 0; 00315 00316 virtual int read(XrdSfsFileOffset fileOffset, 00317 XrdSfsXferSize preread_sz) = 0; 00318 00319 virtual XrdSfsXferSize read(XrdSfsFileOffset fileOffset, 00320 char *buffer, 00321 XrdSfsXferSize buffer_size) = 0; 00322 00323 virtual int read(XrdSfsAio *aioparm) = 0; 00324 00325 virtual XrdSfsXferSize write(XrdSfsFileOffset fileOffset, 00326 const char *buffer, 00327 XrdSfsXferSize buffer_size) = 0; 00328 00329 virtual int write(XrdSfsAio *aioparm) = 0; 00330 00331 virtual int stat(struct stat *buf) = 0; 00332 00333 virtual int sync() = 0; 00334 00335 virtual int sync(XrdSfsAio *aiop) = 0; 00336 00337 virtual int truncate(XrdSfsFileOffset fileOffset) = 0; 00338 00339 virtual int getCXinfo(char cxtype[4], int &cxrsz) = 0; 00340 00341 XrdSfsFile(const char *user=0, int MonID=0) 00342 : error(user, MonID) {} 00343 virtual ~XrdSfsFile() {} 00344 00345 }; // class XrdSfsFile 00346 00347 /******************************************************************************/ 00348 /* X r d S f s D i r e c t o r y */ 00349 /******************************************************************************/ 00350 00351 class XrdSfsDirectory 00352 { 00353 public: 00354 XrdOucErrInfo error; 00355 00356 virtual int open(const char *dirName, 00357 const XrdSecEntity *client = 0, 00358 const char *opaque = 0) = 0; 00359 00360 virtual const char *nextEntry() = 0; 00361 00362 virtual int close() = 0; 00363 00364 virtual const char *FName() = 0; 00365 00366 XrdSfsDirectory(const char *user=0, int MonID=0) 00367 : error(user, MonID) {} 00368 virtual ~XrdSfsDirectory() {} 00369 00370 }; // class XrdSfsDirectory 00371 #endif
1.7.6.1