xrootd
XrdPss.hh
Go to the documentation of this file.
00001 #ifndef _XRDPSS_API_H
00002 #define _XRDPSS_API_H
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                             X r d P s s . h h                              */
00006 /*                                                                            */
00007 /* (c) 2010 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 <errno.h>
00034 #include <unistd.h>
00035 #include <sys/types.h>
00036 #include "XrdSys/XrdSysHeaders.hh"
00037 #include "XrdOuc/XrdOucExport.hh"
00038 #include "XrdOuc/XrdOucName2Name.hh"
00039 #include "XrdOuc/XrdOucPList.hh"
00040 #include "XrdOss/XrdOss.hh"
00041 
00042 /******************************************************************************/
00043 /*                             X r d P s s D i r                              */
00044 /******************************************************************************/
00045 
00046 class XrdPssDir : public XrdOssDF
00047 {
00048 public:
00049 int     Close(long long *retsz=0);
00050 int     Opendir(const char *, XrdOucEnv &);
00051 int     Readdir(char *buff, int blen);
00052 
00053         // Constructor and destructor
00054         XrdPssDir(const char *tid) : tident(tid), dirVec(0) {}
00055        ~XrdPssDir() {if (dirVec) Close();}
00056 private:
00057 const    char      *tident;
00058          char     **dirVec;
00059          int        curEnt;
00060          int        numEnt;
00061 };
00062   
00063 /******************************************************************************/
00064 /*                            X r d P s s F i l e                             */
00065 /******************************************************************************/
00066 
00067 class XrdSfsAio;
00068   
00069 class XrdPssFile : public XrdOssDF
00070 {
00071 public:
00072 
00073 // The following two are virtual functions to allow for upcasting derivations
00074 // of this implementation
00075 //
00076 virtual int     Close(long long *retsz=0);
00077 virtual int     Open(const char *, int, mode_t, XrdOucEnv &);
00078 
00079 int     Fstat(struct stat *);
00080 int     Fsync();
00081 int     Fsync(XrdSfsAio *aiop);
00082 int     Ftruncate(unsigned long long);
00083 off_t   getMmap(void **addr);
00084 int     isCompressed(char *cxidp=0);
00085 ssize_t Read(               off_t, size_t);
00086 ssize_t Read(       void *, off_t, size_t);
00087 int     Read(XrdSfsAio *aiop);
00088 ssize_t ReadRaw(    void *, off_t, size_t);
00089 ssize_t Write(const void *, off_t, size_t);
00090 int     Write(XrdSfsAio *aiop);
00091  
00092          // Constructor and destructor
00093          XrdPssFile(const char *tid) : tident(tid) {fd = -1;}
00094 
00095 virtual ~XrdPssFile() {if (fd >= 0) Close();}
00096 
00097 private:
00098 
00099 const char *tident;
00100       int   crOpts;
00101 };
00102 
00103 /******************************************************************************/
00104 /*                             X r d P s s S y s                              */
00105 /******************************************************************************/
00106   
00107 class XrdOucEnv;
00108 class XrdSysError;
00109 class XrdOucStream;
00110 class XrdOucTList;
00111 
00112 struct XrdVersionInfo;
00113 
00114 class XrdPssSys : public XrdOss
00115 {
00116 public:
00117 virtual XrdOssDF *newDir(const char *tident)
00118                        {return (XrdOssDF *)new XrdPssDir(tident);}
00119 virtual XrdOssDF *newFile(const char *tident)
00120                        {return (XrdOssDF *)new XrdPssFile(tident);}
00121 
00122 int       Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
00123 virtual
00124 int       Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
00125 int       Init(XrdSysLogger *, const char *);
00126 int       Lfn2Pfn(const char *Path, char *buff, int blen);
00127 const
00128 char     *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
00129 int       Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
00130 int       Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
00131 int       Rename(const char *, const char *,
00132                  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
00133 int       Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0);
00134 int       Truncate(const char *, unsigned long long, XrdOucEnv *eP=0);
00135 int       Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
00136 
00137 static char *P2URL(int &retc, char *pbuff, int pblen,
00138                    const char *path,       int Split=0,
00139                    const char *Cgi=0,      int CgiLn=0,
00140                    const char *tIdent=0,   int doN2N=1);
00141 static int   T2UID(const char *Ident);
00142 
00143 static const char  *ConfigFN;       // -> Pointer to the config file name
00144 static const char  *myHost;
00145 static const char  *myName;
00146 static uid_t        myUid;
00147 static gid_t        myGid;
00148 static
00149 XrdOucPListAnchor   XPList;        // Exported path list
00150 
00151 static XrdOucTList *ManList;
00152 static const char  *urlPlain;
00153 static int          urlPlen;
00154 static int          hdrLen;
00155 static const char  *hdrData;
00156 static const char  *urlRdr;
00157 static int          Workers;
00158 static int          Trace;
00159 
00160 static char         allChmod;
00161 static char         allMkdir;
00162 static char         allMv;
00163 static char         allRmdir;
00164 static char         allRm;
00165 static char         allTrunc;
00166 
00167 static char         cfgDone;   // Configuration completed
00168 
00169          XrdPssSys();
00170 virtual ~XrdPssSys() {}
00171 
00172 private:
00173 
00174 char              *LocalRoot;// -> Local n2n root, if any
00175 char              *N2NLib;   // -> Name2Name Library Path
00176 char              *N2NParms; // -> Name2Name Object Parameters
00177 XrdOucName2Name   *theN2N;   // -> File mapper object
00178 unsigned long long DirFlags; // Defaults for exports
00179 char              *cPath;    // -> Cache path
00180 char              *cParm;    // -> Cache parameters
00181 XrdVersionInfo    *myVersion;// -> Compilation version
00182 int                TraceLvl; // Tracing options
00183 
00184 int    buildHdr();
00185 int    Configure(const char *);
00186 int    ConfigProc(const char *ConfigFN);
00187 int    ConfigXeq(char*, XrdOucStream&);
00188 int    ConfigN2N();
00189 int    getCache();
00190 int    xcach(XrdSysError *Eroute, XrdOucStream &Config);
00191 int    xcacl(XrdSysError *Eroute, XrdOucStream &Config);
00192 char  *xcapr(XrdSysError *Eroute, XrdOucStream &Config, char *pBuff);
00193 int    xconf(XrdSysError *Eroute, XrdOucStream &Config);
00194 int    xdef( XrdSysError *Eroute, XrdOucStream &Config);
00195 int    xexp( XrdSysError *Eroute, XrdOucStream &Config);
00196 int    xorig(XrdSysError *errp,   XrdOucStream &Config);
00197 int    xsopt(XrdSysError *Eroute, XrdOucStream &Config);
00198 int    xtrac(XrdSysError *Eroute, XrdOucStream &Config);
00199 int    xnml (XrdSysError *Eroute, XrdOucStream &Config);
00200 };
00201 #endif