Commit 26898fdf authored by Aristeu Rozanski's avatar Aristeu Rozanski Committed by Tejun Heo

devcg: expand may_access() logic

In order to make the next patch more clear, expand may_access() logic.

v2: may_access() returns bool now
Acked-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: default avatarAristeu Rozanski <aris@redhat.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 3ac1707a
...@@ -305,7 +305,7 @@ static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft, ...@@ -305,7 +305,7 @@ static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft,
* @dev_cgroup: dev cgroup to be tested against * @dev_cgroup: dev cgroup to be tested against
* @refex: new exception * @refex: new exception
*/ */
static int may_access(struct dev_cgroup *dev_cgroup, static bool may_access(struct dev_cgroup *dev_cgroup,
struct dev_exception_item *refex) struct dev_exception_item *refex)
{ {
struct dev_exception_item *ex; struct dev_exception_item *ex;
...@@ -332,16 +332,19 @@ static int may_access(struct dev_cgroup *dev_cgroup, ...@@ -332,16 +332,19 @@ static int may_access(struct dev_cgroup *dev_cgroup,
/* /*
* In two cases we'll consider this new exception valid: * In two cases we'll consider this new exception valid:
* - the dev cgroup has its default policy to allow + exception list:
* the new exception should *not* match any of the exceptions
* (behavior == DEVCG_DEFAULT_ALLOW, !match)
* - the dev cgroup has its default policy to deny + exception list: * - the dev cgroup has its default policy to deny + exception list:
* the new exception *should* match the exceptions * the new exception *should* match the exceptions
* (behavior == DEVCG_DEFAULT_DENY, match) * - the dev cgroup has its default policy to allow + exception list:
* the new exception should *not* match any of the exceptions
*/ */
if ((dev_cgroup->behavior == DEVCG_DEFAULT_DENY) == match) if (dev_cgroup->behavior == DEVCG_DEFAULT_DENY) {
return 1; if (match)
return 0; return true;
} else {
if (!match)
return true;
}
return false;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment