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