[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#663868: udev: laserjet1018 (foo2zjs) printer disappears and appears in loop



Package: printer-driver-foo2zjs
Version: 20140925dfsg0-2
Followup-For: Bug #663868

Dear Maintainer,

After a long while I tried to use my LaserJet 1018 again, and I ran
into this bug.

What happens is this: When the printer is plugged in, the firmware
upload script is started by the udev rules. It will try to use the
CUPS USB backend to upload the firmware file to the printer. The CUPS
USB backend will unload and reload the usblp module. This will
generate hotplug events, and udev will restart the firmware upload
script... And so it gets stuck in an infinite loop.

The attached patch 97-hplj1000-fix-firmware-upload-infite-loop.patch
fixes this. In the CUPS code path we ignore usblp-generated events
(with subsystem "usbmisc"), preventing the loop. In the usblp code
path on the other hand we ignore non-usblp events.

I've also attached a revised 30-udev-rules.patch. The old version ran
the firmware upload script on both hotplug and unplug. This was fixed
by adding an ACTION="add" clause to the rules.
Description: Prevent an infinite loop when loading the firmware.
 When using the load_cups method, the CUPS backend will internally
 unload and reload the usblp module. This will generate
 SUBSYSTEM=usbmisc events that need to be ignored in the CUPS code
 path, or this script will be rerun in an infite loop.
   
 But when using the load_usblp method, the usblp module is obviously
 needed. So in this situation we need to ignore the SUBSYSTEM=usb
 events.
Bug-Debian: http://bugs.debian.org/663868
Author: Peter De Wachter <pdewacht@gmail.com>
Last-Update: 2014-10-02
--- a/hplj1000
+++ b/hplj1000
@@ -24,11 +24,6 @@
 #		Mike Morgan (2004)
 #
 
-# udev calls us twice on FC4! Just want /dev/usb/lp<N>
-case "$DEVNAME" in
-/dev/usb/usb*)	exit;;
-esac
-
 PROGNAME="$0"
 
 #
@@ -260,6 +255,7 @@
     #
     # force downloading to a specific device
     #
+    if [ "$SUBSYSTEM" != "usbmisc" ]; then exit; fi
     load_usblp "$DEV"
 elif [ -x $USB_BACKEND ]; then
         #
@@ -267,11 +263,13 @@
         # not need to care whether the system uses the usblp kernel module or
         # libusb 
         #
+        if [ "$SUBSYSTEM" != "usb" ]; then exit; fi
         load_cups
 elif [ -x $PRINTERID ]; then
 	#
 	# Sniff around for printers that need a firmware download
 	#
+	if [ "$SUBSYSTEM" != "usbmisc" ]; then exit; fi
 	usblps=`find /dev/usb -type c -name 'lp*'`" "`find /dev -type c -name 'usblp*'`
 	for dev in $usblps; do
 	    status=`$PRINTERID $dev 2>/dev/null | grep -y "hp LaserJet $MODEL"`
Description: Correct the udev rules:
 a) remove KERNEL=="lp*", as usblp is now blacklisted by CUPS (it will work without CUPS too).
 b) Replace paths: /etc/hotplug/usb/ by no path, as the binaries are shipped in /lib/udev/
 c) Drop the MODE specification
 d) Add ACTION=="ADD", otherwise the firmware script runs after unplugging as well
Author: Luca Capello <luca@pca.it>
Author: Didier Raboud <odyx@debian.org>
Author: Peter De Wachter <pdewacht@gmail.com>
Last-Update: 2014-01-02
--- a/hplj10xx.rules
+++ b/hplj10xx.rules
@@ -2,38 +2,42 @@
 #       hplj10xx.rules.old: udev equal or after 1.30
 #
 #Own udev rule for HP Laserjet 1000
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="hp LaserJet 1000", NAME="usb/%k", \
-	SYMLINK+="hplj1000-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1000" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="hp LaserJet 1000", \
+	SYMLINK+="hplj1000-%n", RUN+="hplj1000" 
 #Own udev rule for HP Laserjet 1005
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="hp LaserJet 1005 series", NAME="usb/%k", \
-	SYMLINK+="hplj1005-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1005" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="hp LaserJet 1005 series", \
+	SYMLINK+="hplj1005-%n", RUN+="hplj1005" 
 #Own udev rule for HP Laserjet 1018
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="HP LaserJet 1018", NAME="usb/%k", \
-	SYMLINK+="hplj1018-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1018" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="HP LaserJet 1018", \
+	SYMLINK+="hplj1018-%n", RUN+="hplj1018" 
 #Own udev rule for HP Laserjet 1020
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="HP LaserJet 1020", NAME="usb/%k", \
-	SYMLINK+="hplj1020-%n", MODE="0666", RUN+="/etc/hotplug/usb/hplj1020" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="HP LaserJet 1020", \
+	SYMLINK+="hplj1020-%n", RUN+="hplj1020" 
 #Own udev rule for HP Laserjet P1005
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="HP LaserJet P1005", NAME="usb/%k", \
-	SYMLINK+="hpljP1005-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1005" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="HP LaserJet P1005", \
+	SYMLINK+="hpljP1005-%n", RUN+="hpljP1005" 
 #Own udev rule for HP Laserjet P1006
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="HP LaserJet P1006", NAME="usb/%k", \
-	SYMLINK+="hpljP1006-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1006" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="HP LaserJet P1006", \
+	SYMLINK+="hpljP1006-%n", RUN+="hpljP1006" 
 #Own udev rule for HP Laserjet P1007
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="HP LaserJet P1007", NAME="usb/%k", \
-	SYMLINK+="hpljP1007-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1007" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="HP LaserJet P1007", \
+	SYMLINK+="hpljP1007-%n", RUN+="hpljP1007" 
 #Own udev rule for HP Laserjet P1008
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="HP LaserJet P1008", NAME="usb/%k", \
-	SYMLINK+="hpljP1008-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1008" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="HP LaserJet P1008", \
+	SYMLINK+="hpljP1008-%n", RUN+="hpljP1008" 
 #Own udev rule for HP Laserjet P1505
-KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
-	ATTRS{product}=="HP LaserJet P1505", NAME="usb/%k", \
-	SYMLINK+="hpljP1505-%n", MODE="0666", RUN+="/etc/hotplug/usb/hpljP1505" 
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="HP LaserJet P1505", \
+	SYMLINK+="hpljP1505-%n", RUN+="hpljP1505" 
+#Own udev rule for HP Laserjet P1505n
+ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", \
+	ATTRS{product}=="HP LaserJet P1505n", \
+	SYMLINK+="hpljP1505n-%n", RUN+="hpljP1505n" 

Reply to: