<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter 7. The USB Filesystem (usbfs)</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /><link rel="home" href="index.html" title="The Linux-USB Host Side API" /><link rel="up" href="index.html" title="The Linux-USB Host Side API" /><link rel="prev" href="API-hcd-buffer-destroy.html" title="hcd_buffer_destroy" /><link rel="next" href="usbfs-fstab.html" title="Mounting and Access Control" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 7. The USB Filesystem (usbfs)</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-hcd-buffer-destroy.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="usbfs-fstab.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 7. The USB Filesystem (usbfs)"><div class="titlepage"><div><div><h2 class="title"><a id="usbfs"></a>Chapter 7. The USB Filesystem (usbfs)</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl><dt><span class="sect1"><a href="usbfs.html#usbfs-files">What files are in "usbfs"?</a></span></dt><dt><span class="sect1"><a href="usbfs-fstab.html">Mounting and Access Control</a></span></dt><dt><span class="sect1"><a href="usbfs-devices.html">/proc/bus/usb/devices</a></span></dt><dt><span class="sect1"><a href="usbfs-bbbddd.html">/proc/bus/usb/BBB/DDD</a></span></dt><dt><span class="sect1"><a href="usbfs-lifecycle.html">Life Cycle of User Mode Drivers</a></span></dt><dt><span class="sect1"><a href="usbfs-ioctl.html">The ioctl() Requests</a></span></dt><dd><dl><dt><span class="sect2"><a href="usbfs-ioctl.html#usbfs-mgmt">Management/Status Requests</a></span></dt><dt><span class="sect2"><a href="usbfs-ioctl.html#usbfs-sync">Synchronous I/O Support</a></span></dt><dt><span class="sect2"><a href="usbfs-ioctl.html#usbfs-async">Asynchronous I/O Support</a></span></dt></dl></dd></dl></div><p>This chapter presents the Linux <span class="emphasis"><em>usbfs</em></span>. You may prefer to avoid writing new kernel code for your USB driver; that's the problem that usbfs set out to solve. User mode device drivers are usually packaged as applications or libraries, and may use usbfs through some programming library that wraps it. Such libraries include <a class="ulink" href="http://libusb.sourceforge.net" target="_top">libusb</a> for C/C++, and <a class="ulink" href="http://jUSB.sourceforge.net" target="_top">jUSB</a> for Java. </p><div class="note" title="Unfinished" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Unfinished</h3><p>This particular documentation is incomplete, especially with respect to the asynchronous mode. As of kernel 2.5.66 the code and this (new) documentation need to be cross-reviewed. </p></div><p>Configure usbfs into Linux kernels by enabling the <span class="emphasis"><em>USB filesystem</em></span> option (CONFIG_USB_DEVICEFS), and you get basic support for user mode USB device drivers. Until relatively recently it was often (confusingly) called <span class="emphasis"><em>usbdevfs</em></span> although it wasn't solving what <span class="emphasis"><em>devfs</em></span> was. Every USB device will appear in usbfs, regardless of whether or not it has a kernel driver. </p><div class="sect1" title="What files are in "usbfs"?"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="usbfs-files"></a>What files are in "usbfs"?</h2></div></div></div><p>Conventionally mounted at <code class="filename">/proc/bus/usb</code>, usbfs features include: </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="filename">/proc/bus/usb/devices</code> ... a text file showing each of the USB devices on known to the kernel, and their configuration descriptors. You can also poll() this to learn about new devices. </p></li><li class="listitem"><p><code class="filename">/proc/bus/usb/BBB/DDD</code> ... magic files exposing the each device's configuration descriptors, and supporting a series of ioctls for making device requests, including I/O to devices. (Purely for access by programs.) </p></li></ul></div><p> </p><p> Each bus is given a number (BBB) based on when it was enumerated; within each bus, each device is given a similar number (DDD). Those BBB/DDD paths are not "stable" identifiers; expect them to change even if you always leave the devices plugged in to the same hub port. <span class="emphasis"><em>Don't even think of saving these in application configuration files.</em></span> Stable identifiers are available, for user mode applications that want to use them. HID and networking devices expose these stable IDs, so that for example you can be sure that you told the right UPS to power down its second server. "usbfs" doesn't (yet) expose those IDs. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-hcd-buffer-destroy.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="usbfs-fstab.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span>hcd_buffer_destroy</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Mounting and Access Control</td></tr></table></div></body></html>