NAME
usbdisk, usbfat: – serve USB mass storage devices

SYNOPSIS
usb/disk [ –dDfl ] [ –m mountpoint ] [ –s srvname ] [ ctrlno id ]

usbfat: [ –fl ] [ disk [ mntpt ] ]

DESCRIPTION
Disk serves a directory named mountpoint (default /n/disk) containing the files ctl and n, where n is the number of a LUN to access, for all detected LUNs of the named or found USB device. Disk searches for a USB device with class 8 (storage), subclass 2 (ATAPI CD/DVD/BD), 5 (removable, ATAPI–like) or 6 (SCSI transparent), and protocol 0x50 (bulk), or uses /dev/usb/ctrlno/id if specified. In every LUN directory are the files data and raw. data gives read/write access to blocks of the device. raw is a raw SCSI–like interface (talk to it with scuzz(8)).

The root directory's ctl file accepts the command reset, which tells disk to again fetch the information about all LUNs, and yields the device geometries when read.

The –d option generates debugging output. The –f option avoids freaking out some cheap USB flash disks by not issuing UMS reset commands to them. The –l option asks the device for its maximum LUN. By default, disk assumes a maximum LUN of zero, since some devices get upset if you ask them for their maximum LUN. Flash memory devices are likely to have multiple LUNs. The –m option mounts the served hierarchy on mountpoint instead of /n/disk. The –s option posts a mountable file descriptor as /srv/srvname. The –D option prints all 9P messages.

EXAMPLES
Access the usual preformatted FAT partition:
% usb/usbd
% usb/disk –l
% disk/fdisk –p /n/disk/0/data
part dos 7 31559
% dossrv –f /n/disk/0/data:7 usbstorage
dossrv: serving #s/usbstorage
% mount /srv/usbstorage /n/d:
% ls –l /n/d:
alrw–rw–rw– M 39 bill trog 180364 Oct    5 18:14 /n/d:/9LOAD
d–rwxrwxrwx M 39 bill trog        0 Nov 13 14:30 /n/d:/benedict

The latter part of the above example, from disk/fdisk to mount, has been packaged up as usbfat:, which mounts the FAT file system in the DOS partition of the named disk (by default /n/disk/0/data) on mntpt (by default /n/usb).

FILES
/n/disk              default mountpoint
/n/usb               default mountpoint for FAT file system on the disk
/srv/usbfat.$user     FAT file system service

SOURCE
/sys/src/cmd/usb/disk
/rc/bin/usbfat:

SEE ALSO
fs(3), sd(3), usb(3), partfs(8), prep(8), scuzz(8)

BUGS
Should implement sd(3)'s interface for each LUN. Currently, if there are multiple partitions, you can use fs(3) to manage them. If fdisk –p prints nothing, there is no partition table on the device, so one can invoke dossrv(4) directly.

USB 1 flash disks' I/O rates are slow and variable. Reading and writing in large units (e.g., 4KB) seems to be faster by an order of magnitude when transferring large volumes of data.

Copyright © 2008 Lucent Technologies. All rights reserved.