00001 #ifndef __SFS_INTERFACE_H__
00002 #define __SFS_INTERFACE_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <string.h>
00014 #include <sys/types.h>
00015 #include <sys/stat.h>
00016 #include <sys/socket.h>
00017
00018 #include "XrdOuc/XrdOucErrInfo.hh"
00019
00020
00021
00022
00023
00024 #define SFS_O_RDONLY 0 // open read/only
00025 #define SFS_O_WRONLY 1 // open write/only
00026 #define SFS_O_RDWR 2 // open read/write
00027 #define SFS_O_CREAT 0x100 // used for file creation
00028 #define SFS_O_TRUNC 0x200 // used for file truncation
00029 #define SFS_O_POSC 0x0100000 // persist on successful close
00030 #define SFS_O_NOWAIT 0x01000000 // do not impose operational delays
00031 #define SFS_O_RAWIO 0x02000000 // allow client-side decompression
00032 #define SFS_O_RESET 0x04000000 // Reset any cached information
00033 #define SFS_O_REPLICA 0x08000000 // Open for replication
00034
00035
00036
00037
00038 #define SFS_O_MKPTH 0x00004000 // Make directory path if missing
00039
00040
00041
00042
00043 #define SFS_O_LOCATE 0x10000000 // This request generated by locate()
00044 #define SFS_O_STAT 0x20000000 // This request generated by stat()
00045 #define SFS_O_META 0x40000000 // This request generated by metaop
00046
00047
00048
00049
00050
00051
00052
00053 #define SFS_FCTL_GETFD 1 // Return file descriptor if possible
00054 #define SFS_FCTL_STATV 2 // Return visa information
00055
00056
00057
00058 #define SFS_FSCTL_CMD 255
00059
00060 #define SFS_FSCTL_LOCATE 1 // Locate a file
00061 #define SFS_FSCTL_STATFS 2 // Return FS data
00062 #define SFS_FSCTL_STATLS 3 // Return LS data
00063 #define SFS_FSCTL_STATXA 4 // Return XA data
00064 #define SFS_FSCTL_PLUGIN 8 // Return Implementation Dependent Data
00065 #define SFS_FSCTL_PLUGIO 16 // Return Implementation Dependent Data
00066
00067
00068
00069 #define SFS_STALL 1 // ErrInfo code -> Seconds to stall client
00070 #define SFS_OK 0 // ErrInfo code -> All is well
00071 #define SFS_ERROR -1 // ErrInfo code -> Error occurred
00072 #define SFS_REDIRECT -256 // ErrInfo code -> Port number to redirect to
00073 #define SFS_STARTED -512 // ErrInfo code -> Estimated seconds to completion
00074 #define SFS_DATA -1024 // ErrInfo code -> Length of data
00075
00076
00077
00078
00079
00080 typedef long long XrdSfsFileOffset;
00081 typedef int XrdSfsFileOpenMode;
00082 typedef int XrdSfsMode;
00083 typedef int XrdSfsXferSize;
00084
00085 enum XrdSfsFileExistence
00086 {
00087 XrdSfsFileExistNo,
00088 XrdSfsFileExistIsFile,
00089 XrdSfsFileExistIsDirectory
00090 };
00091
00092
00093 #define Prep_PRTY0 0
00094 #define Prep_PRTY1 1
00095 #define Prep_PRTY2 2
00096 #define Prep_PRTY3 3
00097 #define Prep_PMASK 3
00098 #define Prep_SENDAOK 4
00099 #define Prep_SENDERR 8
00100 #define Prep_SENDACK 12
00101 #define Prep_WMODE 16
00102 #define Prep_STAGE 32
00103 #define Prep_COLOC 64
00104 #define Prep_FRESH 128
00105
00106 class XrdOucTList;
00107
00108 struct XrdSfsFSctl
00109 {
00110 const char *Arg1;
00111 int Arg1Len;
00112 int Arg2Len;
00113 const char *Arg2;
00114 };
00115
00116 struct XrdSfsPrep
00117 {
00118 char *reqid;
00119 char *notify;
00120 int opts;
00121 XrdOucTList *paths;
00122 XrdOucTList *oinfo;
00123 };
00124
00125
00126
00127
00128
00129 class XrdSfsFile;
00130 class XrdSfsDirectory;
00131 class XrdOucTList;
00132 class XrdSecEntity;
00133
00134
00135
00136
00137
00138 class XrdSfsFileSystem
00139 {
00140 public:
00141
00142
00143
00144 virtual XrdSfsDirectory *newDir(char *user=0) = 0;
00145
00146 virtual XrdSfsFile *newFile(char *user=0) = 0;
00147
00148
00149
00150 virtual int chmod(const char *Name,
00151 XrdSfsMode Mode,
00152 XrdOucErrInfo &out_error,
00153 const XrdSecEntity *client = 0,
00154 const char *opaque = 0) = 0;
00155
00156 virtual int FSctl(const int cmd,
00157 XrdSfsFSctl &args,
00158 XrdOucErrInfo &out_error,
00159 const XrdSecEntity *client = 0) {return SFS_OK;}
00160
00161 virtual int fsctl(const int cmd,
00162 const char *args,
00163 XrdOucErrInfo &out_error,
00164 const XrdSecEntity *client = 0) = 0;
00165
00166 virtual int getStats(char *buff, int blen) = 0;
00167
00168 virtual const char *getVersion() = 0;
00169
00170 virtual int exists(const char *fileName,
00171 XrdSfsFileExistence &exists_flag,
00172 XrdOucErrInfo &out_error,
00173 const XrdSecEntity *client = 0,
00174 const char *opaque = 0) = 0;
00175
00176 virtual int mkdir(const char *dirName,
00177 XrdSfsMode Mode,
00178 XrdOucErrInfo &out_error,
00179 const XrdSecEntity *client = 0,
00180 const char *opaque = 0) = 0;
00181
00182 virtual int prepare( XrdSfsPrep &pargs,
00183 XrdOucErrInfo &out_error,
00184 const XrdSecEntity *client = 0) = 0;
00185
00186 virtual int rem(const char *path,
00187 XrdOucErrInfo &out_error,
00188 const XrdSecEntity *client = 0,
00189 const char *opaque = 0) = 0;
00190
00191 virtual int remdir(const char *dirName,
00192 XrdOucErrInfo &out_error,
00193 const XrdSecEntity *client = 0,
00194 const char *opaque = 0) = 0;
00195
00196 virtual int rename(const char *oldFileName,
00197 const char *newFileName,
00198 XrdOucErrInfo &out_error,
00199 const XrdSecEntity *client = 0,
00200 const char *opaqueO = 0,
00201 const char *opaqueN = 0) = 0;
00202
00203 virtual int stat(const char *Name,
00204 struct stat *buf,
00205 XrdOucErrInfo &out_error,
00206 const XrdSecEntity *client = 0,
00207 const char *opaque = 0) = 0;
00208
00209 virtual int stat(const char *Name,
00210 mode_t &mode,
00211 XrdOucErrInfo &out_error,
00212 const XrdSecEntity *client = 0,
00213 const char *opaque = 0) = 0;
00214
00215 virtual int truncate(const char *Name,
00216 XrdSfsFileOffset fileOffset,
00217 XrdOucErrInfo &out_error,
00218 const XrdSecEntity *client = 0,
00219 const char *opaque = 0) = 0;
00220
00221 XrdSfsFileSystem() {}
00222 virtual ~XrdSfsFileSystem() {}
00223
00224 protected:
00225 };
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 class XrdSfsAio;
00250
00251 class XrdSfsFile
00252 {
00253 public:
00254 XrdOucErrInfo error;
00255
00256 virtual int open(const char *fileName,
00257 XrdSfsFileOpenMode openMode,
00258 mode_t createMode,
00259 const XrdSecEntity *client = 0,
00260 const char *opaque = 0) = 0;
00261
00262 virtual int close() = 0;
00263
00264 virtual int fctl(const int cmd,
00265 const char *args,
00266 XrdOucErrInfo &out_error) = 0;
00267
00268 virtual const char *FName() = 0;
00269
00270 virtual int getMmap(void **Addr, off_t &Size) = 0;
00271
00272 virtual int read(XrdSfsFileOffset fileOffset,
00273 XrdSfsXferSize preread_sz) = 0;
00274
00275 virtual XrdSfsXferSize read(XrdSfsFileOffset fileOffset,
00276 char *buffer,
00277 XrdSfsXferSize buffer_size) = 0;
00278
00279 virtual int read(XrdSfsAio *aioparm) = 0;
00280
00281 virtual XrdSfsXferSize write(XrdSfsFileOffset fileOffset,
00282 const char *buffer,
00283 XrdSfsXferSize buffer_size) = 0;
00284
00285 virtual int write(XrdSfsAio *aioparm) = 0;
00286
00287 virtual int stat(struct stat *buf) = 0;
00288
00289 virtual int sync() = 0;
00290
00291 virtual int sync(XrdSfsAio *aiop) = 0;
00292
00293 virtual int truncate(XrdSfsFileOffset fileOffset) = 0;
00294
00295 virtual int getCXinfo(char cxtype[4], int &cxrsz) = 0;
00296
00297 XrdSfsFile(const char *user=0) {error.setErrUser(user);}
00298 virtual ~XrdSfsFile() {}
00299
00300 };
00301
00302
00303
00304
00305
00306 class XrdSfsDirectory
00307 {
00308 public:
00309 XrdOucErrInfo error;
00310
00311 virtual int open(const char *dirName,
00312 const XrdSecEntity *client = 0,
00313 const char *opaque = 0) = 0;
00314
00315 virtual const char *nextEntry() = 0;
00316
00317 virtual int close() = 0;
00318
00319 virtual const char *FName() = 0;
00320
00321 XrdSfsDirectory(const char *user=0) {error.setErrUser(user);}
00322 virtual ~XrdSfsDirectory() {}
00323
00324 };
00325 #endif