]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix HGFS for linux kernel 3.2.x.
authorVMware, Inc <>
Thu, 22 Dec 2011 00:19:27 +0000 (16:19 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 22 Dec 2011 00:19:27 +0000 (16:19 -0800)
'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>
open-vm-tools/modules/linux/vmhgfs/fsutil.c
open-vm-tools/modules/linux/vmhgfs/tcp.c

index 0c5102bea2808f4b9ede669850e30cd00e7e328b..a978005bc593c9e4b6f2d253f93106c0799d2b7a 100644 (file)
@@ -62,6 +62,31 @@ static int HgfsPackGetattrRequest(HgfsReq *req,
  * 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
+
+
 /*
  *----------------------------------------------------------------------
  *
@@ -607,7 +632,7 @@ HgfsChangeFileAttributes(struct inode *inode,          // IN/OUT: Inode
     * 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
index c7070a6b8d8d47dc887a270e623fc8b5d03a90a5..31a40dfa4b1f6fa9d482f5c647a64749f2360e6c 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/in.h>
 #include <linux/net.h>
 #include <linux/inet.h>
+#include <linux/moduleparam.h>
 #include <linux/errno.h>
 #include <linux/kthread.h>