capability: add cap_isidentical

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Mateusz Guzik 2023-01-25 16:55:56 +01:00 committed by Linus Torvalds
parent 103830683c
commit a4eecbae09
1 changed files with 10 additions and 0 deletions

View File

@ -157,6 +157,16 @@ static inline bool cap_isclear(const kernel_cap_t a)
return true;
}
static inline bool cap_isidentical(const kernel_cap_t a, const kernel_cap_t b)
{
unsigned __capi;
CAP_FOR_EACH_U32(__capi) {
if (a.cap[__capi] != b.cap[__capi])
return false;
}
return true;
}
/*
* Check if "a" is a subset of "set".
* return true if ALL of the capabilities in "a" are also in "set"