1 | #!/bin/bash
|
---|
2 | # $Id: loadfs.sh 76553 2019-01-01 01:45:53Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # For GA development.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2006-2019 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="vboxfs"
|
---|
29 | MOUNTHLP="vboxfsmount"
|
---|
30 |
|
---|
31 | DRVFILE=`dirname "$0"`
|
---|
32 | DRVFILE=`cd "$DRVFILE" && pwd`
|
---|
33 | MOUNTHLPFILE="$DRVFILE/$MOUNTHLP"
|
---|
34 | DRVFILE="$DRVFILE/$DRVNAME"
|
---|
35 | if [ ! -f "$DRVFILE" ]; then
|
---|
36 | echo "loadfs.sh: Cannot find $DRVFILE or it's not a file..."
|
---|
37 | exit 1;
|
---|
38 | fi
|
---|
39 | if [ ! -f "$MOUNTHLPFILE" ]; then
|
---|
40 | echo "load.sh: Cannot find $MOUNTHLPFILE or it's not a file..."
|
---|
41 | exit 1;
|
---|
42 | fi
|
---|
43 |
|
---|
44 | SUDO=sudo
|
---|
45 | #set -x
|
---|
46 |
|
---|
47 | # Unload the driver if loaded.
|
---|
48 | for drv in $DRVNAME;
|
---|
49 | do
|
---|
50 | LOADED=`modinfo | grep -w "$drv"`
|
---|
51 | if test -n "$LOADED"; then
|
---|
52 | MODID=`echo "$LOADED" | cut -d ' ' -f 1`
|
---|
53 | $SUDO modunload -i $MODID;
|
---|
54 | LOADED=`modinfo | grep -w "$drv"`;
|
---|
55 | if test -n "$LOADED"; then
|
---|
56 | echo "load.sh: failed to unload $drv";
|
---|
57 | dmesg | tail
|
---|
58 | exit 1;
|
---|
59 | fi
|
---|
60 | fi
|
---|
61 | done
|
---|
62 |
|
---|
63 | #
|
---|
64 | # Remove old stuff.
|
---|
65 | #
|
---|
66 | MY_RC=1
|
---|
67 | set -e
|
---|
68 | $SUDO rm -f \
|
---|
69 | "/usr/kernel/fs/${DRVNAME}" \
|
---|
70 | "/usr/kernel/fs/amd64/${DRVNAME}" \
|
---|
71 | "/etc/fs/vboxfs/mount"
|
---|
72 | sync
|
---|
73 | set +e
|
---|
74 |
|
---|
75 | #
|
---|
76 | # Install the mount program.
|
---|
77 | #
|
---|
78 | if [ ! -d /etc/fs/vboxfs ]; then
|
---|
79 | $SUDO mkdir -p /etc/fs/vboxfs
|
---|
80 | fi
|
---|
81 | $SUDO ln -sf "$MOUNTHLPFILE" /etc/fs/vboxfs/mount
|
---|
82 |
|
---|
83 | #
|
---|
84 | # Load the module. We can load it without copying it to /usr/kernel/fs/.
|
---|
85 | #
|
---|
86 | if $SUDO modload "$DRVFILE"; then
|
---|
87 | sync
|
---|
88 | MY_RC=0
|
---|
89 | else
|
---|
90 | dmesg | tail
|
---|
91 | echo "load.sh: add_drv failed."
|
---|
92 | fi
|
---|
93 |
|
---|
94 | exit $MY_RC;
|
---|
95 |
|
---|