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

Fix rmmod after umount problem

parent 9a1cf2b4
...@@ -20,6 +20,8 @@ MODINFO=/sbin/modinfo ...@@ -20,6 +20,8 @@ MODINFO=/sbin/modinfo
# against run with sudo # against run with sudo
export PATH=$PATH:/sbin:/usr/sbin export PATH=$PATH:/sbin:/usr/sbin
. @DATADIR@/functions.sh
PACKAGEINFO=@DATADIR@/package.conf PACKAGEINFO=@DATADIR@/package.conf
if [ -f "$PACKAGEINFO" ] ; then if [ -f "$PACKAGEINFO" ] ; then
. $PACKAGEINFO . $PACKAGEINFO
...@@ -124,6 +126,24 @@ is_origmoduled() ...@@ -124,6 +126,24 @@ is_origmoduled()
lsmod | grep "^$ORIGMODULENAME" > /dev/null 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() umount_cifs()
{ {
WASCIFS= WASCIFS=
...@@ -142,6 +162,7 @@ umount_cifs() ...@@ -142,6 +162,7 @@ umount_cifs()
done done
success success
fi fi
return 0
} }
mount_cifs() mount_cifs()
...@@ -156,8 +177,15 @@ load_module() ...@@ -156,8 +177,15 @@ load_module()
local i local i
if is_origmoduled ; then if is_origmoduled ; then
umount_cifs 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... " echo -n "Removing vanilla kernel module $ORIGMODULENAME... "
$RMMOD $ORIGMODULENAME || { failure ; return ; } $RMMOD $ORIGMODULENAME --wait
success success
fi fi
...@@ -194,9 +222,16 @@ start() ...@@ -194,9 +222,16 @@ start()
stop() stop()
{ {
umount_cifs 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... " echo -n "Unloading kernel module $MODULENAME... "
is_moduled || { passed ; return ; } is_moduled || { passed ; return ; }
$RMMOD $MODULENAME || { failure ; echo "You have to umount all CIFS resources before module unloading."; return ; } $RMMOD $MODULENAME --wait
success success
} }
......
...@@ -38,13 +38,8 @@ exit_handler() ...@@ -38,13 +38,8 @@ exit_handler()
exit $rc 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= SPECIFIC_CENTOS=
if [ -r "/etc/redhat-release" ] ; then if [ -r "/etc/redhat-release" ] ; then
grep 'CentOS' /etc/redhat-release >/dev/null && SPECIFIC_CENTOS=1 grep 'CentOS' /etc/redhat-release >/dev/null && SPECIFIC_CENTOS=1
...@@ -61,7 +56,7 @@ detect_etercifs_sources() ...@@ -61,7 +56,7 @@ detect_etercifs_sources()
N4=`echo $KERNEL4 | cut -d"-" -f 2 | cut -d"." -f 1` N4=`echo $KERNEL4 | cut -d"-" -f 2 | cut -d"." -f 1`
CENTOS=0 CENTOS=0
if [ "$N1" -eq '2' ] && [ "$N2" -eq '6' ] ; then if [ "$N1" -eq 2 ] && [ "$N2" -eq 6 ] ; then
if [ "$N3" -eq 18 ] ; then if [ "$N3" -eq 18 ] ; then
if [ "$N4" -eq 164 ] ; then if [ "$N4" -eq 164 ] ; then
echo "You kernel is 2.6.18-164.x" echo "You kernel is 2.6.18-164.x"
...@@ -94,6 +89,18 @@ detect_etercifs_sources() ...@@ -94,6 +89,18 @@ detect_etercifs_sources()
else else
echo "Warning! Your kernel in not 2.6.x" echo "Warning! Your kernel in not 2.6.x"
fi 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 if [ "$CENTOS" -eq 54 ] ; then
echo "Building from legacy sources with patch for kernels 2.6.18-164.x from CentOS 5.4." 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` KERNEL_SOURCE_ETERCIFS_LINK=`ls -1 $ETERCIFS_SOURCES_LIST | grep 'centos54' | sort -r | head -n 1`
...@@ -106,7 +113,6 @@ detect_etercifs_sources() ...@@ -106,7 +113,6 @@ detect_etercifs_sources()
else else
echo "Building from legacy sources." echo "Building from legacy sources."
fi fi
echo
fi fi
# end of CentOS-RHEL specific part # 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