XrdOss.hh

Go to the documentation of this file.
00001 #ifndef _XRDOSS_H
00002 #define _XRDOSS_H
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                     X r d O s s   &   X r d O s s D F                      */
00006 /*                                                                            */
00007 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdOss.hh 34000 2010-06-21 06:49:56Z ganis $
00014 
00015 #include <dirent.h>
00016 #include <errno.h>
00017 #include <strings.h>
00018 #include <sys/stat.h>
00019 #include <sys/types.h>
00020 #include <string.h>
00021 
00022 class XrdOucEnv;
00023 class XrdSysLogger;
00024 class XrdSfsAio;
00025 
00026 #ifndef XrdOssOK
00027 #define XrdOssOK 0
00028 #endif
00029 
00030 /******************************************************************************/
00031 /*                              X r d O s s D F                               */
00032 /******************************************************************************/
00033 
00034 // This class defines the object that handles directory as well as file
00035 // oriented requests. It is instantiated for each file/dir to be opened.
00036 // The object is obtained by calling newDir() or newFile() in class XrdOss.
00037 // This allows flexibility on how to structure an oss plugin.
00038   
00039 class XrdOssDF
00040 {
00041 public:
00042                 // Directory oriented methods
00043 virtual int     Opendir(const char *)                        {return -ENOTDIR;}
00044 virtual int     Readdir(char *buff, int blen)                {return -ENOTDIR;}
00045 
00046                 // File oriented methods
00047 virtual int     Fchmod(mode_t mode)                          {return -EISDIR;}
00048 virtual int     Fstat(struct stat *)                         {return -EISDIR;}
00049 virtual int     Fsync()                                      {return -EISDIR;}
00050 virtual int     Fsync(XrdSfsAio *aiop)                       {return -EISDIR;}
00051 virtual int     Ftruncate(unsigned long long)                {return -EISDIR;}
00052 virtual int     getFD()                                      {return -1;}
00053 virtual off_t   getMmap(void **addr)                         {return 0;}
00054 virtual int     isCompressed(char *cxidp=0)                  {return -EISDIR;}
00055 virtual int     Open(const char *, int, mode_t, XrdOucEnv &) {return -EISDIR;}
00056 virtual ssize_t Read(off_t, size_t)                          {return (ssize_t)-EISDIR;}
00057 virtual ssize_t Read(void *, off_t, size_t)                  {return (ssize_t)-EISDIR;}
00058 virtual int     Read(XrdSfsAio *aoip)                        {return (ssize_t)-EISDIR;}
00059 virtual ssize_t ReadRaw(    void *, off_t, size_t)           {return (ssize_t)-EISDIR;}
00060 virtual ssize_t Write(const void *, off_t, size_t)           {return (ssize_t)-EISDIR;}
00061 virtual int     Write(XrdSfsAio *aiop)                       {return (ssize_t)-EISDIR;}
00062 
00063                 // Methods common to both
00064 virtual int     Close(long long *retsz=0)=0;
00065 inline  int     Handle() {return fd;}
00066 
00067                 XrdOssDF() {fd = -1;}
00068 virtual        ~XrdOssDF() {}
00069 
00070 protected:
00071 
00072 int     fd;      // The associated file descriptor.
00073 };
00074 
00075 /******************************************************************************/
00076 /*                                X r d O s s                                 */
00077 /******************************************************************************/
00078 
00079 // Options that can be passed to Create()
00080 //
00081 #define XRDOSS_mkpath 0x01
00082 #define XRDOSS_new    0x02
00083 #define XRDOSS_Online 0x04
00084 #define XRDOSS_isPFN  0x08
00085 #define XRDOSS_isMIG  0x10
00086 
00087 // Options that can be passed to Stat()
00088 //
00089 #define XRDOSS_resonly 0x01
00090 #define XRDOSS_updtatm 0x02
00091 
00092 // Class passed to StatVS()
00093 //
00094 class XrdOssVSInfo
00095 {
00096 public:
00097 long long Total;   // Total bytes
00098 long long Free;    // Total bytes free
00099 long long Large;   // Total bytes in largest partition
00100 long long LFree;   // Max   bytes free in contiguous chunk
00101 long long Usage;   // Used  bytes (if usage enabled)
00102 long long Quota;   // Quota bytes (if quota enabled)
00103 int       Extents; // Number of partitions/extents
00104 int       Reserved;
00105 
00106           XrdOssVSInfo() : Total(0),Free(0),Large(0),LFree(0),Usage(-1),
00107                            Quota(-1),Extents(0),Reserved(0) {}
00108          ~XrdOssVSInfo() {}
00109 };
00110   
00111 class XrdOss
00112 {
00113 public:
00114 virtual XrdOssDF *newDir(const char *tident)=0;
00115 virtual XrdOssDF *newFile(const char *tident)=0;
00116 
00117 virtual int     Chmod(const char *, mode_t mode)=0;
00118 virtual int     Create(const char *, const char *, mode_t, XrdOucEnv &, 
00119                        int opts=0)=0;
00120 virtual int     Init(XrdSysLogger *, const char *)=0;
00121 virtual int     Mkdir(const char *, mode_t mode, int mkpath=0)=0;
00122 virtual int     Reloc(const char *, const char *, const char *, const char *x=0)
00123                       {return -ENOTSUP;}
00124 virtual int     Remdir(const char *, int Opts=0)=0;
00125 virtual int     Rename(const char *, const char *)=0;
00126 virtual int     Stat(const char *, struct stat *, int opts=0)=0;
00127 virtual int     StatFS(const char *path, char *buff, int &blen) 
00128                       {return -ENOTSUP;}
00129 virtual int     StatLS(XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
00130                       {return -ENOTSUP;}
00131 virtual int     StatXA(const char *path, char *buff, int &blen)
00132                       {return -ENOTSUP;}
00133 virtual int     StatXP(const char *path, unsigned long long &attr)
00134                       {return -ENOTSUP;}
00135 virtual int     Truncate(const char *, unsigned long long)=0;
00136 virtual int     Unlink(const char *, int Opts=0)=0;
00137 
00138 virtual int     Stats(char *bp, int bl) {return 0;}
00139 
00140 virtual int     StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
00141                       {return -ENOTSUP;}
00142 
00143 virtual int     Lfn2Pfn(const char *Path, char *buff, int blen)
00144                        {if ((int)strlen(Path) >= blen) return -ENAMETOOLONG;
00145                         strcpy(buff, Path); return 0;
00146                        }
00147 
00148                 XrdOss() {}
00149 virtual        ~XrdOss() {}
00150 };
00151 
00152 /******************************************************************************/
00153 /*           S t o r a g e   S y s t e m   I n s t a n t i a t o r            */
00154 /******************************************************************************/
00155 
00156 // This function is called to obtain an instance of a configured XrdOss object.
00157 // It is passed the object that would have been used as the storage system.
00158 // The object is not initialized (i.e., Init() has not yet been called).
00159 // This allows one to easily wrap the native implementation or to completely 
00160 // replace it, as needed. The name of the config file and any parameters
00161 // specified after the path on the ofs.osslib directive are also passed (note
00162 // that if no parameters exist, parms may be null).
00163 
00164 extern "C"
00165 {
00166 XrdOss *XrdOssGetStorageSystem(XrdOss       *native_oss,
00167                                XrdSysLogger *Logger,
00168                                const char   *config_fn,
00169                                const char   *parms);
00170 }
00171 #endif

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