Skip to contentSkip to conversation

ide.rc

DISCUSSION Marco d'Itri 3 participants 6 messages Oct 29, 2004 – Nov 1, 2004

lore
Share & tools
lore
#0 lore raw

I'm attaching a .rc script for hotplug which loads at boot time the ide-* modules needed by the system (which, as everybody knows by now, cannot be automatically loaded anymore when using udev).

Signature · 2 lines
ciao, |
Marco | [8804 tr7xD/mgdubuA]

#!/bin/sh -e
#
# ide.rc loads the modules for IDE devices at boot time, if needed
# it requires a 2.6 kernel
#
# Copyright (C) 2004 Marco d'Itri <[email protected]>
#

# only 2.6 kernels are supported
[ -d /sys/block/ ] || exit 0

cd /etc/hotplug
. ./hotplug.functions

# XXX this function should be moved to hotplug.functions

is_blacklisted() {
    MODULE_EXPR="$(echo $1 | sed -e 's/[-_]/[-_]/g')"
    if grep -qs "^${MODULE_EXPR}$" \
		$HOTPLUG_DIR/blacklist $HOTPLUG_DIR/blacklist.d/*; then
	return 0
    fi
    return 1
}

ide_boot_events() {
[ "$(echo /proc/ide/*/media)" = "/proc/ide/*/media" ] && return

for drive in /proc/ide/*/media; do
# nothing to do if the device has already been took in charge unit=${drive#/proc/ide/}; unit=${unit%/media}
[ -d /sys/block/$unit ] && continue

read media < $drive
case "$media" in
disk) MODULE=ide-disk ;;
cdrom) MODULE=ide-cd ;;
tape) MODULE=ide-tape ;;
floppy) MODULE=ide-floppy ;;
*) MODULE=ide-generic ;;
esac

# ignore blacklisted modules
if is_blacklisted $MODULE; then
mesg " $MODULE: blacklisted"
continue
fi

if modprobe --quiet $MODULE; then
mesg " $MODULE: loaded sucessfully"
else
mesg " $MODULE: can't be loaded"
fi
done
}

# See how we were called.
case "$1" in

    start|restart)
        ide_boot_events
        ;;
    stop)
        ;;
    status)
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1

esac

#1 lore raw
Quoted 3 lines · Marco d'Itri

I'm attaching a .rc script for hotplug which loads at boot time the ide-* modules needed by the system (which, as everybody knows by now, cannot be automatically loaded anymore when using udev).

This script would be probably a bit wrong for my old server. This server has a LSI Logic SCSI adapter (with two hard disks attached) and a ServerWorks IDE adapter with one attached CD-ROM drive. For some strange reason, to use this CD-ROM, I must have both serverworks, ide_generic and ide_cd modules loaded. Your script won't load ide_generic. The kernel is 2.6.7-1-686.

ds:~# ls /proc/ide/*/media
/proc/ide/hda/media
ds:~# cat /proc/ide/hda/media
cdrom

Also, your script starts before pci.rc (because "i" is before "p" in the alphabet) and therefore will not find anything on my old server at all (the serverworks module is loaded by pci.rc).

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_idU88&alloc_id065&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#2 lore raw
In reply to Marco d'Itri
Quoted 5 lines · Alexander E. Patrakov
Quoted 3 lines · Marco d'Itri

I'm attaching a .rc script for hotplug which loads at boot time the ide-* modules needed by the system (which, as everybody knows by now, cannot be automatically loaded anymore when using udev).

I didn't look at the script so it may be useful, but it doesn't seem needed to me when it comes to loading additional modules. To load additional drivers automatically in Linux 2.6 I use the /etc/modprobe.conf file of the module-init-tools package. You'll have to create a rule for each and every driver, but that also gives you the flexibility to create customised rules on a per driver basis.

examples: (see man modprobe.conf)
install atkbd /sbin/modprobe --ignore-install atkbd && { /sbin/modprobe i8042; }

install psmouse /sbin/modprobe --ignore-install psmouse && { /sbin/modprobe i8042; /sbin/modprobe mousedev; }

