Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

Generated on Sun Nov 6 13:35:16 2011 for xrootd by  doxygen 1.3.9.1