Slashdot Mirror


User Space Driver for USB Storage Devices?

Zarf asks: "With Linux, if you don't like something, fix it yourself. So when I couldn't get my USB pen-drive to work and none of the canned solutions were satifactory... I took it upon myself to fix Linux. I've posted my solution in my Slashdot user's journal. But it seems to me that there must be a better way to promote my solution. Where should I post my fix so it can help the most people?"

59 comments

  1. I suggest... by KDan · · Score: 4, Funny

    Posting it on slashdot. I hear lots of people read that site.

    Daniel

    --
    Carpe Diem
    1. Re:I suggest... by jpop32 · · Score: 3, Funny

      Posting it on slashdot. I hear lots of people read that site.

      Dude, you failed to include the URL.

    2. Re:I suggest... by Anonymous Coward · · Score: 0

      He did that on purpose so the site wouldn't get slashdotted.

    3. Re:I suggest... by pcmills · · Score: 1


      I don't use the url you insensitive clod!!

      http://66.35.250.150

      --
      Ask Slashdot - google for stupid people.
    4. Re:I suggest... by Dave2+Wickham · · Score: 1

      Uhh... that is a URL, isn't it?

  2. The Manufacturer by rmohr02 · · Score: 5, Insightful

    Contact the manufacturer of the pendrive--ask them to place it on their website. If someone had the same problem you had, they would go to the manufacturer. They might even put your code on one of those mini-cds that the put the Windows 98 USB drivers on.

    1. Re:The Manufacturer by Zarf · · Score: 1

      The driver is for all pen-drives. It's a "user space driver" not a binary driver. All it does is create fstab entries and clean up mountpoints for you.

      --
      [signature]
  3. SourceForge by Baines · · Score: 3, Informative

    http://sourceforge.net/

    --

    ---
    Heavily armed, easily bored and off my medication.
    1. Re:SourceForge by Zarf · · Score: 1

      Okay buster, so I should start a Sourceforge project for one lousy PERL script? I don't think so.

      --
      [signature]
  4. You did this in Perl by Dancin_Santa · · Score: 1, Insightful

    Any thoughts to port it to C and releasing it as a closed source driver? Might make a couple bucks...

    If you were unhappy with the driver, it's more than likely some Japanese embedded engineer is sitting in his cube wishing that he could get his hands on a working USB pen storage driver that he didn't have to worry about releasing the source to.

    1. Re:You did this in Perl by Sembiance · · Score: 3, Funny
      Any thoughts to port it to C and releasing it as a closed source driver? Might make a couple bucks...


      Your promoting recoding into C, making it closed source and then SELLING it for profit?

      What kind of geek are you?
    2. Re:You did this in Perl by Dancin_Santa · · Score: 1

      I make toys for good boys and girls the world over. I think I'm doing my part.

    3. Re:You did this in Perl by gmhowell · · Score: 1

      I make toys for good boys and girls the world over.

      Bullshit. The slave-labor elves you have trapped in your non-union sweatshop do the work. Not only that, but you take jobs away from American elves.

      Bastard.

      --
      Jesus was all right but his disciples were thick and ordinary. -John Lennon
    4. Re:You did this in Perl by Dave2+Wickham · · Score: 1
      Why port it to C if you're just going to make it closed source?
      [dave@tc11 bloat-dev]$ perlcc -o bloat.o bloat
      [dave@tc11 bloat-dev]$ file bloat.o bloat
      bloat.o: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked (uses shared libs), not stripped
      bloat: perl script text executable
      Hey, you could even use perlcc -c (outputs C code) with the same usage options, make it open source, and still have the benefits of it being closed ;-) (if you don't get this joke, you've not seen C output by perlcc).
    5. Re:You did this in Perl by Dancin_Santa · · Score: 1

      American elves are fat, lazy, and overpaid.

      That's why I moved my factories to the NP: unionbusting is easy, just toss the little nits into the snow and wait for them to come begging for their job back.

    6. Re:You did this in Perl by Anonymous Coward · · Score: 0

      You must be having a rough time of it, what with the polar ice shelves breaking and all...

  5. Sir by gazbo · · Score: 5, Funny
    Slashdot is the wrong place not only for the driver, but also for you. You had a need, and used the open source philosophy to scratch your itch, and then released the code; Slashdot is designed for people who don't actually have coding skills, but instead like to talk about how great open source is because if they could code and if they ever actually needed to, then they could modify software.

    Oh, and for people who waste their lives gaming too.

    1. Re:Sir by ideatrack · · Score: 1

      And who all really use Windows 95 and Internet Explorer 3.

    2. Re:Sir by SharpFang · · Score: 1

      Err, I'm at a wrong place then. Been hacking xpdf sources already, to print a print-forbidden pdf :)

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
  6. Hotplug by warmcat · · Score: 5, Informative

    Maybe you should contact hotplug, so they can consider to either include it in the docs or the package, since it just seems to be a perl hotplug script.

    1. Re:Hotplug by Zarf · · Score: 1

      I give you the gold medal. You actually tried to answer my question. Kudos to you!

      The problem is that this is a "Redhat 9" problem. If you look at the Red Hat 9 standard "/etc/hotplug/usb" directory you'll find one script in there. It's the "usbcam" script written by... A programmer at Redhat. So I assume that the "correct" place for "/etc/hotplug/usb" scripts to come from are from distro people.

      I will contact the hotplug people but I have a feeling that they will respond that this isn't "part of" hotplug and that it's a user add on. Further... I have to wonder why Redhat didn't commission anyone to write this script to begin with... it wasn't hard.

      --
      [signature]
  7. DO NOT DO THIS by Anonymous Coward · · Score: 4, Interesting

    Please do not do this. It gives the impression that OSS programmers are free labor for hardware companies. Put it on a page on SourceForge or host it on your own site. Make sure, whatever you do, that you do it on your own terms. Do not make everyone else's work worthless by giving it away for free with no reciprocity.

    If you needed it and you want to share it with others, that's awesome. But don't let someone else get away with making a buck off of it without putting an ounce of effort into helping you.

    If you do approach the company, make it clear that you are willing to sell them a license to distribute it.

    1. Re:DO NOT DO THIS by passthecrackpipe · · Score: 4, Insightful

      On the contrary, it may signal to hardware developers that OSS developers are a clever buch that are willing to help out to make *their* hardware work. They may become more lenient in publishing hardware specs under reasonable disclosure terms, and who knows, we could get better drivers.....

      --
      People who think they know everything are a great annoyance to those of us who do.
    2. Re:DO NOT DO THIS by Brandybuck · · Score: 1

      If you do approach the company, make it clear that you are willing to sell them a license to distribute it.

      Unless you place your code under any Free or Open Source license. Then you ALREADY have given them a license to distribute it.

      --
      Don't blame me, I didn't vote for either of them!
    3. Re:DO NOT DO THIS by rmohr02 · · Score: 2, Interesting

      You can still sell them the rights to use it under an alternative license so that they don't have to worry about the restrictions of the GPL when distributing the program to customers.

  8. Ehh... by LinuxGeek8 · · Score: 4, Informative

    Sorry, but I don't get it. What you're doing is adding the device id's to the usb.usermap. If that's all that's needed, you culd just add it to the driver itself, or wherever it is normally put.

    For the script, all it does is load the right modules and mount the device, right?
    Loading the modules is what hotplug does, and mounting automatically with sync can be done with supermount.

    I'm no usbguru, programmer or bashguru, so maybe I'm missing something...
    I'd just contact the people from the usb-storage driver, and the hotplug people, if I had issues with it, and it's not clear to me what your isssue exatly was, and what you really needed to do to fix your issue.

    --
    Well, don't worry about that. We can get you back before you leave. (Dr. Who)
    1. Re:Ehh... by LinuxGeek8 · · Score: 4, Insightful

      Btw, what's up with the title "User Space Driver for USB Storage Devices"?
      You're still loading the kernel drivers to talk to the device, and mount that. If you mean the automount script, that's not really a driver.

      If you really need user space you could look at libusb, all that libusb needs is a driver loaded for the host controller, and for the rest it should be able to talk to the device from userspace. But if it can do usb-storage, I have no clue about that.

      --
      Well, don't worry about that. We can get you back before you leave. (Dr. Who)
    2. Re:Ehh... by Zarf · · Score: 1

      I think you've completely missed the point. The point is that to the uninitiated user, they plug the drive in and nothing happens. The GUI doesn't automatically respond to the presence of the new drive and so ... it doesn't "automagically" work. This proves that users are indeed stupid. For if they were smart they would merely read /var/log/message themselves and know which scsi emulated device was added and then mount it themselves either with su, sudo, or by hand editing their fstab.

      My solution is not worthy of a sourceforge project, a kernel posting, or anything so grand. It's at best a small hack that fixes something in userspace. Redhat should know about this short coming... but how do I point it out to them? How do I send this to the right people? The right people being redhat 9 users with a clue.

      --
      [signature]
    3. Re:Ehh... by LinuxGeek8 · · Score: 1

      I don't know how RedHat deals with this thing, but you could file a bugreport on their bugzilla I guess.
      In Mandrake, the modules should be loaded by hotplug, and then dynamic should make an icon on your Gnome or Kde desktop, which you can use to mount it. Ofcourse, hotplug and the usb drivers should know which driver belongs to the hardware, when looking at the device id's, so essentially that should be all that's needed to do.
      If it doesn't work like that, something is broken somewhere.

      --
      Well, don't worry about that. We can get you back before you leave. (Dr. Who)
    4. Re:Ehh... by cooksus · · Score: 1

      I am using RH 8.0 and a NextCom pen drive called Sundrive. Any ideas for getting your perl script to work there? I saw your note that you have to insert the pen drive twice after reboot under RH 9. That didn't make a difference here. In /var/log/messages: usb.agent: module setup usbstorage for USB product d7d/150/100 But no /etc/fstab entry or mounting is happening automagically. I am currently using the see-which-device-to-mount-in-messages-and-mount-it philosophy but will be delivering a system to a customer whose operators cannot be depended on to do this. Need to automate as much as possible. Any additional help getting hotplug to work under 8.0 would be appreciated.

    5. Re:Ehh... by Zarf · · Score: 1

      Okee dokee...

      Did you try the script in my journal at all? You should look at the "hotplug" stuff online... if you don't want to just trust me... You'll need to edit the file /etc/hotplug/usb.usermap and add the line: "usbstorage 0x0030 0x0000 0x0000 0x0000 0x0000 0x00 0x00 0x00 0x08 0x00 0x00 0x00000000" ... the 0x08 matches on the usbstorage device... you can map this on to a specific device or whatever.

      Next you'll want to copy the script from here:

      http://slashdot.org/~Zarf/journal/44708

      into the file: /etc/hotplug/usb/usbstorage and a-way-she goes! Once you're done you should beable to stab the drive into a USB socket and go. I've noticed that you occasionally need to stab the drive in twice because of the whole "insmod" business not working cleanly.

      This should work in theory on any Linux with USB support and hotplug. Eventually I'll mess around with getting with the hotplug people and finding out what the right way to do this is.

      As it stands I'm not completely satisfied with the way things are working... and it really is starting to tick me off. I've noticed problems with the whole USB subsystem locking up and crashing in the last few weeks on both my linux machines with uptimes only around a few weeks... what gives? Once again I'm going to have to dig deeper to get a solution I'm happy with from the user's stand point.

      If this doesn't work for you... we'll have to "get serious" ... contact me in my user's journal under the Entry I posted the code in if it isn't archived yet.

      --
      [signature]
  9. Re:Question for the moderators by Anonymous Coward · · Score: 0

    Apparently even the paid Microsoft lackeys get mod points once in a while.

  10. UM...LKML or find the USB maintainer for it by haplo21112 · · Score: 1

    The approrite place would be on the LKML...
    In One of two ways....
    1. Post the patch to the list explaining what its for and what it does...
    2. Post to the list asking who the maintainer of the USB realm for that device is, send the patch to them...

    or
    3. Check the Kernel Maintainers file for same information as #2

    --
    Power Corrupts,Absolute Power Corrupts Absolutely, leaving one person(group)in charge is absolutely corrupt.
  11. LKML by _iris · · Score: 1

    LKML, Duh.

    1. Re:LKML by Specialist2k · · Score: 1
      LKML for a Perl userspace driver? I don't think so...

      OTOH, the idea of rewriting the Linux kernel in Perl is certainly nice *g*

  12. Nice... Not really a driver, though. by Gordonjcp · · Score: 1

    You appear to have independently invented hotplug, or usb-mgr. Cool, though.

    1. Re:Nice... Not really a driver, though. by Zarf · · Score: 1

      It's a user-space driver or a hotplug script.

      --
      [signature]
  13. Any Success Stories? by Schlaegel · · Score: 2, Interesting

    Does anyone have a success story for these sticks working out of the box on a linux distro.

    I have become embarrassed when my Windows using friends want me to copy something onto their usb stick.

    I am running Red Hat 9, and can not get the sticks to work. I can dual boot to Windows on the same hardware and they just work.

    1. Re:Any Success Stories? by satterth · · Score: 2, Informative
      you'll have to load all the needed modules.

      /sbin/modprobe sr_mod

      /sbin/modprobe sd_mod

      /sbin/modprobe usbcore

      /sbin/modprobe uhci

      /sbin/modprobe usb-storage

      /sbin/modprobe vfat

      --
      Being called a dork on Slashdot must be like being called the retard in special ed.
    2. Re:Any Success Stories? by Brandybuck · · Score: 3, Interesting

      I think this whole topic is hilarious. Why? Because all the Linux fanboys keep telling me that FreeBSD is antiquated, dying, and doesn't support any hardware. But I can stick any USB Mass Storage device on my system and it just works. Out Of The Box(tm). This includes every thumb drive I've tried, my Olympus digital camera, and that cheesy Iomega USB CDRW at work (it won't burn to CD though).

      Of course, FreeBSD by default has a bare bones configuration, so I do a trivial amount of work to allow user mounting of filesystems. But with a KDE icon on my desktop right next to the Floppy and DVD icons, I never even notice how difficult and unfriendly it is.

      Frankly, I can't understand why Linux has problems with USB Mass Storage. Is UMass, like SATA, just something that no one in the Linux community paid any attention to until now?

      --
      Don't blame me, I didn't vote for either of them!
    3. Re:Any Success Stories? by Anonymous Coward · · Score: 0

      no..its that the drivers arent loaded by default. USB on linux is regarded the same way as IRDA on freeBSD...i.e. not very highly.
      nothing stops anyone from manually loading the drivers with modprobe in the correct order and getting it working tho.

    4. Re:Any Success Stories? by Brandybuck · · Score: 1

      Different architecture I guess. The USB drivers are kernel modules under FreeBSD as well. But they will get used as needed, without having to do an explicit kldload (insmod/modprobe).

      --
      Don't blame me, I didn't vote for either of them!
    5. Re:Any Success Stories? by OzPixel · · Score: 1


      I have a success story, on RH8. I have a TwinMOS "Mobile Disk", plugged it in to my box, and it was automatically detected. I had to mount it manually (" mount /dev/sdb1 /mnt/disk "), and it worked perfectly. (Ok, it did take me 10 minutes to realise that I should mount sdb1, not sdb - I blame lack of sleep).

      Seems weird that it would work less easily under RH9.

      David.

    6. Re:Any Success Stories? by whoami-ky · · Score: 1

      Actually, yes. I have a USB stick that works out of the box on SuSE 8.2. The REALLY neat thing is that I got the stick from MS (it even has the Micro$oft logo on it) as a "thank you" for attending one of their free seminars.

      --
      See my blog at Who's Who
    7. Re:Any Success Stories? by Anonymous Coward · · Score: 0

      I have RedHat 9 and did the same thing. It was sda1 instead, but that was all I needed.

    8. Re:Any Success Stories? by juhaz · · Score: 1

      Frankly, I can't understand why Linux has problems with USB Mass Storage.

      Umm. It doesn't.

      Did you even read those journal entries (oh, yes, this is slashdot. Of course you didn't.), this is not really a driver and he didn't have any trouble getting that USB Mass Storage to work Out Of The Box(tm), he just didn't like having to mount it manually and wrote a hotplug script that does that. No big deal.

    9. Re:Any Success Stories? by Brandybuck · · Score: 1

      he just didn't like having to mount it manually

      Wouldn't just a KDE icon do the same thing? I thought hotplug was just when you need to do weird stuff when you connected a device.

      --
      Don't blame me, I didn't vote for either of them!
    10. Re:Any Success Stories? by Anonymous Coward · · Score: 0

      Uh yeah.

      I've got Mandrake 9.1 and it just recognises my USB Pen Drive and my USB Compact Flash card reader and my USB external drive.

      Don't know about other distros, but MDK rocks.

      Peter

    11. Re:Any Success Stories? by haruchai · · Score: 1

      Has anyone tried using Mandrake? I have a USB-to-IDE
      external kit that I use to add a second hard drive to my laptop.
      Under Mandrake 9.1, I pop the 20gig drive into the case, connect both ends of the cable and the drive gets automounted. Couldn't be simpler.

      --
      Pain is merely failure leaving the body
    12. Re:Any Success Stories? by Zarf · · Score: 1

      It will not always be sda1, different systems running the same distro may make the drive a different scsi device. Don't you people read the articles?

      --
      [signature]
    13. Re:Any Success Stories? by Zarf · · Score: 1

      My boss didn't like that he had to click the icon.

      --
      [signature]
    14. Re:Any Success Stories? by Zarf · · Score: 1

      Red Hat 9, actually does work out of the box. It's just that to find what drive you should issue a "mount" command on you need to look in /var/log/messages, or at your scsi bus to figure out not only that a usb device has been hooked to the system but that it is running as ... most commonly ... sda1. Remember you aren't guaranteed sda1, if you have two pen drives one will be sda1 and another will be sdb1 ... or something.

      You can add a line in fstab, or you can use my script to do it for you... yes, I know it's not a "real driver" ...

      --
      [signature]
  14. USBMan.com by Stavr0 · · Score: 2, Interesting
    A nice resource for all that is USB. I found some UBS drivers for DOS that allows mounting Pendrives off a strait msdos boot floppy -- something that was supposed to be impossible.

    USBman's Linux section

  15. So as a Linux beginner, it does work for me by phoenix123 · · Score: 1

    Plug that usb stick in, wait 3 secs, mount /dev/usbX /mnt/usb-disk and you're set. Do all file transfer work, then umount /mnt/usb-disk and remove that thing.

    I used a properly patched Redhat 9 and it worked extremely easy. I used a no-name generic usb-stick with the lowest price tag I could find.

    The only quirk was a "device busy"-bug that occured sometimes so the filesystem could not be cleanly unmounted. This was because some subsystems of Nautilus or any other filemananger component did not release the filesystem lock properly when closing its windows and the force-unmount had no effect.

    It was annoying, since the usb-mass-storage driver is at kernel level and the usb-device still existed after "forcefully" removing that damn key from the slot and requiring a reboot when one wished to use that key again.

    However, none of these problems occured when using console access only on this usb-stick (pure console or text-mode filemanager, mc etc.) so I guess it's not the usb-part of the system that is buggy.

    1. Re:So as a Linux beginner, it does work for me by Zarf · · Score: 1

      The only quirk was a "device busy"-bug that occured sometimes so the filesystem could not be cleanly unmounted. This was because some subsystems of Nautilus or any other filemananger component did not release the filesystem lock properly when closing its windows and the force-unmount had no effect.

      My "driver" fixes this problem... to a certain extent. The boss didn't like having to drop to the command line to mount and unmount the device. So I was commissioned to write this script. The other problems I anticipated that would later cause headaches were the "Device busy" bug. You do an "umount -l" to fix this. "-l" is the "Lazy" unmount. I incorporated this command into my script at two points to doubly make sure that the users didn't screw their naughty nautilus sessions.

      --
      [signature]
  16. This from someone named "passthecrackpipe"... by benjaminchoate · · Score: 1

    Not that I disagree or anything, I just thought it was funny. I think that you both have good points. Maybe he could contact the company and give the software to them on the condition that they agree to release any needed information (now and in future products) for the development of better drivers?

    Just a thought-

    Benjamin

  17. As a regular slashdot reader... by Zarf · · Score: 1

    I would like to thank you all for your comments. I have found the majority of your posts entertaining. If I had enough moderator points I'd give most of you a pat on the back. I would like to thank those of you who actually tried to answer my question and I'll be off now to try and implement some of these.

    Those of you who actually read the discussion threads in my Journal might see how even amongst the intelligent and clueful people who post in my Journals that there is confusion on the "proper" way to handle a USB drive. Should it be automount? Should it be in the driver itself? Why bother with a script at all? How do you deal with the fact that the pen-drive can "move around" from sda1 to sdb1 if you have two pen-drives?

    In writing this "user space driver" I had to learn that usb-pen drives were usb masstorage devices. I had to learn about all the technologies involved, then I had to learn the "right way" to implement a "driver" that did what I wanted. I suspect that many people don't want to learn all those things. They shouldn't have to.

    In closing, I admit I was a little sensational with my article... USB storage devices do work with Redhat 9 Linux but the default Gnome desktop and KDE don't offer any clues that the drive is working. I see this as a flaw in the distro.

    It's a pitty this made it to Slashdot on the week I was on vacation.

    --
    [signature]