Linux 3.6: dentry_open API change
authorMarc Dionne <marc.c.dionne@gmail.com>
Tue, 14 Aug 2012 01:36:15 +0000 (21:36 -0400)
committerDerrick Brashear <shadow@dementix.org>
Fri, 17 Aug 2012 05:29:37 +0000 (22:29 -0700)
dentry_open now takes a path argument that combines the dentry and
the vfsmount pointers.
Add a configure test and a new compat inline function to keep things
cleaner in the main source file.

Change-Id: Ia29422d60d438cf4c795840566d4610649aa1f10
Reviewed-on: http://gerrit.openafs.org/7982
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

acinclude.m4
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_file.c
src/cf/linux-test4.m4

index 45026da..260c754 100644 (file)
@@ -976,6 +976,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 LINUX_IOP_CREATE_TAKES_UMODE_T
                 LINUX_EXPORT_OP_ENCODE_FH_TAKES_INODES
                 LINUX_KMAP_ATOMIC_TAKES_NO_KM_TYPE
+                LINUX_DENTRY_OPEN_TAKES_PATH
 
                 dnl If we are guaranteed that keyrings will work - that is
                 dnl  a) The kernel has keyrings enabled
index 52c4d2d..a4b83a1 100644 (file)
@@ -498,4 +498,20 @@ afs_get_dentry_ref(struct path *path, struct vfsmount **mnt, struct dentry **dpp
 })
 #endif
 
+#if defined(STRUCT_TASK_STRUCT_HAS_CRED)
+static inline struct file *
+afs_dentry_open(struct dentry *dp, struct vfsmount *mnt, int flags, const struct cred *creds) {
+#if defined(DENTRY_OPEN_TAKES_PATH)
+    struct path path;
+    struct file *filp;
+    path.mnt = mnt;
+    path.dentry = dp;
+    filp = dentry_open(&path, flags, creds);
+    return filp;
+#else
+    return dentry_open(dp, mntget(mnt), flags, creds);
+#endif
+}
+#endif
+
 #endif /* AFS_LINUX_OSI_COMPAT_H */
index 2e57fbb..eacffca 100644 (file)
@@ -56,9 +56,9 @@ afs_linux_raw_open(afs_dcache_id_t *ainode)
 
 #if defined(STRUCT_TASK_STRUCT_HAS_CRED)
     /* Use stashed credentials - prevent selinux/apparmor problems  */
-    filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, cache_creds);
+    filp = afs_dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, cache_creds);
     if (IS_ERR(filp))
-       filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred());
+       filp = afs_dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred());
 #else
     filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR);
 #endif
index fefa40e..6c1ae52 100644 (file)
@@ -677,3 +677,15 @@ AC_DEFUN([LINUX_KMAP_ATOMIC_TAKES_NO_KM_TYPE], [
                        [define if kmap_atomic takes no km_type argument],
                        [-Werror])
 ])
+
+
+AC_DEFUN([LINUX_DENTRY_OPEN_TAKES_PATH], [
+  AC_CHECK_LINUX_BUILD([whether dentry_open takes a path argument],
+                       [ac_cv_linux_dentry_open_takes_path],
+                       [#include <linux/fs.h>],
+                       [struct path p;
+                       dentry_open(&p, 0, NULL);],
+                       [DENTRY_OPEN_TAKES_PATH],
+                       [define if dentry_open takes a path argument],
+                       [-Werror])
+])