From 1c8e07a6e09d25d1f3dc63b4af8f7267eabe34ee Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Mon, 6 Jul 2015 13:01:38 -0300 Subject: [PATCH 5/6] Linux 4.2: Changes in link operation APIs The follow_link and put_link operations are revised. Test for the new signature and adapt the code. Reviewed-on: http://gerrit.openafs.org/11928 Tested-by: BuildBot Reviewed-by: Jeffrey Altman (cherry picked from commit 6c3ac6dc1ea865153a65b5c5c4f288617a3e6d0f) Change-Id: I779fe8a29ec75a5db545b5d370927b810c1165c9 Reviewed-on: http://gerrit.openafs.org/11951 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Stephan Wiesand (cherry picked from commit b93da6f3e99735ef2584fb172d028284bb581011) --- acinclude.m4 | 10 ++++++++++ src/afs/LINUX/osi_vnodeops.c | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index c924d90..e9e84a7f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -845,6 +845,16 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_KBUILD_USES_EXTRA_CFLAGS LINUX_KERNEL_COMPILE_WORKS + dnl Operation signature checks + AC_CHECK_LINUX_OPERATION([inode_operations], [follow_link], [no_nameidata], + [#include ], + [const char *], + [struct dentry *dentry, void **link_data]) + AC_CHECK_LINUX_OPERATION([inode_operations], [put_link], [no_nameidata], + [#include ], + [void], + [struct inode *inode, void *link_data]) + dnl Check for header files AC_CHECK_LINUX_HEADER([config.h]) AC_CHECK_LINUX_HEADER([completion.h]) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index a878eb4..3c0cb33 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1896,14 +1896,22 @@ afs_linux_readlink(struct dentry *dp, char *target, int maxlen) /* afs_linux_follow_link * a file system dependent link following routine. */ +#if defined(HAVE_LINUX_INODE_OPERATIONS_FOLLOW_LINK_NO_NAMEIDATA) +static const char *afs_linux_follow_link(struct dentry *dentry, void **link_data) +#else static int afs_linux_follow_link(struct dentry *dentry, struct nameidata *nd) +#endif { int code; char *name; name = kmalloc(PATH_MAX, GFP_NOFS); if (!name) { +#if defined(HAVE_LINUX_INODE_OPERATIONS_FOLLOW_LINK_NO_NAMEIDATA) + return ERR_PTR(-EIO); +#else return -EIO; +#endif } AFS_GLOCK(); @@ -1911,14 +1919,32 @@ static int afs_linux_follow_link(struct dentry *dentry, struct nameidata *nd) AFS_GUNLOCK(); if (code < 0) { +#if defined(HAVE_LINUX_INODE_OPERATIONS_FOLLOW_LINK_NO_NAMEIDATA) + return ERR_PTR(code); +#else return code; +#endif } name[code] = '\0'; +#if defined(HAVE_LINUX_INODE_OPERATIONS_FOLLOW_LINK_NO_NAMEIDATA) + return *link_data = name; +#else nd_set_link(nd, name); return 0; +#endif } +#if defined(HAVE_LINUX_INODE_OPERATIONS_PUT_LINK_NO_NAMEIDATA) +static void +afs_linux_put_link(struct inode *inode, void *link_data) +{ + char *name = link_data; + + if (name && !IS_ERR(name)) + kfree(name); +} +#else static void afs_linux_put_link(struct dentry *dentry, struct nameidata *nd) { @@ -1927,6 +1953,7 @@ afs_linux_put_link(struct dentry *dentry, struct nameidata *nd) if (name && !IS_ERR(name)) kfree(name); } +#endif /* HAVE_LINUX_INODE_OPERATIONS_PUT_LINK_NO_NAMEIDATA */ #endif /* USABLE_KERNEL_PAGE_SYMLINK_CACHE */ -- 2.5.1