Skyld AV
0.6
On access virus scanning for Linux
|
Cache for virus scanning results. More...
#include <ScanCache.h>
Public Member Functions | |
ScanCache (Environment *) | |
void | add (const struct stat *, const unsigned int) |
Adds scan result to cache. More... | |
void | clear () |
Removes all entries from the cache. More... | |
int | get (const struct stat *) |
Adds scan result to cache. More... | |
void | remove (const struct stat *) |
Remove scan result from cache. More... | |
virtual | ~ScanCache () |
Static Public Attributes | |
static const unsigned int | CACHE_MISS = 0xfffd |
No matching element found in cache. More... | |
Private Member Functions | |
ScanCache (const ScanCache &) | |
Private Attributes | |
std::set< ScanResult *, ScanResultComperator > * | s |
pthread_mutex_t | mutex |
Mutex used when reading from or writing to the cache. More... | |
Environment * | e |
Environment. More... | |
unsigned long long | misses |
Number of cache misses. More... | |
unsigned long long | hits |
Number of cache hits. More... | |
ScanResult | root |
Root for double linked list. More... | |
Cache for virus scanning results.
The scan results are kept in two data structures:
root
as left and right end The linked list is used for implementing a LRU (least recently used) strategy. Accessed entries are brought to the * left end of the double linked list. When the cache exceeds its maximum size the rightmost element is eliminated.
The set is used to find a scan result in O(log(n)) time.
Definition at line 108 of file ScanCache.h.
ScanCache::ScanCache | ( | Environment * | env | ) |
Creates cache for virus scan results.
env | environment |
Definition at line 34 of file ScanCache.cc.
|
virtual |
|
private |
void ScanCache::add | ( | const struct stat * | stat, |
const unsigned int | response | ||
) |
Adds scan result to cache.
stat | File status as returned by fstat() |
response | Response to be used for fanotify (FAN_ALLOW, FAN_DENY) |
Definition at line 50 of file ScanCache.cc.
void ScanCache::clear | ( | ) |
Removes all entries from the cache.
Definition at line 104 of file ScanCache.cc.
int ScanCache::get | ( | const struct stat * | stat | ) |
Adds scan result to cache.
stat | file status as returned by fstat() |
Definition at line 123 of file ScanCache.cc.
void ScanCache::remove | ( | const struct stat * | stat | ) |
Remove scan result from cache.
stat | file status as returned by fstat() |
Definition at line 168 of file ScanCache.cc.
|
static |
No matching element found in cache.
Definition at line 113 of file ScanCache.h.
|
private |
Definition at line 132 of file ScanCache.h.
|
private |
Number of cache hits.
Definition at line 140 of file ScanCache.h.
|
private |
Number of cache misses.
Definition at line 136 of file ScanCache.h.
|
private |
Mutex used when reading from or writing to the cache.
Definition at line 128 of file ScanCache.h.
|
private |
Root for double linked list.
Definition at line 144 of file ScanCache.h.
|
private |
Cache data set.
Definition at line 124 of file ScanCache.h.