VirtualBox

source: vbox/trunk/src/VBox/Main/solaris/DynLoadLibSolaris.cpp@ 28800

Last change on this file since 28800 was 28800, checked in by vboxsync, 14 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/* $Id: DynLoadLibSolaris.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * Dynamically load libraries for Solaris hosts.
4 */
5
6/*
7 * Copyright (C) 2008 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include "DynLoadLibSolaris.h"
19
20#include <iprt/err.h>
21#include <iprt/ldr.h>
22
23
24/** -=-=-=-=-= LIB DLPI -=-=-=-=-=-=- **/
25
26/**
27 * Global pointer to the libdlpi module. This should only be set once all needed libraries
28 * and symbols have been successfully loaded.
29 */
30static RTLDRMOD g_hLibDlpi = NULL;
31
32/**
33 * Whether we have tried to load libdlpi yet. This flag should only be set
34 * to "true" after we have either loaded both libraries and all symbols which we need,
35 * or failed to load something and unloaded.
36 */
37static bool g_fCheckedForLibDlpi = false;
38
39/** All the symbols we need from libdlpi.
40 * @{
41 */
42int (*g_pfnLibDlpiWalk)(dlpi_walkfunc_t *, void *, uint_t);
43/** @} */
44
45bool VBoxSolarisLibDlpiFound(void)
46{
47 RTLDRMOD hLibDlpi;
48
49 if (g_hLibDlpi && g_fCheckedForLibDlpi)
50 return true;
51 if (g_fCheckedForLibDlpi)
52 return false;
53 if (!RT_SUCCESS(RTLdrLoad(LIB_DLPI, &hLibDlpi)))
54 return false;
55 /*
56 * Unfortunately; we cannot make use of dlpi_get_physaddr because it requires us to
57 * open the VNIC/link which requires root permissions :/
58 */
59 if (RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_walk", (void **)&g_pfnLibDlpiWalk)))
60 {
61 g_hLibDlpi = hLibDlpi;
62 g_fCheckedForLibDlpi = true;
63 return true;
64 }
65 else
66 {
67 RTLdrClose(hLibDlpi);
68 g_fCheckedForLibDlpi = true;
69 return false;
70 }
71}
72
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette