xrootd
|
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 00018 #include "XrdOss/XrdOss.hh" 00019 00020 /******************************************************************************/ 00021 /* X r d P s s D i r */ 00022 /******************************************************************************/ 00023 00024 class XrdPssDir : public XrdOssDF 00025 { 00026 public: 00027 int Close(long long *retsz=0); 00028 int Opendir(const char *); 00029 int Readdir(char *buff, int blen); 00030 00031 // Constructor and destructor 00032 XrdPssDir(const char *tid) : tident(tid), dirVec(0) {} 00033 ~XrdPssDir() {if (dirVec) Close();} 00034 private: 00035 const char *tident; 00036 char **dirVec; 00037 int curEnt; 00038 int numEnt; 00039 }; 00040 00041 /******************************************************************************/ 00042 /* X r d P s s F i l e */ 00043 /******************************************************************************/ 00044 00045 class XrdSfsAio; 00046 00047 class XrdPssFile : public XrdOssDF 00048 { 00049 public: 00050 00051 // The following two are virtual functions to allow for upcasting derivations 00052 // of this implementation 00053 // 00054 virtual int Close(long long *retsz=0); 00055 virtual int Open(const char *, int, mode_t, XrdOucEnv &); 00056 00057 int Fstat(struct stat *); 00058 int Fsync(); 00059 int Fsync(XrdSfsAio *aiop); 00060 int Ftruncate(unsigned long long); 00061 off_t getMmap(void **addr); 00062 int isCompressed(char *cxidp=0); 00063 ssize_t Read( off_t, size_t); 00064 ssize_t Read( void *, off_t, size_t); 00065 int Read(XrdSfsAio *aiop); 00066 ssize_t ReadRaw( void *, off_t, size_t); 00067 ssize_t Write(const void *, off_t, size_t); 00068 int Write(XrdSfsAio *aiop); 00069 00070 // Constructor and destructor 00071 XrdPssFile(const char *tid) {fd = -1; tident = tid;} 00072 00073 virtual ~XrdPssFile() {if (fd >= 0) Close();} 00074 00075 private: 00076 00077 const char *tident; 00078 const char *crPath; 00079 int crOpts; 00080 }; 00081 00082 /******************************************************************************/ 00083 /* X r d P s s S y s */ 00084 /******************************************************************************/ 00085 00086 class XrdOucEnv; 00087 class XrdSysError; 00088 class XrdOucStream; 00089 class XrdOucTList; 00090 00091 class XrdPssSys : public XrdOss 00092 { 00093 public: 00094 virtual XrdOssDF *newDir(const char *tident) 00095 {return (XrdOssDF *)new XrdPssDir(tident);} 00096 virtual XrdOssDF *newFile(const char *tident) 00097 {return (XrdOssDF *)new XrdPssFile(tident);} 00098 00099 int Chmod(const char *, mode_t mode); 00100 virtual 00101 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0); 00102 int Init(XrdSysLogger *, const char *); 00103 int Mkdir(const char *, mode_t mode, int mkpath=0); 00104 int Remdir(const char *, int Opts=0); 00105 int Rename(const char *, const char *); 00106 int Stat(const char *, struct stat *, int resonly=0); 00107 int Truncate(const char *, unsigned long long); 00108 int Unlink(const char *, int Opts=0); 00109 00110 static char *P2URL(char *pbuff, int pblen, const char *path, int Split=0, 00111 const char *Cgi=0, int CgiLn=0, const char *tIdent=0); 00112 static int T2UID(const char *Ident); 00113 00114 static const char *ConfigFN; // -> Pointer to the config file name 00115 static const char *myHost; 00116 static const char *myName; 00117 static uid_t myUid; 00118 static gid_t myGid; 00119 static XrdOucTList *ManList; 00120 static const char *urlPlain; 00121 static int urlPlen; 00122 static int hdrLen; 00123 static const char *hdrData; 00124 static int Workers; 00125 00126 static char allChmod; 00127 static char allMkdir; 00128 static char allMv; 00129 static char allRmdir; 00130 static char allRm; 00131 static char allTrunc; 00132 00133 XrdPssSys() {} 00134 virtual ~XrdPssSys() {} 00135 00136 private: 00137 00138 int buildHdr(); 00139 int Configure(const char *); 00140 int ConfigProc(const char *ConfigFN); 00141 int ConfigXeq(char*, XrdOucStream&); 00142 int xconf(XrdSysError *Eroute, XrdOucStream &Config); 00143 int xorig(XrdSysError *errp, XrdOucStream &Config); 00144 int xsopt(XrdSysError *Eroute, XrdOucStream &Config); 00145 int xtrac(XrdSysError *Eroute, XrdOucStream &Config); 00146 }; 00147 #endif