00001 #ifndef __XRD_DIGFS_H__
00002 #define __XRD_DIGFS_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 #include <sys/types.h>
00033 #include <string.h>
00034 #include <dirent.h>
00035
00036 #include "XrdSfs/XrdSfsInterface.hh"
00037
00038 class XrdSysError;
00039 class XrdSysLogger;
00040
00041
00042
00043
00044
00045 class XrdDigDirectory : public XrdSfsDirectory
00046 {
00047 public:
00048
00049 int open(const char *dirName,
00050 const XrdSecClientName *client = 0,
00051 const char *opaque = 0);
00052
00053 const char *nextEntry();
00054
00055 int close();
00056
00057 const char *FName() {return (const char *)fname;}
00058
00059 int autoStat(struct stat *buf) {sBuff = buf; return SFS_OK;}
00060
00061 XrdDigDirectory(char *user=0, int monid=0)
00062 : XrdSfsDirectory(user, monid),
00063 dh((DIR *)0), fname(0), sBuff(0),
00064 d_pnt(&dirent_full.d_entry),
00065 dirFD(-1), ateof(false),
00066 isProc(false), isBase(false) {}
00067
00068 ~XrdDigDirectory() {if (dh) close();}
00069 private:
00070
00071 DIR *dh;
00072 char *fname;
00073 struct stat *sBuff;
00074 struct dirent *d_pnt;
00075 int dirFD;
00076 bool ateof;
00077 bool isProc;
00078 bool isBase;
00079 bool noTag;
00080
00081 static const int aESZ = (MAXNAMLEN+MAXPATHLEN)/sizeof(const char *);
00082
00083 struct {struct dirent d_entry;
00084 union {const char *aEnt[aESZ];
00085 char nbf[MAXNAMLEN+MAXPATHLEN];
00086 char pad[MAXNAMLEN];
00087 };
00088 } dirent_full;
00089 };
00090
00091
00092
00093
00094
00095 class XrdSfsAio;
00096
00097 class XrdDigFile : public XrdSfsFile
00098 {
00099 public:
00100
00101 int open(const char *fileName,
00102 XrdSfsFileOpenMode openMode,
00103 mode_t createMode,
00104 const XrdSecClientName *client = 0,
00105 const char *opaque = 0);
00106
00107 int close();
00108
00109 using XrdSfsFile::fctl;
00110
00111 int fctl(const int cmd,
00112 const char *args,
00113 XrdOucErrInfo &out_error);
00114
00115 const char *FName() {return fname;}
00116
00117 int getMmap(void **Addr, off_t &Size)
00118 {if (Addr) Addr = 0; Size = 0; return SFS_OK;}
00119
00120 int read(XrdSfsFileOffset fileOffset,
00121 XrdSfsXferSize preread_sz) {return SFS_OK;}
00122
00123 XrdSfsXferSize read(XrdSfsFileOffset fileOffset,
00124 char *buffer,
00125 XrdSfsXferSize buffer_size);
00126
00127 int read(XrdSfsAio *aioparm);
00128
00129 XrdSfsXferSize readv(XrdOucIOVec *readV,
00130 int readCount);
00131
00132 XrdSfsXferSize write(XrdSfsFileOffset fileOffset,
00133 const char *buffer,
00134 XrdSfsXferSize buffer_size) {return SFS_OK;}
00135
00136 int write(XrdSfsAio *aioparm) {return SFS_OK;}
00137
00138 int sync() {return SFS_OK;}
00139
00140 int sync(XrdSfsAio *aiop) {return SFS_OK;}
00141
00142 int stat(struct stat *buf);
00143
00144 int truncate(XrdSfsFileOffset fileOffset) {return SFS_OK;}
00145
00146 int getCXinfo(char cxtype[4], int &cxrsz) {return cxrsz = 0;}
00147
00148 XrdDigFile(char *user=0, int monid=0)
00149 : XrdSfsFile(user, monid),
00150 oh(-1), fname(0), isProc(false) {}
00151 ~XrdDigFile() {if (oh >= 0) close();}
00152 private:
00153
00154 int oh;
00155 char *fname;
00156 bool isProc;
00157 };
00158
00159
00160
00161
00162
00163 class XrdDigFS : public XrdSfsFileSystem
00164 {
00165 public:
00166
00167
00168
00169 XrdSfsDirectory *newDir(char *user=0, int monid=0)
00170 {return (XrdSfsDirectory *)new XrdDigDirectory(user,monid);}
00171
00172 XrdSfsFile *newFile(char *user=0,int monid=0)
00173 {return (XrdSfsFile *)new XrdDigFile(user,monid);}
00174
00175
00176
00177 int chmod(const char *Name,
00178 XrdSfsMode Mode,
00179 XrdOucErrInfo &out_error,
00180 const XrdSecClientName *client = 0,
00181 const char *opaque = 0)
00182 {return Reject("chmod", Name, out_error);}
00183
00184 int exists(const char *fileName,
00185 XrdSfsFileExistence &exists_flag,
00186 XrdOucErrInfo &out_error,
00187 const XrdSecClientName *client = 0,
00188 const char *opaque = 0);
00189
00190 int fsctl(const int cmd,
00191 const char *args,
00192 XrdOucErrInfo &out_error,
00193 const XrdSecClientName *client = 0);
00194
00195 int getStats(char *buff, int blen) {return 0;}
00196
00197 const char *getVersion();
00198
00199 int mkdir(const char *dirName,
00200 XrdSfsMode Mode,
00201 XrdOucErrInfo &out_error,
00202 const XrdSecClientName *client = 0,
00203 const char *opaque = 0)
00204 {return Reject("mkdir", dirName, out_error);}
00205
00206 int prepare( XrdSfsPrep &pargs,
00207 XrdOucErrInfo &out_error,
00208 const XrdSecClientName *client = 0) {return 0;}
00209
00210 int rem(const char *path,
00211 XrdOucErrInfo &out_error,
00212 const XrdSecClientName *client = 0,
00213 const char *opaque = 0)
00214 {return Reject("rm", path, out_error);}
00215
00216 int remdir(const char *dirName,
00217 XrdOucErrInfo &out_error,
00218 const XrdSecClientName *client = 0,
00219 const char *opaque = 0)
00220 {return Reject("rmdir", dirName, out_error);}
00221
00222 int rename(const char *oldFileName,
00223 const char *newFileName,
00224 XrdOucErrInfo &out_error,
00225 const XrdSecClientName *client = 0,
00226 const char *opaqueO = 0,
00227 const char *opaqueN = 0)
00228 {return Reject("rename", oldFileName, out_error);}
00229
00230 int stat(const char *Name,
00231 struct stat *buf,
00232 XrdOucErrInfo &out_error,
00233 const XrdSecClientName *client = 0,
00234 const char *opaque = 0);
00235
00236 int stat(const char *Name,
00237 mode_t &mode,
00238 XrdOucErrInfo &out_error,
00239 const XrdSecClientName *client = 0,
00240 const char *opaque = 0)
00241 {struct stat bfr;
00242 int rc = stat(Name, &bfr, out_error, client);
00243 if (!rc) mode = bfr.st_mode;
00244 return rc;
00245 }
00246
00247 int truncate(const char *Name,
00248 XrdSfsFileOffset fileOffset,
00249 XrdOucErrInfo &out_error,
00250 const XrdSecEntity *client = 0,
00251 const char *opaque = 0)
00252 {return Reject("truncate", Name, out_error);}
00253
00254
00255
00256 static int Emsg(const char *, XrdOucErrInfo&, int, const char *x,
00257 const char *y="");
00258
00259 static int Validate(const char *);
00260
00261 XrdDigFS() {}
00262 virtual ~XrdDigFS() {}
00263
00264 private:
00265 int Reject(const char *op, const char *trg, XrdOucErrInfo&);
00266 };
00267 #endif