From: VMware, Inc <> Date: Tue, 29 Mar 2011 20:07:22 +0000 (-0700) Subject: vmblock: fix problem with missing Panic symbol on FreeBSD X-Git-Tag: 2011.03.28-387002~51 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2e7bbe3b3f8331b63fd8e5d2c05e166c195e64eb;p=thirdparty%2Fopen-vm-tools.git vmblock: fix problem with missing Panic symbol on FreeBSD We need to make sure we compile and link stubs.c so that out Panic() resolves. And since FreeBSD does not have panic that takes va_list arguments we need to implement one. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/modules/freebsd/vmblock/Makefile b/open-vm-tools/modules/freebsd/vmblock/Makefile index 10c0886dc..594cba40e 100644 --- a/open-vm-tools/modules/freebsd/vmblock/Makefile +++ b/open-vm-tools/modules/freebsd/vmblock/Makefile @@ -39,9 +39,11 @@ HEADERS += vmblock_k.h HEADERS += os.h CSRCS := block.c +CSRCS += os_panic.c CSRCS += vfsops.c CSRCS += vnops.c CSRCS += subr.c +CSRCS += stubs.c SRCS := $(HEADERS) $(CSRCS) diff --git a/open-vm-tools/modules/freebsd/vmblock/os.h b/open-vm-tools/modules/freebsd/vmblock/os.h index 615a19fb2..5528f2a53 100644 --- a/open-vm-tools/modules/freebsd/vmblock/os.h +++ b/open-vm-tools/modules/freebsd/vmblock/os.h @@ -47,6 +47,7 @@ #include #include #include +#include #include "vm_basic_types.h" @@ -75,7 +76,7 @@ typedef struct file * os_blocker_id_t; #define OS_FMTTID "p" #define os_threadid curthread -#define os_panic(fmt, args) panic(fmt, args) +extern NORETURN void os_panic(const char *fmt, va_list args); #define os_rwlock_init(lock) sx_init(lock, "vmblock-sx") #define os_rwlock_destroy(lock) sx_destroy(lock) diff --git a/open-vm-tools/modules/freebsd/vmblock/os_panic.c b/open-vm-tools/modules/freebsd/vmblock/os_panic.c new file mode 100644 index 000000000..94e79aae5 --- /dev/null +++ b/open-vm-tools/modules/freebsd/vmblock/os_panic.c @@ -0,0 +1,70 @@ +/********************************************************* + * Copyright (C) 2011 VMware, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of VMware Inc. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission of VMware Inc. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + *********************************************************/ + + +/* + * os_panic.c -- + * + * Vararg panic implementation for FreeBSD. + */ + +#include +#include +#include + +#include "os.h" + +/* + *---------------------------------------------------------------------------- + * + * os_panic -- + * + * FreeBSD panic implementation that takes va_list argument. + * + * Results: + * None. + * + * Side effects: + * We panic. + * + *---------------------------------------------------------------------------- + */ + +void +os_panic(const char *fmt, // IN + va_list args) // IN +{ + static char message[1024]; + + vsnprintf(message, sizeof message - 1, fmt, args); + message[sizeof message - 1] = '\0'; + + panic("%s", message); +} diff --git a/open-vm-tools/modules/shared/vmblock/stubs.c b/open-vm-tools/modules/shared/vmblock/stubs.c index 45bf7f806..cc284da4d 100644 --- a/open-vm-tools/modules/shared/vmblock/stubs.c +++ b/open-vm-tools/modules/shared/vmblock/stubs.c @@ -65,9 +65,15 @@ * Common stubs. */ +#if defined(__FreeBSD__) +#include +#include +#else #include +#endif #include "os.h" +#include "vm_assert.h" /* *---------------------------------------------------------------------------- @@ -93,4 +99,11 @@ Panic(const char *fmt, ...) va_start(args, fmt); os_panic(fmt, args); va_end(args); + + /* + * Solaris's vcmn_err() is not marked as NORETURN and thus generates a + * warning. I'd use NOT_REACHED(), as recommended, except that we are + * already in Panic(). + */ + INFINITE_LOOP(); } diff --git a/open-vm-tools/vmblock-fuse/os.h b/open-vm-tools/vmblock-fuse/os.h index 5bfc3d9cb..68afbf835 100644 --- a/open-vm-tools/vmblock-fuse/os.h +++ b/open-vm-tools/vmblock-fuse/os.h @@ -59,7 +59,7 @@ typedef char * os_blocker_id_t; #define os_panic(fmt, args) \ ({ \ - fprintf(stderr, fmt, args); \ + vfprintf(stderr, fmt, args); \ abort(); \ })