xrootd
XrdSfsNative.hh
Go to the documentation of this file.
1 #ifndef __SFS_NATIVE_H__
2 #define __SFS_NATIVE_H__
3 /******************************************************************************/
4 /* */
5 /* X r d S f s N a t i v e . h h */
6 /* */
7 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC03-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 // $Id$
14 
15 #include <sys/types.h>
16 #include <string.h>
17 #include <dirent.h>
18 
20 
21 class XrdSysError;
22 class XrdSysLogger;
23 
24 /******************************************************************************/
25 /* X r d S f s N a t i v e D i r e c t o r y */
26 /******************************************************************************/
27 
29 {
30 public:
31 
32  int open(const char *dirName,
33  const XrdSecClientName *client = 0,
34  const char *opaque = 0);
35 
36  const char *nextEntry();
37 
38  int close();
39 
40 const char *FName() {return (const char *)fname;}
41 
42  XrdSfsNativeDirectory(char *user=0, int monid=0)
43  : XrdSfsDirectory(user, monid)
44  {ateof = 0; fname = 0;
45  dh = (DIR *)0;
46  d_pnt = &dirent_full.d_entry;
47  }
48 
50 private:
51 
52 DIR *dh; // Directory stream handle
53 char ateof;
54 char *fname;
55 
56 struct {struct dirent d_entry;
57  char pad[MAXNAMLEN]; // This is only required for Solaris!
58  } dirent_full;
59 
60 struct dirent *d_pnt;
61 
62 };
63 
64 /******************************************************************************/
65 /* X r d S f s N a t i v e F i l e */
66 /******************************************************************************/
67 
68 class XrdSfsAio;
69 
71 {
72 public:
73 
74  int open(const char *fileName,
75  XrdSfsFileOpenMode openMode,
76  mode_t createMode,
77  const XrdSecClientName *client = 0,
78  const char *opaque = 0);
79 
80  int close();
81 
82  int fctl(const int cmd,
83  const char *args,
84  XrdOucErrInfo &out_error);
85 
86  const char *FName() {return fname;}
87 
88  int getMmap(void **Addr, off_t &Size)
89  {if (Addr) Addr = 0; Size = 0; return SFS_OK;}
90 
91  int read(XrdSfsFileOffset fileOffset,
92  XrdSfsXferSize preread_sz) {return SFS_OK;}
93 
95  char *buffer,
96  XrdSfsXferSize buffer_size);
97 
98  int read(XrdSfsAio *aioparm);
99 
101  const char *buffer,
102  XrdSfsXferSize buffer_size);
103 
104  int write(XrdSfsAio *aioparm);
105 
106  int sync();
107 
108  int sync(XrdSfsAio *aiop);
109 
110  int stat(struct stat *buf);
111 
112  int truncate(XrdSfsFileOffset fileOffset);
113 
114  int getCXinfo(char cxtype[4], int &cxrsz) {return cxrsz = 0;}
115 
116  XrdSfsNativeFile(char *user=0, int monid=0)
117  : XrdSfsFile(user, monid)
118  {oh = -1; fname = 0;}
120 private:
121 
122 int oh;
123 char *fname;
124 
125 };
126 
127 /******************************************************************************/
128 /* X r d S f s N a t i v e */
129 /******************************************************************************/
130 
132 {
133 public:
134 
135 // Object Allocation Functions
136 //
137  XrdSfsDirectory *newDir(char *user=0, int monid=0)
138  {return (XrdSfsDirectory *)new XrdSfsNativeDirectory(user,monid);}
139 
140  XrdSfsFile *newFile(char *user=0,int monid=0)
141  {return (XrdSfsFile *)new XrdSfsNativeFile(user,monid);}
142 
143 // Other Functions
144 //
145  int chmod(const char *Name,
147  XrdOucErrInfo &out_error,
148  const XrdSecClientName *client = 0,
149  const char *opaque = 0);
150 
151  int exists(const char *fileName,
152  XrdSfsFileExistence &exists_flag,
153  XrdOucErrInfo &out_error,
154  const XrdSecClientName *client = 0,
155  const char *opaque = 0);
156 
157  int fsctl(const int cmd,
158  const char *args,
159  XrdOucErrInfo &out_error,
160  const XrdSecClientName *client = 0);
161 
162  int getStats(char *buff, int blen) {return 0;}
163 
164 const char *getVersion();
165 
166  int mkdir(const char *dirName,
168  XrdOucErrInfo &out_error,
169  const XrdSecClientName *client = 0,
170  const char *opaque = 0);
171 
172  int prepare( XrdSfsPrep &pargs,
173  XrdOucErrInfo &out_error,
174  const XrdSecClientName *client = 0) {return 0;}
175 
176  int rem(const char *path,
177  XrdOucErrInfo &out_error,
178  const XrdSecClientName *client = 0,
179  const char *opaque = 0);
180 
181  int remdir(const char *dirName,
182  XrdOucErrInfo &out_error,
183  const XrdSecClientName *client = 0,
184  const char *opaque = 0);
185 
186  int rename(const char *oldFileName,
187  const char *newFileName,
188  XrdOucErrInfo &out_error,
189  const XrdSecClientName *client = 0,
190  const char *opaqueO = 0,
191  const char *opaqueN = 0);
192 
193  int stat(const char *Name,
194  struct stat *buf,
195  XrdOucErrInfo &out_error,
196  const XrdSecClientName *client = 0,
197  const char *opaque = 0);
198 
199  int stat(const char *Name,
200  mode_t &mode,
201  XrdOucErrInfo &out_error,
202  const XrdSecClientName *client = 0,
203  const char *opaque = 0)
204  {struct stat bfr;
205  int rc = stat(Name, &bfr, out_error, client);
206  if (!rc) mode = bfr.st_mode;
207  return rc;
208  }
209 
210  int truncate(const char *Name,
211  XrdSfsFileOffset fileOffset,
212  XrdOucErrInfo &out_error,
213  const XrdSecEntity *client = 0,
214  const char *opaque = 0);
215 
216 // Common functions
217 //
218 static int Mkpath(const char *path, mode_t mode,
219  const char *info=0);
220 
221 static int Emsg(const char *, XrdOucErrInfo&, int, const char *x,
222  const char *y="");
223 
225 virtual ~XrdSfsNative() {}
226 
227 private:
228 
230 };
231 #endif