VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/solaris/load.sh@ 97441

Last change on this file since 97441 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1#!/bin/bash
2# $Id: load.sh 96407 2022-08-22 17:43:14Z vboxsync $
3## @file
4# For development.
5#
6
7#
8# Copyright (C) 2006-2022 Oracle and/or its affiliates.
9#
10# This file is part of VirtualBox base platform packages, as
11# available from https://www.virtualbox.org.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation, in version 3 of the
16# License.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, see <https://www.gnu.org/licenses>.
25#
26# The contents of this file may alternatively be used under the terms
27# of the Common Development and Distribution License Version 1.0
28# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
29# in the VirtualBox distribution, in which case the provisions of the
30# CDDL are applicable instead of those of the GPL.
31#
32# You may elect to license modified versions of this file under the
33# terms and conditions of either the GPL or the CDDL or both.
34#
35# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
36#
37
38DRVNAME="vboxdrv"
39DRIVERS_USING_IT="vboxusb vboxusbmon vboxnet vboxflt vboxbow"
40
41DRVFILE=`dirname "$0"`
42DRVFILE=`cd "$DRVFILE" && pwd`
43DRVFILE="$DRVFILE/$DRVNAME"
44if [ ! -f "$DRVFILE" ]; then
45 echo "load.sh: Cannot find $DRVFILE or it's not a file..."
46 exit 1;
47fi
48if [ ! -f "$DRVFILE.conf" ]; then
49 echo "load.sh: Cannot find $DRVFILE.conf or it's not a file..."
50 exit 1;
51fi
52
53SUDO=sudo
54#set -x
55
56# Disable the zone access service.
57servicefound=`svcs -H "virtualbox/zoneaccess" 2>/dev/null | grep '^online'`
58if test ! -z "$servicefound"; then
59 $SUDO svcadm disable svc:/application/virtualbox/zoneaccess:default
60fi
61
62# Unload driver that may depend on the driver we're going to (re-)load
63# as well as the driver itself.
64for drv in $DRIVERS_USING_IT $DRVNAME;
65do
66 LOADED=`modinfo | grep -w "$drv"`
67 if test -n "$LOADED"; then
68 MODID=`echo "$LOADED" | cut -d ' ' -f 1`
69 $SUDO modunload -i $MODID;
70 LOADED=`modinfo | grep -w "$drv"`;
71 if test -n "$LOADED"; then
72 echo "load.sh: failed to unload $drv";
73 dmesg | tail
74 exit 1;
75 fi
76 fi
77done
78
79#
80# Reconfigure the driver so it get a major number.
81#
82# Note! We have to copy the driver and config files to somewhere the kernel can
83# find them. It is searched for as drv/${DRVNAME}.conf in
84# kobj_module_path, which is usually:
85# /platform/i86pc/kernel /kernel /usr/kernel
86# To try prevent bad drivers from being loaded on the next boot, we remove
87# always the files.
88#
89MY_RC=1
90set -e
91$SUDO rm -f \
92 "/platform/i86pc/kernel/drv/${DRVNAME}.conf" \
93 "/platform/i86pc/kernel/drv/${DRVNAME}" \
94 "/platform/i86pc/kernel/drv/amd64/${DRVNAME}"
95sync
96$SUDO cp "${DRVFILE}" /platform/i86pc/kernel/drv/amd64/
97$SUDO cp "${DRVFILE}.conf" /platform/i86pc/kernel/drv/
98set +e
99
100$SUDO rem_drv $DRVNAME
101if $SUDO add_drv -v $DRVNAME; then
102 sync
103 if $SUDO modload "/platform/i86pc/kernel/drv/amd64/${DRVNAME}"; then
104 echo "load.sh: successfully loaded the driver"
105 modinfo | grep -w "$DRVNAME"
106 MY_RC=0
107 if test ! -h "/dev/vboxdrv"; then
108 $SUDO ln -sf "/devices/pseudo/vboxdrv@0:vboxdrv" /dev/vboxdrv
109 $SUDO chmod 0666 /dev/vboxdrv
110 fi
111 else
112 dmesg | tail
113 echo "load.sh: modload failed"
114 fi
115else
116 dmesg | tail
117 echo "load.sh: add_drv failed."
118fi
119
120$SUDO rm -f \
121 "/platform/i86pc/kernel/drv/${DRVNAME}.conf" \
122 "/platform/i86pc/kernel/drv/${DRVNAME}" \
123 "/platform/i86pc/kernel/drv/amd64/${DRVNAME}"
124sync
125
126exit $MY_RC;
127
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