#!/bin/sh

# Upon request, this file mounts a host directory containing kernel modules

#     Copyright 2002-2007 Massimo Rimondini - Computer Networks Research Group,
#     Roma Tre University.
#
#     This file is part of Netkit.
#
#     Netkit is free software: you can redistribute it and/or modify it under
#     the terms of the GNU General Public License as published by the Free
#     Software Foundation, either version 3 of the License, or (at your option)
#     any later version.
#
#     Netkit is distributed in the hope that it will be useful, but WITHOUT ANY
#     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#     FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
#     details.
#
#     You should have received a copy of the GNU General Public License along
#     with Netkit.  If not, see <http://www.gnu.org/licenses/>.


MODULES=`cat /proc/cmdline | awk -v FS== -v RS=' ' '{if ($1=="modules") {print $2}}'`

if [ -n "$MODULES" ]; then
   MODULES="$MODULES"/lib/modules
   echo "Mounting kernel modules directory ($MODULES) on /lib/modules/ ..."
   # Write access is needed for depmod in order to work properly
   mount none /lib/modules/ -t hostfs -o rw,$MODULES
else
   echo "Modules directory not mounted."
fi

