lkml.org 
[lkml]   [2015]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] CAPABILITIES: add cap_isequal helper
Date
Can be used to determine whether two given sets have the same
capabilities.

Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
---
include/linux/capability.h | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/include/linux/capability.h b/include/linux/capability.h
index af9f0b9..2fcf941 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -155,6 +155,16 @@ static inline int cap_isclear(const kernel_cap_t a)
return 1;
}

+static inline int cap_isequal(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 0;
+ }
+ return 1;
+}
+
/*
* Check if "a" is a subset of "set".
* return 1 if ALL of the capabilities in "a" are also in "set"
--
1.8.3.1


\
 
 \ /
  Last update: 2015-03-09 21:41    [W:0.071 / U:0.580 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site