diff --git a/vmnet/Makefile b/vmnet/Makefile index 459846e..cd29652 100644 --- a/vmnet/Makefile +++ b/vmnet/Makefile @@ -43,7 +43,11 @@ INCLUDE += -I$(SRCROOT)/shared endif +ifdef KVERSION +VM_UNAME = $(KVERSION) +else VM_UNAME = $(shell uname -r) +endif # Header directory for the running kernel ifdef LINUXINCLUDE diff --git a/vmnet/Makefile.kernel b/vmnet/Makefile.kernel index 2d8e6f6..a14166b 100644 --- a/vmnet/Makefile.kernel +++ b/vmnet/Makefile.kernel @@ -19,7 +19,7 @@ INCLUDE := -I$(SRCROOT) -EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) +EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) $(LINUXINCLUDE) EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/netif_trans_update.c,-DVMW_NETIF_TRANS_UPDATE, ) obj-m += $(DRIVER).o diff --git a/vmnet/driver.c b/vmnet/driver.c index 7e7ad99..5f508f6 100644 --- a/vmnet/driver.c +++ b/vmnet/driver.c @@ -137,7 +137,16 @@ static ssize_t VNetFileOpWrite(struct file *filp, const char *buf, size_t count static long VNetFileOpUnlockedIoctl(struct file * filp, unsigned int iocmd, unsigned long ioarg); -static struct file_operations vnetFileOps; +static struct file_operations vnetFileOps = { + .owner = THIS_MODULE, + .read = VNetFileOpRead, + .write = VNetFileOpWrite, + .poll = VNetFileOpPoll, + .unlocked_ioctl = VNetFileOpUnlockedIoctl, + .compat_ioctl = VNetFileOpUnlockedIoctl, + .open = VNetFileOpOpen, + .release = VNetFileOpClose +}; /* * Utility functions @@ -317,22 +326,6 @@ init_module(void) goto err_proto; } - /* - * Initialize the file_operations structure. Because this code is always - * compiled as a module, this is fine to do it here and not in a static - * initializer. - */ - - memset(&vnetFileOps, 0, sizeof vnetFileOps); - vnetFileOps.owner = THIS_MODULE; - vnetFileOps.read = VNetFileOpRead; - vnetFileOps.write = VNetFileOpWrite; - vnetFileOps.poll = VNetFileOpPoll; - vnetFileOps.unlocked_ioctl = VNetFileOpUnlockedIoctl; - vnetFileOps.compat_ioctl = VNetFileOpUnlockedIoctl; - vnetFileOps.open = VNetFileOpOpen; - vnetFileOps.release = VNetFileOpClose; - retval = register_chrdev(VNET_MAJOR_NUMBER, "vmnet", &vnetFileOps); if (retval) { LOG(0, (KERN_NOTICE "/dev/vmnet: could not register major device %d\n", diff --git a/vmnet/vm_device_version.h b/vmnet/vm_device_version.h index e2cb477..3dd7097 100644 --- a/vmnet/vm_device_version.h +++ b/vmnet/vm_device_version.h @@ -53,7 +53,9 @@ * VMware HD Audio codec * VMware HD Audio controller */ +#ifndef PCI_VENDOR_ID_VMWARE #define PCI_VENDOR_ID_VMWARE 0x15AD +#endif #define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405 #define PCI_DEVICE_ID_VMWARE_SVGA 0x0710 #define PCI_DEVICE_ID_VMWARE_VGA 0x0711 diff --git a/vmnet/vmnetInt.h b/vmnet/vmnetInt.h index 0ee52ec..4e3b923 100644 --- a/vmnet/vmnetInt.h +++ b/vmnet/vmnetInt.h @@ -48,7 +48,7 @@ extern struct proto vmnet_proto; #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) || defined(sk_net_refcnt) # define compat_sk_alloc(_bri, _pri) sk_alloc(&init_net, \ - PF_NETLINK, _pri, &vmnet_proto, 1) + PF_NETLINK, _pri, &vmnet_proto, 0) #else # define compat_sk_alloc(_bri, _pri) sk_alloc(&init_net, \ PF_NETLINK, _pri, &vmnet_proto)