cas_cache: Generic classifier for string conditions.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
5603a77302
commit
e36c8c53c6
@ -185,6 +185,34 @@ error:
|
||||
return result;
|
||||
}
|
||||
|
||||
/* String condition constructor. @data is expected to contain string
|
||||
* to be matched. */
|
||||
static int _cas_cls_string_ctr(struct cas_classifier *cls,
|
||||
struct cas_cls_condition *c, char *data)
|
||||
{
|
||||
struct cas_cls_string *ctx;
|
||||
|
||||
if (!data || strlen(data) == 0) {
|
||||
CAS_CLS_MSG(KERN_ERR, "Missing string specifier\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (strlen(data) > MAX_STRING_SPECIFIER_LEN) {
|
||||
CAS_CLS_MSG(KERN_ERR, "String specifier to long: %s\n", data);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
|
||||
if (!ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
strcpy(ctx->string, data);
|
||||
|
||||
c->context = ctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unsigned int numeric test function */
|
||||
static cas_cls_eval_t _cas_cls_numeric_test_u(
|
||||
struct cas_cls_condition *c, uint64_t val)
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef __CLASSIFIER_DEFS_H__
|
||||
#define __CLASSIFIER_DEFS_H__
|
||||
|
||||
#define MAX_STRING_SPECIFIER_LEN 256
|
||||
|
||||
/* Rule matches 1:1 with io class. It contains multiple conditions with
|
||||
* associated logical operator (and/or) */
|
||||
struct cas_cls_rule {
|
||||
@ -118,6 +120,12 @@ struct cas_cls_numeric {
|
||||
uint64_t v_u64;
|
||||
};
|
||||
|
||||
/* String condition context */
|
||||
struct cas_cls_string {
|
||||
/* String specifier*/
|
||||
char string[MAX_STRING_SPECIFIER_LEN];
|
||||
};
|
||||
|
||||
/* Directory condition context */
|
||||
struct cas_cls_directory {
|
||||
/* 1 if directory had been resolved */
|
||||
|
Loading…
Reference in New Issue
Block a user