File boot.blktrace of Package preload

#! /bin/sh
#
# Copyright (c) 2007 SuSE GmbH Nuernberg, Germany.  All rights reserved.
#
### BEGIN INIT INFO
# Provides:          boot.blktrace
# Required-Start:    
# Required-Stop:   
# X-Start-Before:    boot.udev
# Default-Start:     B
# Default-Stop:
# Description:       Start blktrace if the kernel cmdline has remap in it
# Short-Description: Start blktrace to read blocks used
### END INIT INFO

. /etc/rc.status
rc_reset

ROOT_IS_EXT3=
while read  where what type options rest  ; do
    case "$where" in
        \#*|"") ;;
        *) if test "$type" = "ext3" -a "$what" = "/"; then
		ROOT_IS_EXT3=$where
		break
            fi ;;
    esac
done < /etc/fstab

case "$1" in
    start)
        rm -f /var/run/blktrace.pid
        if test -n "$ROOT_IS_EXT3"; then
  	   for o in $(cat /proc/cmdline); do if test "$o" = "remap"; then
	      echo "Activating blktrace on $ROOT_IS_EXT3..."
              /bin/blktrace -r /sys/kernel/debug -d $ROOT_IS_EXT3 -o /dev/shm/blktrace.out &
           fi; done
        fi
	rc_status -v -r
	;;
    stop)
	rc_status -v
	;;
    reload)
        rc_failed 3
        rc_status -v
        ;;
    status)
	rc_failed 4
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status}"
	exit 1
	;;
esac

rc_exit
openSUSE Build Service is sponsored by