1 | #!/bin/bash
|
---|
2 | # $Id: load.sh 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # For GA development.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2006-2023 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 |
|
---|
38 | DRVNAME="vboxguest"
|
---|
39 | DRIVERS_USING_IT="vboxfs"
|
---|
40 |
|
---|
41 | DRVFILE=`dirname "$0"`
|
---|
42 | DRVFILE=`cd "$DRVFILE" && pwd`
|
---|
43 | DRVFILE="$DRVFILE/$DRVNAME"
|
---|
44 | if [ ! -f "$DRVFILE" ]; then
|
---|
45 | echo "load.sh: Cannot find $DRVFILE or it's not a file..."
|
---|
46 | exit 1;
|
---|
47 | fi
|
---|
48 |
|
---|
49 | SUDO=sudo
|
---|
50 | #set -x
|
---|
51 |
|
---|
52 | # Unload driver that may depend on the driver we're going to (re-)load
|
---|
53 | # as well as the driver itself.
|
---|
54 | for drv in $DRIVERS_USING_IT $DRVNAME;
|
---|
55 | do
|
---|
56 | LOADED=`modinfo | grep -w "$drv"`
|
---|
57 | if test -n "$LOADED"; then
|
---|
58 | MODID=`echo "$LOADED" | cut -d ' ' -f 1`
|
---|
59 | $SUDO modunload -i $MODID;
|
---|
60 | LOADED=`modinfo | grep -w "$drv"`;
|
---|
61 | if test -n "$LOADED"; then
|
---|
62 | echo "load.sh: failed to unload $drv";
|
---|
63 | dmesg | tail
|
---|
64 | exit 1;
|
---|
65 | fi
|
---|
66 | fi
|
---|
67 | done
|
---|
68 |
|
---|
69 | #
|
---|
70 | # Update the devlink.tab file so we get a /dev/vboxguest node.
|
---|
71 | #
|
---|
72 | set -e
|
---|
73 | sed -e '/name=vboxguest/d' /etc/devlink.tab > /tmp/devlink.vbox
|
---|
74 | echo -e "type=ddi_pseudo;name=vboxguest\t\D" >> /tmp/devlink.vbox
|
---|
75 | $SUDO cp /tmp/devlink.vbox /etc/devlink.tab
|
---|
76 | $SUDO ln -fs ../devices/pci@0,0/pci80ee,cafe@4:vboxguest /dev/vboxguest
|
---|
77 | set +e
|
---|
78 |
|
---|
79 | #
|
---|
80 | # The add_drv command will load the driver, so we need to temporarily put it
|
---|
81 | # in a place that is searched in order to load it.
|
---|
82 | #
|
---|
83 | MY_RC=1
|
---|
84 | set -e
|
---|
85 | $SUDO rm -f \
|
---|
86 | "/usr/kernel/drv/${DRVNAME}" \
|
---|
87 | "/usr/kernel/drv/amd64/${DRVNAME}"
|
---|
88 | sync
|
---|
89 | $SUDO cp "${DRVFILE}" /platform/i86pc/kernel/drv/amd64/
|
---|
90 | set +e
|
---|
91 |
|
---|
92 | $SUDO rem_drv $DRVNAME
|
---|
93 | if $SUDO add_drv -ipci80ee,cafe -m"* 0666 root sys" -v $DRVNAME; then
|
---|
94 | sync
|
---|
95 | $SUDO /usr/sbin/devfsadm -i $DRVNAME
|
---|
96 | MY_RC=0
|
---|
97 | else
|
---|
98 | dmesg | tail
|
---|
99 | echo "load.sh: add_drv failed."
|
---|
100 | fi
|
---|
101 |
|
---|
102 | $SUDO rm -f \
|
---|
103 | "/usr/kernel/drv/${DRVNAME}" \
|
---|
104 | "/usr/kernel/drv/amd64/${DRVNAME}"
|
---|
105 | sync
|
---|
106 |
|
---|
107 | exit $MY_RC;
|
---|
108 |
|
---|