mirror of
https://github.com/ceph/ceph
synced 2024-12-17 17:05:42 +00:00
cls: add a filter to the hello class for testing
Signed-off-by: John Spray <john.spray@redhat.com>
This commit is contained in:
parent
e749b214e7
commit
60d51fc4a9
@ -258,6 +258,35 @@ static int bad_writer(cls_method_context_t hctx, bufferlist *in, bufferlist *out
|
||||
}
|
||||
|
||||
|
||||
class PGLSHelloFilter : public PGLSFilter {
|
||||
string val;
|
||||
public:
|
||||
PGLSHelloFilter(bufferlist::iterator& params) {
|
||||
::decode(xattr, params);
|
||||
::decode(val, params);
|
||||
}
|
||||
virtual ~PGLSHelloFilter() {}
|
||||
virtual bool filter(const hobject_t &obj, bufferlist& xattr_data,
|
||||
bufferlist& outdata)
|
||||
{
|
||||
if (val.size() != xattr_data.length())
|
||||
return false;
|
||||
|
||||
if (memcmp(val.c_str(), xattr_data.c_str(), val.size()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
PGLSFilter *hello_filter(bufferlist::iterator *q)
|
||||
{
|
||||
assert(q);
|
||||
return new PGLSHelloFilter(*q);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initialize class
|
||||
*
|
||||
@ -304,4 +333,7 @@ void __cls_init()
|
||||
bad_reader, &h_bad_reader);
|
||||
cls_register_cxx_method(h_class, "bad_writer", CLS_METHOD_RD,
|
||||
bad_writer, &h_bad_writer);
|
||||
|
||||
// A PGLS filter
|
||||
cls_register_cxx_filter(h_class, "hello", hello_filter);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user