XrdSfsInterface.hh

Go to the documentation of this file.
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 /*       All Rights Reserved. See XrdInfo.cc for complete License Terms       */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 #include <string.h>      // For strlcpy()
00014 #include <sys/types.h>
00015 #include <sys/stat.h>
00016 #include <sys/socket.h>  // for sockaddr
00017 
00018 #include "XrdOuc/XrdOucErrInfo.hh"
00019 
00020 /******************************************************************************/
00021 /*                            O p e n   M o d e s                             */
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 // The following flag may be set in the access mode arg for open() & mkdir()
00036 // Note that on some systems mode_t is 16-bits so we use a careful value!
00037 //
00038 #define SFS_O_MKPTH   0x00004000         // Make directory path if missing
00039 
00040 // The following options are here to provide a uniform clustering interface.
00041 // They may be passed through open/locate/stat, as applicable.
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 /*                               D e f i n e s                                */
00049 /******************************************************************************/
00050 
00051 // Common fctl  command values (0 to 255)
00052 //
00053 #define SFS_FCTL_GETFD    1 // Return file descriptor if possible
00054 #define SFS_FCTL_STATV    2 // Return visa information
00055 
00056 // Common fsctl command values (0 to 255)
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 // Return Values for Integer Returning XrdSfs Interface
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 /*                 S t r u c t u r e s   &   T y p e d e f s                  */
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 // SFS_FSCTL_PLUGIN/PLUGIO parameters
00109 {
00110  const char            *Arg1;      // PLUGIO & PLUGIN
00111        int              Arg1Len;
00112        int              Arg2Len;
00113  const char            *Arg2;      // PLUGIN opaque string
00114 };
00115 
00116 struct XrdSfsPrep  // Prepare parameters
00117 {
00118        char            *reqid;     // Request ID
00119        char            *notify;    // Notification path or 0
00120        int              opts;      // Prep_xxx
00121        XrdOucTList     *paths;     // List of paths
00122        XrdOucTList     *oinfo;     // 1-to-1 correspondence of opaque info
00123 };
00124 
00125 /******************************************************************************/
00126 /*                      A b s t r a c t   C l a s s e s                       */
00127 /******************************************************************************/
00128 
00129 class  XrdSfsFile;
00130 class  XrdSfsDirectory;
00131 class  XrdOucTList;
00132 class  XrdSecEntity;
00133 
00134 /******************************************************************************/
00135 /*                      X r d S f s F i l e S y s t e m                       */
00136 /******************************************************************************/
00137   
00138 class XrdSfsFileSystem
00139 {
00140 public:
00141 
00142 // The following two methods allocate a directory or file object
00143 //
00144 virtual XrdSfsDirectory *newDir(char *user=0)  = 0;
00145 
00146 virtual XrdSfsFile      *newFile(char *user=0) = 0;
00147 
00148 // The following are filesystem related methods
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 /*              F i l e   S y s t e m   I n s t a n t i a t o r               */
00229 /******************************************************************************/
00230 
00231 /* When building a shared library plugin, the following "C" entry point must
00232    exist in the library:
00233 
00234    extern "C"
00235          {XrdSfsFileSystem *XrdSfsGetFileSystem(XrdSfsFileSystem *nativeFS,
00236                                                 XrdSysLogger     *Logger,
00237                                                 const char       *configFn);
00238          }
00239 
00240    This entry is called to get an instance of the file system. Return 0 if upon
00241    failure to properly create such an object. For statically linked file systems
00242    the non-extern C XrdSfsGetDefaultFileSystem() is used instead.
00243 */
00244 
00245 /******************************************************************************/
00246 /*                            X r d S f s F i l e                             */
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 }; // class XrdSfsFile
00301 
00302 /******************************************************************************/
00303 /*                       X r d S f s D i r e c t o r y                        */
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 }; // class XrdSfsDirectory
00325 #endif

Generated on Tue Jul 5 14:47:02 2011 for ROOT_528-00b_version by  doxygen 1.5.1