From 737a2802e9207fb53f598ef88c0ce1f9ad27a348 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 20 Nov 2011 19:00:00 -0500 Subject: [PATCH] Linux: 3.2: Use set_nlink to update i_nlink As of v3.2-rc1~84^2~1, struct inode.i_nlink is now const to prevent direct modification. Signed-off-by: Anders Kaseorg Reviewed-on: http://gerrit.openafs.org/6096 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit f1dd2d696fb9ab71b4192b156042e0c63019c58a) Change-Id: I685aa6e8638e8fe864f1a6a7e428dfb6839ebcea Reviewed-on: http://gerrit.openafs.org/6099 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- acinclude.m4 | 1 + src/afs/LINUX/osi_vfsops.c | 4 ++++ src/cf/linux-test4.m4 | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index c5cf9495ee..f09fbb2d33 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -943,6 +943,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_REGISTER_SYSCTL_TABLE_NOFLAG LINUX_HAVE_DCACHE_LOCK LINUX_D_COUNT_IS_INT + LINUX_HAVE_SET_NLINK dnl If we are guaranteed that keyrings will work - that is dnl a) The kernel has keyrings enabled diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index 596d0644f0..d32720f5cc 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -439,7 +439,11 @@ void vattr2inode(struct inode *ip, struct vattr *vp) { ip->i_ino = vp->va_nodeid; +#ifdef HAVE_SET_NLINK + set_nlink(ip, vp->va_nlink); +#else ip->i_nlink = vp->va_nlink; +#endif ip->i_blocks = vp->va_blocks; #ifdef STRUCT_INODE_HAS_I_BLKBITS ip->i_blkbits = AFS_BLKBITS; diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 3d3aa8f4b4..f10ea47996 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -618,3 +618,15 @@ AC_DEFUN([LINUX_DOP_D_DELETE_TAKES_CONST], [ [define if dentry.d_op->d_delete takes a const argument], [-Werror]) ]) + + +AC_DEFUN([LINUX_HAVE_SET_NLINK], [ + AC_CHECK_LINUX_BUILD([for set_nlink], + [ac_cv_linux_have_set_nlink], + [#include ], + [struct inode _inode; + set_nlink(&_inode, 1);], + [HAVE_SET_NLINK], + [define if set_nlink exists], + [-Werror]) +])