Workaround for Redhat-Bug 683265



Contents
0. Preliminaries
0.1 Notation
0.2 Actual Version

1. Description
1.1 How it Works (for Experts)

2. Usage
2.1 Usage for Experts
2.1.1 Testing the Modules Functionality
2.1.2 Avoiding Hang on Boot
2.1.2.1 If Your Linux-Root-Fs is Not on Your Usb-Stick
2.1.2.2 If Your Linux-Root-Fs is on Your Usb-Stick
2.2 Usage for Normal Users

3. Compiled Modules

4. Source

5. Compiling the Source


0. Preliminaries

0.1 Notation
  • e. g. "${X}" is a variable-notation like in a "bash-script".
  • If "X=0x0781" it expands to "0x0781".

  • 0.2 Actual Version

    The actual version of the modules are "version: 0.0.2" that are: "usb_storage0x05bf_0beta" and "strange_usb_sticks0x05bf_0_0_2betabeta".
    Modules with "version: 0.0.1" that is: "strange_usb_sticks0x05bf_0_0_1betabeta" may be used too.

    1. Description

    Adding some files and changing some file in "drivers/usb/storage" (see "4. Source") leads to 2 new modules in the above folder:
    "usb_storage0x05bf_0beta" and "strange_usb_sticks0x05bf_0_0_2betabeta".
    The modules are named that way to discern my workaround-modules from original modules.
    The module "usb_storage0x05bf_0beta" replaces the standard module "usb_storage" and together with the module "strange_usb_sticks0x05bf_0_0_2betabeta" the usb-stick is prevented from sending erronous media-change-messages to the kernel.
    The usb-sticks handled that way, must be specified by setting appropriate module-parameters for the module "strange_usb_sticks0x05bf_0_0_2betabeta".
    The module "usb_storage0x05bf_0beta" may use all the modules that the standard "usb_storage"-module may use (e.g. "libusual").


    1.1 How it Works (for Experts)

    The module "usb_storage0x05bf_0beta" exports the function "set_strange_usb_sticks_hook0x05bf()". When the module "strange_usb_sticks0x05bf_0_0_2betabeta" is loaded, it hooks his (main-)function "handle_strange_usb_sticks()" by the exported function above in the "usb_storage0x05bf_0beta""-module.

    We have the following situations:
  • 1. The module "usb_storage0x05bf_0beta"" is loaded and the module "strange_usb_sticks0x05bf_0_0_2betabeta"" is not loaded:
    In this case, i have tried to keep the impact on the module "usb_storage0x05bf_0beta"" as little as possible: Only for "GET_EVENT_STATUS_NOTIFICATION"-scsi-commands for devices of type "TYPE_ROM" i ask, whether the main-function of module "strange_usb_sticks0x05bf_0_0_2betabeta"" is hooked in, and here it is not, so the program-flow is just as in the original "usb_storage"-module.

  • 2. The module "usb_storage0x05bf_0beta"" and the module "strange_usb_sticks0x05bf_0_0_2betabeta"" are loaded:
    After the above tests for command, device-type and hooked in function, the program-flow continues in "handle_strange_usb_sticks()". There is checked, if the command is for a specified usb-stick, an if so, the scsi-command is not passed to the usb-stick but terminated with a faked result, that says: "no media change". For usb-sticks, that are not specified, the scsi-command is passed back to the module "usb_storage0x05bf_0beta"" and handled there as if the module "strange_usb_sticks0x05bf_0_0_2betabeta"" is not loaded.

  • 2. Usage

    2.1 Usage for Experts

    2.1.1 Testing the Modules Functionality
  • Load the appropriate modules for your kernel (see "3. Compiled Modules") in a folder (directory) of your choice.

  • Clear all references to "usb_storage" by unmounting mounts, swapoff-ing swaps etc. on your connected usb-storage-devices.

  • To avoid the oops described in Comment 35 remove "sr_mod" first. Because "sr_mod" is very busy due to the media-change-messages from the stick, you will have to try several times, until "lsmod" does no longer show it.

  • Remove "usb_storage".

  • Load the module "usb_storage0x05bf_0beta" by "insmod".

  • 2.1.1.1: In another shell-window/terminal start "udevadm monitor --kernel". It will show a lot of messages as in Comment 27.

  • Load the module "strange_usb_sticks0x05bf_0_0_2betabeta" by "insmod", supplying the necessary module parameters for your usb-sticks. Have a look at "/proc/bus/usb/devices" [hope it exists in your kernel, else use "/sys/...".] there you should find lines like "S: Manufacturer=SanDisk". Use the corresponding blocks and proceed as described in the output of "modinfo -p strange_usb_sticks0x05bf_0_0_2betabeta.ko". You should also add the parameter "debug=1".

  • If you have done the above correctly and kernel-info messages are shown on your display, you will see messages like:
    "[...] strange_usb_sticks: handling a stick with usb-id = (X, Y)";
    where X = vendor_id_of_your_stick, Y = product_id_of_your_stick.
    Maybe you will have to use "dmesg" to see these messages. If you do not see them, even with "dmesg", you should check if you have entered your parameters correctly: you should find in "dmesg" lines like:
    "[...] strange_usb_sticks: usb-id[I] = (X, Y)"; X, Y as above.

  • If that works, after a certain time, the messages according to "2.1.1.1" should cease.

  • Now everything is perfect, your usb-stick is now handled correctly.

  • 2.1.2 Avoiding Hang on Boot

    2.1.2.1 If Your Linux-Root-Fs is Not on Your Usb-Stick
  • Move the module "usb_storage" out of your kernel-modules-tree in "/lib/modules"; the folder you move it to, should be at least in "/lib/modules" and not in "/lib/modules/kernel...".

  • Copy the module "usb_storage0x05bf_0beta" and the module "strange_usb_sticks0x05bf_0_0_2betabeta" to your kernel- modules-tree.

  • Make a "depmod -a".

  • You should find a line like "/sbin/start_udev" in the file "/etc/rc.d/rc.sysinit". At the line before, add the following 2 lines:
    "/sbin/rmmod usb_storage"
    "/sbin/modprobe strange_usb_sticks0x05bf_0_0_2betabeta".

  • You should add a file like ${xyz}.conf to "/etc/modprobe.d" containing something like the following line:
    "options strange_usb_sticks0x05bf_0_0_2betabeta Vendor0=${X} ProdId0=${Y}",
    where X and Y are the appropriate module-parameters for your stick (see above).

  • If everything above is correct, you can restart your computer and boot will no longer hang.

  • 2.1.2.2 If Your Linux-Root-Fs is on Your Usb-Stick

    It gets difficult:

  • first you have to do the steps described in "2.1.2.1 If Your Linux-Root-Fs is Not on Your Usb-Stick".

  • Make a copy for your "/boot/initramfs-..." from the kernel to which belong your modules "usb_storage0x05bf_0beta" and "strange_usb_sticks0x05bf_0_0_2betabeta" to another "/boot/initramfs-..." with a different name; add a "/boot/grub/grub.conf"-entry for that "...initramfs-..." ... .

  • Replace in your copy "...initramfs-..." the module "usb_storage" as described in "2.1.2.1".

    I think, the following will not be necessary:
  • Add an appropriate file "${xyz}.conf" to "/etc/modprobe.d" of your copy "...initramfs-..." .

  • To do the two operations above, you will have to unpack the "...initramfs-...", apply the changes and then repack it.

  • After restarting, you should choose in the boot-menu, to boot with your new "...initramfs-...".

  • I hope it works then.

  • 2.2 Usage for Normal Users

    Description and ev. a user-friendly rpm-package will follow.


    3. Compiled Modules

    They are available for the following architectures and kernels:
  • i386
  • version 0.0.1
  • kernel-2.6.38.6-27.fc15.i686
  • kernel-PAE-2.6.38.6-27.fc15.i686

  • version 0.0.2
  • kernel-2.6.38.6-27.fc15.i686
  • kernel-PAE-2.6.38.6-27.fc15.i686

  • x86_64
  • version 0.0.1
  • kernel-2.6.38.6-27.fc15.x86_64

  • version 0.0.2
  • kernel-2.6.38.6-27.fc15.x86_64


  • 4. Source

    The source of the 2 modules "usb_storage0x05bf_0beta" and "strange_usb_sticks0x05bf_0_0_2betabeta" depends on the kernel-version.
    E.g. for "kernel-2.6.38.6-27.fc15.i386" you need (all folders are relative to the root of the kernel-source tree) besides the files in the folder "include" the following files and folders:
    "drivers/": folder,
    "drivers/scsi": folder,
    "drivers/scsi/scsi.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/scsi/scsi.h",
    "drivers/usb/": folder,
    "drivers/usb/storage/": folder,
    "drivers/usb/storage/.config": link to or copy of "${kernel-devel-2.6.38.6-27.fc15.i386}/.config",
    "drivers/usb/storage/Makefile": adapted Makefile for the kernel-version,
    "drivers/usb/storage/debug.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/debug.h",
    "drivers/usb/storage/debug0x05bf.h": new file: version: 0,
    "drivers/usb/storage/initializers.c": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/initializers.c",
    "drivers/usb/storage/initializers.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/initializers.h",
    "drivers/usb/storage/option_ms.c": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/option_ms.c",
    "drivers/usb/storage/option_ms.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/option_ms.h",
    "drivers/usb/storage/protocol.c": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/protocol.c",
    "drivers/usb/storage/protocol.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/protocol.h",
    "drivers/usb/storage/scsiglue.c": "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/scsiglue.c" with changes: version: 0,
    "drivers/usb/storage/scsiglue.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/scsiglue.h",
    "drivers/usb/storage/sierra_ms.c": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/sierra_ms.c",
    "drivers/usb/storage/sierra_ms.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/sierra_ms.h",
    "drivers/usb/storage/strange_usb_sticks0x05bf.c":  new file: version: 0.0.2,
    "drivers/usb/storage/strange_usb_sticks0x05bf.h":  new file: version: 0,
    "drivers/usb/storage/transport.c": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/transport.c",
    "drivers/usb/storage/transport.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/transport.h",
    "drivers/usb/storage/unusual_alauda.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_alauda.h",
    "drivers/usb/storage/unusual_cypress.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_cypress.h",
    "drivers/usb/storage/unusual_datafab.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_datafab.h",
    "drivers/usb/storage/unusual_devs.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_devs.h",
    "drivers/usb/storage/unusual_freecom.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_freecom.h",
    "drivers/usb/storage/unusual_isd200.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_isd200.h",
    "drivers/usb/storage/unusual_jumpshot.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_jumpshot.h",
    "drivers/usb/storage/unusual_karma.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_karma.h",
    "drivers/usb/storage/unusual_onetouch.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_onetouch.h",
    "drivers/usb/storage/unusual_sddr09.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_sddr09.h",
    "drivers/usb/storage/unusual_sddr55.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_sddr55.h",
    "drivers/usb/storage/unusual_usbat.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/unusual_usbat.h",
    "drivers/usb/storage/usb.c": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/usb.c",
    "drivers/usb/storage/usb.h": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/usb.h",
    "drivers/usb/storage/usual-tables.c": link to or copy of "${kernel-2.6.38.6-27.fc15-source}/drivers/usb/storage/usual-tables.c",


    5. Compiling the Source
    follows.

    I hope this text helps and has not too many mistakes.

    Thomas Bruecker <public0x05bf@bluewin.ch>, Version: 0.0.1, 06jun2011 .