install hid /sbin/modprobe --ignore-install hid && { /sbin/modprobe mousedev; }

install hpt366 /sbin/modprobe --ignore-install hpt366 && { /sbin/modprobe ide-cd; /sbin/modprobe ide-disk; }

install pdc202xx_new /sbin/modprobe --ignore-install pdc202xx_new && { /sbin/modprobe ide-cd; /sbin/modprobe ide-disk; }

install pdc202xx_old /sbin/modprobe --ignore-install pdc202xx_old && { /sbin/modprobe ide-cd; /sbin/modprobe ide-disk; }

install piix /sbin/modprobe --ignore-install piix && { /sbin/modprobe ide-cd; /sbin/modprobe ide-disk; }

install via82cxxx /sbin/modprobe --ignore-install via82cxxx && { /sbin/modprobe ide-cd; /sbin/modprobe ide-disk; }

options aha152x io=0x0140 irq
install aha152x /sbin/modprobe --ignore-install aha152x && { /sbin/modprobe sd_mod; /sbin/modprobe sr_mod; }

P.S.: the above lines may be wrapped !!!

Quoted 6 lines

This script would be probably a bit wrong for my old server. This server has a LSI Logic SCSI adapter (with two hard disks attached) and a ServerWorks IDE adapter with one attached CD-ROM drive. For some strange reason, to use this CD-ROM, I must have both serverworks, ide_generic and ide_cd modules loaded. Your script won't load ide_generic. The kernel is 2.6.7-1-686.

I hope the above can help you create a customised rule for your device.

Quoted 5 lines

Also, your script starts before pci.rc (because "i" is before "p" in the alphabet) and therefore will not find anything on my old server at all (the serverworks module is loaded by pci.rc).

I think this also counts for the input.rc script. AFAIK input.rc always runs before the other .rc scripts. So drivers for input devices will always be loaded after input.rc has run. Therefore it seems to me that input.rc never really does anything, unless I'm overlooking something.

I guess that running the hotplug rc scripts in alphabetical order will never be the right thing to do, unless they get sequenced somehow. e.g.: Maybe by adding some sequence number like udev-rules and udev-permissions.

-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_idU88&alloc_id065&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Marco d'Itri
Quoted 6 lines · Remco
Quoted 4 lines · Alexander E. Patrakov
Quoted 3 lines · Marco d'Itri

I'm attaching a .rc script for hotplug which loads at boot time the ide-* modules needed by the system (which, as everybody knows by now, cannot be automatically loaded anymore when using udev).

Quoted 6 lines

I didn't look at the script so it may be useful, but it doesn't seem needed to me when it comes to loading additional modules. To load additional drivers automatically in Linux 2.6 I use the /etc/modprobe.conf file of the module-init-tools package. You'll have to create a rule for each and every driver, but that also gives you the flexibility to create customised rules on a per driver basis.

<snip examples>

Just adding ide-generic to /etc/modules (a Debian-specific file that lists modules to be unconditionally loaded on each boot) is much easier.

Quoted 9 lines
Quoted 3 lines

Also, your script starts before pci.rc (because "i" is before "p" in the alphabet) and therefore will not find anything on my old server at all (the serverworks module is loaded by pci.rc).

I think this also counts for the input.rc script. AFAIK input.rc always runs before the other .rc scripts. So drivers for input devices will always be loaded after input.rc has run. Therefore it seems to me that input.rc never really does anything, unless I'm overlooking something.

Quoted 4 lines

I guess that running the hotplug rc scripts in alphabetical order will never be the right thing to do, unless they get sequenced somehow. e.g.: Maybe by adding some sequence number like udev-rules and udev-permissions.

In fact, if a module has been loaded by one rc script, agents should catch the resulting hotplug events. So the order _should_ not matter with good agents, except for the number of duplicate fake hotplug events. The problem is that there is no "ide.agent" file. Sorry for my initial not-very-correct description of this ordering problem.

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_idU88&alloc_id065&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#4 lore raw
In reply to Marco d'Itri
Quoted 5 lines · Alexander E. Patrakov

