Definition at line 29 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 55 of file XrdPfcBlacklistDecision.cc.
56{
57 if (! parms || ! parms[0] || (strlen(parms) == 0))
58 {
59 m_log.
Emsg(
"ConfigDecision",
"Blacklist file not specified.");
60 return false;
61 }
62 m_log.
Emsg(
"ConfigDecision",
"Using blacklist", parms);
63 FILE * fp =
fopen(parms,
"r");
64 if (fp == 0)
65 {
66 m_log.
Emsg(
"ConfigDecision", errno,
"Failed to open blacklist:", parms);
67 return false;
68 }
69
70 char line[4096];
71 while(fgets(line, sizeof(line), fp))
72 {
73 char *trimmed = line;
74 while (trimmed[0] && isspace(trimmed[0])) {trimmed++; }
75 if (trimmed[0] == 0) {continue; }
76 size_t filelen = strlen(trimmed);
77 if (trimmed[filelen-1] == '\n') {trimmed[filelen-1] = '\0'; }
78 m_blacklist.push_back(trimmed);
79 }
80 if (! feof(fp))
81 {
82 m_log.
Emsg(
"ConfigDecision", errno,
"Failed to parse blacklist");
83 }
85 for (std::vector<std::string>::const_iterator it = m_blacklist.begin(); it!=m_blacklist.end(); it++)
86 {
87 m_log.
Emsg(
"ConfigDecision",
"Cache is blacklisting paths matching", it->c_str());
88 }
89 return true;
90}
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 36 of file XrdPfcBlacklistDecision.cc.
37{
38
39 for (std::vector<std::string>::const_iterator it = m_blacklist.begin(); it != m_blacklist.end(); it++)
40 {
41 if (! fnmatch(it->c_str(), lfn.c_str(), FNM_PATHNAME))
42 {
43
44 return false;
45 }
46 }
47
48 return true;
49}
The documentation for this class was generated from the following file: