Definition at line 27 of file XrdPfcBlacklistDecision.cc.
◆ BlacklistDecision()
BlacklistDecision::BlacklistDecision |
( |
XrdSysError & |
log | ) |
|
|
inline |
◆ ConfigDecision()
virtual bool BlacklistDecision::ConfigDecision |
( |
const char * |
params | ) |
|
|
inlinevirtual |
Parse configuration arguments.
- Parameters
-
params | configuration parameters |
- Returns
- status of configuration
Reimplemented from XrdPfc::Decision.
Definition at line 53 of file XrdPfcBlacklistDecision.cc.
54{
55 if (! parms || ! parms[0] || (strlen(parms) == 0))
56 {
57 m_log.
Emsg(
"ConfigDecision",
"Blacklist file not specified.");
58 return false;
59 }
60 m_log.
Emsg(
"ConfigDecision",
"Using blacklist", parms);
61 FILE * fp =
fopen(parms,
"r");
62 if (fp == 0)
63 {
64 m_log.
Emsg(
"ConfigDecision", errno,
"Failed to open blacklist:", parms);
65 return false;
66 }
67
68 char line[4096];
69 while(fgets(line, sizeof(line), fp))
70 {
71 char *trimmed = line;
72 while (trimmed[0] && isspace(trimmed[0])) {trimmed++; }
73 if (trimmed[0] == 0) {continue; }
74 size_t filelen = strlen(trimmed);
75 if (trimmed[filelen-1] == '\n') {trimmed[filelen-1] = '\0'; }
76 m_blacklist.push_back(trimmed);
77 }
78 if (! feof(fp))
79 {
80 m_log.
Emsg(
"ConfigDecision", errno,
"Failed to parse blacklist");
81 }
83 for (std::vector<std::string>::const_iterator it = m_blacklist.begin(); it!=m_blacklist.end(); it++)
84 {
85 m_log.
Emsg(
"ConfigDecision",
"Cache is blacklisting paths matching", it->c_str());
86 }
87 return true;
88}
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
References XrdSysError::Emsg(), fclose(), and fopen.
◆ Decide()
virtual bool BlacklistDecision::Decide |
( |
const std::string & |
lfn, |
|
|
XrdOss & |
|
|
) |
| const |
|
inlinevirtual |
A decision library that allows all files to be cached except for a blacklist.
Implements XrdPfc::Decision.
Definition at line 34 of file XrdPfcBlacklistDecision.cc.
35{
36
37 for (std::vector<std::string>::const_iterator it = m_blacklist.begin(); it != m_blacklist.end(); it++)
38 {
39 if (! fnmatch(it->c_str(), lfn.c_str(), FNM_PATHNAME))
40 {
41
42 return false;
43 }
44 }
45
46 return true;
47}
The documentation for this class was generated from the following file: