xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdSfs
XrdSfsInterface.hh
Go to the documentation of this file.
1
#ifndef __SFS_INTERFACE_H__
2
#define __SFS_INTERFACE_H__
3
/******************************************************************************/
4
/* */
5
/* X r d S f s I n t e r f a c e . h h */
6
/* */
7
/* (c) 2010 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 <string.h>
// For strlcpy()
33
#include <sys/errno.h>
34
#include <sys/types.h>
35
#include <sys/stat.h>
36
#include <sys/socket.h>
// for sockaddr
37
38
#include "
XrdOuc/XrdOucErrInfo.hh
"
39
40
/******************************************************************************/
41
/* O p e n M o d e s */
42
/******************************************************************************/
43
44
#define SFS_O_RDONLY 0 // open read/only
45
#define SFS_O_WRONLY 1 // open write/only
46
#define SFS_O_RDWR 2 // open read/write
47
#define SFS_O_CREAT 0x100 // used for file creation
48
#define SFS_O_TRUNC 0x200 // used for file truncation
49
#define SFS_O_POSC 0x0100000 // persist on successful close
50
#define SFS_O_NOWAIT 0x01000000 // do not impose operational delays
51
#define SFS_O_RAWIO 0x02000000 // allow client-side decompression
52
#define SFS_O_RESET 0x04000000 // Reset any cached information
53
#define SFS_O_REPLICA 0x08000000 // Open for replication
54
55
// The following flag may be set in the access mode arg for open() & mkdir()
56
// Note that on some systems mode_t is 16-bits so we use a careful value!
57
//
58
#define SFS_O_MKPTH 0x00004000 // Make directory path if missing
59
60
// The following options are here to provide a uniform clustering interface.
61
// They may be passed through open/locate/stat, as applicable.
62
//
63
#define SFS_O_LOCATE 0x10000000 // This request generated by locate()
64
#define SFS_O_STAT 0x20000000 // This request generated by stat()
65
#define SFS_O_META 0x40000000 // This request generated by metaop
66
67
/******************************************************************************/
68
/* D e f i n e s */
69
/******************************************************************************/
70
71
// Common fctl command values (0 to 255)
72
//
73
#define SFS_FCTL_GETFD 1 // Return file descriptor if possible
74
#define SFS_FCTL_STATV 2 // Return visa information
75
76
// Common fsctl command values (0 to 255)
77
//
78
#define SFS_FSCTL_CMD 255
79
80
#define SFS_FSCTL_LOCATE 1 // Locate a file
81
#define SFS_FSCTL_STATFS 2 // Return FS data
82
#define SFS_FSCTL_STATLS 3 // Return LS data
83
#define SFS_FSCTL_STATXA 4 // Return XA data
84
#define SFS_FSCTL_PLUGIN 8 // Return Implementation Dependent Data
85
#define SFS_FSCTL_PLUGIO 16 // Return Implementation Dependent Data
86
87
// Return Values for Integer Returning XrdSfs Interface
88
//
89
#define SFS_STALL 1 // ErrInfo code -> Seconds to stall client
90
#define SFS_OK 0 // ErrInfo code -> All is well
91
#define SFS_ERROR -1 // ErrInfo code -> Error occurred
92
#define SFS_REDIRECT -256 // ErrInfo code -> Port number to redirect to
93
#define SFS_STARTED -512 // ErrInfo code -> Estimated seconds to completion
94
#define SFS_DATA -1024 // ErrInfo code -> Length of data
95
96
/******************************************************************************/
97
/* S t r u c t u r e s & T y p e d e f s */
98
/******************************************************************************/
99
100
typedef
long
long
XrdSfsFileOffset
;
101
typedef
int
XrdSfsFileOpenMode
;
102
typedef
int
XrdSfsMode
;
103
typedef
int
XrdSfsXferSize
;
104
105
enum
XrdSfsFileExistence
106
{
107
XrdSfsFileExistNo
,
108
XrdSfsFileExistIsFile
,
109
XrdSfsFileExistIsDirectory
110
};
111
//------------------------------------------------
112
113
#define Prep_PRTY0 0
114
#define Prep_PRTY1 1
115
#define Prep_PRTY2 2
116
#define Prep_PRTY3 3
117
#define Prep_PMASK 3
118
#define Prep_SENDAOK 4
119
#define Prep_SENDERR 8
120
#define Prep_SENDACK 12
121
#define Prep_WMODE 16
122
#define Prep_STAGE 32
123
#define Prep_COLOC 64
124
#define Prep_FRESH 128
125
126
class
XrdOucTList
;
127
128
struct
XrdSfsFSctl
// SFS_FSCTL_PLUGIN/PLUGIO parameters
129
{
130
const
char
*
Arg1
;
// PLUGIO & PLUGIN
131
int
Arg1Len
;
132
int
Arg2Len
;
133
const
char
*
Arg2
;
// PLUGIN opaque string
134
};
135
136
struct
XrdSfsPrep
// Prepare parameters
137
{
138
char
*
reqid
;
// Request ID
139
char
*
notify
;
// Notification path or 0
140
int
opts
;
// Prep_xxx
141
XrdOucTList
*
paths
;
// List of paths
142
XrdOucTList
*
oinfo
;
// 1-to-1 correspondence of opaque info
143
};
144
145
/******************************************************************************/
146
/* A b s t r a c t C l a s s e s */
147
/******************************************************************************/
148
149
class
XrdSfsFile
;
150
class
XrdSfsDirectory
;
151
class
XrdOucTList
;
152
class
XrdSecEntity
;
153
154
/******************************************************************************/
155
/* X r d S f s F i l e S y s t e m */
156
/******************************************************************************/
157
158
class
XrdSfsFileSystem
159
{
160
public
:
161
162
// The following two methods allocate a directory or file object
163
//
164
virtual
XrdSfsDirectory
*
newDir
(
char
*user=0,
int
MonID=0) = 0;
165
166
virtual
XrdSfsFile
*
newFile
(
char
*user=0,
int
MonID=0) = 0;
167
168
// The following are filesystem related methods
169
//
170
171
enum
csFunc
{
csCalc
= 0,
csGet
,
csSize
};
172
173
virtual
int
chksum
(
csFunc
Func,
174
const
char
*csName,
175
const
char
*Path,
176
XrdOucErrInfo
&out_error,
177
const
XrdSecEntity
*client = 0,
178
const
char
*opaque = 0)
179
{out_error.
setErrInfo
(ENOTSUP,
"Not supported."
);
180
return
SFS_ERROR
;
181
}
182
183
virtual
int
chmod
(
const
char
*Name,
184
XrdSfsMode
Mode,
185
XrdOucErrInfo
&out_error,
186
const
XrdSecEntity
*client = 0,
187
const
char
*opaque = 0) = 0;
188
189
virtual
int
FSctl
(
const
int
cmd,
190
XrdSfsFSctl
&args,
191
XrdOucErrInfo
&out_error,
192
const
XrdSecEntity
*client = 0) {
return
SFS_OK
;}
193
194
virtual
int
fsctl
(
const
int
cmd,
195
const
char
*args,
196
XrdOucErrInfo
&out_error,
197
const
XrdSecEntity
*client = 0) = 0;
198
199
virtual
int
getStats
(
char
*buff,
int
blen) = 0;
200
201
virtual
const
char
*
getVersion
() = 0;
202
203
virtual
int
exists
(
const
char
*fileName,
204
XrdSfsFileExistence
&exists_flag,
205
XrdOucErrInfo
&out_error,
206
const
XrdSecEntity
*client = 0,
207
const
char
*opaque = 0) = 0;
208
209
virtual
int
mkdir
(
const
char
*dirName,
210
XrdSfsMode
Mode,
211
XrdOucErrInfo
&out_error,
212
const
XrdSecEntity
*client = 0,
213
const
char
*opaque = 0) = 0;
214
215
virtual
int
prepare
(
XrdSfsPrep
&pargs,
216
XrdOucErrInfo
&out_error,
217
const
XrdSecEntity
*client = 0) = 0;
218
219
virtual
int
rem
(
const
char
*path,
220
XrdOucErrInfo
&out_error,
221
const
XrdSecEntity
*client = 0,
222
const
char
*opaque = 0) = 0;
223
224
virtual
int
remdir
(
const
char
*dirName,
225
XrdOucErrInfo
&out_error,
226
const
XrdSecEntity
*client = 0,
227
const
char
*opaque = 0) = 0;
228
229
virtual
int
rename
(
const
char
*oldFileName,
230
const
char
*newFileName,
231
XrdOucErrInfo
&out_error,
232
const
XrdSecEntity
*client = 0,
233
const
char
*opaqueO = 0,
234
const
char
*opaqueN = 0) = 0;
235
236
virtual
int
stat
(
const
char
*Name,
237
struct
stat
*buf,
238
XrdOucErrInfo
&out_error,
239
const
XrdSecEntity
*client = 0,
240
const
char
*opaque = 0) = 0;
241
242
virtual
int
stat
(
const
char
*Name,
243
mode_t &mode,
244
XrdOucErrInfo
&out_error,
245
const
XrdSecEntity
*client = 0,
246
const
char
*opaque = 0) = 0;
247
248
virtual
int
truncate
(
const
char
*Name,
249
XrdSfsFileOffset
fileOffset,
250
XrdOucErrInfo
&out_error,
251
const
XrdSecEntity
*client = 0,
252
const
char
*opaque = 0) = 0;
253
254
XrdSfsFileSystem
() {}
255
virtual
~XrdSfsFileSystem
() {}
256
257
protected
:
258
};
259
260
/******************************************************************************/
261
/* F i l e S y s t e m I n s t a n t i a t o r */
262
/******************************************************************************/
263
264
/* When building a shared library plugin, the following "C" entry point must
265
exist in the library:
266
267
extern "C"
268
{XrdSfsFileSystem *XrdSfsGetFileSystem(XrdSfsFileSystem *nativeFS,
269
XrdSysLogger *Logger,
270
const char *configFn);
271
}
272
273
*/
274
275
//------------------------------------------------------------------------------
281
//------------------------------------------------------------------------------
282
289
/******************************************************************************/
290
/* X r d S f s F i l e */
291
/******************************************************************************/
292
293
class
XrdSfsAio
;
294
295
class
XrdSfsFile
296
{
297
public
:
298
XrdOucErrInfo
error
;
299
300
virtual
int
open
(
const
char
*fileName,
301
XrdSfsFileOpenMode
openMode,
302
mode_t createMode,
303
const
XrdSecEntity
*client = 0,
304
const
char
*opaque = 0) = 0;
305
306
virtual
int
close
() = 0;
307
308
virtual
int
fctl
(
const
int
cmd,
309
const
char
*args,
310
XrdOucErrInfo
&out_error) = 0;
311
312
virtual
const
char
*
FName
() = 0;
313
314
virtual
int
getMmap
(
void
**Addr, off_t &Size) = 0;
315
316
virtual
int
read
(
XrdSfsFileOffset
fileOffset,
317
XrdSfsXferSize
preread_sz) = 0;
318
319
virtual
XrdSfsXferSize
read
(
XrdSfsFileOffset
fileOffset,
320
char
*buffer,
321
XrdSfsXferSize
buffer_size) = 0;
322
323
virtual
int
read
(
XrdSfsAio
*aioparm) = 0;
324
325
virtual
XrdSfsXferSize
write
(
XrdSfsFileOffset
fileOffset,
326
const
char
*buffer,
327
XrdSfsXferSize
buffer_size) = 0;
328
329
virtual
int
write
(
XrdSfsAio
*aioparm) = 0;
330
331
virtual
int
stat
(
struct
stat
*buf) = 0;
332
333
virtual
int
sync
() = 0;
334
335
virtual
int
sync
(
XrdSfsAio
*aiop) = 0;
336
337
virtual
int
truncate
(
XrdSfsFileOffset
fileOffset) = 0;
338
339
virtual
int
getCXinfo
(
char
cxtype[4],
int
&cxrsz) = 0;
340
341
XrdSfsFile
(
const
char
*user=0,
int
MonID=0)
342
:
error
(user, MonID) {}
343
virtual
~XrdSfsFile
() {}
344
345
};
// class XrdSfsFile
346
347
/******************************************************************************/
348
/* X r d S f s D i r e c t o r y */
349
/******************************************************************************/
350
351
class
XrdSfsDirectory
352
{
353
public
:
354
XrdOucErrInfo
error
;
355
356
virtual
int
open
(
const
char
*dirName,
357
const
XrdSecEntity
*client = 0,
358
const
char
*opaque = 0) = 0;
359
360
virtual
const
char
*
nextEntry
() = 0;
361
362
virtual
int
close
() = 0;
363
364
virtual
const
char
*
FName
() = 0;
365
366
XrdSfsDirectory
(
const
char
*user=0,
int
MonID=0)
367
:
error
(user, MonID) {}
368
virtual
~XrdSfsDirectory
() {}
369
370
};
// class XrdSfsDirectory
371
#endif
Generated by
1.8.4