XrdSfsNative.hh

Go to the documentation of this file.
00001 #ifndef __SFS_NATIVE_H__
00002 #define __SFS_NATIVE_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                       X r d S f s N a t i v 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: XrdSfsNative.hh 24468 2008-06-22 16:47:03Z ganis $
00014 
00015 #include <sys/types.h>
00016 #include <string.h>
00017 #include <dirent.h>
00018   
00019 #include "XrdSfs/XrdSfsInterface.hh"
00020 
00021 class XrdSysError;
00022 class XrdSysLogger;
00023 
00024 /******************************************************************************/
00025 /*                 X r d S f s N a t i v e D i r e c t o r y                  */
00026 /******************************************************************************/
00027   
00028 class XrdSfsNativeDirectory : public XrdSfsDirectory
00029 {
00030 public:
00031 
00032         int         open(const char              *dirName,
00033                          const XrdSecClientName  *client = 0,
00034                          const char              *opaque = 0);
00035 
00036         const char *nextEntry();
00037 
00038         int         close();
00039 
00040 const   char       *FName() {return (const char *)fname;}
00041 
00042                     XrdSfsNativeDirectory(char *user=0) : XrdSfsDirectory(user)
00043                                 {ateof = 0; fname = 0;
00044                                  dh    = (DIR *)0;
00045                                  d_pnt = &dirent_full.d_entry;
00046                                 }
00047 
00048                    ~XrdSfsNativeDirectory() {if (dh) close();}
00049 private:
00050 
00051 DIR           *dh;  // Directory stream handle
00052 char           ateof;
00053 char          *fname;
00054 
00055 struct {struct dirent d_entry;
00056                char   pad[MAXNAMLEN];   // This is only required for Solaris!
00057        } dirent_full;
00058 
00059 struct dirent *d_pnt;
00060 
00061 };
00062 
00063 /******************************************************************************/
00064 /*                      X r d S f s N a t i v e F i l e                       */
00065 /******************************************************************************/
00066   
00067 class XrdSfsAio;
00068 
00069 class XrdSfsNativeFile : public XrdSfsFile
00070 {
00071 public:
00072 
00073         int            open(const char                *fileName,
00074                                   XrdSfsFileOpenMode   openMode,
00075                                   mode_t               createMode,
00076                             const XrdSecClientName    *client = 0,
00077                             const char                *opaque = 0);
00078 
00079         int            close();
00080 
00081         int            fctl(const int               cmd,
00082                             const char             *args,
00083                                   XrdOucErrInfo    &out_error);
00084 
00085         const char    *FName() {return fname;}
00086 
00087         int            getMmap(void **Addr, off_t &Size)
00088                               {if (Addr) Addr = 0; Size = 0; return SFS_OK;}
00089 
00090         int            read(XrdSfsFileOffset   fileOffset,
00091                             XrdSfsXferSize     preread_sz) {return SFS_OK;}
00092 
00093         XrdSfsXferSize read(XrdSfsFileOffset   fileOffset,
00094                             char              *buffer,
00095                             XrdSfsXferSize     buffer_size);
00096 
00097         int            read(XrdSfsAio *aioparm);
00098 
00099         XrdSfsXferSize write(XrdSfsFileOffset   fileOffset,
00100                              const char        *buffer,
00101                              XrdSfsXferSize     buffer_size);
00102 
00103         int            write(XrdSfsAio *aioparm);
00104 
00105         int            sync();
00106 
00107         int            sync(XrdSfsAio *aiop);
00108 
00109         int            stat(struct stat *buf);
00110 
00111         int            truncate(XrdSfsFileOffset   fileOffset);
00112 
00113         int            getCXinfo(char cxtype[4], int &cxrsz) {return cxrsz = 0;}
00114 
00115                        XrdSfsNativeFile(char *user=0) : XrdSfsFile(user)
00116                                           {oh = -1; fname = 0;}
00117                       ~XrdSfsNativeFile() {if (oh) close();}
00118 private:
00119 
00120 int   oh;
00121 char *fname;
00122 
00123 };
00124 
00125 /******************************************************************************/
00126 /*                          X r d S f s N a t i v e                           */
00127 /******************************************************************************/
00128   
00129 class XrdSfsNative : public XrdSfsFileSystem
00130 {
00131 public:
00132 
00133 // Object Allocation Functions
00134 //
00135         XrdSfsDirectory *newDir(char *user=0)
00136                         {return (XrdSfsDirectory *)new XrdSfsNativeDirectory(user);}
00137 
00138         XrdSfsFile      *newFile(char *user=0)
00139                         {return      (XrdSfsFile *)new XrdSfsNativeFile(user);}
00140 
00141 // Other Functions
00142 //
00143         int            chmod(const char             *Name,
00144                                    XrdSfsMode        Mode,
00145                                    XrdOucErrInfo    &out_error,
00146                              const XrdSecClientName *client = 0,
00147                              const char             *opaque = 0);
00148 
00149         int            exists(const char                *fileName,
00150                                     XrdSfsFileExistence &exists_flag,
00151                                     XrdOucErrInfo       &out_error,
00152                               const XrdSecClientName    *client = 0,
00153                               const char                *opaque = 0);
00154 
00155         int            fsctl(const int               cmd,
00156                              const char             *args,
00157                                    XrdOucErrInfo    &out_error,
00158                              const XrdSecClientName *client = 0);
00159 
00160         int            getStats(char *buff, int blen) {return 0;}
00161 
00162 const   char          *getVersion();
00163 
00164         int            mkdir(const char             *dirName,
00165                                    XrdSfsMode        Mode,
00166                                    XrdOucErrInfo    &out_error,
00167                              const XrdSecClientName *client = 0,
00168                              const char             *opaque = 0);
00169 
00170         int            prepare(      XrdSfsPrep       &pargs,
00171                                      XrdOucErrInfo    &out_error,
00172                                const XrdSecClientName *client = 0) {return 0;}
00173 
00174         int            rem(const char             *path,
00175                                  XrdOucErrInfo    &out_error,
00176                            const XrdSecClientName *client = 0,
00177                            const char             *opaque = 0);
00178 
00179         int            remdir(const char             *dirName,
00180                                     XrdOucErrInfo    &out_error,
00181                               const XrdSecClientName *client = 0,
00182                               const char             *opaque = 0);
00183 
00184         int            rename(const char             *oldFileName,
00185                               const char             *newFileName,
00186                                     XrdOucErrInfo    &out_error,
00187                               const XrdSecClientName *client = 0,
00188                               const char             *opaqueO = 0,
00189                               const char             *opaqueN = 0);
00190 
00191         int            stat(const char             *Name,
00192                                   struct stat      *buf,
00193                                   XrdOucErrInfo    &out_error,
00194                             const XrdSecClientName *client = 0,
00195                             const char             *opaque = 0);
00196 
00197         int            stat(const char             *Name,
00198                                   mode_t           &mode,
00199                                   XrdOucErrInfo    &out_error,
00200                             const XrdSecClientName *client = 0,
00201                             const char             *opaque = 0)
00202                        {struct stat bfr;
00203                         int rc = stat(Name, &bfr, out_error, client);
00204                         if (!rc) mode = bfr.st_mode;
00205                         return rc;
00206                        }
00207 
00208         int            truncate(const char             *Name,
00209                                       XrdSfsFileOffset fileOffset,
00210                                       XrdOucErrInfo    &out_error,
00211                                 const XrdSecEntity     *client = 0,
00212                                 const char             *opaque = 0);
00213 
00214 // Common functions
00215 //
00216 static  int            Mkpath(const char *path, mode_t mode, 
00217                               const char *info=0);
00218 
00219 static  int            Emsg(const char *, XrdOucErrInfo&, int, const char *x,
00220                             const char *y="");
00221 
00222                        XrdSfsNative(XrdSysError *lp);
00223 virtual               ~XrdSfsNative() {}
00224 
00225 private:
00226 
00227 static XrdSysError *eDest;
00228 };
00229 #endif

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