• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

XrdPosixXrootd.hh

Go to the documentation of this file.
00001 #ifndef __XRDPOSIXXROOTD_H__
00002 #define __XRDPOSIXXROOTD_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d P o s i x X r o o t d                         */
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 /* Modified by Frank Winklmeier to add the full Posix file system definition. */
00012 /******************************************************************************/
00013   
00014 //           $Id: XrdPosixXrootd.hh,v 1.26 2010/02/28 06:37:32 abh Exp $
00015 
00016 #include <dirent.h>
00017 #include <unistd.h>
00018 #include <sys/stat.h>
00019 #include <sys/statvfs.h>
00020 #include <sys/types.h>
00021 
00022 #if defined(__macos__) || defined(__FreeBSD__)
00023 #include <sys/param.h>
00024 #include <sys/mount.h>
00025 #else
00026 #include <sys/statfs.h>
00027 #endif
00028 
00029 #include "XrdPosix/XrdPosixOsDep.hh"
00030 #include "XrdSys/XrdSysPthread.hh"
00031 
00032 class XrdPosixCallBack;
00033 class XrdPosixFile;
00034 class XrdPosixDir;
00035 
00036 class XrdPosixXrootd
00037 {
00038 public:
00039 
00040 // POSIX methods
00041 //
00042 static int     Close(int fildes, int Stream=0);
00043 
00044 static int     Closedir(DIR *dirp);
00045 
00046 static int     Fstat(int fildes, struct stat *buf);
00047 
00048 static int     Fsync(int fildes);
00049 
00050 static int     Ftruncate(int fildes, off_t offset);
00051 
00052 static long long Getxattr (const char *path, const char *name,
00053                            void *value, unsigned long long size);
00054 
00055 static off_t   Lseek(int fildes, off_t offset, int whence);
00056 
00057 static int     Mkdir(const char *path, mode_t mode);
00058 
00059 static const int isStream = 0x40000000; // Internal for Open oflag
00060 
00061 static int     Open(const char *path, int oflag, mode_t mode=0,
00062                     XrdPosixCallBack *cbP=0);
00063 
00064 static DIR*    Opendir(const char *path);
00065   
00066 static ssize_t Pread(int fildes, void *buf, size_t nbyte, off_t offset);
00067   
00068 static ssize_t Read(int fildes, void *buf, size_t nbyte);
00069 
00070 static ssize_t Readv(int fildes, const struct iovec *iov, int iovcnt);
00071 
00072 static struct dirent*   Readdir  (DIR *dirp);
00073 static struct dirent64* Readdir64(DIR *dirp);
00074 
00075 static int     Readdir_r  (DIR *dirp, struct dirent   *entry, struct dirent   **result);
00076 static int     Readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result);
00077 
00078 static int     Rename(const char *oldpath, const char *newpath);
00079 
00080 static void    Rewinddir(DIR *dirp);
00081 
00082 static int     Rmdir(const char *path);
00083 
00084 static void    Seekdir(DIR *dirp, long loc);
00085 
00086 static int     Stat(const char *path, struct stat *buf);
00087 
00088 static int     Statfs(const char *path, struct statfs *buf);
00089 
00090 static int     Statvfs(const char *path, struct statvfs *buf);
00091 
00092 static ssize_t Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
00093 
00094 static long    Telldir(DIR *dirp);
00095 
00096 static int     Truncate(const char *path, off_t offset);
00097 
00098 static int     Unlink(const char *path);
00099 
00100 static ssize_t Write(int fildes, const void *buf, size_t nbyte);
00101 
00102 static ssize_t Write(int fildes, void *buf, size_t nbyte, off_t offset);
00103 
00104 static ssize_t Writev(int fildes, const struct iovec *iov, int iovcnt);
00105 
00106 // Some non POSIX methods
00107 //
00108 static int     Access(const char *path, int amode);
00109 
00110 static int     endPoint(int FD, char *Buff, int Blen);
00111 
00112 static bool    isXrootdDir(DIR *dirp);
00113 
00114 static int     mapError(int rc);
00115 
00116 static
00117 inline bool    myFD(int fd) {return fd <= highFD && myFiles && myFiles[fd];}
00118 
00119 static void    OpenCB(XrdPosixFile *fp, void *cbArg, int res);
00120 
00121 static long long QueryOpaque(const char*, char*, int);
00122 
00123 static void    setDebug(int val);
00124 
00125 static void    setEnv(const char *var, const char *val);
00126 
00127 static void    setEnv(const char *var, long val);
00128 
00129 static int     Debug;
00130 
00131                XrdPosixXrootd(int maxfd=255, int maxdir=255, int maxthr=255);
00132               ~XrdPosixXrootd();
00133 
00134 private:
00135 
00136 static void                  initEnv();
00137 static int                   Fault(XrdPosixFile *fp, int complete=1);
00138 static XrdPosixFile         *findFP(int fildes, int glk=0);
00139 static XrdPosixDir          *findDIR(DIR *dirp, int glk=0);
00140 static void                  initStat(struct stat *buf);
00141 static void                  initXdev(dev_t &st_dev, dev_t &st_rdev);
00142 static int                   mapFlags(int flags);
00143 static int                   mapMode(mode_t Mode);
00144 
00145 static XrdSysMutex    myMutex;
00146 static XrdPosixFile **myFiles;
00147 static XrdPosixDir  **myDirs;
00148 static int            lastFD;
00149 static int            highFD;
00150 static int            lastDir;
00151 static int            highDir;
00152 static int            devNull;
00153 static int            pllOpen;
00154 static int            maxThreads;
00155 };
00156 #endif

Generated on Wed Sep 1 2010 for xrootd by  doxygen 1.7.1