VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/darwin/load.sh@ 13073

Last change on this file since 13073 was 10712, checked in by vboxsync, 16 years ago

Made the mac os x load*.sh scripts produce symbols and a copy of the kext for kernel debugging with gdb.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
1#!/bin/bash
2## @file
3# For development.
4#
5
6#
7# Copyright (C) 2006-2007 Sun Microsystems, Inc.
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# The contents of this file may alternatively be used under the terms
18# of the Common Development and Distribution License Version 1.0
19# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20# VirtualBox OSE distribution, in which case the provisions of the
21# CDDL are applicable instead of those of the GPL.
22#
23# You may elect to license modified versions of this file under the
24# terms and conditions of either the GPL or the CDDL or both.
25#
26# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27# Clara, CA 95054 USA or visit http://www.sun.com if you need
28# additional information or have any questions.
29#
30
31DRVNAME="VBoxDrv.kext"
32BUNDLE="org.virtualbox.kext.VBoxDrv"
33
34DIR=`dirname "$0"`
35DIR=`cd "$DIR" && pwd`
36DIR="$DIR/$DRVNAME"
37if [ ! -d "$DIR" ]; then
38 echo "Cannot find $DIR or it's not a directory..."
39 exit 1;
40fi
41if [ -n "$*" ]; then
42 OPTS="$*"
43else
44 OPTS="-t"
45fi
46
47# Make sure VBoxUSB is unloaded as it might be using symbols from us.
48LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
49if test -n "$LOADED"; then
50 echo "load.sh: Unloading org.virtualbox.kext.VBoxUSB..."
51 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxUSB
52 LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
53 if test -n "$LOADED"; then
54 echo "load.sh: failed to unload org.virtualbox.kext.VBoxUSB, see above..."
55 exit 1;
56 fi
57 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxUSB"
58fi
59
60# Try unload any existing instance first.
61LOADED=`kextstat -b $BUNDLE -l`
62if test -n "$LOADED"; then
63 echo "load.sh: Unloading $BUNDLE..."
64 sudo kextunload -v 6 -b $BUNDLE
65 LOADED=`kextstat -b $BUNDLE -l`
66 if test -n "$LOADED"; then
67 echo "load.sh: failed to unload $BUNDLE, see above..."
68 exit 1;
69 fi
70 echo "load.sh: Successfully unloaded $BUNDLE"
71fi
72
73set -e
74
75# Copy the .kext to the symbols directory and tweak the kextload options.
76if test -n "$VBOX_DARWIN_SYMS"; then
77 echo "load.sh: copying the extension the symbol area..."
78 rm -Rf "$VBOX_DARWIN_SYMS/$DRVNAME"
79 mkdir -p "$VBOX_DARWIN_SYMS"
80 cp -R "$DIR" "$VBOX_DARWIN_SYMS/"
81 OPTS="$OPTS -s $VBOX_DARWIN_SYMS/ "
82 sync
83fi
84
85trap "sudo chown -R `whoami` $DIR; exit 1" INT
86# On smbfs, this might succeed just fine but make no actual changes,
87# so we might have to temporarily copy the driver to a local directory.
88sudo chown -R root:wheel "$DIR"
89OWNER=`/usr/bin/stat -f "%u" "$DIR"`
90if test "$OWNER" -ne 0; then
91 TMP_DIR=/tmp/loaddrv.tmp
92 echo "load.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
93
94 # clean up first (no sudo rm)
95 if test -e "$TMP_DIR"; then
96 sudo chown -R `whoami` "$TMP_DIR"
97 rm -Rf "$TMP_DIR"
98 fi
99
100 # make a copy and switch over DIR
101 mkdir -p "$TMP_DIR/"
102 cp -Rp "$DIR" "$TMP_DIR/"
103 DIR="$TMP_DIR/$DRVNAME"
104
105 # retry
106 sudo chown -R root:wheel "$DIR"
107fi
108sudo chmod -R o-rwx "$DIR"
109sync
110echo "load.sh: loading $DIR..."
111sudo kextload $OPTS "$DIR"
112sync
113sudo chown -R `whoami` "$DIR"
114#sudo chmod 666 /dev/vboxdrv
115kextstat | grep org.virtualbox.kext
116
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