VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.cpp@ 69500

Last change on this file since 69500 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.2 KB
Line 
1/* $Id: DynLoadLibSolaris.cpp 69500 2017-10-28 15:14:05Z vboxsync $ */
2/** @file
3 * Dynamically load libraries for Solaris hosts.
4 */
5
6/*
7 * Copyright (C) 2008-2017 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 = NIL_RTLDRMOD;
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);
43int (*g_pfnLibDlpiOpen)(const char *, dlpi_handle_t *, uint_t);
44void (*g_pfnLibDlpiClose)(dlpi_handle_t);
45/** @} */
46
47bool VBoxSolarisLibDlpiFound(void)
48{
49 RTLDRMOD hLibDlpi;
50
51 if (g_fCheckedForLibDlpi)
52 return g_hLibDlpi != NIL_RTLDRMOD;
53 g_fCheckedForLibDlpi = true;
54 int rc = RTLdrLoad(LIB_DLPI, &hLibDlpi);
55 if (RT_SUCCESS(rc))
56 {
57 /*
58 * Unfortunately; we cannot make use of dlpi_get_physaddr because it requires us to
59 * open the VNIC/link which requires root permissions :/
60 */
61 rc = RTLdrGetSymbol(hLibDlpi, "dlpi_walk", (void **)&g_pfnLibDlpiWalk);
62 rc |= RTLdrGetSymbol(hLibDlpi, "dlpi_close", (void **)&g_pfnLibDlpiClose);
63 rc |= RTLdrGetSymbol(hLibDlpi, "dlpi_open", (void **)&g_pfnLibDlpiOpen);
64 if (RT_SUCCESS(rc))
65 {
66 g_hLibDlpi = hLibDlpi;
67 return true;
68 }
69
70 RTLdrClose(hLibDlpi);
71 }
72 hLibDlpi = NIL_RTLDRMOD;
73 return false;
74}
75
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