Commit 698b4622 authored by Pavel Shilovsky's avatar Pavel Shilovsky

Fix rmmod after umount problem

parent 9a1cf2b4
......@@ -20,18 +20,20 @@ MODINFO=/sbin/modinfo
# against run with sudo
export PATH=$PATH:/sbin:/usr/sbin
. @DATADIR@/functions.sh
PACKAGEINFO=@DATADIR@/package.conf
if [ -f "$PACKAGEINFO" ] ; then
. $PACKAGEINFO
. $PACKAGEINFO
else
fatal "Not found package information file $PACKAGEINFO"
fatal "Not found package information file $PACKAGEINFO"
fi
CONFIGFILE=@SYSCONFIGDIR@/etercifs.conf
if [ -f $CONFIGFILE ] ; then
. $CONFIGFILE
. $CONFIGFILE
else
fatal "Not found configuration file $CONFIGFILE"
fatal "Not found configuration file $CONFIGFILE"
fi
[ -n "$BUILT" ] || BUILT=0
......@@ -124,6 +126,24 @@ is_origmoduled()
lsmod | grep "^$ORIGMODULENAME" > /dev/null
}
check_for_old_kernel()
{
detect_host_kernel
N1=`echo $KERNEL | cut -d"." -f 1`
N2=`echo $KERNEL | cut -d"." -f 2`
N3=`echo $KERNEL | cut -d"." -f 3 | cut -d"-" -f 1`
if [ "$N1" -eq 2 ] && [ "$N2" -eq 6 ] ; then
if [ "$N3" -ge 29 ] ; then
return 0
fi
fi
check_for_centos > /dev/null
if [ -n "$SPECIFIC_CENTOS" ] && [ "$CENTOS" -ge 54 ] ; then
return 0
fi
return 1
}
umount_cifs()
{
WASCIFS=
......@@ -142,6 +162,7 @@ umount_cifs()
done
success
fi
return 0
}
mount_cifs()
......@@ -156,8 +177,15 @@ load_module()
local i
if is_origmoduled ; then
umount_cifs
if [ "$?" -eq 1 ] ; then
return
fi
check_for_old_kernel
if [ "$?" -eq 1 ]; then
sleep 2s
fi
echo -n "Removing vanilla kernel module $ORIGMODULENAME... "
$RMMOD $ORIGMODULENAME || { failure ; return ; }
$RMMOD $ORIGMODULENAME --wait
success
fi
......@@ -194,9 +222,16 @@ start()
stop()
{
umount_cifs
if [ "$?" -eq 1 ] ; then
return
fi
check_for_old_kernel
if [ "$?" -eq 1 ]; then
sleep 2s
fi
echo -n "Unloading kernel module $MODULENAME... "
is_moduled || { passed ; return ; }
$RMMOD $MODULENAME || { failure ; echo "You have to umount all CIFS resources before module unloading."; return ; }
$RMMOD $MODULENAME --wait
success
}
......
......@@ -38,13 +38,8 @@ exit_handler()
exit $rc
}
detect_etercifs_sources()
check_for_centos()
{
[ -n "$ETERCIFS_SOURCES_LIST" ] || ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs*
[ -n "`ls $ETERCIFS_SOURCES_LIST`" ] || fatal "Etercifs kernel module sources does not installed!"
KERNEL_SOURCE_ETERCIFS_LINK=`ls -1 $ETERCIFS_SOURCES_LIST | grep $KERNEL | sort -r | head -n 1`
# CentOS-RHEL specific part
SPECIFIC_CENTOS=
if [ -r "/etc/redhat-release" ] ; then
grep 'CentOS' /etc/redhat-release >/dev/null && SPECIFIC_CENTOS=1
......@@ -61,7 +56,7 @@ detect_etercifs_sources()
N4=`echo $KERNEL4 | cut -d"-" -f 2 | cut -d"." -f 1`
CENTOS=0
if [ "$N1" -eq '2' ] && [ "$N2" -eq '6' ] ; then
if [ "$N1" -eq 2 ] && [ "$N2" -eq 6 ] ; then
if [ "$N3" -eq 18 ] ; then
if [ "$N4" -eq 164 ] ; then
echo "You kernel is 2.6.18-164.x"
......@@ -94,6 +89,18 @@ detect_etercifs_sources()
else
echo "Warning! Your kernel in not 2.6.x"
fi
fi
}
detect_etercifs_sources()
{
[ -n "$ETERCIFS_SOURCES_LIST" ] || ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs*
[ -n "`ls $ETERCIFS_SOURCES_LIST`" ] || fatal "Etercifs kernel module sources does not installed!"
KERNEL_SOURCE_ETERCIFS_LINK=`ls -1 $ETERCIFS_SOURCES_LIST | grep $KERNEL | sort -r | head -n 1`
# CentOS-RHEL specific part
check_for_centos
if [ -n "$SPECIFIC_CENTOS" ] ; then
if [ "$CENTOS" -eq 54 ] ; then
echo "Building from legacy sources with patch for kernels 2.6.18-164.x from CentOS 5.4."
KERNEL_SOURCE_ETERCIFS_LINK=`ls -1 $ETERCIFS_SOURCES_LIST | grep 'centos54' | sort -r | head -n 1`
......@@ -106,7 +113,6 @@ detect_etercifs_sources()
else
echo "Building from legacy sources."
fi
echo
fi
# end of CentOS-RHEL specific part
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment