diff --git a/acinclude.m4 b/acinclude.m4 index 51f2f6d2d1..1f3e498122 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -848,6 +848,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) AC_CHECK_LINUX_FUNC([pagevec_lru_add_file], [#include ], [__pagevec_lru_add_file(NULL);]) + AC_CHECK_LINUX_FUNC([path_lookup], + [#include ], + [path_lookup(NULL, 0, NULL);]) AC_CHECK_LINUX_FUNC([rcu_read_lock], [#include ], [rcu_read_lock();]) diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index cee3ade6f2..e4f0735a8d 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -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 */ diff --git a/src/afs/LINUX/osi_misc.c b/src/afs/LINUX/osi_misc.c index 79fa763127..1158304aba 100644 --- a/src/afs/LINUX/osi_misc.c +++ b/src/afs/LINUX/osi_misc.c @@ -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; }