-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompareXAttributeTask.php
71 lines (64 loc) · 1.64 KB
/
CompareXAttributeTask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Aternos\Rados\Operation\Common\Task;
use Aternos\Rados\Constants\XAttributeComparisonOperator;
use Aternos\Rados\Operation\Common\CommonOperationTask;
use Aternos\Rados\Operation\Operation;
/**
* Ensure that given xattr satisfies comparison,
* with the supplied value on the left hand side (i.e.
* for OP_LT, the comparison is value < actual_value)
*
* If the comparison is not satisfied, the return code of the
* operation will be -ECANCELED
*
* @extends CommonOperationTask<null>
*/
class CompareXAttributeTask extends CommonOperationTask
{
/**
* @param string $name
* @param string $value
* @param XAttributeComparisonOperator $operator
*/
public function __construct(
protected string $name,
protected string $value,
protected XAttributeComparisonOperator $operator = XAttributeComparisonOperator::Equal
)
{
}
/**
* @inheritDoc
*/
protected function parseResult(): null
{
return null;
}
/**
* @inheritDoc
*/
protected function initTask(Operation $operation): void
{
$operation->getFFI()->{$this->getFunctionName($operation)}(
$operation->getCData(),
$this->name,
$this->operator->getCValue($operation->getFFI()),
$this->value,
strlen($this->value)
);
}
/**
* @inheritDoc
*/
protected function getReadFunctionName(): string
{
return "rados_read_op_cmpxattr";
}
/**
* @inheritDoc
*/
protected function getWriteFunctionName(): string
{
return "rados_write_op_cmpxattr";
}
}