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-AC02-76-SFO0515 with the Department of Energy              */
00011 /*                                                                            */
00012 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
00031 /******************************************************************************/
00032 
00033 #include <dirent.h>
00034 #include <errno.h>
00035 #include <strings.h>
00036 #include <sys/stat.h>
00037 #include <sys/types.h>
00038 #include <string.h>
00039 
00040 class XrdOucEnv;
00041 class XrdSysLogger;
00042 class XrdSfsAio;
00043 
00044 #ifndef XrdOssOK
00045 #define XrdOssOK 0
00046 #endif
00047 
00048 /******************************************************************************/
00049 /*                              X r d O s s D F                               */
00050 /******************************************************************************/
00051 
00056   
00057 class XrdOssDF
00058 {
00059 public:
00060                 // Directory oriented methods
00061 virtual int     Opendir(const char *, XrdOucEnv &)           {return -ENOTDIR;}
00062 virtual int     Readdir(char *buff, int blen)                {return -ENOTDIR;}
00063 
00064                 // File oriented methods
00065 virtual int     Fchmod(mode_t mode)                          {return -EISDIR;}
00066 virtual int     Fstat(struct stat *)                         {return -EISDIR;}
00067 virtual int     Fsync()                                      {return -EISDIR;}
00068 virtual int     Fsync(XrdSfsAio *aiop)                       {return -EISDIR;}
00069 virtual int     Ftruncate(unsigned long long)                {return -EISDIR;}
00070 virtual int     getFD()                                      {return -1;}
00071 virtual off_t   getMmap(void **addr)                         {return 0;}
00072 virtual int     isCompressed(char *cxidp=0)                  {return -EISDIR;}
00073 virtual int     Open(const char *, int, mode_t, XrdOucEnv &) {return -EISDIR;}
00074 virtual ssize_t Read(off_t, size_t)                          {return (ssize_t)-EISDIR;}
00075 virtual ssize_t Read(void *, off_t, size_t)                  {return (ssize_t)-EISDIR;}
00076 virtual int     Read(XrdSfsAio *aoip)                        {return (ssize_t)-EISDIR;}
00077 virtual ssize_t ReadRaw(    void *, off_t, size_t)           {return (ssize_t)-EISDIR;}
00078 virtual ssize_t Write(const void *, off_t, size_t)           {return (ssize_t)-EISDIR;}
00079 virtual int     Write(XrdSfsAio *aiop)                       {return (ssize_t)-EISDIR;}
00080 
00081                 // Methods common to both
00082 virtual int     Close(long long *retsz=0)=0;
00083 inline  int     Handle() {return fd;}
00084 
00085                 XrdOssDF() {fd = -1;}
00086 virtual        ~XrdOssDF() {}
00087 
00088 protected:
00089 
00090 int     fd;      // The associated file descriptor.
00091 };
00092 
00093 /******************************************************************************/
00094 /*                                X r d O s s                                 */
00095 /******************************************************************************/
00096 
00097 // Options that can be passed to Create()
00098 //
00099 #define XRDOSS_mkpath  0x01
00100 #define XRDOSS_new     0x02
00101 #define XRDOSS_Online  0x04
00102 #define XRDOSS_isPFN   0x10
00103 #define XRDOSS_isMIG   0x20
00104 #define XRDOSS_setnoxa 0x40
00105 
00106 // Options that can be passed to Stat()
00107 //
00108 #define XRDOSS_resonly 0x01
00109 #define XRDOSS_updtatm 0x02
00110 
00111 // Class passed to StatVS()
00112 //
00113 class XrdOssVSInfo
00114 {
00115 public:
00116 long long Total;   // Total bytes
00117 long long Free;    // Total bytes free
00118 long long Large;   // Total bytes in largest partition
00119 long long LFree;   // Max   bytes free in contiguous chunk
00120 long long Usage;   // Used  bytes (if usage enabled)
00121 long long Quota;   // Quota bytes (if quota enabled)
00122 int       Extents; // Number of partitions/extents
00123 int       Reserved;
00124 
00125           XrdOssVSInfo() : Total(0),Free(0),Large(0),LFree(0),Usage(-1),
00126                            Quota(-1),Extents(0),Reserved(0) {}
00127          ~XrdOssVSInfo() {}
00128 };
00129   
00130 class XrdOss
00131 {
00132 public:
00133 virtual XrdOssDF *newDir(const char *tident)=0;
00134 virtual XrdOssDF *newFile(const char *tident)=0;
00135 
00136 virtual int     Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)=0;
00137 virtual int     Create(const char *, const char *, mode_t, XrdOucEnv &, 
00138                        int opts=0)=0;
00139 virtual int     Init(XrdSysLogger *, const char *)=0;
00140 virtual int     Mkdir(const char *, mode_t mode, int mkpath=0,
00141                       XrdOucEnv *eP=0)=0;
00142 virtual int     Reloc(const char *, const char *, const char *, const char *x=0)
00143                       {return -ENOTSUP;}
00144 virtual int     Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)=0;
00145 virtual int     Rename(const char *, const char *,
00146                        XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)=0;
00147 virtual int     Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)=0;
00148 virtual int     StatFS(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
00149                       {return -ENOTSUP;}
00150 virtual int     StatLS(XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
00151                       {return -ENOTSUP;}
00152 virtual int     StatXA(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
00153                       {return -ENOTSUP;}
00154 virtual int     StatXP(const char *path, unsigned long long &attr,
00155                        XrdOucEnv *eP=0) {return -ENOTSUP;}
00156 virtual int     Truncate(const char *, unsigned long long, XrdOucEnv *eP=0)=0;
00157 virtual int     Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)=0;
00158 
00159 virtual int     Stats(char *bp, int bl) {return 0;}
00160 
00161 virtual int     StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
00162                       {return -ENOTSUP;}
00163 
00164 virtual int     Lfn2Pfn(const char *Path, char *buff, int blen)
00165                        {if ((int)strlen(Path) >= blen) return -ENAMETOOLONG;
00166                         strcpy(buff, Path); return 0;
00167                        }
00168 virtual
00169 const char     *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
00170                        {rc = 0; return Path;}
00171 
00172                 XrdOss() {}
00173 virtual        ~XrdOss() {}
00174 };
00175 
00176 /******************************************************************************/
00177 /*           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            */
00178 /******************************************************************************/
00179 
00180 //------------------------------------------------------------------------------
00201 //------------------------------------------------------------------------------
00209 //------------------------------------------------------------------------------
00215 //------------------------------------------------------------------------------
00216 
00222 #endif

Generated on 16 Jan 2014 for xrootd by  doxygen 1.4.7