1
0

sd 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. .TH SD 3
  2. .SH NAME
  3. sd \- storage device interface
  4. .SH SYNOPSIS
  5. .nf
  6. .B bind #S /dev
  7. .BI /dev/sd Cu /ctl
  8. .BI /dev/sd Cu /raw
  9. .BI /dev/sd Cu /data
  10. \&...
  11. .fi
  12. .SH DESCRIPTION
  13. .PP
  14. The storage device interface serves a two-level directory
  15. giving access to multiple storage units,
  16. typically ATA(PI) or SCSI discs.
  17. Each unit
  18. is accessed via files in the directory named by the controller
  19. to which it is attached,
  20. .IR C ,
  21. and by its unit number
  22. .IR u .
  23. The controller naming convention for ATA(PI) units starts
  24. with the first controller being named
  25. .LR C ,
  26. the second
  27. .LR D ,
  28. etc. up to a maximum of 4 controllers
  29. .RB ([ C-F ]);
  30. legacy controllers are always 'C' and 'D'.
  31. There can be a maximum of 2 units per ATA(PI) controller
  32. .RB ([ 01 ]).
  33. The controller naming convention for SCSI units starts with
  34. the first controller being named
  35. .LR 0 ,
  36. the second
  37. .LR 1 ,
  38. etc. up to a maximum of 16 controllers
  39. .RB ([ 0-9a-f ]).
  40. There can be a maximum of 16 units per SCSI controller
  41. .RB ([ 0-9a-f ]).
  42. .PP
  43. Units are not accessed before the first attach.
  44. Units may be individually attached using the attach specifier,
  45. for example
  46. .IP
  47. .EX
  48. bind -a '#SsdD0' /dev
  49. .EE
  50. .PP
  51. An attach without a specifier will cause the driver to scan for all possible
  52. units before processing the rest of the name.
  53. .PP
  54. The subdirectory for each unit contains two files,
  55. .I ctl
  56. and
  57. .IR raw .
  58. In addition,
  59. if the unit is a direct-access disc of some type
  60. it may be split into partitions and
  61. the subdirectory may contain a file per partition.
  62. By default,
  63. the partition
  64. .I data
  65. will exist for such media.
  66. .PP
  67. Partitions are added and deleted by writing to the
  68. .I ctl
  69. file
  70. .IP
  71. .EX
  72. part \f2name start-sector end-sector\fP
  73. delpart \f2name\fP
  74. .EE
  75. .PP
  76. The default
  77. .I data
  78. partition may be deleted.
  79. A partition cannot be deleted if a process has it open.
  80. If a change of removable media is detected,
  81. the new media cannot be opened until all open partitions
  82. on the old media are closed.
  83. .PP
  84. Partitions are usually created using
  85. .I fdisk
  86. and
  87. .IR prep (8);
  88. the convention is to name non-Plan 9 partitions after their corresponding operating systems
  89. (e.g.,
  90. .BR /dev/sdC0/dos )
  91. and Plan 9 partitions according to their function
  92. (e.g.,
  93. .BR /dev/sdC0/swap ).
  94. The example in
  95. .IR prep (8)
  96. shows how this is done.
  97. .PP
  98. Reading the
  99. .I ctl
  100. file returns at least one line of textual information about
  101. the unit.
  102. The first line will always be prefixed by
  103. .B inquiry
  104. and will give a manufacturer and model number if possible.
  105. A line prefixed by
  106. .B config
  107. will be returned for appropriate media,
  108. e.g. for ATA(PI) units the remainder of the line contains
  109. configuration information from the device's
  110. .I identify
  111. command (config and capabilities)
  112. and also the available I/O transfer options;
  113. this is a diagnostic aid.
  114. A line prefixed by
  115. .B geometry
  116. will be returned for appropriate media;
  117. at least two numbers will follow,
  118. the first being the number of sectors contained in the unit
  119. and the second the sector size in bytes.
  120. Any remaining information on the
  121. .B geometry
  122. line is unit-dependent,
  123. for instance, head,
  124. cylinder and sector counts for ATA discs.
  125. If any partitions are defined for the media,
  126. their name, start-sector and end-sector will be returned,
  127. prefixed by
  128. .BR part .
  129. .IP
  130. .EX
  131. % cat /dev/sdD0/ctl
  132. inquiry KENWOOD CD-ROM UCR-421 208E10/20/99 7.39 2 M0
  133. config 85C0 capabilities 0F00 dma 00550004 dmactl 00000000
  134. geometry 242725 2352
  135. part data 0 242725
  136. %
  137. .EE
  138. .PP
  139. The use of DMA and multi-sector read/write commands may be
  140. enabled and disabled on ATA(PI) units by writing to the
  141. .B ctl
  142. file
  143. .B dma
  144. and
  145. .B rwm
  146. respectively followed by
  147. .B on
  148. or
  149. .BR off .
  150. For example, to enable DMA on a unit that supports it:
  151. .IP
  152. .EX
  153. % echo 'dma on'>/dev/sd00/ctl
  154. .EE
  155. .PP
  156. If supported by the unit,
  157. the standby timer may be enabled:
  158. .IP
  159. .EX
  160. % echo 'standby \f2T\fP'>/dev/sdC0/ctl
  161. .EE
  162. .PP
  163. where
  164. .I T
  165. is the standby timer period in seconds.
  166. .I T
  167. must be between 30 and 1200,
  168. or can be 0 to disable the timer.
  169. .PP
  170. The
  171. .B raw
  172. file is used to execute an arbitrary command on the unit at
  173. a low level.
  174. This is used by programs such as
  175. .IR scuzz (8)
  176. to manipulate devices that do not fit the simple storage model
  177. or for maintenance purposes.
  178. The following steps may be used to execute a command
  179. .IP
  180. \- Write the command to the
  181. .I raw
  182. file;
  183. .IP
  184. \- Read or write data associated with the command, according to the direction of the transfer.
  185. .IP
  186. \- Read the
  187. .I raw
  188. file to retrieve the status of the command,
  189. returned as a text integer.
  190. .SH SOURCE
  191. .B /sys/src/9/port/devsd.c
  192. .br
  193. .B /sys/src/9/*/sd*.[hc]
  194. .SH SEE ALSO
  195. .IR scuzz (8)
  196. .SH BUGS
  197. .PP
  198. Still in development.
  199. .PP
  200. No LUNs.
  201. .PP
  202. The 4 controller limit for ATA(PI) is not enforced.
  203. .PP
  204. No account is taken of some buggy ATA PCI controllers
  205. such as the CMD640.
  206. .PP
  207. ATA(PI) units come up with DMA and multi-sector read/write
  208. capability disabled.