00001 #ifndef __XRDPOSIXXROOTD_H__
00002 #define __XRDPOSIXXROOTD_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <dirent.h>
00035 #include <unistd.h>
00036 #include <sys/stat.h>
00037 #include <sys/statvfs.h>
00038 #include <sys/types.h>
00039
00040 #if defined(__APPLE__) || defined(__FreeBSD__)
00041 #include <sys/param.h>
00042 #include <sys/mount.h>
00043 #else
00044 #include <sys/statfs.h>
00045 #endif
00046
00047 #include "XrdPosix/XrdPosixOsDep.hh"
00048 #include "XrdSys/XrdSysPthread.hh"
00049
00050 class XrdOucCache;
00051 class XrdOucEnv;
00052 class XrdPosixCallBack;
00053 class XrdPosixFile;
00054 class XrdPosixDir;
00055
00056 class XrdPosixXrootd
00057 {
00058 public:
00059
00060
00061
00062 static int Close(int fildes, int Stream=0);
00063
00064 static int Closedir(DIR *dirp);
00065
00066 static int Fstat(int fildes, struct stat *buf);
00067
00068 static int Fsync(int fildes);
00069
00070 static int Ftruncate(int fildes, off_t offset);
00071
00072 static long long Getxattr (const char *path, const char *name,
00073 void *value, unsigned long long size);
00074
00075 static off_t Lseek(int fildes, off_t offset, int whence);
00076
00077 static int Mkdir(const char *path, mode_t mode);
00078
00079 static const int isStream = 0x40000000;
00080
00081 static int Open(const char *path, int oflag, mode_t mode=0,
00082 XrdPosixCallBack *cbP=0);
00083
00084 static DIR* Opendir(const char *path);
00085
00086 static ssize_t Pread(int fildes, void *buf, size_t nbyte, off_t offset);
00087
00088 static ssize_t Read(int fildes, void *buf, size_t nbyte);
00089
00090 static ssize_t Readv(int fildes, const struct iovec *iov, int iovcnt);
00091
00092 static struct dirent* Readdir (DIR *dirp);
00093 static struct dirent64* Readdir64(DIR *dirp);
00094
00095 static int Readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result);
00096 static int Readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result);
00097
00098 static int Rename(const char *oldpath, const char *newpath);
00099
00100 static void Rewinddir(DIR *dirp);
00101
00102 static int Rmdir(const char *path);
00103
00104 static void Seekdir(DIR *dirp, long loc);
00105
00106 static int Stat(const char *path, struct stat *buf);
00107
00108 static int Statfs(const char *path, struct statfs *buf);
00109
00110 static int Statvfs(const char *path, struct statvfs *buf);
00111
00112 static ssize_t Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
00113
00114 static long Telldir(DIR *dirp);
00115
00116 static int Truncate(const char *path, off_t offset);
00117
00118 static int Unlink(const char *path);
00119
00120 static ssize_t Write(int fildes, const void *buf, size_t nbyte);
00121
00122 static ssize_t Write(int fildes, void *buf, size_t nbyte, off_t offset);
00123
00124 static ssize_t Writev(int fildes, const struct iovec *iov, int iovcnt);
00125
00126
00127
00128 static int Access(const char *path, int amode);
00129
00130 static int endPoint(int FD, char *Buff, int Blen);
00131
00132 static bool isXrootdDir(DIR *dirp);
00133
00134 static int mapError(int rc);
00135
00136 static
00137 inline bool myFD(int fd) {return fd >= baseFD && fd <= (highFD+baseFD)
00138 && myFiles && myFiles[fd-baseFD];
00139 }
00140
00141 static void OpenCB(XrdPosixFile *fp, void *cbArg, int res);
00142
00143 static int QueryChksum(const char *, time_t &, char *, int);
00144
00145 static long long QueryOpaque(const char*, char*, int);
00146
00147 static void setDebug(int val);
00148
00149 static void setEnv(const char *var, const char *val);
00150
00151 static void setEnv(const char *var, long val);
00152
00153 static void setCache(XrdOucCache *cP);
00154
00155 static int Debug;
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 XrdPosixXrootd(int maxfd=255, int maxdir=255, int maxthr=255);
00170 ~XrdPosixXrootd();
00171
00172 private:
00173
00174 static void initEnv();
00175 static void initEnv(char *eData);
00176 static void initEnv(XrdOucEnv &, const char *, long long &);
00177 static int Fault(XrdPosixFile *fp, int complete=1);
00178 static XrdPosixFile *findFP(int fildes, int glk=0);
00179 static XrdPosixDir *findDIR(DIR *dirp, int glk=0);
00180 static void initStat(struct stat *buf);
00181 static void initXdev(dev_t &st_dev, dev_t &st_rdev);
00182 static int mapFlags(int flags);
00183 static int mapMode(mode_t Mode);
00184
00185 static XrdSysMutex myMutex;
00186 static XrdPosixFile **myFiles;
00187 static XrdPosixDir **myDirs;
00188 static XrdOucCache *myCache;
00189 static int lastFD;
00190 static int highFD;
00191 static int baseFD;
00192 static int freeFD;
00193 static int lastDir;
00194 static int highDir;
00195 static int devNull;
00196 static int pllOpen;
00197 static int maxThreads;
00198 static int initDone;
00199 };
00200 #endif