xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdDigFS.hh
Go to the documentation of this file.
1 #ifndef __XRD_DIGFS_H__
2 #define __XRD_DIGFS_H__
3 /******************************************************************************/
4 /* */
5 /* X r d D i g F S . h h */
6 /* */
7 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <sys/types.h>
33 #include <cstring>
34 #include <dirent.h>
35 
37 
38 class XrdSysError;
39 class XrdSysLogger;
40 
41 /******************************************************************************/
42 /* X r d D i g D i r e c t o r y */
43 /******************************************************************************/
44 
46 {
47 public:
48 
49  int open(const char *dirName,
50  const XrdSecClientName *client = 0,
51  const char *opaque = 0);
52 
53  const char *nextEntry();
54 
55  int close();
56 
57 const char *FName() {return (const char *)fname;}
58 
59  int autoStat(struct stat *buf) {sBuff = buf; return SFS_OK;}
60 
61  XrdDigDirectory(char *user=0, int monid=0)
62  : XrdSfsDirectory(user, monid),
63  dh((DIR *)0), fname(0), sBuff(0),
65  dirFD(-1), ateof(false),
66  isProc(false), isBase(false) {}
67 
69 private:
70 
71 DIR *dh; // Directory stream handle
72 char *fname;
73 struct stat *sBuff;
74 struct dirent *d_pnt;
75 int dirFD;
76 bool ateof;
77 bool isProc;
78 bool isBase;
79 bool noTag;
80 
81 static const int aESZ = (MAXNAMLEN+MAXPATHLEN)/sizeof(const char *);
82 
83 struct {struct dirent d_entry;
84  union {const char *aEnt[aESZ];
85  char nbf[MAXNAMLEN+MAXPATHLEN];
86  char pad[MAXNAMLEN]; // This is only required for Solaris!
87  };
88  } dirent_full;
89 };
90 
91 /******************************************************************************/
92 /* X r d D i g F i l e */
93 /******************************************************************************/
94 
95 class XrdSfsAio;
96 
97 class XrdDigFile : public XrdSfsFile
98 {
99 public:
100 
101  int open(const char *fileName,
102  XrdSfsFileOpenMode openMode,
103  mode_t createMode,
104  const XrdSecClientName *client = 0,
105  const char *opaque = 0);
106 
107  int close();
108 
109  using XrdSfsFile::fctl;
110 
111  int fctl(const int cmd,
112  const char *args,
113  XrdOucErrInfo &out_error);
114 
115  const char *FName() {return fname;}
116 
117  int getMmap(void **Addr, off_t &Size)
118  {if (Addr) Addr = 0; Size = 0; return SFS_OK;}
119 
120  int read(XrdSfsFileOffset fileOffset,
121  XrdSfsXferSize preread_sz) {return SFS_OK;}
122 
124  char *buffer,
125  XrdSfsXferSize buffer_size);
126 
127  int read(XrdSfsAio *aioparm);
128 
130  int readCount);
131 
133  const char *buffer,
134  XrdSfsXferSize buffer_size) {return SFS_OK;}
135 
136  int write(XrdSfsAio *aioparm) {return SFS_OK;}
137 
138  int sync() {return SFS_OK;}
139 
140  int sync(XrdSfsAio *aiop) {return SFS_OK;}
141 
142  int stat(struct stat *buf);
143 
144  int truncate(XrdSfsFileOffset fileOffset) {return SFS_OK;}
145 
146  int getCXinfo(char cxtype[4], int &cxrsz) {return cxrsz = 0;}
147 
148  XrdDigFile(char *user=0, int monid=0)
149  : XrdSfsFile(user, monid),
150  oh(-1), fname(0), isProc(false) {}
151  ~XrdDigFile() {if (oh >= 0) close();}
152 private:
153 
154 int oh;
155 char *fname;
156 bool isProc;
157 };
158 
159 /******************************************************************************/
160 /* X r d D i g F S */
161 /******************************************************************************/
162 
163 class XrdDigFS : public XrdSfsFileSystem
164 {
165 public:
166 
167 // Object Allocation Functions
168 //
169  XrdSfsDirectory *newDir(char *user=0, int monid=0)
170  {return (XrdSfsDirectory *)new XrdDigDirectory(user,monid);}
171 
172  XrdSfsFile *newFile(char *user=0,int monid=0)
173  {return (XrdSfsFile *)new XrdDigFile(user,monid);}
174 
175 // Other Functions
176 //
177  int chmod(const char *Name,
178  XrdSfsMode Mode,
179  XrdOucErrInfo &out_error,
180  const XrdSecClientName *client = 0,
181  const char *opaque = 0)
182  {return Reject("chmod", Name, out_error);}
183 
184  int exists(const char *fileName,
185  XrdSfsFileExistence &exists_flag,
186  XrdOucErrInfo &out_error,
187  const XrdSecClientName *client = 0,
188  const char *opaque = 0);
189 
190  int fsctl(const int cmd,
191  const char *args,
192  XrdOucErrInfo &out_error,
193  const XrdSecClientName *client = 0);
194 
195  int getStats(char *buff, int blen) {return 0;}
196 
197 const char *getVersion();
198 
199  int mkdir(const char *dirName,
200  XrdSfsMode Mode,
201  XrdOucErrInfo &out_error,
202  const XrdSecClientName *client = 0,
203  const char *opaque = 0)
204  {return Reject("mkdir", dirName, out_error);}
205 
206  int prepare( XrdSfsPrep &pargs,
207  XrdOucErrInfo &out_error,
208  const XrdSecClientName *client = 0) {return 0;}
209 
210  int rem(const char *path,
211  XrdOucErrInfo &out_error,
212  const XrdSecClientName *client = 0,
213  const char *opaque = 0)
214  {return Reject("rm", path, out_error);}
215 
216  int remdir(const char *dirName,
217  XrdOucErrInfo &out_error,
218  const XrdSecClientName *client = 0,
219  const char *opaque = 0)
220  {return Reject("rmdir", dirName, out_error);}
221 
222  int rename(const char *oldFileName,
223  const char *newFileName,
224  XrdOucErrInfo &out_error,
225  const XrdSecClientName *client = 0,
226  const char *opaqueO = 0,
227  const char *opaqueN = 0)
228  {return Reject("rename", oldFileName, out_error);}
229 
230  int stat(const char *Name,
231  struct stat *buf,
232  XrdOucErrInfo &out_error,
233  const XrdSecClientName *client = 0,
234  const char *opaque = 0);
235 
236  int stat(const char *Name,
237  mode_t &mode,
238  XrdOucErrInfo &out_error,
239  const XrdSecClientName *client = 0,
240  const char *opaque = 0)
241  {struct stat bfr;
242  int rc = stat(Name, &bfr, out_error, client);
243  if (!rc) mode = bfr.st_mode;
244  return rc;
245  }
246 
247  int truncate(const char *Name,
248  XrdSfsFileOffset fileOffset,
249  XrdOucErrInfo &out_error,
250  const XrdSecEntity *client = 0,
251  const char *opaque = 0)
252  {return Reject("truncate", Name, out_error);}
253 
254 // Common functions
255 //
256 static int Emsg(const char *, XrdOucErrInfo&, int, const char *x,
257  const char *y="");
258 
259 static int Validate(const char *);
260 
261  XrdDigFS() {}
262 virtual ~XrdDigFS() {}
263 
264 private:
265 int Reject(const char *op, const char *trg, XrdOucErrInfo&);
266 };
267 #endif
#define XrdSecClientName
Definition: XrdSecEntity.hh:122
~XrdDigFile()
Definition: XrdDigFS.hh:151
char * fname
Definition: XrdDigFS.hh:72
int chmod(const char *Name, XrdSfsMode Mode, XrdOucErrInfo &out_error, const XrdSecClientName *client=0, const char *opaque=0)
Definition: XrdDigFS.hh:177
int fsctl(const int cmd, const char *args, XrdOucErrInfo &out_error, const XrdSecClientName *client=0)
int stat(struct stat *buf)
const char * aEnt[aESZ]
Definition: XrdDigFS.hh:84
struct dirent d_entry
Definition: XrdDigFS.hh:83
int sync(XrdSfsAio *aiop)
Definition: XrdDigFS.hh:140
int mkdir(const char *dirName, XrdSfsMode Mode, XrdOucErrInfo &out_error, const XrdSecClientName *client=0, const char *opaque=0)
Definition: XrdDigFS.hh:199
const char * getVersion()
const char * nextEntry()
XrdDigFile(char *user=0, int monid=0)
Definition: XrdDigFS.hh:148
int autoStat(struct stat *buf)
Definition: XrdDigFS.hh:59
#define SFS_OK
Definition: XrdSfsInterface.hh:106
int getMmap(void **Addr, off_t &Size)
Definition: XrdDigFS.hh:117
bool isProc
Definition: XrdDigFS.hh:77
int oh
Definition: XrdDigFS.hh:154
char nbf[MAXNAMLEN+MAXPATHLEN]
Definition: XrdDigFS.hh:85
static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, const char *y="")
int open(const char *fileName, XrdSfsFileOpenMode openMode, mode_t createMode, const XrdSecClientName *client=0, const char *opaque=0)
bool isBase
Definition: XrdDigFS.hh:78
virtual ~XrdDigFS()
Definition: XrdDigFS.hh:262
int XrdSfsXferSize
Definition: XrdSfsInterface.hh:129
int write(XrdSfsAio *aioparm)
Definition: XrdDigFS.hh:136
XrdSfsFileExistence
Definition: XrdSfsInterface.hh:131
int exists(const char *fileName, XrdSfsFileExistence &exists_flag, XrdOucErrInfo &out_error, const XrdSecClientName *client=0, const char *opaque=0)
virtual int fctl(const int cmd, const char *args, XrdOucErrInfo &eInfo)=0
bool noTag
Definition: XrdDigFS.hh:79
bool ateof
Definition: XrdDigFS.hh:76
XrdDigDirectory(char *user=0, int monid=0)
Definition: XrdDigFS.hh:61
Definition: XrdSysError.hh:89
int read(XrdSfsFileOffset fileOffset, XrdSfsXferSize preread_sz)
Definition: XrdDigFS.hh:120
Definition: XrdSfsInterface.hh:238
XrdDigFS()
Definition: XrdDigFS.hh:261
long long XrdSfsFileOffset
Definition: XrdSfsInterface.hh:126
static int Validate(const char *)
DIR * dh
Definition: XrdDigFS.hh:71
int Reject(const char *op, const char *trg, XrdOucErrInfo &)
XrdSfsXferSize readv(XrdOucIOVec *readV, int readCount)
XrdSfsFile * newFile(char *user=0, int monid=0)
Definition: XrdDigFS.hh:172
int sync()
Definition: XrdDigFS.hh:138
const char * FName()
Definition: XrdDigFS.hh:57
Definition: XrdOucErrInfo.hh:100
XrdSfsDirectory * newDir(char *user=0, int monid=0)
Definition: XrdDigFS.hh:169
XrdSfsXferSize write(XrdSfsFileOffset fileOffset, const char *buffer, XrdSfsXferSize buffer_size)
Definition: XrdDigFS.hh:132
Definition: XrdOucIOVec.hh:40
static const int aESZ
Definition: XrdDigFS.hh:81
int truncate(XrdSfsFileOffset fileOffset)
Definition: XrdDigFS.hh:144
struct stat * sBuff
Definition: XrdDigFS.hh:73
int getCXinfo(char cxtype[4], int &cxrsz)
Definition: XrdDigFS.hh:146
int getStats(char *buff, int blen)
Definition: XrdDigFS.hh:195
const char * FName()
Definition: XrdDigFS.hh:115
int rem(const char *path, XrdOucErrInfo &out_error, const XrdSecClientName *client=0, const char *opaque=0)
Definition: XrdDigFS.hh:210
int remdir(const char *dirName, XrdOucErrInfo &out_error, const XrdSecClientName *client=0, const char *opaque=0)
Definition: XrdDigFS.hh:216
struct dirent * d_pnt
Definition: XrdDigFS.hh:74
Definition: XrdSysLogger.hh:52
Definition: XrdDigFS.hh:163
#define stat(a, b)
Definition: XrdPosix.hh:96
int dirFD
Definition: XrdDigFS.hh:75
~XrdDigDirectory()
Definition: XrdDigFS.hh:68
int XrdSfsMode
Definition: XrdSfsInterface.hh:128
int prepare(XrdSfsPrep &pargs, XrdOucErrInfo &out_error, const XrdSecClientName *client=0)
Definition: XrdDigFS.hh:206
Definition: XrdDigFS.hh:97
int rename(const char *oldFileName, const char *newFileName, XrdOucErrInfo &out_error, const XrdSecClientName *client=0, const char *opaqueO=0, const char *opaqueN=0)
Definition: XrdDigFS.hh:222
char pad[MAXNAMLEN]
Definition: XrdDigFS.hh:86
Definition: XrdDigFS.hh:45
int stat(const char *Name, mode_t &mode, XrdOucErrInfo &out_error, const XrdSecClientName *client=0, const char *opaque=0)
Definition: XrdDigFS.hh:236
Definition: XrdSecEntity.hh:63
char * fname
Definition: XrdDigFS.hh:155
int open(const char *dirName, const XrdSecClientName *client=0, const char *opaque=0)
Definition: XrdSfsAio.hh:58
Definition: XrdSfsInterface.hh:364
&lt; Prepare parameters
Definition: XrdSfsInterface.hh:167
int fctl(const int cmd, const char *args, XrdOucErrInfo &out_error)
int stat(const char *Name, struct stat *buf, XrdOucErrInfo &out_error, const XrdSecClientName *client=0, const char *opaque=0)
bool isProc
Definition: XrdDigFS.hh:156
int truncate(const char *Name, XrdSfsFileOffset fileOffset, XrdOucErrInfo &out_error, const XrdSecEntity *client=0, const char *opaque=0)
Definition: XrdDigFS.hh:247
int XrdSfsFileOpenMode
Definition: XrdSfsInterface.hh:127
struct XrdDigDirectory::@89 dirent_full