'struct inode' got changed in linux kernel 3.2.0. With the new change,
'i_nlink' attribute of the inode data structure was changed to a const
type. So, we can't directly access the i_nlink attribute directly.
Starting from Linux 3.2.x, we should use set_nlink(inode *, int *)
function to set the i_nlink count.
Designed a new function with the same name set_nlink() for kernel versions
before 3.2.0. Modified the code to call set_nlink(). If the user tries
out a latest kernel, the new kernel function gets called else the new
function that is added in this changeset will be called.
While testing the fix, noticed that build process couldn't resolve
module_param function in tcp.c file. Not sure if anything got changed
in linux kernel 3.2.x. Fixed the build issue by including proper header
file in tcp.c.
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
* Private function implementations.
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
+/*
+ *----------------------------------------------------------------------------
+ *
+ * set_nlink --
+ *
+ * Set an inode's link count.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------------
+ */
+
+static inline void
+set_nlink(struct inode *inode, unsigned int nlink)
+{
+ inode->i_nlink = nlink;
+}
+#endif
+
+
/*
*----------------------------------------------------------------------
*
* account for '.' and ".."), and find printed a hard link error. So until
* we have getattr support for nlink, everyone gets 1.
*/
- inode->i_nlink = 1;
+ set_nlink(inode, 1);
/*
* Use the stored uid and gid if we were given them at mount-time, or if
#include <linux/in.h>
#include <linux/net.h>
#include <linux/inet.h>
+#include <linux/moduleparam.h>
#include <linux/errno.h>
#include <linux/kthread.h>