]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
vmblock, HGFS: allow compiling on kernels 3.4+
authorVMware, Inc <>
Mon, 21 May 2012 22:27:15 +0000 (15:27 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Tue, 22 May 2012 18:57:13 +0000 (11:57 -0700)
Commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b removed d_alloc_root()
(it was replaced by d_make_root), adjust our code to call the new
function and provide the replacement on older kernels.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/modules/linux/shared/compat_fs.h
open-vm-tools/modules/linux/vmblock/linux/filesystem.c
open-vm-tools/modules/linux/vmhgfs/filesystem.c

index 7ec30bd8811612dbc63ebeec7f92216cc9909776..f762f6f40a45d652b66f6dbbd2838b5648ccb95c 100644 (file)
@@ -254,4 +254,13 @@ typedef umode_t compat_umode_t;
 typedef int compat_umode_t;
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
+#define d_make_root(inode) ({                      \
+   struct dentry * ____res = d_alloc_root(inode);  \
+   if (!____res) {                                 \
+      iput(inode);                                 \
+   }                                               \
+   ____res;                                        \
+})
+#endif
 #endif /* __COMPAT_FS_H__ */
index b7c535ecb992c7d6ebcba22e22de9c6be9a6e146..af574995bc271ec7cb9d207bcc24afa7ab1f1fea 100644 (file)
@@ -28,8 +28,8 @@
 #include <linux/module.h>
 #include <linux/proc_fs.h>
 #include <linux/mount.h>
-#include <linux/fs.h>
 
+#include "compat_fs.h"
 #include "compat_namei.h"
 
 #include "os.h"
@@ -525,9 +525,8 @@ FsOpReadSuper(struct super_block *sb, // OUT: Superblock object
       return -EINVAL;
    }
 
-   rootDentry = d_alloc_root(rootInode);
+   rootDentry = d_make_root(rootInode);
    if (!rootDentry) {
-      iput(rootInode);
       return -ENOMEM;
    }
    sb->s_root = rootDentry;
index 17c8c694d3dcf9728d692fc1a7b609b5b85055f2..f101ca7ad5f388938ae0f8366da5be15e95ab1dd 100644 (file)
@@ -376,15 +376,20 @@ HgfsGetRootDentry(struct super_block *sb,       // IN: Super block object
       goto exit;
    }
 
-   tempRootDentry = d_alloc_root(rootInode);
+   tempRootDentry = d_make_root(rootInode);
+   /*
+    * d_make_root() does iput() on failure; if d_make_root() completes
+    * successfully then subsequent dput() will do iput() for us, so we
+    * should just ignore root inode from now on.
+    */
+   rootInode = NULL;
+
    if (tempRootDentry == NULL) {
       LOG(4, (KERN_WARNING "VMware hgfs: %s: Could not get "
               "root dentry\n", __func__));
       goto exit;
    }
 
-   rootInode = NULL;
-
    result = HgfsPrivateGetattr(tempRootDentry, &rootDentryAttr, NULL);
    if (result) {
       LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not"