Skyld AV  0.6
On access virus scanning for Linux
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
ScanCache Class Reference

Cache for virus scanning results. More...

#include <ScanCache.h>

Collaboration diagram for ScanCache:
Collaboration graph

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...
 
Environmente
 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...
 

Detailed Description

Cache for virus scanning results.

The scan results are kept in two data structures:

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.

Constructor & Destructor Documentation

ScanCache::ScanCache ( Environment env)

Creates cache for virus scan results.

Parameters
envenvironment

Definition at line 34 of file ScanCache.cc.

Here is the call graph for this function:

ScanCache::~ScanCache ( )
virtual

Definition at line 187 of file ScanCache.cc.

Here is the call graph for this function:

ScanCache::ScanCache ( const ScanCache )
private

Member Function Documentation

void ScanCache::add ( const struct stat *  stat,
const unsigned int  response 
)

Adds scan result to cache.

Parameters
statFile status as returned by fstat()
responseResponse to be used for fanotify (FAN_ALLOW, FAN_DENY)

Definition at line 50 of file ScanCache.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void ScanCache::clear ( )

Removes all entries from the cache.

Definition at line 104 of file ScanCache.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int ScanCache::get ( const struct stat *  stat)

Adds scan result to cache.

Parameters
statfile status as returned by fstat()
Returns
response to be used for fanotify (FAN_ALLOW, FAN_DENY) or CACHE_MISS

Definition at line 123 of file ScanCache.cc.

Here is the caller graph for this function:

void ScanCache::remove ( const struct stat *  stat)

Remove scan result from cache.

Parameters
statfile status as returned by fstat()

Definition at line 168 of file ScanCache.cc.

Here is the caller graph for this function:

Member Data Documentation

const unsigned int ScanCache::CACHE_MISS = 0xfffd
static

No matching element found in cache.

Definition at line 113 of file ScanCache.h.

Environment* ScanCache::e
private

Environment.

Definition at line 132 of file ScanCache.h.

unsigned long long ScanCache::hits
private

Number of cache hits.

Definition at line 140 of file ScanCache.h.

unsigned long long ScanCache::misses
private

Number of cache misses.

Definition at line 136 of file ScanCache.h.

pthread_mutex_t ScanCache::mutex
private

Mutex used when reading from or writing to the cache.

Definition at line 128 of file ScanCache.h.

ScanResult ScanCache::root
private

Root for double linked list.

Definition at line 144 of file ScanCache.h.

std::set<ScanResult *, ScanResultComperator>* ScanCache::s
private

Cache data set.

Definition at line 124 of file ScanCache.h.


The documentation for this class was generated from the following files: