1 | #!/bin/bash
|
---|
2 | # $Id: load.sh 69109 2017-10-17 14:22:06Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # For GA development.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2006-2017 Oracle Corporation
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | # General Public License (GPL) as published by the Free Software
|
---|
14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | #
|
---|
18 | # The contents of this file may alternatively be used under the terms
|
---|
19 | # of the Common Development and Distribution License Version 1.0
|
---|
20 | # (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
21 | # VirtualBox OSE distribution, in which case the provisions of the
|
---|
22 | # CDDL are applicable instead of those of the GPL.
|
---|
23 | #
|
---|
24 | # You may elect to license modified versions of this file under the
|
---|
25 | # terms and conditions of either the GPL or the CDDL or both.
|
---|
26 | #
|
---|
27 |
|
---|
28 | DRVNAME="vboxguest"
|
---|
29 | DRIVERS_USING_IT="vboxfs"
|
---|
30 |
|
---|
31 | DRVFILE=`dirname "$0"`
|
---|
32 | DRVFILE=`cd "$DRVFILE" && pwd`
|
---|
33 | DRVFILE="$DRVFILE/$DRVNAME"
|
---|
34 | if [ ! -f "$DRVFILE" ]; then
|
---|
35 | echo "load.sh: Cannot find $DRVFILE or it's not a file..."
|
---|
36 | exit 1;
|
---|
37 | fi
|
---|
38 |
|
---|
39 | SUDO=sudo
|
---|
40 | #set -x
|
---|
41 |
|
---|
42 | # Unload driver that may depend on the driver we're going to (re-)load
|
---|
43 | # as well as the driver itself.
|
---|
44 | for drv in $DRIVERS_USING_IT $DRVNAME;
|
---|
45 | do
|
---|
46 | LOADED=`modinfo | grep -w "$drv"`
|
---|
47 | if test -n "$LOADED"; then
|
---|
48 | MODID=`echo "$LOADED" | cut -d ' ' -f 1`
|
---|
49 | $SUDO modunload -i $MODID;
|
---|
50 | LOADED=`modinfo | grep -w "$drv"`;
|
---|
51 | if test -n "$LOADED"; then
|
---|
52 | echo "load.sh: failed to unload $drv";
|
---|
53 | dmesg | tail
|
---|
54 | exit 1;
|
---|
55 | fi
|
---|
56 | fi
|
---|
57 | done
|
---|
58 |
|
---|
59 | #
|
---|
60 | # Update the devlink.tab file so we get a /dev/vboxguest node.
|
---|
61 | #
|
---|
62 | set -e
|
---|
63 | sed -e '/name=vboxguest/d' /etc/devlink.tab > /tmp/devlink.vbox
|
---|
64 | echo -e "type=ddi_pseudo;name=vboxguest\t\D" >> /tmp/devlink.vbox
|
---|
65 | $SUDO cp /tmp/devlink.vbox /etc/devlink.tab
|
---|
66 | $SUDO ln -fs ../devices/pci@0,0/pci80ee,cafe@4:vboxguest /dev/vboxguest
|
---|
67 | set +e
|
---|
68 |
|
---|
69 | #
|
---|
70 | # The add_drv command will load the driver, so we need to temporarily put it
|
---|
71 | # in a place that is searched in order to load it.
|
---|
72 | #
|
---|
73 | MY_RC=1
|
---|
74 | set -e
|
---|
75 | $SUDO rm -f \
|
---|
76 | "/usr/kernel/drv/${DRVNAME}" \
|
---|
77 | "/usr/kernel/drv/amd64/${DRVNAME}"
|
---|
78 | sync
|
---|
79 | $SUDO cp "${DRVFILE}" /platform/i86pc/kernel/drv/amd64/
|
---|
80 | set +e
|
---|
81 |
|
---|
82 | $SUDO rem_drv $DRVNAME
|
---|
83 | if $SUDO add_drv -ipci80ee,cafe -m"* 0666 root sys" -v $DRVNAME; then
|
---|
84 | sync
|
---|
85 | $SUDO /usr/sbin/devfsadm -i $DRVNAME
|
---|
86 | MY_RC=0
|
---|
87 | else
|
---|
88 | dmesg | tail
|
---|
89 | echo "load.sh: add_drv failed."
|
---|
90 | fi
|
---|
91 |
|
---|
92 | $SUDO rm -f \
|
---|
93 | "/usr/kernel/drv/${DRVNAME}" \
|
---|
94 | "/usr/kernel/drv/amd64/${DRVNAME}"
|
---|
95 | sync
|
---|
96 |
|
---|
97 | exit $MY_RC;
|
---|
98 |
|
---|