xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdPosix
XrdPosixXrootd.hh
Go to the documentation of this file.
1
#ifndef __XRDPOSIXXROOTD_H__
2
#define __XRDPOSIXXROOTD_H__
3
/******************************************************************************/
4
/* */
5
/* X r d P o s i x X r o o t d */
6
/* */
7
/* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC02-76-SFO0515 with the Department of Energy */
11
/* Modified by Frank Winklmeier to add the full Posix file system definition. */
12
/******************************************************************************/
13
14
#include <dirent.h>
15
#include <unistd.h>
16
#include <sys/stat.h>
17
#include <sys/statvfs.h>
18
#include <sys/types.h>
19
20
#if defined(__macos__) || defined(__FreeBSD__)
21
#include <sys/param.h>
22
#include <sys/mount.h>
23
#else
24
#include <sys/statfs.h>
25
#endif
26
27
#include "
XrdPosix/XrdPosixOsDep.hh
"
28
#include "
XrdSys/XrdSysPthread.hh
"
29
30
class
XrdOucCache
;
31
class
XrdOucEnv
;
32
class
XrdPosixCallBack
;
33
class
XrdPosixFile
;
34
class
XrdPosixDir
;
35
36
class
XrdPosixXrootd
37
{
38
public
:
39
40
// POSIX methods
41
//
42
static
int
Close
(
int
fildes,
int
Stream=0);
43
44
static
int
Closedir
(DIR *dirp);
45
46
static
int
Fstat
(
int
fildes,
struct
stat
*buf);
47
48
static
int
Fsync
(
int
fildes);
49
50
static
int
Ftruncate
(
int
fildes, off_t offset);
51
52
static
long
long
Getxattr
(
const
char
*path,
const
char
*name,
53
void
*value,
unsigned
long
long
size);
54
55
static
off_t
Lseek
(
int
fildes, off_t offset,
int
whence);
56
57
static
int
Mkdir
(
const
char
*path, mode_t mode);
58
59
static
const
int
isStream
= 0x40000000;
// Internal for Open oflag
60
61
static
int
Open
(
const
char
*path,
int
oflag, mode_t mode=0,
62
XrdPosixCallBack
*cbP=0);
63
64
static
DIR*
Opendir
(
const
char
*path);
65
66
static
ssize_t
Pread
(
int
fildes,
void
*buf,
size_t
nbyte, off_t offset);
67
68
static
ssize_t
Read
(
int
fildes,
void
*buf,
size_t
nbyte);
69
70
static
ssize_t
Readv
(
int
fildes,
const
struct
iovec *iov,
int
iovcnt);
71
72
static
struct
dirent*
Readdir
(DIR *dirp);
73
static
struct
dirent64*
Readdir64
(DIR *dirp);
74
75
static
int
Readdir_r
(DIR *dirp,
struct
dirent *entry,
struct
dirent **result);
76
static
int
Readdir64_r
(DIR *dirp,
struct
dirent64 *entry,
struct
dirent64 **result);
77
78
static
int
Rename
(
const
char
*oldpath,
const
char
*newpath);
79
80
static
void
Rewinddir
(DIR *dirp);
81
82
static
int
Rmdir
(
const
char
*path);
83
84
static
void
Seekdir
(DIR *dirp,
long
loc);
85
86
static
int
Stat
(
const
char
*path,
struct
stat
*buf);
87
88
static
int
Statfs
(
const
char
*path,
struct
statfs
*buf);
89
90
static
int
Statvfs
(
const
char
*path,
struct
statvfs
*buf);
91
92
static
ssize_t
Pwrite
(
int
fildes,
const
void
*buf,
size_t
nbyte, off_t offset);
93
94
static
long
Telldir
(DIR *dirp);
95
96
static
int
Truncate
(
const
char
*path, off_t offset);
97
98
static
int
Unlink
(
const
char
*path);
99
100
static
ssize_t
Write
(
int
fildes,
const
void
*buf,
size_t
nbyte);
101
102
static
ssize_t
Write
(
int
fildes,
void
*buf,
size_t
nbyte, off_t offset);
103
104
static
ssize_t
Writev
(
int
fildes,
const
struct
iovec *iov,
int
iovcnt);
105
106
// Some non POSIX methods
107
//
108
static
int
Access
(
const
char
*path,
int
amode);
109
110
static
int
endPoint
(
int
FD,
char
*Buff,
int
Blen);
111
112
static
bool
isXrootdDir
(DIR *dirp);
113
114
static
int
mapError
(
int
rc);
115
116
static
117
inline
bool
myFD
(
int
fd) {
return
fd >=
baseFD
&& fd <= (
highFD
+
baseFD
)
118
&&
myFiles
&&
myFiles
[fd-
baseFD
];
119
}
120
121
static
void
OpenCB
(
XrdPosixFile
*fp,
void
*cbArg,
int
res);
122
123
static
int
QueryChksum
(
const
char
*, time_t &,
char
*,
int
);
124
125
static
long
long
QueryOpaque
(
const
char
*,
char
*,
int
);
126
127
static
void
setDebug
(
int
val);
128
129
static
void
setEnv
(
const
char
*var,
const
char
*val);
130
131
static
void
setEnv
(
const
char
*var,
long
val);
132
133
static
void
setCache
(
XrdOucCache
*cP);
134
135
static
int
Debug
;
136
137
/* There must be one instance of this object per executable image. Typically,
138
this object is declared in main() or at file level. This is necessary to
139
properly do one-time initialization of the static members. When declaring
140
this object, you can pass the following information:
141
maxfd - maximum number of simultaneous files to support (i.e. fdlimit).
142
The value returned by getrlimit() over-rides the passed value
143
unless maxfd is negative. When negative, abs(maxfd) becomes the
144
absolute maximum and shadow file descriptors are not used.
145
maxdir - maximum number of open directories that can be supported. This
146
is independent of maxfd.
147
maxthr - maximum number of threads to use for the callback function.
148
*/
149
XrdPosixXrootd
(
int
maxfd=255,
int
maxdir=255,
int
maxthr=255);
150
~XrdPosixXrootd
();
151
152
private
:
153
154
static
void
initEnv
();
155
static
void
initEnv
(
char
*eData);
156
static
void
initEnv
(
XrdOucEnv
&,
const
char
*,
long
long
&);
157
static
int
Fault
(
XrdPosixFile
*fp,
int
complete=1);
158
static
XrdPosixFile
*
findFP
(
int
fildes,
int
glk=0);
159
static
XrdPosixDir
*
findDIR
(DIR *dirp,
int
glk=0);
160
static
void
initStat
(
struct
stat
*buf);
161
static
void
initXdev
(dev_t &st_dev, dev_t &st_rdev);
162
static
int
mapFlags
(
int
flags);
163
static
int
mapMode
(mode_t
Mode
);
164
165
static
XrdSysMutex
myMutex
;
166
static
XrdPosixFile
**
myFiles
;
167
static
XrdPosixDir
**
myDirs
;
168
static
XrdOucCache
*
myCache
;
169
static
int
lastFD
;
170
static
int
highFD
;
171
static
int
baseFD
;
172
static
int
freeFD
;
173
static
int
lastDir
;
174
static
int
highDir
;
175
static
int
devNull
;
176
static
int
pllOpen
;
177
static
int
maxThreads
;
178
static
int
initDone
;
179
};
180
#endif
Generated by
1.8.1.2