This script would be probably a bit wrong for my old server. This server has a LSI Logic SCSI adapter (with two hard disks attached) and a ServerWorks IDE adapter with one attached CD-ROM drive. For some strange reason, to use this CD-ROM, I must have both serverworks, ide_generic and ide_cd modules loaded. Your script won't load ide_generic. The kernel is 2.6.7-1-686.

As it has been explained, this is probably a bug/feature in the serverworks driver. The correct solution would be for the debian kernel package to ship a /etc/modprobe.d/kernel-image-2.6.7-1-686 file containing something like:

install serverworks /sbin/modprobe --ignore-install serverworks && { /sbin/modprobe ide-generic; /sbin/modprobe ide-cd; }

(Do you mind opening a bug about this in the debian BTS?)

Quoted 3 lines

Also, your script starts before pci.rc (because "i" is before "p" in the alphabet) and therefore will not find anything on my old server at all (the serverworks module is loaded by pci.rc).

Good point. tsort(1) comes to help, as you can see in the attached replacement for the main hotplug init script.
There is no ide.agent script because there are no "real" IDE hotplug events from the kernel. Probably there is no need for them, this is just a workaround to load the modules for udev.

Signature · 2 lines
ciao, |
Marco | [8851 soOFdKlIC1OSk]

#!/bin/sh -e
#
# description: Starts and stops each hotpluggable subsystem.
# On startup, may simulate hotplug events for devices
# that were present at boot time, before filesystems
# used by /sbin/hotplug became available.

PATH=/sbin:/bin:/usr/sbin:/usr/bin

[ -x /sbin/hotplug ] || exit 0

if [ ! -f /proc/sys/kernel/hotplug ]; then
echo "Kernel hotplug support not enabled."
exit 0
fi

[ -e /etc/default/hotplug ] && . /etc/default/hotplug

run_rcs() {
    SUBSYSTEMS=$(
    {
    for RC in /etc/hotplug/*.rc; do
	basename=${RC#/etc/hotplug/}
	name=${basename%.rc}
	echo "$name $name"
    done
    # follows couples of ordered elements
    echo "ide pci"
    echo "usb pci"
    } | tsort | tac
    )

    for name in $SUBSYSTEMS; do
	printf "   %-8s\n" $name
	if [ "$(eval echo \$HOTPLUG_RC_$name)" = no ]; then
	    printf "   %-8s [disabled]\n" $name
	    continue
	fi
	set +e
	/etc/hotplug/$name.rc $1
	RC_STATUS=$?
	set -e
	if [ "$1" = status ]; then
	    continue
	fi
	if [ $RC_STATUS = 0 ]; then
	    printf "   %-8s [success]\n" $name
	else
	    printf "   %-8s [failed]\n" $name
	fi
    done
}

case "$1" in
start)
echo "Starting hotplug subsystem:"
echo /sbin/hotplug > /proc/sys/kernel/hotplug
run_rcs $1
echo "done"
;;

stop)
echo "Stopping hotplug subsystem:"
run_rcs $1
echo /bin/true > /proc/sys/kernel/hotplug
echo "done"
;;

restart|force-reload)

    echo -n "Restarting hotplug subsystem:"
    run_rcs stop
    run_rcs start
    echo "."
    ;;

status)

    run_rcs $1
    ;;

*)
echo "Usage: $0 {start|stop|restart|status|force-reload}" >&2 exit 1
;;
esac

exit 0

#5 lore raw
In reply to Marco d'Itri
Quoted 9 lines · Marco d'Itri

As it has been explained, this is probably a bug/feature in the serverworks driver. The correct solution would be for the debian kernel package to ship a /etc/modprobe.d/kernel-image-2.6.7-1-686 file containing something like:

install serverworks /sbin/modprobe --ignore-install serverworks && { /sbin/modprobe ide-generic; /sbin/modprobe ide-cd; }

(Do you mind opening a bug about this in the debian BTS?)

Will do so after experimenting with other IDE controllers.

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_idU88&alloc_id065&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel