capability: add cap_isidentical
authorMateusz Guzik <mjguzik@gmail.com>
Wed, 25 Jan 2023 15:55:56 +0000 (16:55 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Feb 2023 00:39:19 +0000 (16:39 -0800)
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>
include/linux/capability.h

index 03c2a61..d3c6c2d 100644 (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"