sd 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. .TH SD 3
  2. .SH NAME
  3. sd \- storage device interface
  4. .SH SYNOPSIS
  5. .nf
  6. .B bind #S /dev
  7. .B /dev/sdctl
  8. .BI /dev/sd Cu /ctl
  9. .BI /dev/sd Cu /raw
  10. .BI /dev/sd Cu /data
  11. \&...
  12. .fi
  13. .SH DESCRIPTION
  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 taken to execute a command
  179. .IP \- 3
  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. .LP
  191. Reading
  192. .B /dev/sdctl
  193. yields information about each controller,
  194. one line per controller.
  195. Writing `\fLconfig \fImessage\fR' to
  196. .B /dev/sdctl
  197. passes
  198. .I message
  199. to the legacy configuration machinery,
  200. used to set attributes such as IRQ, port and size.
  201. Writing `\fIctltype message\fR' to
  202. .B /dev/sdctl
  203. passes
  204. .I message
  205. to
  206. .IR ctltype 's
  207. .B wtopctl
  208. function with a nil
  209. .B sdev
  210. argument,
  211. where
  212. .I ctltype
  213. is a known controller type such as
  214. .B ata
  215. or
  216. .BR scsi .
  217. Writing `\c
  218. .BI sd "ctlletter message\fR'
  219. to
  220. .B /dev/sdctl
  221. passes
  222. .I message
  223. to
  224. .BI sd ctlletter\fR's
  225. .B wtopctl
  226. function with an
  227. .B sdev
  228. argument corresponding to the named controller,
  229. where
  230. .I ctlletter
  231. is a known controller letter such as
  232. .B C
  233. or
  234. .BR 0 .
  235. .SH SOURCE
  236. .B /sys/src/9/port/devsd.c
  237. .br
  238. .B /sys/src/9/*/sd*.[hc]
  239. .SH SEE ALSO
  240. .IR scuzz (8)
  241. .SH BUGS
  242. LUNs (logical unit numbers) are not implemented.
  243. For (S)ATA drives,
  244. LUNs are not merely ignored but are actively
  245. prevented from working except for INQUIRY commands.
  246. .PP
  247. The 4 controller limit for ATA(PI) is not enforced.
  248. .PP
  249. No account is taken of some buggy ATA PCI controllers
  250. such as the CMD640.
  251. .PP
  252. ATA(PI) units come up with DMA and multi-sector read/write
  253. capability disabled.