[Ocfs2-devel] [PATCH 19/30] ocfs2: Handle missing macro is_owner_or_cap()

Sunil Mushran sunil.mushran at oracle.com
Mon Dec 31 14:24:11 PST 2007


Commit 3bd858ab1c451725c07a805dcb315215dc85b86e in mainline introduces
helper macro is_owner_or_cap(). This patch allows one to build ocfs2 with
kernels having/not having this change.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
 Makefile                  |    3 ++-
 configure.in              |    5 +++++
 kapi-compat/include/cap.h |    7 +++++++
 3 files changed, 14 insertions(+), 1 deletions(-)
 create mode 100644 kapi-compat/include/cap.h

diff --git a/Makefile b/Makefile
index 1807eac..cb395cc 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,8 @@ KAPI_COMPAT_FILES = \
 	kapi-compat/include/configfs.h \
 	kapi-compat/include/register_sysctl.h \
 	kapi-compat/include/su_mutex.h \
-	kapi-compat/include/kobject.h
+	kapi-compat/include/kobject.h \
+	kapi-compat/include/cap.h
 
 PATCH_FILES =
 
diff --git a/configure.in b/configure.in
index 3ea990f..c1525a6 100644
--- a/configure.in
+++ b/configure.in
@@ -243,6 +243,11 @@ OCFS2_CHECK_KERNEL([struct subsystem in kobject.h], kobject.h,
 AC_SUBST(STRUCT_SUBSYSTEM_DEFINED)
 KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS kobject.h"
 
+cap_compat_header=""
+OCFS2_CHECK_KERNEL([is_owner_or_cap() in fs.h], fs.h,
+  , cap_compat_header="cap.h", [^#define is_owner_or_cap])
+KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $cap_compat_header"
+
 # using -include has two advantages:
 #  the source doesn't need to know to include compat headers
 #  the compat header file names don't go through the search path
diff --git a/kapi-compat/include/cap.h b/kapi-compat/include/cap.h
new file mode 100644
index 0000000..a10a12f
--- /dev/null
+++ b/kapi-compat/include/cap.h
@@ -0,0 +1,7 @@
+#ifndef KAPI_CAP_H
+#define KAPI_CAP_H
+
+#define is_owner_or_cap(inode)  \
+	        ((current->fsuid == (inode)->i_uid) || capable(CAP_FOWNER))
+
+#endif
-- 
1.5.3.4




More information about the Ocfs2-devel mailing list