Skip to contentSkip to conversation

Device has module AND init script

DISCUSSION Jim Carter 2 participants 2 messages Jan 21, 2002

lore
Share & tools
lore

Jim Carter

author
#0 lore raw

I have a joystick which has the usual module stack, but which also needs to have jscal executed upon hotplugging (via my script /etc/hotplug/usb/setupstick). There are three issues here:

1. The logical place to name the setup script is usb.usermap, but if any modules are found, usb.agent bypasses usb.usermap. Workaround: put the lines in usb.handmap.

2. Both modules and setup scripts have an order dependence which modprobe may not be able to 100% straighten out. Workaround: Use the source, Luke! The right effect is achieved if the script is listed first, then the most specific driver, to the most general. I'm not sure how order dependence could be enforced neatly, specifically to get the script executed last, so I didn't try to hack anything for this.

3. In the obsolete version in my distro (2001_04_24-1_6), hotplug.functions :: load_drivers tries to find the module in /lib/modules/$KERNEL. Three issues (relevant to the current version 2002_01_14) go with this:

a. If that "directory" is a symlink, which it is in my system, "find" will not find the module. Fix: MODULE_DIR=/lib/modules/$KERNEL/.

b. "find" (at least Gnu Find 4.1.7) returns 0 if there was no error even if no files were found. The script always thought it saw the module anyway. The current version doesn't have the find.

c. It's a lot easier to test for an init script first, and if it's not an init script then run modprobe, and if that fails you don't have to figure out why it failed, just say that it did.

I've appended a patch for the above points, versus hotplug-2002_01_14.tar.gz.

James F. Carter Voice 310 825 2897 FAX 310 206 6673
UCLA-Mathnet; 6115 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA 90095-1555
Email: [email protected] http://www.math.ucla.edu/~jimc (q.v. for PGP key)

*** ../hotplug/hotplug.functions Mon Jan 14 11:26:45 2002
--- hotplug.functions Sun Jan 20 18:25:14 2002
***************
*** 14,20 ****
PATH=/bin:/sbin:/usr/sbin:/usr/bin

KERNEL=uname -r
! MODULE_DIR=/lib/modules/$KERNEL

HOTPLUG_DIR=/etc/hotplug

--- 14,20 ----
PATH=/bin:/sbin:/usr/sbin:/usr/bin

KERNEL=uname -r
! MODULE_DIR=/lib/modules/$KERNEL/.

HOTPLUG_DIR=/etc/hotplug

***************
*** 138,153 ****
if grep -q "^$MODULE\$" /etc/hotplug/blacklist \
>/dev/null 2>&1; then
debug_mesg "... blacklisted module: $MODULE"

! 	    # user mode drivers will ONLY have a setup script,
! 	    # so it's not an error if a module doesn't exist
! 	    elif $MODPROBE -n $MODULE >/dev/null 2>&1 &&

! ! $MODPROBE $MODULE >/dev/null 2>&1 ; then
! mesg "... can't load module $MODULE"
elif [ -x /etc/hotplug/$TYPE/$MODULE ]; then
debug_mesg Module setup $MODULE for $DESCRIPTION /etc/hotplug/$TYPE/$MODULE
! else
! mesg "missing kernel or user mode driver $MODULE "
fi
fi
done
--- 138,150 ----
if grep -q "^$MODULE\$" /etc/hotplug/blacklist \
>/dev/null 2>&1; then
debug_mesg "... blacklisted module: $MODULE"
! # Bypass modprobe if it's a user driver or setup script.
elif [ -x /etc/hotplug/$TYPE/$MODULE ]; then
debug_mesg Module setup $MODULE for $DESCRIPTION /etc/hotplug/$TYPE/$MODULE
! elif $MODPROBE -n $MODULE >/dev/null 2>&1 &&
! ! $MODPROBE $MODULE >/dev/null 2>&1 ; then
! mesg "... can't load module $MODULE nor execute /etc/hotplug/$TYPE/$MODULE"
fi
fi
done

_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 7 lines

I have a joystick which has the usual module stack, but which also needs to have jscal executed upon hotplugging (via my script /etc/hotplug/usb/setupstick). There are three issues here:

1. The logical place to name the setup script is usb.usermap, but if any modules are found, usb.agent bypasses usb.usermap. Workaround: put the lines in usb.handmap.

Simplest is to just name your setup script after the name of the relevant module ... perhaps "joydev", and use "case $PRODUCT" in that script to trigger "jscal" (or "setupstick" etc) for this device.

Quoted 6 lines

2. Both modules and setup scripts have an order dependence which modprobe may not be able to 100% straighten out. Workaround: Use the source, Luke! The right effect is achieved if the script is listed first, then the most specific driver, to the most general. I'm not sure how order dependence could be enforced neatly, specifically to get the script executed last, so I didn't try to hack anything for this.

The sequence is always: modprobe, then run setup script of that same name (if it exists). The setup scripts can run modprobe itself, if that helps.

If that doesn't resolve your problem, then I'm not sure I understand the issue you're trying to describe.

Quoted 2 lines

3. In the obsolete version in my distro (2001_04_24-1_6),
...

I'll look at that a bit later.

- Dave

_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel