Subject: kern/14770: raidframe startupscript doesn't handle autoconfigured devices correctly
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wgstuken@nagler-company.com>
List: netbsd-bugs
Date: 11/29/2001 16:16:03
>Number:         14770
>Category:       kern
>Synopsis:       raidframe startupscript doesn't handle autoconfigured devices correctly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 29 05:16:04 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Stukenbrock (wgstuken@nagler-compay.com)
>Release:        NetBSD release 1.5.2
>Organization:
Dr. Nagler & Comapny GmbH
>Environment:
	
System: NetBSD test-s4 1.5.2 NetBSD 1.5.2 (NSW-Firewall) #2: Thu Nov 29 15:07:53 CET 2001 wgstuken@test-s4:/export/netbsd-1.5.2/usr/src/sys/arch/i386/compile/NSW-Firewall i386


>Description:
	The raidframe startup script in /etc/rc.d will only configure raid devices, but does noch check parity on autoconfigured raid devices.
        For autoconfigured raid-devices (e.g. the root device) there is no raidx.conf and this script just ignores suh devices.
        A second bug in this script is, that it only looks for raid0 to raid3.
        This can be done much better be examining the /dev/raid*d devices.
>How-To-Repeat:
        seen on every boot ...
>Fix:
	change the raidframe startupscript in a way like the following:


#!/bin/sh
#
# $NetBSD: raidframe,v 1.x 2000/05/16 16:54:33 oster Exp $
#

# PROVIDE: disks

. /etc/rc.subr

name="raidframe"
start_cmd="raidframe_start"
stop_cmd=":"

raidframe_start()
{
  ( for dev in `(cd /dev && echo raid*d) | sed -e 's/raid\([0-9]\)d/raid\1/g'`; do
      if raidctl -s $dev > /dev/null 2>&1; then
# raid device already configured - just check parity in background ...
        echo -n " $dev"
      else
        if [ -f /etc/$dev.conf ]; then
# raid device not configured - check for config file ...
	  raidctl -c /etc/$dev.conf $dev
          echo -n " $dev"
        fi
      fi
  done
  ) | read alldev;
  if [ -n "$alldev" ]; then
    ( for dev in $alldev; do raidctl -P $dev; done ) &
  fi
}

load_rc_config $name
run_rc_command "$1"
>Release-Note:
>Audit-Trail:
>Unformatted: