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 #include "XrdOuc/XrdOucIOVec.hh"
00041 
00042 class XrdOucEnv;
00043 class XrdSysLogger;
00044 class XrdSfsAio;
00045 
00046 #ifndef XrdOssOK
00047 #define XrdOssOK 0
00048 #endif
00049 
00050 /******************************************************************************/
00051 /*                              X r d O s s D F                               */
00052 /******************************************************************************/
00053 
00058   
00059 class XrdOssDF
00060 {
00061 public:
00062                 // Directory oriented methods
00063 virtual int     Opendir(const char *, XrdOucEnv &)           {return -ENOTDIR;}
00064 virtual int     Readdir(char *buff, int blen)                {(void)buff; (void)blen; return -ENOTDIR;}
00065 virtual int     StatRet(struct stat *buff)                   {(void)buff; return -ENOTSUP;}
00066 
00067                 // File oriented methods
00068 virtual int     Fchmod(mode_t mode)                          {(void)mode; return -EISDIR;}
00069 virtual int     Fstat(struct stat *)                         {return -EISDIR;}
00070 virtual int     Fsync()                                      {return -EISDIR;}
00071 virtual int     Fsync(XrdSfsAio *aiop)                       {(void)aiop; return -EISDIR;}
00072 virtual int     Ftruncate(unsigned long long)                {return -EISDIR;}
00073 virtual int     getFD()                                      {return -1;}
00074 virtual off_t   getMmap(void **addr)                         {(void)addr; return 0;}
00075 virtual int     isCompressed(char *cxidp=0)                  {(void)cxidp; return -EISDIR;}
00076 virtual int     Open(const char *, int, mode_t, XrdOucEnv &) {return -EISDIR;}
00077 virtual ssize_t Read(off_t, size_t)                          {return (ssize_t)-EISDIR;}
00078 virtual ssize_t Read(void *, off_t, size_t)                  {return (ssize_t)-EISDIR;}
00079 virtual int     Read(XrdSfsAio *aoip)                        {(void)aoip; return (ssize_t)-EISDIR;}
00080 virtual ssize_t ReadRaw(    void *, off_t, size_t)           {return (ssize_t)-EISDIR;}
00081 virtual ssize_t Write(const void *, off_t, size_t)           {return (ssize_t)-EISDIR;}
00082 virtual int     Write(XrdSfsAio *aiop)                       {(void)aiop; return (ssize_t)-EISDIR;}
00083 
00084 // Implemented in the header, as many folks will be happy with the default.
00085 //
00086 virtual ssize_t ReadV(XrdOucIOVec *readV, int n)
00087                      {ssize_t nbytes = 0, curCount = 0;
00088                       for (int i=0; i<n; i++)
00089                           {curCount = Read((void *)readV[i].data,
00090                                             (off_t)readV[i].offset,
00091                                            (size_t)readV[i].size);
00092                            if (curCount != readV[i].size)
00093                               {if (curCount < 0) return curCount;
00094                                return -ESPIPE;
00095                               }
00096                            nbytes += curCount;
00097                           }
00098                       return nbytes;
00099                      }
00100 
00101 // Implemented in the header, as many folks will be happy with the default.
00102 //
00103 virtual ssize_t WriteV(XrdOucIOVec *writeV, int n)
00104                       {ssize_t nbytes = 0, curCount = 0;
00105                        for (int i=0; i<n; i++)
00106                            {curCount =Write((void *)writeV[i].data,
00107                                              (off_t)writeV[i].offset,
00108                                             (size_t)writeV[i].size);
00109                             if (curCount != writeV[i].size)
00110                                {if (curCount < 0) return curCount;
00111                                 return -ESPIPE;
00112                                }
00113                             nbytes += curCount;
00114                            }
00115                        return nbytes;
00116                       }
00117 
00118                 // Methods common to both
00119 virtual int     Close(long long *retsz=0)=0;
00120 inline  int     Handle() {return fd;}
00121 virtual int     Fctl(int cmd, int alen, const char *args, char **resp=0)
00122 {
00123   (void)cmd; (void)alen; (void)args; (void)resp;
00124   return -ENOTSUP;
00125 }
00126 
00127                 XrdOssDF() {fd = -1;}
00128 virtual        ~XrdOssDF() {}
00129 
00130 protected:
00131 
00132 int     fd;      // The associated file descriptor.
00133 };
00134 
00135 /******************************************************************************/
00136 /*                                X r d O s s                                 */
00137 /******************************************************************************/
00138 
00139 // Options that can be passed to Create()
00140 //
00141 #define XRDOSS_mkpath  0x01
00142 #define XRDOSS_new     0x02
00143 #define XRDOSS_Online  0x04
00144 #define XRDOSS_isPFN   0x10
00145 #define XRDOSS_isMIG   0x20
00146 #define XRDOSS_setnoxa 0x40
00147 
00148 // Options that can be passed to Stat()
00149 //
00150 #define XRDOSS_resonly 0x0001
00151 #define XRDOSS_updtatm 0x0002
00152 #define XRDOSS_preop   0x0004
00153 
00154 // Class passed to StatVS()
00155 //
00156 class XrdOssVSInfo
00157 {
00158 public:
00159 long long Total;   // Total bytes
00160 long long Free;    // Total bytes free
00161 long long Large;   // Total bytes in largest partition
00162 long long LFree;   // Max   bytes free in contiguous chunk
00163 long long Usage;   // Used  bytes (if usage enabled)
00164 long long Quota;   // Quota bytes (if quota enabled)
00165 int       Extents; // Number of partitions/extents
00166 int       Reserved;
00167 
00168           XrdOssVSInfo() : Total(0),Free(0),Large(0),LFree(0),Usage(-1),
00169                            Quota(-1),Extents(0),Reserved(0) {}
00170          ~XrdOssVSInfo() {}
00171 };
00172   
00173 class XrdOss
00174 {
00175 public:
00176 virtual XrdOssDF *newDir(const char *tident)=0;
00177 virtual XrdOssDF *newFile(const char *tident)=0;
00178 
00179 virtual int     Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)=0;
00180 virtual int     Create(const char *, const char *, mode_t, XrdOucEnv &, 
00181                        int opts=0)=0;
00182 virtual int     Init(XrdSysLogger *, const char *)=0;
00183 virtual int     Mkdir(const char *, mode_t mode, int mkpath=0,
00184                       XrdOucEnv *eP=0)=0;
00185 virtual int     Reloc(const char *, const char *, const char *, const char *x=0)
00186                       {(void)x; return -ENOTSUP;}
00187 virtual int     Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)=0;
00188 virtual int     Rename(const char *, const char *,
00189                        XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)=0;
00190 virtual int     Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)=0;
00191 virtual int     StatFS(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
00192 { (void)path; (void)buff; (void)blen; (void)eP; return -ENOTSUP;}
00193 virtual int     StatLS(XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
00194 { (void)env; (void)cgrp; (void)buff; (void)blen; return -ENOTSUP;}
00195 virtual int     StatPF(const char *, struct stat *)
00196                       {return -ENOTSUP;}
00197 virtual int     StatXA(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
00198 { (void)path; (void)buff; (void)blen; (void)eP; return -ENOTSUP;}
00199 virtual int     StatXP(const char *path, unsigned long long &attr,
00200                        XrdOucEnv *eP=0)
00201 { (void)path; (void)attr; (void)eP; return -ENOTSUP;}
00202 virtual int     Truncate(const char *, unsigned long long, XrdOucEnv *eP=0)=0;
00203 virtual int     Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)=0;
00204 
00205 virtual int     Stats(char *bp, int bl) { (void)bp; (void)bl; return 0;}
00206 
00207 virtual int     StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
00208 { (void)sP; (void)sname; (void)updt; return -ENOTSUP;}
00209 
00210 virtual int     Lfn2Pfn(const char *Path, char *buff, int blen)
00211                        {if ((int)strlen(Path) >= blen) return -ENAMETOOLONG;
00212                         strcpy(buff, Path); return 0;
00213                        }
00214 virtual
00215 const char     *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
00216 { (void)buff; (void)blen; rc = 0; return Path;}
00217 
00218 virtual int     FSctl(int cmd, int alen, const char *args, char **resp=0)
00219 { (void)cmd; (void)alen; (void)args; (void)resp; return -ENOTSUP;}
00220 
00221 virtual void    EnvInfo(XrdOucEnv *envP) {(void)envP;}
00222 
00223                 XrdOss() {}
00224 virtual        ~XrdOss() {}
00225 };
00226 
00227 /******************************************************************************/
00228 /*           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            */
00229 /******************************************************************************/
00230 
00231 //------------------------------------------------------------------------------
00252 //------------------------------------------------------------------------------
00260 //------------------------------------------------------------------------------
00266 //------------------------------------------------------------------------------
00267 
00273 #endif

Generated on 5 Oct 2016 for xrootd by  doxygen 1.4.7