From: VMware, Inc <> Date: Fri, 12 Apr 2013 19:41:16 +0000 (-0700) Subject: HGFS: make Linux client build on 3.8 kernels X-Git-Tag: 2013.04.16-1098359~78 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=40bce13f621285dd287922f4d4e7a2b911f56f0d;p=thirdparty%2Fopen-vm-tools.git HGFS: make Linux client build on 3.8 kernels The vmtruncate system call was removed from the kernel in 3.8. This addresses that by making the call to the suggested system API instead. Fixed up HgfsPermission function which was generating some compiler warnings. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/modules/linux/vmhgfs/inode.c b/open-vm-tools/modules/linux/vmhgfs/inode.c index a86e246b6..dd291aa9d 100644 --- a/open-vm-tools/modules/linux/vmhgfs/inode.c +++ b/open-vm-tools/modules/linux/vmhgfs/inode.c @@ -885,7 +885,19 @@ HgfsTruncatePages(struct inode *inode, // IN: Inode whose page to truncate ASSERT(inode); LOG(4, (KERN_DEBUG "VMware hgfs: HgfsTruncatePages: entered\n")); - result = compat_vmtruncate(inode, newSize); + + /* + * In 3.8.0, vmtruncate was removed and replaced by calling the check + * size and set directly. + */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0) + result = vmtruncate(inode, newSize); +#else + result = inode_newsize_ok(inode, newSize); + if (0 == result) { + truncate_setsize(inode, newSize); + } +#endif if (result) { LOG(4, (KERN_DEBUG "VMware hgfs: HgfsTruncatePages: vmtruncate failed " "with error code %d\n", result)); @@ -1812,21 +1824,19 @@ HgfsPermission(struct inode *inode, if (mask & MAY_ACCESS) { /* For sys_access. */ struct dentry *dentry; struct hlist_node *p; - int dcount = 0; if (mask & MAY_NOT_BLOCK) return -ECHILD; /* Find a dentry with valid d_count. Refer bug 587879. */ hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) { - dcount = dentry->d_count; + int dcount = dentry->d_count; if (dcount) { LOG(4, ("Found %s %d \n", dentry->d_name.name, dcount)); - break; + return HgfsAccessInt(dentry, mask & (MAY_READ | MAY_WRITE | MAY_EXEC)); } } - ASSERT(dcount); - return HgfsAccessInt(dentry, mask & (MAY_READ | MAY_WRITE | MAY_EXEC)); + ASSERT(FALSE); } return 0; } @@ -1853,8 +1863,6 @@ HgfsPermission(struct inode *inode, if (mask & MAY_ACCESS) { /* For sys_access. */ #endif struct list_head *pos; - int dcount = 0; - struct dentry *dentry = NULL; /* * In 2.6.38 path walk is done in 2 distinct modes: rcu-walk and @@ -1873,7 +1881,8 @@ HgfsPermission(struct inode *inode, /* Find a dentry with valid d_count. Refer bug 587879. */ list_for_each(pos, &inode->i_dentry) { - dentry = list_entry(pos, struct dentry, d_alias); + int dcount; + struct dentry *dentry = list_entry(pos, struct dentry, d_alias); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38) dcount = atomic_read(&dentry->d_count); #else @@ -1881,11 +1890,10 @@ HgfsPermission(struct inode *inode, #endif if (dcount) { LOG(4, ("Found %s %d \n", (dentry)->d_name.name, dcount)); - break; + return HgfsAccessInt(dentry, mask & (MAY_READ | MAY_WRITE | MAY_EXEC)); } } - ASSERT(dcount); - return HgfsAccessInt(dentry, mask & (MAY_READ | MAY_WRITE | MAY_EXEC)); + ASSERT(FALSE); } return 0; }