From: VMware, Inc <> Date: Mon, 21 May 2012 22:27:15 +0000 (-0700) Subject: vmblock, HGFS: allow compiling on kernels 3.4+ X-Git-Tag: 2012.05.21-724730~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfb3e18afb5712d6ea8fd9dd26a62b11e130bc80;p=thirdparty%2Fopen-vm-tools.git vmblock, HGFS: allow compiling on kernels 3.4+ 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 --- diff --git a/open-vm-tools/modules/linux/shared/compat_fs.h b/open-vm-tools/modules/linux/shared/compat_fs.h index 7ec30bd88..f762f6f40 100644 --- a/open-vm-tools/modules/linux/shared/compat_fs.h +++ b/open-vm-tools/modules/linux/shared/compat_fs.h @@ -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__ */ diff --git a/open-vm-tools/modules/linux/vmblock/linux/filesystem.c b/open-vm-tools/modules/linux/vmblock/linux/filesystem.c index b7c535ecb..af574995b 100644 --- a/open-vm-tools/modules/linux/vmblock/linux/filesystem.c +++ b/open-vm-tools/modules/linux/vmblock/linux/filesystem.c @@ -28,8 +28,8 @@ #include #include #include -#include +#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; diff --git a/open-vm-tools/modules/linux/vmhgfs/filesystem.c b/open-vm-tools/modules/linux/vmhgfs/filesystem.c index 17c8c694d..f101ca7ad 100644 --- a/open-vm-tools/modules/linux/vmhgfs/filesystem.c +++ b/open-vm-tools/modules/linux/vmhgfs/filesystem.c @@ -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"