00001 #ifndef __SFS_INTERFACE_H__
00002 #define __SFS_INTERFACE_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 <sys/errno.h>
00034 #include <sys/types.h>
00035 #include <sys/stat.h>
00036 #include <sys/socket.h>
00037
00038 #include "XrdOuc/XrdOucErrInfo.hh"
00039
00040
00041
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
00056
00057
00058 #define SFS_O_MKPTH 0x00004000 // Make directory path if missing
00059
00060
00061
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
00069
00070
00071
00072
00073 #define SFS_FCTL_GETFD 1 // Return file descriptor if possible
00074 #define SFS_FCTL_STATV 2 // Return visa information
00075
00076
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
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
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
00129 {
00130 const char *Arg1;
00131 int Arg1Len;
00132 int Arg2Len;
00133 const char *Arg2;
00134 };
00135
00136 struct XrdSfsPrep
00137 {
00138 char *reqid;
00139 char *notify;
00140 int opts;
00141 XrdOucTList *paths;
00142 XrdOucTList *oinfo;
00143 };
00144
00145
00146
00147
00148
00149 class XrdSfsFile;
00150 class XrdSfsDirectory;
00151 class XrdOucTList;
00152 class XrdSecEntity;
00153
00154
00155
00156
00157
00158 class XrdSfsFileSystem
00159 {
00160 public:
00161
00162
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
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
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00281
00282
00289
00290
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 };
00346
00347
00348
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 };
00371 #endif