• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

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

Generated on Wed Sep 1 2010 for xrootd by  doxygen 1.7.1