--- sane-backends-1.0.18/tools/sane-desc.c.udev-098 2007-08-07 14:56:03.000000000 +0200 +++ sane-backends-1.0.18/tools/sane-desc.c 2007-08-08 12:45:27.000000000 +0200 @@ -3153,14 +3153,14 @@ print_udev_header (void) ("#\n" "# udev rules file for supported USB devices\n" "#\n" - "# To add a USB device, add a rule to the list below between the SUBSYSTEM...\n" - "# and LABEL... lines.\n" + "# To add support for a USB device, add rules to the \"usb\" and \"usb_device\"\n" + "# lists below between their respective \"# BEGIN ...\" and \"# END ...\" lines.\n" "#\n" "# To run a script when your device is plugged in, add RUN=\"/path/to/script\"\n" - "# to the appropriate rule.\n"); + "# to the appropriate rules.\n"); printf ("#\n" - "# The following list already contains a lot of scanners. If your scanner\n" + "# The following lists already contains a lot of scanners. If your scanner\n" "# isn't mentioned there, add it as explained above and mail the entry to\n" "# the sane-devel mailing list (sane-devel@lists.alioth.debian.org).\n" "#\n"); @@ -3169,11 +3169,44 @@ print_udev_header (void) static void print_udev (void) { - usbid_type *usbid = create_usbids_table (); + usbid_type *usbid_first = create_usbids_table (); + usbid_type *usbid = usbid_first; print_udev_header (); + printf ("\nACTION!=\"add\", GOTO=\"libsane_rules_end\"\n"); - printf ("SUBSYSTEM!=\"usb_device\", GOTO=\"libsane_rules_end\"\n\n"); + printf ("\nATTR{dev}!=\"?*\", GOTO=\"libsane_rules_end\"\n"); + printf ("SUBSYSTEM==\"usb\", GOTO=\"libsane_usb_rules\"\n"); + printf ("SUBSYSTEM==\"usb_device\", GOTO=\"libsane_usb_device_rules\"\n\n"); + printf ("GOTO=\"libsane_rules_end\"\n\n"); + + /* SUBSYSTEM=="usb" -> ATTR{} */ + printf ("LABEL=\"libsane_usb_rules\"\n\n"); + printf ("# BEGIN scanner rules for SUBSYSTEM==\"usb\"\n"); + while (usbid) + { + manufacturer_model_type * name = usbid->name; + + printf ("# "); + while (name) + { + if (name != usbid->name) + printf (" | "); + printf ("%s", name->name); + name = name->next; + } + printf ("\n"); + printf ("ATTR{idVendor}==\"%s\", ATTR{idProduct}==\"%s\", SYMLINK+=\"scanner-%%k\"\n", + usbid->usb_vendor_id + 2, usbid->usb_product_id + 2); + usbid = usbid->next; + } + printf ("# END scanner rules for SUBSYSTEM==\"usb\"\n"); + printf ("GOTO=\"libsane_rules_end\"\n\n"); + + /* SUBSYSTEM=="usb_device" -> ATTRS{} */ + printf ("LABEL=\"libsane_usb_device_rules\"\n\n"); + printf ("# BEGIN scanner rules for SUBSYSTEM==\"usb_device\"\n"); + usbid = usbid_first; while (usbid) { manufacturer_model_type * name = usbid->name; @@ -3187,10 +3220,13 @@ print_udev (void) name = name->next; } printf ("\n"); - printf ("SYSFS{idVendor}==\"%s\", SYSFS{idProduct}==\"%s\", SYMLINK+=\"scanner-%%k\"\n", + printf ("ATTRS{idVendor}==\"%s\", ATTRS{idProduct}==\"%s\", SYMLINK+=\"scanner-%%k\"\n", usbid->usb_vendor_id + 2, usbid->usb_product_id + 2); usbid = usbid->next; } + printf ("# END scanner rules for SUBSYSTEM==\"usb_device\"\n"); + printf ("GOTO=\"libsane_rules_end\"\n"); + printf ("\nLABEL=\"libsane_rules_end\"\n"); }