#include <XrdXrootdPrepare.hh>
Definition at line 83 of file XrdXrootdPrepare.hh.
◆ XrdXrootdPrepare()
◆ ~XrdXrootdPrepare()
XrdXrootdPrepare::~XrdXrootdPrepare |
( |
| ) |
|
|
inline |
◆ Close()
static int XrdXrootdPrepare::Close |
( |
int |
fd | ) |
|
|
inlinestatic |
◆ DoIt()
void XrdXrootdPrepare::DoIt |
( |
| ) |
|
|
inlinevirtual |
◆ List()
Definition at line 92 of file XrdXrootdPrepare.cc.
101 if (!LogDir)
return -1;
106 {
if (!(pargs.dirP =
opendir((
const char *)LogDir)))
107 {
eDest->
Emsg(
"List", errno,
"open prep log directory", LogDir);
110 if (pargs.
reqid) pargs.reqlen = strlen(pargs.
reqid);
111 if (pargs.
user) pargs.usrlen = strlen(pargs.
user);
117 while((dp =
readdir(pargs.dirP)))
118 {
if (!(up = (
char *) index((
const char *)dp->d_name,
'_')))
continue;
119 if (pargs.reqlen && strncmp(dp->d_name, pargs.
reqid, pargs.reqlen))
122 if (!up || strcmp((
const char *)up+1,(
const char *)pargs.
user))
124 strcpy(path, (
const char *)LogDir);
125 strcpy(path+LogDirLen, (
const char *)dp->d_name);
126 if (
stat((
const char *)path, &buf))
continue;
128 if ((up = (
char *) index((
const char *)(up+1), (
int)
'_'))) *up =
' ';
130 if ((up = (
char *) index((
const char *)(up+1), (
int)
'_'))) *up =
' ';
132 return snprintf(resp, resplen-1,
"%s %lld",
133 dp->d_name, (
long long) buf.st_mtime);
139 eDest->
Emsg(
"List", errno,
"read prep log directory", LogDir);
142 return (rc ? -1 : 0);
static XrdSysError eDest(0,"crypto_")
int stat(const char *path, struct stat *buf)
struct dirent * readdir(DIR *dirp)
DIR * opendir(const char *path)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
References closedir(), eDest, XrdSysError::Emsg(), opendir(), readdir(), XrdXrootdPrepArgs::reqid, stat(), and XrdXrootdPrepArgs::user.
◆ Log()
Definition at line 149 of file XrdXrootdPrepare.cc.
151 int rc, pnum = 0, xfd;
153 char buff[2048], blink[2048];
154 struct iovec iovec[2];
162 while(tp) {pnum++; tp = tp->
next;}
166 snprintf(buff,
sizeof(buff)-1,
"%s%s_%s_%d_%d", LogDir,
171 if ((xfd =
open(buff, O_WRONLY|O_CREAT|O_TRUNC,0644)) < 0)
172 {
eDest->
Emsg(
"Log", errno,
"open prep log file", buff);
178 iovec[1].iov_base = (
char *)
" ";
179 iovec[1].iov_len = 1;
182 {
if (tp->
next == 0) iovec[1].iov_base = (
char *)
"\n";
183 iovec[0].iov_base = tp->
text;
184 iovec[0].iov_len = strlen(tp->
text);
185 do {rc =
writev(xfd, (
const struct iovec *)iovec, 2);}
186 while(rc < 0 && errno == EINTR);
188 {
eDest->
Emsg(
"Log", errno,
"write prep log file", buff);
198 strcpy(blink, LogDir);
200 if (symlink((
const char *)buff, (
const char *)blink))
201 {
eDest->
Emsg(
"Log", errno,
"create symlink to prep log file", buff);
int open(const char *path, int oflag,...)
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt)
References close, eDest, XrdSysError::Emsg(), XrdOucTList::next, open(), XrdXrootdPrepArgs::paths, XrdXrootdPrepArgs::prty, XrdXrootdPrepArgs::reqid, strlcpy(), XrdOucTList::text, XrdXrootdPrepArgs::user, and writev().
◆ Logdel()
void XrdXrootdPrepare::Logdel |
( |
char * |
reqid | ) |
|
|
static |
Definition at line 210 of file XrdXrootdPrepare.cc.
213 char path[MAXPATHLEN+256], buff[MAXPATHLEN+1];
217 if (!LogDir || strlen(reqid) > 255)
return;
221 strcpy(path, (
const char *)LogDir);
222 strcpy(&path[LogDirLen], (
const char *)reqid);
226 if ((rc = readlink((
const char *)path, buff,
sizeof(buff)-1)) < 0)
227 {
if (errno != ENOENT) eDest->
Emsg(
"Logdel",errno,
"read symlink",path);
234 if (
unlink((
const char *)buff)
235 && errno != ENOENT) eDest->
Emsg(
"Logdel",errno,
"remove",buff);
237 if (
unlink((
const char *)path)
238 && errno != ENOENT) eDest->
Emsg(
"Logdel", errno,
"remove", path);
int unlink(const char *path)
References DEBUG, eDest, XrdSysError::Emsg(), TRACE, and unlink().
◆ Open()
int XrdXrootdPrepare::Open |
( |
const char * |
reqid, |
|
|
int & |
fsz |
|
) |
| |
|
static |
Definition at line 246 of file XrdXrootdPrepare.cc.
249 char path[MAXPATHLEN+264];
254 if (!LogDir)
return -ENOTSUP;
258 strcpy(path, (
const char *)LogDir);
259 strcpy(path+LogDirLen, reqid);
263 if ((fd =
open((
const char *)path, O_RDONLY)) < 0)
return -errno;
267 if (
fstat(fd, &buf) != 0) {
int fstat(int fildes, struct stat *buf)
References close, fstat(), open(), and stat().
◆ Scrub()
void XrdXrootdPrepare::Scrub |
( |
| ) |
|
|
static |
Definition at line 281 of file XrdXrootdPrepare.cc.
284 time_t stale = time(0) - scrubkeep;
285 char *up, path[2048], *fn = path+LogDirLen;
295 if (!(prepD =
opendir((
const char *)LogDir)))
296 {
eDest->
Emsg(
"Scrub", errno,
"open prep log directory", LogDir);
299 strcpy(path, (
const char *)LogDir);
305 {
if (!(up = (
char *) index((
const char *)dp->d_name,
'_')))
continue;
306 strcpy(fn, (
const char *)dp->d_name);
307 if (
stat((
const char *)path, &buf))
continue;
308 if (buf.st_mtime <= stale)
309 {
TRACE(
DEBUG,
"Scrub removed stale prep log " <<path);
310 unlink((
const char *)path);
311 *(fn+(up-dp->d_name)) =
'\0';
312 unlink((
const char *)path);
320 eDest->
Emsg(
"List", errno,
"read prep log directory", LogDir);
References closedir(), DEBUG, eDest, XrdSysError::Emsg(), opendir(), readdir(), stat(), TRACE, and unlink().
Referenced by DoIt().
◆ setParms() [1/2]
int XrdXrootdPrepare::setParms |
( |
char * |
ldir | ) |
|
|
static |
Definition at line 334 of file XrdXrootdPrepare.cc.
346 if (
access((
const char *)ldir, X_OK | W_OK | R_OK) ||
stat(ldir, &buf))
348 if ((buf.st_mode & S_IFMT) != S_IFDIR)
return -ENOTDIR;
352 if (LogDir) free(LogDir);
356 if (path[plen-1] !=
'/') path[plen++] =
'/';
361 LogDir = strdup(path);
362 LogDirLen = strlen(LogDir);
int access(const char *path, int amode)
References access(), and stat().
◆ setParms() [2/2]
int XrdXrootdPrepare::setParms |
( |
int |
stime, |
|
|
int |
skeep |
|
) |
| |
|
static |
Definition at line 328 of file XrdXrootdPrepare.cc.
329 {
if (stime > 0) scrubtime = stime;
330 if (keep > 0) scrubkeep = keep;
The documentation for this class was generated from the following files: