Linux: 2.6.39: replace path_lookup with kern_path
authorMarc Dionne <marc.c.dionne@gmail.com>
Sun, 27 Mar 2011 14:59:55 +0000 (10:59 -0400)
committerDerrick Brashear <shadow@dementia.org>
Mon, 28 Mar 2011 13:36:31 +0000 (06:36 -0700)
path_lookup is no longer available, use kern_path instead.

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

acinclude.m4
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_misc.c

index 9af652c..174f9c2 100644 (file)
@@ -847,6 +847,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 AC_CHECK_LINUX_FUNC([pagevec_lru_add_file],
                                     [#include <linux/pagevec.h>],
                                     [__pagevec_lru_add_file(NULL);])
+                AC_CHECK_LINUX_FUNC([path_lookup],
+                                    [#include <linux/namei.h>],
+                                    [path_lookup(NULL, 0, NULL);])
                 AC_CHECK_LINUX_FUNC([rcu_read_lock],
                                     [#include <linux/rcupdate.h>],
                                     [rcu_read_lock();])
index cee3ade..e4f0735 100644 (file)
@@ -403,4 +403,35 @@ afs_inode_setattr(struct osi_file *afile, struct iattr *newattrs) {
     return code;
 }
 
+static inline int
+afs_kern_path(char *aname, int flags, struct nameidata *nd, struct path *path) {
+#if defined(HAVE_LINUX_PATH_LOOKUP)
+    return path_lookup(aname, flags, nd);
+#else
+    return kern_path(aname, flags, path);
+#endif
+}
+
+static inline void
+afs_get_dentry_ref(struct nameidata *nd, struct path *path, struct vfsmount **mnt, struct dentry **dpp) {
+#if defined(STRUCT_NAMEIDATA_HAS_PATH)
+# if defined(HAVE_LINUX_PATH_LOOKUP)
+    *dpp = dget(nd->path.dentry);
+    if (mnt)
+       *mnt = mntget(nd->path.mnt);
+    path_put(&nd->path);
+# else
+    *dpp = dget(path->dentry);
+    if (mnt)
+       *mnt = mntget(path->mnt);
+    path_put(path);
+# endif
+#else
+    *dpp = dget(nd->dentry);
+    if (mnt)
+       *mnt = mntget(nd->mnt);
+    path_release(nd);
+#endif
+}
+
 #endif /* AFS_LINUX_OSI_COMPAT_H */
index 79fa763..1158304 100644 (file)
@@ -23,6 +23,8 @@
 #include "afsincludes.h"
 #include "afs/afs_stats.h"
 
+#include "osi_compat.h"
+
 int afs_osicred_initialized = 0;
 afs_ucred_t afs_osi_cred;
 
@@ -58,26 +60,17 @@ osi_lookupname_internal(char *aname, int followlink, struct vfsmount **mnt,
 {
     int code;
     struct nameidata nd;
+    struct path path;
     int flags = LOOKUP_POSITIVE;
     code = ENOENT;
 
     if (followlink)
        flags |= LOOKUP_FOLLOW;
-    code = path_lookup(aname, flags, &nd);
+    code = afs_kern_path(aname, flags, &nd, &path);
+
+    if (!code)
+       afs_get_dentry_ref(&nd, &path, mnt, dpp);
 
-    if (!code) {
-#if defined(STRUCT_NAMEIDATA_HAS_PATH)
-       *dpp = dget(nd.path.dentry);
-        if (mnt)
-           *mnt = mntget(nd.path.mnt);
-       path_put(&nd.path);
-#else
-       *dpp = dget(nd.dentry);
-        if (mnt)
-           *mnt = mntget(nd.mnt);
-       path_release(&nd);
-#endif
-    }
     return code;
 }