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