SD(3) SD(3) NAME sd - storage device interface SYNOPSIS bind #S /dev /dev/sdctl /dev/sdCu/ctl /dev/sdCu/raw /dev/sdCu/data ... DESCRIPTION The storage device interface serves a two-level directory giving access to multiple storage units, typically ATA(PI) or SCSI discs. Each unit is accessed via files in the directory named by the controller to which it is attached, C, and by its unit number u. The controller naming conven- tion for ATA(PI) units starts with the first controller being named `C', the second `D', etc. up to a maximum of 4 controllers ([C-F]); legacy controllers are always 'C' and 'D'. There can be a maximum of 2 units per ATA(PI) con- troller (). The controller naming convention for SCSI units starts with the first controller being named `0', the second `1', etc. up to a maximum of 16 controllers ([0-9a-f]). There can be a maximum of 16 units per SCSI controller ([0-9a-f]). Units are not accessed before the first attach. Units may be individually attached using the attach specifier, for example bind -a '#SsdD0' /dev An attach without a specifier will cause the driver to scan for all possible units before processing the rest of the name. The subdirectory for each unit contains two files, ctl and raw. In addition, if the unit is a direct-access disc of some type it may be split into partitions and the subdirec- tory may contain a file per partition. By default, the par- tition data will exist for such media. Partitions are added and deleted by writing to the ctl file part name start-sector end-sector delpart name The default data partition may be deleted. A partition SD(3) SD(3) cannot be deleted if a process has it open. If a change of removable media is detected, the new media cannot be opened until all open partitions on the old media are closed. Partitions are usually created using fdisk and prep(8); the convention is to name non-Plan 9 partitions after their cor- responding operating systems (e.g., /dev/sdC0/dos) and Plan 9 partitions according to their function (e.g., /dev/sdC0/swap). The example in prep(8) shows how this is done. Reading the ctl file returns at least one line of textual information about the unit. The first line will always be prefixed by inquiry and will give a manufacturer and model number if possible. A line prefixed by config will be returned for appropriate media, e.g. for ATA(PI) units the remainder of the line contains configuration information from the device's identify command (config and capabilities) and also the available I/O transfer options; this is a diag- nostic aid. A line prefixed by geometry will be returned for appropriate media; at least two numbers will follow, the first being the number of sectors contained in the unit and the second the sector size in bytes. Any remaining informa- tion on the geometry line is unit-dependent, for instance, head, cylinder and sector counts for ATA discs. If any par- titions are defined for the media, their name, start-sector and end-sector will be returned, prefixed by part. % cat /dev/sdD0/ctl inquiry KENWOOD CD-ROM UCR-421 208E10/20/99 7.39 2 M0 config 85C0 capabilities 0F00 dma 00550004 dmactl 00000000 geometry 242725 2352 part data 0 242725 % The use of DMA and multi-sector read/write commands may be enabled and disabled on ATA(PI) units by writing to the ctl file dma and rwm respectively followed by on or off. For example, to enable DMA on a unit that supports it: % echo 'dma on'>/dev/sd00/ctl If supported by the unit, the standby timer may be enabled: % echo 'standby T'>/dev/sdC0/ctl where T is the standby timer period in seconds. T must be between 30 and 1200, or can be 0 to disable the timer. The raw file is used to execute an arbitrary command on the unit at a low level. This is used by programs such as scuzz(8) to manipulate devices that do not fit the simple SD(3) SD(3) storage model or for maintenance purposes. The following steps may be taken to execute a command - Write the command to the raw file; - Read or write data associated with the command, according to the direction of the transfer. - Read the raw file to retrieve the status of the command, returned as a text integer. Reading /dev/sdctl yields information about each controller, one line per controller. Writing `config message' to /dev/sdctl passes message to the legacy configuration machinery, used to set attributes such as IRQ, port and size. Writing `ctltype message' to /dev/sdctl passes message to ctltype's wtopctl function with a nil sdev argu- ment, where ctltype is a known controller type such as ata or scsi. Writing `sdctlletter message' to /dev/sdctl passes message to sdctlletter's wtopctl function with an sdev argu- ment corresponding to the named controller, where ctlletter is a known controller letter such as C or 0. SOURCE /sys/src/9/port/devsd.c /sys/src/9/*/sd*.[hc] SEE ALSO scuzz(8) BUGS LUNs (logical unit numbers) are not implemented. For (S)ATA drives, LUNs are not merely ignored but are actively pre- vented from working except for INQUIRY commands. The 4 controller limit for ATA(PI) is not enforced. No account is taken of some buggy ATA PCI controllers such as the CMD640. ATA(PI) units come up with DMA and multi-sector read/write capability disabled.