├── files ├── tools.conf ├── shutdown └── vmtoolsd.init ├── README.md ├── Makefile └── patches └── openwrt-patches.patch /files/tools.conf: -------------------------------------------------------------------------------- 1 | [guestinfo] 2 | disable-perf-mon=1 3 | -------------------------------------------------------------------------------- /files/shutdown: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #compatibility script for openvmtools 3 | 4 | if [ "$1" == "-r" ]; then 5 | /sbin/reboot 6 | else 7 | /sbin/poweroff 8 | fi 9 | -------------------------------------------------------------------------------- /files/vmtoolsd.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=10 4 | 5 | USE_PROCD=1 6 | PROG=/bin/vmtoolsd 7 | 8 | start_service() { 9 | procd_open_instance 10 | procd_set_param command "$PROG" 11 | procd_set_param respawn 12 | procd_close_instance 13 | } 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # openwrt-vm-tools 2 | vmware tools open-vm-tools for OpenWRT 3 | 4 | This is an OpenWRT port of VMWare official open-vm-tools. This port uses latest devel branch(01/23/2019) of original, fixed bunches of bugs by https://github.com/srchack/custom-packages . 5 | 6 | I have it tested with the follow platform: 7 | OpenWRT 18.06.1 x86_64 on ESXi 6.x 8 | 9 | Power on/Shutdown/Report IPs etc. are functional normally with this build. It should works with both lede 17.x and OpenWRT 18.x. Feel free to report bugs here. 10 | 11 | With this build, I don't see any crashes or segfault anymore. and that's why I made this build. 12 | 13 | ## Compile 14 | 15 | ``` 16 | # Step 1 17 | # git clone OpenWRT and checkout the same branch as your router. 18 | # Since open-vm-tools has many dependencies of basic libraries in OpenWRT, I don't think you can compile this tools with only SDK. 19 | # So just make sure you cloned the full openwrt repo. 20 | 21 | # Step 2 22 | git clone https://github.com/fangli/openwrt-vm-tools package/open-vm-tools 23 | 24 | # Step 3 25 | make menuconfig 26 | # And Set `Utilities` - `open-vm-tools` to `M` (modularizes features) 27 | 28 | # Step 4 29 | make package/open-vm-tools/compile 30 | 31 | # Finish 32 | # Then ./bin/packages/x86_64/base/open-vm-tools_devel-1a39495-1_x86_64.ipk is what you need. 33 | 34 | ``` 35 | 36 | ## For convenience, I published the ipk binary for OpenWRT 18.06.1, if you are running the same version of openwrt, feel free to just download and install it: 37 | 38 | ``` 39 | cd /tmp 40 | wget https://xxxxx/open-vm-tools_devel-1a39495-1_x86_64.ipk (Get the URL on releases page of this repo) 41 | opkg update 42 | opkg install open-vm-tools_devel-1a39495-1_x86_64.ipk 43 | reboot 44 | ``` 45 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2018 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=open-vm-tools 11 | PKG_VERSION:=devel-1a39495 12 | PKG_RELEASE:=1 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 15 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) 16 | PKG_SOURCE_PROTO:=git 17 | PKG_SOURCE_URL=https://github.com/vmware/open-vm-tools.git 18 | PKG_SOURCE_VERSION:=1a39495618c1573c0fb16dd15368d0f2e606372c 19 | 20 | PKG_FIXUP:=autoreconf 21 | PKG_LICENSE:=LGPL-2.1 22 | 23 | include $(INCLUDE_DIR)/package.mk 24 | 25 | define Package/open-vm-tools 26 | SECTION:=utils 27 | CATEGORY:=Utilities 28 | DEPENDS:=@TARGET_x86 +glib2 +libpthread +libtirpc 29 | TITLE:=open-vm-tools 30 | URL:=https://github.com/vmware/open-vm-tools 31 | endef 32 | 33 | define Package/open-vm-tools-vm-tools/description 34 | Open Virtual Machine Tools for VMware guest OS 35 | endef 36 | 37 | 38 | CONFIGURE_PATH = open-vm-tools 39 | MAKE_PATH = open-vm-tools 40 | 41 | CONFIGURE_ARGS+= \ 42 | --without-icu \ 43 | --disable-multimon \ 44 | --disable-docs \ 45 | --disable-tests \ 46 | --without-gtkmm \ 47 | --without-gtkmm3 \ 48 | --without-xerces \ 49 | --without-pam \ 50 | --disable-grabbitmqproxy \ 51 | --disable-vgauth \ 52 | --disable-deploypkg \ 53 | --without-root-privileges \ 54 | --without-kernel-modules \ 55 | --without-dnet \ 56 | --with-tirpc \ 57 | --without-x \ 58 | --without-gtk2 \ 59 | --without-gtk3 \ 60 | --without-xerces 61 | 62 | 63 | define Package/open-vm-tools/install 64 | $(INSTALL_DIR) $(1)/etc/init.d/ 65 | $(INSTALL_BIN) ./files/vmtoolsd.init $(1)/etc/init.d/vmtoolsd 66 | 67 | $(INSTALL_DIR) $(1)/etc/vmware-tools/ 68 | $(INSTALL_DATA) ./files/tools.conf $(1)/etc/vmware-tools/ 69 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/scripts/poweroff-vm-default $(1)/etc/vmware-tools/ 70 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/scripts/poweron-vm-default $(1)/etc/vmware-tools/ 71 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/scripts/resume-vm-default $(1)/etc/vmware-tools/ 72 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/scripts/suspend-vm-default $(1)/etc/vmware-tools/ 73 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/scripts/common/statechange.subr $(1)/etc/vmware-tools/ 74 | 75 | $(INSTALL_DIR) $(1)/etc/vmware-tools/scripts/vmware/ 76 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/scripts/linux/network $(1)/etc/vmware-tools/scripts/vmware/ 77 | 78 | $(INSTALL_DIR) $(1)/bin/ 79 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/checkvm/.libs/vmware-checkvm $(1)/bin/ 80 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/namespacetool/.libs/vmware-namespace-cmd $(1)/bin/ 81 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/xferlogs/.libs/vmware-xferlogs $(1)/bin/ 82 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/hgfsclient/.libs/vmware-hgfsclient $(1)/bin/ 83 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/services/vmtoolsd/.libs/vmtoolsd $(1)/bin/ 84 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/rpctool/vmware-rpctool $(1)/bin/ 85 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/toolbox/.libs/vmware-toolbox-cmd $(1)/bin/ 86 | 87 | $(INSTALL_DIR) $(1)/sbin/ 88 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/open-vm-tools/hgfsmounter/mount.vmhgfs $(1)/sbin/ 89 | $(INSTALL_BIN) ./files/shutdown $(1)/sbin/ 90 | 91 | $(INSTALL_DIR) $(1)/lib/ 92 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/libhgfs/.libs/libhgfs.so.0.0.0 $(1)/lib/ 93 | $(LN) libhgfs.so.0.0.0 $(1)/lib/libhgfs.so.0 94 | $(LN) libhgfs.so.0.0.0 $(1)/lib/libhgfs.so 95 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/libguestlib/.libs/libguestlib.so.0.0.0 $(1)/lib/ 96 | $(LN) libguestlib.so.0.0.0 $(1)/lib/libguestlib.so.0 97 | $(LN) libguestlib.so.0.0.0 $(1)/lib/libguestlib.so 98 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/libvmtools/.libs/libvmtools.so.0.0.0 $(1)/lib/ 99 | $(LN) libvmtools.so.0.0.0 $(1)/lib/libvmtools.so.0 100 | $(LN) libvmtools.so.0.0.0 $(1)/lib/libvmtools.so 101 | 102 | $(INSTALL_DIR) $(1)/usr/lib/open-vm-tools/plugins/common/ 103 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/plugins/vix/.libs/libvix.so $(1)/usr/lib/open-vm-tools/plugins/common/ 104 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/plugins/hgfsServer/.libs/libhgfsServer.so $(1)/usr/lib/open-vm-tools/plugins/common/ 105 | 106 | $(INSTALL_DIR) $(1)/usr/lib/open-vm-tools/plugins/vmsvc/ 107 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/plugins/resolutionKMS/.libs/libresolutionKMS.so $(1)/usr/lib/open-vm-tools/plugins/vmsvc/ 108 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/plugins/powerOps/.libs/libpowerOps.so $(1)/usr/lib/open-vm-tools/plugins/vmsvc/ 109 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/plugins/timeSync/.libs/libtimeSync.so $(1)/usr/lib/open-vm-tools/plugins/vmsvc/ 110 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/plugins/guestInfo/.libs/libguestInfo.so $(1)/usr/lib/open-vm-tools/plugins/vmsvc/ 111 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/plugins/vmbackup/.libs/libvmbackup.so $(1)/usr/lib/open-vm-tools/plugins/vmsvc/ 112 | 113 | $(INSTALL_DIR) $(1)/lib/udev/rules.d/ 114 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/udev/99-vmware-scsi-udev.rules $(1)/lib/udev/rules.d/ 115 | 116 | $(INSTALL_DIR) $(1)/share/open-vm-tools/messages/ko/ 117 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/vmtoolsd/l10n/ko.vmsg $(1)/share/open-vm-tools/messages/ko/vmtoolsd.vmsg 118 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/toolbox/l10n/ko.vmsg $(1)/share/open-vm-tools/messages/ko/toolboxcmd.vmsg 119 | $(INSTALL_DIR) $(1)/share/open-vm-tools/messages/de/ 120 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/vmtoolsd/l10n/de.vmsg $(1)/share/open-vm-tools/messages/de/vmtoolsd.vmsg 121 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/toolbox/l10n/de.vmsg $(1)/share/open-vm-tools/messages/de/toolboxcmd.vmsg 122 | $(INSTALL_DIR) $(1)/share/open-vm-tools/messages/ja/ 123 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/services/vmtoolsd/l10n/ja.vmsg $(1)/share/open-vm-tools/messages/ja/vmtoolsd.vmsg 124 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/toolbox/l10n/ja.vmsg $(1)/share/open-vm-tools/messages/ja/toolboxcmd.vmsg 125 | $(INSTALL_DIR) $(1)/share/open-vm-tools/messages/zh_CN/ 126 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/open-vm-tools/toolbox/l10n/zh_CN.vmsg $(1)/share/open-vm-tools/messages/zh_CN/toolboxcmd.vmsg 127 | endef 128 | 129 | $(eval $(call BuildPackage,open-vm-tools)) 130 | -------------------------------------------------------------------------------- /patches/openwrt-patches.patch: -------------------------------------------------------------------------------- 1 | diff -urN a/open-vm-tools/configure.ac b/open-vm-tools/configure.ac 2 | --- a/open-vm-tools/configure.ac 2019-01-23 16:28:44.000000000 +0800 3 | +++ b/open-vm-tools/configure.ac 2019-01-23 15:59:55.000000000 +0800 4 | @@ -937,7 +937,7 @@ 5 | AC_VMW_CHECK_LIB([dnet], 6 | [DNET], 7 | [], 8 | - [dnet-config], 9 | + [], 10 | [], 11 | [dnet.h], 12 | [intf_open], 13 | @@ -1151,6 +1151,7 @@ 14 | AC_TYPE_PID_T 15 | AC_TYPE_SIZE_T 16 | AC_CHECK_MEMBERS([struct stat.st_rdev]) 17 | +AC_CHECK_MEMBERS([struct timespec.tv_sec],[],[],[[#include ]]) 18 | AC_HEADER_TIME 19 | AC_STRUCT_TM 20 | AC_C_VOLATILE 21 | diff -urN a/open-vm-tools/lib/asyncsocket/asyncsocket.c b/open-vm-tools/lib/asyncsocket/asyncsocket.c 22 | --- a/open-vm-tools/lib/asyncsocket/asyncsocket.c 2019-01-23 16:28:44.000000000 +0800 23 | +++ b/open-vm-tools/lib/asyncsocket/asyncsocket.c 2019-01-23 16:10:13.000000000 +0800 24 | @@ -69,8 +69,8 @@ 25 | #else 26 | #include 27 | #include 28 | +#include 29 | #include 30 | -#include 31 | #include 32 | #include 33 | #include 34 | @@ -86,7 +86,7 @@ 35 | #include "random.h" 36 | #include "asyncsocket.h" 37 | #include "asyncSocketBase.h" 38 | -#include "poll.h" 39 | +#include "vm_poll.h" 40 | #include "log.h" 41 | #include "err.h" 42 | #include "hostinfo.h" 43 | diff -urN a/open-vm-tools/lib/err/errPosix.c b/open-vm-tools/lib/err/errPosix.c 44 | --- a/open-vm-tools/lib/err/errPosix.c 2019-01-23 16:28:44.000000000 +0800 45 | +++ b/open-vm-tools/lib/err/errPosix.c 2019-01-23 16:15:29.000000000 +0800 46 | @@ -31,6 +31,7 @@ 47 | #include 48 | #include 49 | #include 50 | +#include 51 | 52 | #include "vmware.h" 53 | #include "errInt.h" 54 | @@ -63,11 +64,13 @@ 55 | { 56 | char *p; 57 | 58 | -#if defined(__linux__) && !defined(__ANDROID__) 59 | +#if defined(__GLIBC__) && !defined(__ANDROID__) 60 | p = strerror_r(errorNumber, buf, bufSize); 61 | #else 62 | - p = strerror(errorNumber); 63 | -#endif 64 | + if (strerror_r(errorNumber, buf, bufSize) != 0) 65 | + snprintf(buf, bufSize, "unknown error %i", errorNumber); 66 | + p = buf; 67 | +#endif /* defined __GLIBC__ */ 68 | ASSERT(p != NULL); 69 | return p; 70 | } 71 | diff -urN a/open-vm-tools/lib/file/fileIOPosix.c b/open-vm-tools/lib/file/fileIOPosix.c 72 | --- a/open-vm-tools/lib/file/fileIOPosix.c 2019-01-23 16:28:44.000000000 +0800 73 | +++ b/open-vm-tools/lib/file/fileIOPosix.c 2019-01-23 16:16:39.000000000 +0800 74 | @@ -206,10 +206,10 @@ 75 | * the symbols (and anyone building XOPEN<700 gets nothing). 76 | */ 77 | extern ssize_t preadv64(int fd, const struct iovec *iov, int iovcnt, 78 | - __off64_t offset) __attribute__ ((weak)); 79 | + off64_t offset) __attribute__ ((weak)); 80 | 81 | extern ssize_t pwritev64(int fd, const struct iovec *iov, int iovcnt, 82 | - __off64_t offset) __attribute__ ((weak)); 83 | + off64_t offset) __attribute__ ((weak)); 84 | #else 85 | #error "Large file support unavailable. Aborting." 86 | #endif 87 | diff -urN a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c 88 | --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c 2019-01-23 16:28:44.000000000 +0800 89 | +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c 2019-01-23 16:10:36.000000000 +0800 90 | @@ -48,7 +48,7 @@ 91 | #include "hgfsServerOplock.h" 92 | #include "hgfsDirNotify.h" 93 | #include "userlock.h" 94 | -#include "poll.h" 95 | +#include "vm_poll.h" 96 | #include "mutexRankLib.h" 97 | #include "vm_basic_asm.h" 98 | #include "unicodeOperations.h" 99 | diff -urN a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c 100 | --- a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c 2019-01-23 16:28:44.000000000 +0800 101 | +++ b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c 2019-01-23 16:16:01.000000000 +0800 102 | @@ -108,8 +108,10 @@ 103 | * ALLPERMS (mode 07777) and ACCESSPERMS (mode 0777) are not defined in the 104 | * Solaris version of . 105 | */ 106 | -#ifdef sun 107 | +#ifndef ACCESSPERMS 108 | # define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) 109 | +#endif 110 | +#ifndef ALLPERMS 111 | # define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) 112 | #endif 113 | 114 | @@ -5292,8 +5294,8 @@ 115 | goto exit; 116 | } 117 | 118 | - LOG(6, ("%s: File Size limits: 0x%"FMT64"x 0x%"FMT64"x\n", 119 | - __FUNCTION__, fileSize.rlim_cur, fileSize.rlim_max)); 120 | + LOG(6, ("%s: File Size limits: 0x%jx 0x%jx\n", 121 | + __FUNCTION__, (uintmax_t)fileSize.rlim_cur, (uintmax_t)fileSize.rlim_max)); 122 | 123 | /* 124 | * Check the offset is within the file size range. 125 | diff -urN a/open-vm-tools/lib/include/asyncsocket.h b/open-vm-tools/lib/include/asyncsocket.h 126 | --- a/open-vm-tools/lib/include/asyncsocket.h 2019-01-23 16:28:44.000000000 +0800 127 | +++ b/open-vm-tools/lib/include/asyncsocket.h 2019-01-23 16:10:59.000000000 +0800 128 | @@ -164,7 +164,7 @@ 129 | * Or the client can specify its favorite poll class and locking behavior. 130 | * Use of IVmdbPoll is only supported for regular sockets and for Attach. 131 | */ 132 | -#include "poll.h" 133 | +#include "vm_poll.h" 134 | struct IVmdbPoll; 135 | typedef struct AsyncSocketPollParams { 136 | int flags; /* Default 0, only POLL_FLAG_NO_BULL is valid */ 137 | diff -urN a/open-vm-tools/lib/include/hgfsUtil.h b/open-vm-tools/lib/include/hgfsUtil.h 138 | --- a/open-vm-tools/lib/include/hgfsUtil.h 2019-01-23 16:28:44.000000000 +0800 139 | +++ b/open-vm-tools/lib/include/hgfsUtil.h 2019-01-23 16:00:49.000000000 +0800 140 | @@ -53,13 +53,7 @@ 141 | # include 142 | # endif 143 | # include "vm_basic_types.h" 144 | -# if !defined _STRUCT_TIMESPEC && \ 145 | - !defined _TIMESPEC_DECLARED && \ 146 | - !defined __timespec_defined && \ 147 | - !defined sun && \ 148 | - !defined __FreeBSD__ && \ 149 | - !__APPLE__ && \ 150 | - !defined _WIN32 151 | +# if !defined HAVE_STRUCT_TIMESPEC_TV_SEC 152 | struct timespec { 153 | time_t tv_sec; 154 | long tv_nsec; 155 | diff -urN a/open-vm-tools/lib/include/poll.h b/open-vm-tools/lib/include/poll.h 156 | --- a/open-vm-tools/lib/include/poll.h 2019-01-23 16:28:44.000000000 +0800 157 | +++ b/open-vm-tools/lib/include/poll.h 1970-01-01 08:00:00.000000000 +0800 158 | @@ -1,330 +0,0 @@ 159 | -/********************************************************* 160 | - * Copyright (C) 1998-2018 VMware, Inc. All rights reserved. 161 | - * 162 | - * This program is free software; you can redistribute it and/or modify it 163 | - * under the terms of the GNU Lesser General Public License as published 164 | - * by the Free Software Foundation version 2.1 and no later version. 165 | - * 166 | - * This program is distributed in the hope that it will be useful, but 167 | - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 168 | - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public 169 | - * License for more details. 170 | - * 171 | - * You should have received a copy of the GNU Lesser General Public License 172 | - * along with this program; if not, write to the Free Software Foundation, Inc., 173 | - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 174 | - * 175 | - *********************************************************/ 176 | - 177 | -/********************************************************* 178 | - * The contents of this file are subject to the terms of the Common 179 | - * Development and Distribution License (the "License") version 1.0 180 | - * and no later version. You may not use this file except in 181 | - * compliance with the License. 182 | - * 183 | - * You can obtain a copy of the License at 184 | - * http://www.opensource.org/licenses/cddl1.php 185 | - * 186 | - * See the License for the specific language governing permissions 187 | - * and limitations under the License. 188 | - * 189 | - *********************************************************/ 190 | - 191 | - 192 | -#ifndef _POLL_H_ 193 | -#define _POLL_H_ 194 | - 195 | -#define INCLUDE_ALLOW_USERLEVEL 196 | -#define INCLUDE_ALLOW_VMCORE 197 | -#include "includeCheck.h" 198 | - 199 | -#include "vm_basic_types.h" 200 | -#include "vm_basic_defs.h" 201 | -#include "vmware.h" 202 | -#include "userlock.h" 203 | - 204 | -#if defined(__cplusplus) 205 | -extern "C" { 206 | -#endif 207 | - 208 | -#ifdef _WIN32 209 | -#define HZ 100 210 | -#elif defined linux 211 | -#include 212 | -#elif __APPLE__ 213 | -#include 214 | -/* 215 | - * Old SDKs don't define TARGET_OS_IPHONE at all. 216 | - * New ones define it to 0 on Mac OS X, 1 on iOS. 217 | - */ 218 | -#if !defined(TARGET_OS_IPHONE) || TARGET_OS_IPHONE == 0 219 | -#include 220 | -#endif 221 | -#include 222 | -#define HZ 100 223 | -#endif 224 | -#ifdef __ANDROID__ 225 | -/* 226 | - * of android should be included, but its name is same 227 | - * with this file. So its content is put here to avoid conflict. 228 | - */ 229 | -#include 230 | -#define HZ 100 231 | -typedef unsigned int nfds_t; 232 | -int poll(struct pollfd *, nfds_t, long); 233 | -#endif 234 | - 235 | - 236 | -/* 237 | - * Poll event types: each type has a different reason for firing, 238 | - * or condition that must be met before firing. 239 | - */ 240 | - 241 | -typedef enum { 242 | - /* 243 | - * Actual Poll queue types against which you can register callbacks. 244 | - */ 245 | - POLL_VIRTUALREALTIME = -1, /* Negative because it doesn't have its own Q */ 246 | - POLL_VTIME = 0, 247 | - POLL_REALTIME, 248 | - POLL_DEVICE, 249 | - POLL_MAIN_LOOP, 250 | - POLL_NUM_QUEUES 251 | -} PollEventType; 252 | - 253 | - 254 | -/* 255 | - * Classes of events 256 | - * 257 | - * These are the predefined classes. More can be declared 258 | - * with Poll_AllocClass(). 259 | - */ 260 | - 261 | -typedef enum PollClass { 262 | - POLL_CLASS_MAIN, 263 | - POLL_CLASS_PAUSE, 264 | - POLL_CLASS_IPC, 265 | - POLL_CLASS_CPT, 266 | - POLL_CLASS_MKS, 267 | - POLL_FIXED_CLASSES, 268 | - POLL_DEFAULT_FIXED_CLASSES, 269 | - /* Size enum to maximum */ 270 | - POLL_MAX_CLASSES = 31, 271 | -} PollClass; 272 | - 273 | -/* 274 | - * Do not use; Special pseudo private poll class supported by 275 | - * PollDefault only 276 | - */ 277 | -#define POLL_DEFAULT_CLASS_NET POLL_FIXED_CLASSES 278 | -#define POLL_DEFAULT_CS_NET PollClassSet_Singleton(POLL_DEFAULT_CLASS_NET) 279 | - 280 | -/* 281 | - * Each callback is registered in a set of classes 282 | - */ 283 | - 284 | -typedef struct PollClassSet { 285 | - uintptr_t bits; 286 | -} PollClassSet; 287 | - 288 | -/* An empty PollClassSet. */ 289 | -static INLINE PollClassSet 290 | -PollClassSet_Empty(void) 291 | -{ 292 | - PollClassSet set = { 0 }; 293 | - return set; 294 | -} 295 | - 296 | -/* A PollClassSet with the single member. */ 297 | -static INLINE PollClassSet 298 | -PollClassSet_Singleton(PollClass c) 299 | -{ 300 | - PollClassSet s = PollClassSet_Empty(); 301 | - 302 | - ASSERT_ON_COMPILE(POLL_MAX_CLASSES < sizeof s.bits * 8); 303 | - ASSERT(c < POLL_MAX_CLASSES); 304 | - 305 | - s.bits = CONST3264U(1) << c; 306 | - return s; 307 | -} 308 | - 309 | -/* Combine two PollClassSets. */ 310 | -static INLINE PollClassSet 311 | -PollClassSet_Union(PollClassSet lhs, PollClassSet rhs) 312 | -{ 313 | - PollClassSet set; 314 | - set.bits = lhs.bits | rhs.bits; 315 | - return set; 316 | -} 317 | - 318 | -/* Add single class to PollClassSet. */ 319 | -static INLINE PollClassSet 320 | -PollClassSet_Include(PollClassSet set, PollClass c) 321 | -{ 322 | - return PollClassSet_Union(set, PollClassSet_Singleton(c)); 323 | -} 324 | - 325 | - 326 | -#define POLL_CS_MAIN PollClassSet_Singleton(POLL_CLASS_MAIN) 327 | -#define POLL_CS_PAUSE PollClassSet_Union(POLL_CS_MAIN, \ 328 | - PollClassSet_Singleton(POLL_CLASS_PAUSE)) 329 | -#define POLL_CS_CPT PollClassSet_Union(POLL_CS_PAUSE, \ 330 | - PollClassSet_Singleton(POLL_CLASS_CPT)) 331 | -#define POLL_CS_IPC PollClassSet_Union(POLL_CS_CPT, \ 332 | - PollClassSet_Singleton(POLL_CLASS_IPC)) 333 | -#define POLL_CS_VMDB POLL_CS_PAUSE /* POLL_CLASS_VMDB is retired */ 334 | -#define POLL_CS_MKS PollClassSet_Singleton(POLL_CLASS_MKS) 335 | -/* 336 | - * DANGER. You don't need POLL_CS_ALWAYS. Really. So don't use it. 337 | - */ 338 | -#define POLL_CS_ALWAYS PollClassSet_Union(POLL_CS_CPT, POLL_CS_IPC) 339 | - 340 | -/* 341 | - * Poll class-set taxonomy: 342 | - * POLL_CS_MAIN 343 | - * - Unless you NEED another class, use POLL_CS_MAIN. 344 | - * POLL_CS_PAUSE 345 | - * - For callbacks that must occur even if the guest is paused. 346 | - * Most VMDB or Foundry commands are in this category. 347 | - * POLL_CS_CPT 348 | - * - Only for callbacks which can trigger intermediate Checkpoint 349 | - * transitions. 350 | - * The ONLY such callback is Migrate. 351 | - * POLL_CS_IPC 352 | - * - Only for callbacks which can contain Msg_(Post|Hint|Question) 353 | - * responses, and for signal handlers (why)? 354 | - * Vigor, VMDB, and Foundry can contain Msg_* responses. 355 | - * POLL_CS_MKS 356 | - * - Callback runs in MKS thread. 357 | - * POLL_CS_ALWAYS 358 | - * - Only for events that must be processed immediately. 359 | - * The ONLY such callback is OvhdMemVmxSizeCheck. 360 | - */ 361 | - 362 | - 363 | -/* 364 | - * Poll_Callback flags 365 | - */ 366 | - 367 | -#define POLL_FLAG_PERIODIC 0x01 // keep after firing 368 | -#define POLL_FLAG_REMOVE_AT_POWEROFF 0x02 // self-explanatory 369 | -#define POLL_FLAG_READ 0x04 // device is ready for reading 370 | -#define POLL_FLAG_WRITE 0x08 // device is ready for writing 371 | -#define POLL_FLAG_SOCKET 0x10 // device is a Windows socket 372 | -#define POLL_FLAG_NO_BULL 0x20 // callback does its own locking 373 | -#define POLL_FLAG_WINSOCK 0x40 // Winsock style write events 374 | -#define POLL_FLAG_FD 0x80 // device is a Windows file descriptor. 375 | -#define POLL_FLAG_ACCEPT_INVALID_FDS 0x100 // For broken 3rd party libs, e.g. curl 376 | -#define POLL_FLAG_THUNK_TO_WND 0x200 // thunk callback to window message loop 377 | - 378 | - 379 | -typedef void (*PollerFunction)(void *clientData); 380 | -typedef void (*PollerFireWrapper)(PollerFunction func, 381 | - void *funcData, 382 | - void *wrapperData); 383 | -typedef Bool (*PollerErrorFn)(const char *errorStr); 384 | - 385 | -/* 386 | - * Initialisers: 387 | - * 388 | - * For the sake of convenience, we declare the initialisers 389 | - * for custom implmentations here, even though the actual 390 | - * implementations are distinct from the core poll code. 391 | - */ 392 | - 393 | -typedef struct PollOptions { 394 | - Bool locked; // Use internal MXUser for locking 395 | - Bool allowFullQueue; // Don't assert when device event queue is full. 396 | - VThreadID windowsMsgThread; // thread that processes Windows messages 397 | - PollerFireWrapper fireWrapperFn; // optional; may be useful for stats 398 | - void *fireWrapperData; // optional 399 | - PollerErrorFn errorFn; // optional; called upon unrecoverable error 400 | -} PollOptions; 401 | - 402 | - 403 | -void Poll_InitDefault(void); 404 | -void Poll_InitDefaultEx(const PollOptions *opts); 405 | -void Poll_InitGtk(void); // On top of glib for Linux 406 | -void Poll_InitCF(void); // On top of CoreFoundation for OSX 407 | - 408 | - 409 | -/* 410 | - * Functions 411 | - */ 412 | -int Poll_SocketPair(Bool vmci, Bool stream, int fds[2]); 413 | -void Poll_Loop(Bool loop, Bool *exit, PollClass c); 414 | -void Poll_LoopTimeout(Bool loop, Bool *exit, PollClass c, int timeout); 415 | -Bool Poll_LockingEnabled(void); 416 | -void Poll_Exit(void); 417 | - 418 | - 419 | -/* 420 | - * Poll_Callback adds a callback regardless of whether an identical one exists. 421 | - * The exception to this rule is POLL_DEVICE callbacks: there is a maximum of 422 | - * one read and one write callback per fd. 423 | - * 424 | - * Poll_CallbackRemove removes one callback. If there are multiple identical 425 | - * callbacks, which one is removed is an implementation detail. Note that in 426 | - * the case of POLL_DEVICE and POLL_REALTIME callbacks, the fd/delay used to 427 | - * create the callback is not specified when removing, so all callbacks 428 | - * of those types with the same flags, function, and clientData are considered 429 | - * "identical" even if their fd/delay differed. 430 | - */ 431 | - 432 | -VMwareStatus Poll_Callback(PollClassSet classSet, 433 | - int flags, 434 | - PollerFunction f, 435 | - void *clientData, 436 | - PollEventType type, 437 | - PollDevHandle info, // fd/microsec delay 438 | - MXUserRecLock *lck); 439 | -Bool Poll_CallbackRemove(PollClassSet classSet, 440 | - int flags, 441 | - PollerFunction f, 442 | - void *clientData, 443 | - PollEventType type); 444 | -Bool Poll_CallbackRemoveOneByCB(PollClassSet classSet, 445 | - int flags, 446 | - PollerFunction f, 447 | - PollEventType type, 448 | - void **clientData); 449 | - 450 | -void Poll_NotifyChange(PollClassSet classSet); 451 | - 452 | -/* 453 | - * Wrappers for Poll_Callback and Poll_CallbackRemove that present 454 | - * simpler subsets of those interfaces. 455 | - */ 456 | - 457 | -VMwareStatus Poll_CB_Device(PollerFunction f, 458 | - void *clientData, 459 | - PollDevHandle device, 460 | - Bool periodic); 461 | - 462 | -Bool Poll_CB_DeviceRemove(PollerFunction f, 463 | - void *clientData, 464 | - Bool periodic); 465 | - 466 | - 467 | -VMwareStatus Poll_CB_RTime(PollerFunction f, 468 | - void *clientData, 469 | - int64 delay, // microseconds 470 | - Bool periodic, 471 | - MXUserRecLock *lock); 472 | - 473 | -Bool Poll_CB_RTimeRemove(PollerFunction f, 474 | - void *clientData, 475 | - Bool periodic); 476 | - 477 | - 478 | -#ifdef _WIN32 479 | -void Poll_SetPumpsWindowsMessages(Bool pumps); 480 | -void Poll_SetWindowMessageRecipient(HWND hWnd, UINT msg, Bool alwaysThunk); 481 | -Bool Poll_FireWndCallback(void *lparam); 482 | -#endif 483 | - 484 | -#if defined(__cplusplus) 485 | -} // extern "C" 486 | -#endif 487 | - 488 | -#endif // _POLL_H_ 489 | diff -urN a/open-vm-tools/lib/include/pollImpl.h b/open-vm-tools/lib/include/pollImpl.h 490 | --- a/open-vm-tools/lib/include/pollImpl.h 2019-01-23 16:28:44.000000000 +0800 491 | +++ b/open-vm-tools/lib/include/pollImpl.h 2019-01-23 16:11:18.000000000 +0800 492 | @@ -44,7 +44,7 @@ 493 | #define INCLUDE_ALLOW_USERLEVEL 494 | #include "includeCheck.h" 495 | 496 | -#include "poll.h" 497 | +#include "vm_poll.h" 498 | #include "vm_basic_asm.h" 499 | 500 | #if defined(__cplusplus) 501 | diff -urN a/open-vm-tools/lib/include/vm_poll.h b/open-vm-tools/lib/include/vm_poll.h 502 | --- a/open-vm-tools/lib/include/vm_poll.h 1970-01-01 08:00:00.000000000 +0800 503 | +++ b/open-vm-tools/lib/include/vm_poll.h 2019-01-23 16:13:08.000000000 +0800 504 | @@ -0,0 +1,330 @@ 505 | +/********************************************************* 506 | + * Copyright (C) 1998-2018 VMware, Inc. All rights reserved. 507 | + * 508 | + * This program is free software; you can redistribute it and/or modify it 509 | + * under the terms of the GNU Lesser General Public License as published 510 | + * by the Free Software Foundation version 2.1 and no later version. 511 | + * 512 | + * This program is distributed in the hope that it will be useful, but 513 | + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 514 | + * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public 515 | + * License for more details. 516 | + * 517 | + * You should have received a copy of the GNU Lesser General Public License 518 | + * along with this program; if not, write to the Free Software Foundation, Inc., 519 | + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 520 | + * 521 | + *********************************************************/ 522 | + 523 | +/********************************************************* 524 | + * The contents of this file are subject to the terms of the Common 525 | + * Development and Distribution License (the "License") version 1.0 526 | + * and no later version. You may not use this file except in 527 | + * compliance with the License. 528 | + * 529 | + * You can obtain a copy of the License at 530 | + * http://www.opensource.org/licenses/cddl1.php 531 | + * 532 | + * See the License for the specific language governing permissions 533 | + * and limitations under the License. 534 | + * 535 | + *********************************************************/ 536 | + 537 | + 538 | +#ifndef _POLL_H_ 539 | +#define _POLL_H_ 540 | + 541 | +#define INCLUDE_ALLOW_USERLEVEL 542 | +#define INCLUDE_ALLOW_VMCORE 543 | +#include "includeCheck.h" 544 | + 545 | +#include "vm_basic_types.h" 546 | +#include "vm_basic_defs.h" 547 | +#include "vmware.h" 548 | +#include "userlock.h" 549 | + 550 | +#if defined(__cplusplus) 551 | +extern "C" { 552 | +#endif 553 | + 554 | +#ifdef _WIN32 555 | +#define HZ 100 556 | +#elif defined linux 557 | +#include 558 | +#elif __APPLE__ 559 | +#include 560 | +/* 561 | + * Old SDKs don't define TARGET_OS_IPHONE at all. 562 | + * New ones define it to 0 on Mac OS X, 1 on iOS. 563 | + */ 564 | +#if !defined(TARGET_OS_IPHONE) || TARGET_OS_IPHONE == 0 565 | +#include 566 | +#endif 567 | +#include 568 | +#define HZ 100 569 | +#endif 570 | +#ifdef __ANDROID__ 571 | +/* 572 | + * of android should be included, but its name is same 573 | + * with this file. So its content is put here to avoid conflict. 574 | + */ 575 | +#include 576 | +#define HZ 100 577 | +typedef unsigned int nfds_t; 578 | +int poll(struct pollfd *, nfds_t, long); 579 | +#endif 580 | + 581 | + 582 | +/* 583 | + * Poll event types: each type has a different reason for firing, 584 | + * or condition that must be met before firing. 585 | + */ 586 | + 587 | +typedef enum { 588 | + /* 589 | + * Actual Poll queue types against which you can register callbacks. 590 | + */ 591 | + POLL_VIRTUALREALTIME = -1, /* Negative because it doesn't have its own Q */ 592 | + POLL_VTIME = 0, 593 | + POLL_REALTIME, 594 | + POLL_DEVICE, 595 | + POLL_MAIN_LOOP, 596 | + POLL_NUM_QUEUES 597 | +} PollEventType; 598 | + 599 | + 600 | +/* 601 | + * Classes of events 602 | + * 603 | + * These are the predefined classes. More can be declared 604 | + * with Poll_AllocClass(). 605 | + */ 606 | + 607 | +typedef enum PollClass { 608 | + POLL_CLASS_MAIN, 609 | + POLL_CLASS_PAUSE, 610 | + POLL_CLASS_IPC, 611 | + POLL_CLASS_CPT, 612 | + POLL_CLASS_MKS, 613 | + POLL_FIXED_CLASSES, 614 | + POLL_DEFAULT_FIXED_CLASSES, 615 | + /* Size enum to maximum */ 616 | + POLL_MAX_CLASSES = 31, 617 | +} PollClass; 618 | + 619 | +/* 620 | + * Do not use; Special pseudo private poll class supported by 621 | + * PollDefault only 622 | + */ 623 | +#define POLL_DEFAULT_CLASS_NET POLL_FIXED_CLASSES 624 | +#define POLL_DEFAULT_CS_NET PollClassSet_Singleton(POLL_DEFAULT_CLASS_NET) 625 | + 626 | +/* 627 | + * Each callback is registered in a set of classes 628 | + */ 629 | + 630 | +typedef struct PollClassSet { 631 | + uintptr_t bits; 632 | +} PollClassSet; 633 | + 634 | +/* An empty PollClassSet. */ 635 | +static INLINE PollClassSet 636 | +PollClassSet_Empty(void) 637 | +{ 638 | + PollClassSet set = { 0 }; 639 | + return set; 640 | +} 641 | + 642 | +/* A PollClassSet with the single member. */ 643 | +static INLINE PollClassSet 644 | +PollClassSet_Singleton(PollClass c) 645 | +{ 646 | + PollClassSet s = PollClassSet_Empty(); 647 | + 648 | + ASSERT_ON_COMPILE(POLL_MAX_CLASSES < sizeof s.bits * 8); 649 | + ASSERT(c < POLL_MAX_CLASSES); 650 | + 651 | + s.bits = CONST3264U(1) << c; 652 | + return s; 653 | +} 654 | + 655 | +/* Combine two PollClassSets. */ 656 | +static INLINE PollClassSet 657 | +PollClassSet_Union(PollClassSet lhs, PollClassSet rhs) 658 | +{ 659 | + PollClassSet set; 660 | + set.bits = lhs.bits | rhs.bits; 661 | + return set; 662 | +} 663 | + 664 | +/* Add single class to PollClassSet. */ 665 | +static INLINE PollClassSet 666 | +PollClassSet_Include(PollClassSet set, PollClass c) 667 | +{ 668 | + return PollClassSet_Union(set, PollClassSet_Singleton(c)); 669 | +} 670 | + 671 | + 672 | +#define POLL_CS_MAIN PollClassSet_Singleton(POLL_CLASS_MAIN) 673 | +#define POLL_CS_PAUSE PollClassSet_Union(POLL_CS_MAIN, \ 674 | + PollClassSet_Singleton(POLL_CLASS_PAUSE)) 675 | +#define POLL_CS_CPT PollClassSet_Union(POLL_CS_PAUSE, \ 676 | + PollClassSet_Singleton(POLL_CLASS_CPT)) 677 | +#define POLL_CS_IPC PollClassSet_Union(POLL_CS_CPT, \ 678 | + PollClassSet_Singleton(POLL_CLASS_IPC)) 679 | +#define POLL_CS_VMDB POLL_CS_PAUSE /* POLL_CLASS_VMDB is retired */ 680 | +#define POLL_CS_MKS PollClassSet_Singleton(POLL_CLASS_MKS) 681 | +/* 682 | + * DANGER. You don't need POLL_CS_ALWAYS. Really. So don't use it. 683 | + */ 684 | +#define POLL_CS_ALWAYS PollClassSet_Union(POLL_CS_CPT, POLL_CS_IPC) 685 | + 686 | +/* 687 | + * Poll class-set taxonomy: 688 | + * POLL_CS_MAIN 689 | + * - Unless you NEED another class, use POLL_CS_MAIN. 690 | + * POLL_CS_PAUSE 691 | + * - For callbacks that must occur even if the guest is paused. 692 | + * Most VMDB or Foundry commands are in this category. 693 | + * POLL_CS_CPT 694 | + * - Only for callbacks which can trigger intermediate Checkpoint 695 | + * transitions. 696 | + * The ONLY such callback is Migrate. 697 | + * POLL_CS_IPC 698 | + * - Only for callbacks which can contain Msg_(Post|Hint|Question) 699 | + * responses, and for signal handlers (why)? 700 | + * Vigor, VMDB, and Foundry can contain Msg_* responses. 701 | + * POLL_CS_MKS 702 | + * - Callback runs in MKS thread. 703 | + * POLL_CS_ALWAYS 704 | + * - Only for events that must be processed immediately. 705 | + * The ONLY such callback is OvhdMemVmxSizeCheck. 706 | + */ 707 | + 708 | + 709 | +/* 710 | + * Poll_Callback flags 711 | + */ 712 | + 713 | +#define POLL_FLAG_PERIODIC 0x01 // keep after firing 714 | +#define POLL_FLAG_REMOVE_AT_POWEROFF 0x02 // self-explanatory 715 | +#define POLL_FLAG_READ 0x04 // device is ready for reading 716 | +#define POLL_FLAG_WRITE 0x08 // device is ready for writing 717 | +#define POLL_FLAG_SOCKET 0x10 // device is a Windows socket 718 | +#define POLL_FLAG_NO_BULL 0x20 // callback does its own locking 719 | +#define POLL_FLAG_WINSOCK 0x40 // Winsock style write events 720 | +#define POLL_FLAG_FD 0x80 // device is a Windows file descriptor. 721 | +#define POLL_FLAG_ACCEPT_INVALID_FDS 0x100 // For broken 3rd party libs, e.g. curl 722 | +#define POLL_FLAG_THUNK_TO_WND 0x200 // thunk callback to window message loop 723 | + 724 | + 725 | +typedef void (*PollerFunction)(void *clientData); 726 | +typedef void (*PollerFireWrapper)(PollerFunction func, 727 | + void *funcData, 728 | + void *wrapperData); 729 | +typedef Bool (*PollerErrorFn)(const char *errorStr); 730 | + 731 | +/* 732 | + * Initialisers: 733 | + * 734 | + * For the sake of convenience, we declare the initialisers 735 | + * for custom implmentations here, even though the actual 736 | + * implementations are distinct from the core poll code. 737 | + */ 738 | + 739 | +typedef struct PollOptions { 740 | + Bool locked; // Use internal MXUser for locking 741 | + Bool allowFullQueue; // Don't assert when device event queue is full. 742 | + VThreadID windowsMsgThread; // thread that processes Windows messages 743 | + PollerFireWrapper fireWrapperFn; // optional; may be useful for stats 744 | + void *fireWrapperData; // optional 745 | + PollerErrorFn errorFn; // optional; called upon unrecoverable error 746 | +} PollOptions; 747 | + 748 | + 749 | +void Poll_InitDefault(void); 750 | +void Poll_InitDefaultEx(const PollOptions *opts); 751 | +void Poll_InitGtk(void); // On top of glib for Linux 752 | +void Poll_InitCF(void); // On top of CoreFoundation for OSX 753 | + 754 | + 755 | +/* 756 | + * Functions 757 | + */ 758 | +int Poll_SocketPair(Bool vmci, Bool stream, int fds[2]); 759 | +void Poll_Loop(Bool loop, Bool *exit, PollClass c); 760 | +void Poll_LoopTimeout(Bool loop, Bool *exit, PollClass c, int timeout); 761 | +Bool Poll_LockingEnabled(void); 762 | +void Poll_Exit(void); 763 | + 764 | + 765 | +/* 766 | + * Poll_Callback adds a callback regardless of whether an identical one exists. 767 | + * The exception to this rule is POLL_DEVICE callbacks: there is a maximum of 768 | + * one read and one write callback per fd. 769 | + * 770 | + * Poll_CallbackRemove removes one callback. If there are multiple identical 771 | + * callbacks, which one is removed is an implementation detail. Note that in 772 | + * the case of POLL_DEVICE and POLL_REALTIME callbacks, the fd/delay used to 773 | + * create the callback is not specified when removing, so all callbacks 774 | + * of those types with the same flags, function, and clientData are considered 775 | + * "identical" even if their fd/delay differed. 776 | + */ 777 | + 778 | +VMwareStatus Poll_Callback(PollClassSet classSet, 779 | + int flags, 780 | + PollerFunction f, 781 | + void *clientData, 782 | + PollEventType type, 783 | + PollDevHandle info, // fd/microsec delay 784 | + MXUserRecLock *lck); 785 | +Bool Poll_CallbackRemove(PollClassSet classSet, 786 | + int flags, 787 | + PollerFunction f, 788 | + void *clientData, 789 | + PollEventType type); 790 | +Bool Poll_CallbackRemoveOneByCB(PollClassSet classSet, 791 | + int flags, 792 | + PollerFunction f, 793 | + PollEventType type, 794 | + void **clientData); 795 | + 796 | +void Poll_NotifyChange(PollClassSet classSet); 797 | + 798 | +/* 799 | + * Wrappers for Poll_Callback and Poll_CallbackRemove that present 800 | + * simpler subsets of those interfaces. 801 | + */ 802 | + 803 | +VMwareStatus Poll_CB_Device(PollerFunction f, 804 | + void *clientData, 805 | + PollDevHandle device, 806 | + Bool periodic); 807 | + 808 | +Bool Poll_CB_DeviceRemove(PollerFunction f, 809 | + void *clientData, 810 | + Bool periodic); 811 | + 812 | + 813 | +VMwareStatus Poll_CB_RTime(PollerFunction f, 814 | + void *clientData, 815 | + int64 delay, // microseconds 816 | + Bool periodic, 817 | + MXUserRecLock *lock); 818 | + 819 | +Bool Poll_CB_RTimeRemove(PollerFunction f, 820 | + void *clientData, 821 | + Bool periodic); 822 | + 823 | + 824 | +#ifdef _WIN32 825 | +void Poll_SetPumpsWindowsMessages(Bool pumps); 826 | +void Poll_SetWindowMessageRecipient(HWND hWnd, UINT msg, Bool alwaysThunk); 827 | +Bool Poll_FireWndCallback(void *lparam); 828 | +#endif 829 | + 830 | +#if defined(__cplusplus) 831 | +} // extern "C" 832 | +#endif 833 | + 834 | +#endif // _POLL_H_ 835 | diff -urN a/open-vm-tools/lib/misc/idLinux.c b/open-vm-tools/lib/misc/idLinux.c 836 | --- a/open-vm-tools/lib/misc/idLinux.c 2019-01-23 16:28:44.000000000 +0800 837 | +++ b/open-vm-tools/lib/misc/idLinux.c 2019-01-23 16:07:55.000000000 +0800 838 | @@ -27,12 +27,9 @@ 839 | #include 840 | #include 841 | #include 842 | -#ifdef __linux__ 843 | -#if defined(__GLIBC__) && \ 844 | - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) 845 | +#ifdef HAVE_SYS_AUXV_H 846 | #include 847 | #endif 848 | -#endif 849 | #ifdef __APPLE__ 850 | #include 851 | #include 852 | @@ -1004,10 +1001,6 @@ 853 | static Bool 854 | IdIsSetUGid(void) 855 | { 856 | -#if defined(__ANDROID__) 857 | - /* Android does not have a secure_getenv, so be conservative. */ 858 | - return TRUE; 859 | -#else 860 | /* 861 | * We use __secure_getenv, which returns NULL if the binary is 862 | * setuid or setgid. Alternatives include, 863 | @@ -1018,17 +1011,20 @@ 864 | * Use (a) when we are based on glibc 2.16, or newer. 865 | */ 866 | 867 | -#if defined(__GLIBC__) && \ 868 | - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) 869 | +#if HAVE_ISSETUGID 870 | + return issetugid(); 871 | +#elif HAVE_GETAUXVAL 872 | return getauxval(AT_SECURE) != 0; 873 | -#else 874 | +#elif HAVE___SECURE_GETENV 875 | static const char envName[] = "VMW_SETUGID_TEST"; 876 | 877 | if (setenv(envName, "1", TRUE) == -1) { 878 | return TRUE; /* Conservative */ 879 | } 880 | return __secure_getenv(envName) == NULL; 881 | -#endif 882 | +#else 883 | + /* Android does not have a secure_getenv, so be conservative. */ 884 | + return TRUE; 885 | #endif 886 | } 887 | #endif 888 | diff -urN a/open-vm-tools/lib/nicInfo/nicInfoPosix.c b/open-vm-tools/lib/nicInfo/nicInfoPosix.c 889 | --- a/open-vm-tools/lib/nicInfo/nicInfoPosix.c 2019-01-23 16:28:44.000000000 +0800 890 | +++ b/open-vm-tools/lib/nicInfo/nicInfoPosix.c 2019-01-23 16:08:41.000000000 +0800 891 | @@ -34,9 +34,13 @@ 892 | #include 893 | #include 894 | #include 895 | -#if defined(__FreeBSD__) || defined(__APPLE__) 896 | +#if HAVE_SYS_SYSCTL_H 897 | # include 898 | +#endif 899 | +#if HAVE_IFADDRS_H 900 | # include 901 | +#endif 902 | +#if HAVE_NET_IF_H 903 | # include 904 | #endif 905 | #ifndef NO_DNET 906 | diff -urN a/open-vm-tools/lib/rpcIn/rpcin.c b/open-vm-tools/lib/rpcIn/rpcin.c 907 | --- a/open-vm-tools/lib/rpcIn/rpcin.c 2019-01-23 16:28:44.000000000 +0800 908 | +++ b/open-vm-tools/lib/rpcIn/rpcin.c 2019-01-23 16:13:42.000000000 +0800 909 | @@ -57,7 +57,7 @@ 910 | 911 | #if defined(VMTOOLS_USE_VSOCKET) 912 | # include 913 | -# include "poll.h" 914 | +# include "vm_poll.h" 915 | # include "asyncsocket.h" 916 | # include "vmci_defs.h" 917 | #include "dataMap.h" 918 | diff -urN a/open-vm-tools/lib/wiper/wiperPosix.c b/open-vm-tools/lib/wiper/wiperPosix.c 919 | --- a/open-vm-tools/lib/wiper/wiperPosix.c 2019-01-23 16:28:44.000000000 +0800 920 | +++ b/open-vm-tools/lib/wiper/wiperPosix.c 2019-01-23 15:59:12.000000000 +0800 921 | @@ -43,6 +43,9 @@ 922 | # include 923 | # endif /* __FreeBSD_version >= 500000 */ 924 | #endif 925 | +#if defined(__linux__) 926 | +#include 927 | +#endif 928 | #include 929 | 930 | #include "vmware.h" 931 | diff -urN a/open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c b/open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c 932 | --- a/open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c 2019-01-23 16:28:44.000000000 +0800 933 | +++ b/open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c 2019-01-23 16:03:18.000000000 +0800 934 | @@ -52,7 +52,7 @@ 935 | 936 | #define DND_ROOTDIR_PERMS (S_IRWXU | S_IRWXG | S_IRWXO) 937 | #define DND_STAGINGDIR_PERMS (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) 938 | -#ifdef sun 939 | +#ifndef ACCESSPERMS 940 | #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) 941 | #endif 942 | #ifdef __ANDROID__ 943 | @@ -61,7 +61,6 @@ 944 | */ 945 | #define NO_SETMNTENT 946 | #define NO_ENDMNTENT 947 | -#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) 948 | #endif 949 | 950 | 951 | diff -urN a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c 952 | --- a/open-vm-tools/services/plugins/vix/vixTools.c 2019-01-23 16:28:44.000000000 +0800 953 | +++ b/open-vm-tools/services/plugins/vix/vixTools.c 2019-01-23 16:09:07.000000000 +0800 954 | @@ -66,7 +66,7 @@ 955 | #include 956 | #endif 957 | 958 | -#if defined(sun) || defined(__FreeBSD__) || defined(__APPLE__) 959 | +#ifdef HAVE_SYS_STAT_H 960 | #include 961 | #endif 962 | 963 | --------------------------------------------------------------------------------