Whamcloud - gitweb
b=20722 Fix watchdog timer messages to be more clear.
[fs/lustre-release.git] / libcfs / libcfs / linux / linux-curproc.c
index deb0f36..be37723 100644 (file)
@@ -16,8 +16,8 @@
  * in the LICENSE file that accompanied this code).
  *
  * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
@@ -120,14 +120,55 @@ char  *cfs_curproc_comm(void)
         return current->comm;
 }
 
-cfs_kernel_cap_t cfs_curproc_cap_get(void)
+/* Currently all the CFS_CAP_* defines match CAP_* ones. */
+#define cfs_cap_pack(cap) (cap)
+#define cfs_cap_unpack(cap) (cap)
+
+void cfs_cap_raise(cfs_cap_t cap)
 {
-        return current->cap_effective;
+        cap_raise(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+}
+
+void cfs_cap_lower(cfs_cap_t cap)
+{
+        cap_lower(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+}
+
+int cfs_cap_raised(cfs_cap_t cap)
+{
+        return cap_raised(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+}
+
+cfs_cap_t cfs_curproc_cap_pack(void)
+{
+#if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330
+        return cfs_cap_pack(current->cap_effective);
+#elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026
+        return cfs_cap_pack(current->cap_effective[0]);
+#elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522
+        /* XXX lost high byte */
+        return cfs_cap_pack(current->cap_effective.cap[0]);
+#else
+        #error "need correct _KERNEL_CAPABILITY_VERSION "
+#endif
+}
+
+void cfs_curproc_cap_unpack(cfs_cap_t cap)
+{
+#if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330
+        current->cap_effective = cfs_cap_unpack(cap);
+#elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026
+        current->cap_effective[0] = cfs_cap_unpack(cap);
+#elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522
+        current->cap_effective.cap[0] = cfs_cap_unpack(cap);
+#else
+        #error "need correct _KERNEL_CAPABILITY_VERSION "
+#endif
 }
 
-void cfs_curproc_cap_set(cfs_kernel_cap_t cap)
+int cfs_capable(cfs_cap_t cap)
 {
-        current->cap_effective = cap;
+        return capable(cfs_cap_unpack(cap));
 }
 
 EXPORT_SYMBOL(cfs_curproc_uid);
@@ -140,8 +181,12 @@ EXPORT_SYMBOL(cfs_curproc_comm);
 EXPORT_SYMBOL(cfs_curproc_groups_nr);
 EXPORT_SYMBOL(cfs_curproc_groups_dump);
 EXPORT_SYMBOL(cfs_curproc_is_in_groups);
-EXPORT_SYMBOL(cfs_curproc_cap_get);
-EXPORT_SYMBOL(cfs_curproc_cap_set);
+EXPORT_SYMBOL(cfs_cap_raise);
+EXPORT_SYMBOL(cfs_cap_lower);
+EXPORT_SYMBOL(cfs_cap_raised);
+EXPORT_SYMBOL(cfs_curproc_cap_pack);
+EXPORT_SYMBOL(cfs_curproc_cap_unpack);
+EXPORT_SYMBOL(cfs_capable);
 
 /*
  * Local variables: