From: VMware, Inc <> Date: Tue, 13 Mar 2012 20:01:24 +0000 (-0700) Subject: HGFS: fix compilation issues on SLES11SP2 X-Git-Tag: 2012.03.13-651368~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4c7daa9484eba9ec5eb18194c977524596a93ecb;p=thirdparty%2Fopen-vm-tools.git HGFS: fix compilation issues on SLES11SP2 "warning: initialization from incompatible pointer type" fsync() method was originally changed in Linux v3.1, but SUSE backported it to their 3.0 kernels. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/modules/linux/shared/autoconf/file_operations_fsync.c b/open-vm-tools/modules/linux/shared/autoconf/file_operations_fsync.c new file mode 100644 index 000000000..47a781549 --- /dev/null +++ b/open-vm-tools/modules/linux/shared/autoconf/file_operations_fsync.c @@ -0,0 +1,47 @@ +/********************************************************* + * Copyright (C) 2011 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation version 2 and no later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *********************************************************/ + +/* + * Linux v3.1 added 2 params to fsync for fine-grained locking control. + * But SLES11 SP2 has backported the change to its 3.0 kernel, + * so we can't rely solely on kernel version to determine number of + * arguments. + */ + +#include "compat_version.h" +#include "compat_autoconf.h" + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) +# error This compile test intentionally fails. +#else + +#include +#include /* loff_t */ + +static int TestFsync(struct file *file, + loff_t start, loff_t end, + int datasync) +{ + return 0; +} + +struct file_operations testFO = { + .fsync = TestFsync, +}; + +#endif diff --git a/open-vm-tools/modules/linux/vmhgfs/Makefile.kernel b/open-vm-tools/modules/linux/vmhgfs/Makefile.kernel index 8f59cfa95..a8a2caab7 100644 --- a/open-vm-tools/modules/linux/vmhgfs/Makefile.kernel +++ b/open-vm-tools/modules/linux/vmhgfs/Makefile.kernel @@ -27,6 +27,7 @@ EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/cachector.c, -DVMW_KMEMCR_CTOR_HAS_3_ARGS, ) EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/cachector1.c, -DVMW_KMEMCR_CTOR_HAS_2_ARGS, ) +EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/file_operations_fsync.c, -DVMW_FSYNC_31, ) # Note: These tests are inverted EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/getsb1.c,, -DVMW_GETSB_2618) diff --git a/open-vm-tools/modules/linux/vmhgfs/file.c b/open-vm-tools/modules/linux/vmhgfs/file.c index 2c3942cc5..5a5926329 100644 --- a/open-vm-tools/modules/linux/vmhgfs/file.c +++ b/open-vm-tools/modules/linux/vmhgfs/file.c @@ -83,7 +83,7 @@ static loff_t HgfsSeek(struct file *file, static int HgfsFsync(struct file *file, #if defined VMW_FSYNC_OLD struct dentry *dentry, -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) +#elif defined VMW_FSYNC_31 loff_t start, loff_t end, #endif @@ -992,7 +992,7 @@ static int HgfsFsync(struct file *file, // IN: File we operate on #if defined VMW_FSYNC_OLD struct dentry *dentry, // IN: Dentry for this file -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) +#elif defined VMW_FSYNC_31 loff_t start, // IN: start of range to sync loff_t end, // IN: end of range to sync #endif