Ignore:
Timestamp:
May 10, 2013, 8:54:24 PM (6 years ago)
Author:
bruno
Message:

r5281@localhost: bruno | 2013-05-08 11:56:49 +0200

  • Fix support for OBDR tapes on SCSI cards: in some cases the tape remains in OBDR mode (aka CDROM emulation) preventing the init script to work correctly. It now try to detect these cases, and to reset the SCSI device being of type CDROM (5) and looking like a tape drive as a model. (Not tested yet)
  • Improve in consequence the OBDR specific README
  • Adds support for the obdrmods boot parameter if some additional drivers should be removed
  • adds rev to the minimal list of tools to have as this is now potentially required
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mindi/rootfs/etc/init.d/rcS

    r3090 r3119  
    142142    [ ! "$tapedev" ] && tapedev=`grep media-dev /tmp/mondo-restore.cfg 2>/dev/null | tr -s ' ' ' ' | cut -d' ' -f2`
    143143    mt -f $tapedev rewind
     144    if [ $? -ne 0 ]; then
     145        LogIt "WARNING: $tapedev failed to rewind, either not a tape or still in OBDR mode." 1
     146        LogIt "         Trying to find the corresponding SCSI generic device." 1
     147        c=0
     148        for d in `ls /sys/class/scsi_device/*`; do
     149            devtype=`cat $d/device/type`
     150            if [ _"$devtype" -eq _"1" ]; then
     151                LogIt "NOTE: Device /dev/sg$c is a Sequential device." 1
     152                if [ -x /usr/bin/sg_map ]; then
     153                    dev=`/usr/bin/sg_map | grep -E "^/dev/sg$c" | awk '{print $2}'`
     154                    LogIt "      Retry using device $dev" 1
     155                fi
     156            elif [ _"$devtype" -eq _"0" ]; then
     157                # Skipping a HDD
     158            elif [ _"$devtype" -eq _"5" ]; then
     159                # Checking whether it's a CD or a tape in OBDR mode
     160                grep -q -i -E 'dat|ultrium|tape' $d/device/model
     161                if [ $? -eq 0 ]; then
     162                    # Is probably a Tape drive left in OBDR.
     163                    LogIt "Found that /dev/sg$c is a tape drive (`cat $d/device/model`)." 1
     164                    grep -q -i -w 'hp' $d/device/vendor
     165                    if [ $? -eq 0 ]; then
     166                        LogIt "This is an HP tape drive, even better :-)." 1
     167                    fi
     168                    if [ -x /usr/bin/sg_reset ]; then
     169                        OBDR_MODS="st mptsas mptspi aic7xxx aic94xx mpt2sas "
     170                        if [ "`grep -i obdrmods /proc/cmdline`" ]; then
     171                            OBDR_MODS="$OBDR_MODS `cat /proc/cmdline | sed 's~.*obdrmods=\"\(.*\)\".*~\1~'`"
     172                        fi
     173                        LogIt "Removing modules $OBDR_MODS." 1
     174                        for m in $OBDR_MODS; do
     175                            rmmod $i
     176                        done
     177                        LogIt "Trying to force device /dev/sg$c to be in sequential mode." 1
     178                        /usr/bin/sg_reset -d /dev/sg$c
     179                        LogIt "Inserting modules `rev $OBDR_MODS`." 1
     180                        for m in `rev $OBDR_MODS`; do
     181                            modprobe $i
     182                        done
     183                        LogIt "Retry again as the device has been set back into sequential mode." 1
     184                        mt -f $tapedev fsf 2
     185                        res=$?
     186                        # exit the loop to continue and return if that previous mt failed.
     187                        # If it succeeded we transparently continue !!
     188                        break
     189                    else
     190                        LogIt "WARNING: Unable to reset /dev/sg$c as the sg_reset command is not availble." 1
     191                    fi
     192                fi
     193            else
     194                LogIt "Device /dev/sg$c has an unknown type $devtype." 1
     195            fi
     196            c=`expr $c + 1`
     197        done
     198
     199        if [ $res -ne 0 ]; then
     200            cd $old_pwd
     201            return $res
     202        fi
     203    fi
     204
    144205    mt -f $tapedev fsf 2
    145206    # 32k is DEFAULT_INTERNAL_TAPE_BLOCK_SIZE
     
    667728}
    668729
    669 
    670730EnableCcissIfAppropriate() {
    671731    local f
Note: See TracChangeset for help on using the changeset viewer.