1<html><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.78.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 bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><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"><div class="titlepage"><div><div><h1 class="title"><a name="usbfs"></a>Chapter 7. The USB Filesystem (usbfs)</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><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>. 2 You may prefer to avoid writing new kernel code for your 3 USB driver; that's the problem that usbfs set out to solve. 4 User mode device drivers are usually packaged as applications 5 or libraries, and may use usbfs through some programming library 6 that wraps it. Such libraries include 7 <a class="ulink" href="http://libusb.sourceforge.net" target="_top">libusb</a> 8 for C/C++, and 9 <a class="ulink" href="http://jUSB.sourceforge.net" target="_top">jUSB</a> for Java. 10 </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Unfinished</h3><p>This particular documentation is incomplete, 11 especially with respect to the asynchronous mode. 12 As of kernel 2.5.66 the code and this (new) documentation 13 need to be cross-reviewed. 14 </p></div><p>Configure usbfs into Linux kernels by enabling the 15 <span class="emphasis"><em>USB filesystem</em></span> option (CONFIG_USB_DEVICEFS), 16 and you get basic support for user mode USB device drivers. 17 Until relatively recently it was often (confusingly) called 18 <span class="emphasis"><em>usbdevfs</em></span> although it wasn't solving what 19 <span class="emphasis"><em>devfs</em></span> was. 20 Every USB device will appear in usbfs, regardless of whether or 21 not it has a kernel driver. 22 </p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="usbfs-files"></a>What files are in "usbfs"?</h2></div></div></div><p>Conventionally mounted at 23 <code class="filename">/proc/bus/usb</code>, usbfs 24 features include: 25 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="filename">/proc/bus/usb/devices</code> 26 ... a text file 27 showing each of the USB devices on known to the kernel, 28 and their configuration descriptors. 29 You can also poll() this to learn about new devices. 30 </p></li><li class="listitem"><p><code class="filename">/proc/bus/usb/BBB/DDD</code> 31 ... magic files 32 exposing the each device's configuration descriptors, and 33 supporting a series of ioctls for making device requests, 34 including I/O to devices. (Purely for access by programs.) 35 </p></li></ul></div><p> 36 </p><p> Each bus is given a number (BBB) based on when it was 37 enumerated; within each bus, each device is given a similar 38 number (DDD). 39 Those BBB/DDD paths are not "stable" identifiers; 40 expect them to change even if you always leave the devices 41 plugged in to the same hub port. 42 <span class="emphasis"><em>Don't even think of saving these in application 43 configuration files.</em></span> 44 Stable identifiers are available, for user mode applications 45 that want to use them. HID and networking devices expose 46 these stable IDs, so that for example you can be sure that 47 you told the right UPS to power down its second server. 48 "usbfs" doesn't (yet) expose those IDs. 49 </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 class="phrase">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> 50