cdrom.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. ============================
  2. Summary of CDROM ioctl calls
  3. ============================
  4. - Edward A. Falk <efalk@google.com>
  5. November, 2004
  6. This document attempts to describe the ioctl(2) calls supported by
  7. the CDROM layer. These are by-and-large implemented (as of Linux 2.6)
  8. in drivers/cdrom/cdrom.c and drivers/block/scsi_ioctl.c
  9. ioctl values are listed in <linux/cdrom.h>. As of this writing, they
  10. are as follows:
  11. ======================== ===============================================
  12. CDROMPAUSE Pause Audio Operation
  13. CDROMRESUME Resume paused Audio Operation
  14. CDROMPLAYMSF Play Audio MSF (struct cdrom_msf)
  15. CDROMPLAYTRKIND Play Audio Track/index (struct cdrom_ti)
  16. CDROMREADTOCHDR Read TOC header (struct cdrom_tochdr)
  17. CDROMREADTOCENTRY Read TOC entry (struct cdrom_tocentry)
  18. CDROMSTOP Stop the cdrom drive
  19. CDROMSTART Start the cdrom drive
  20. CDROMEJECT Ejects the cdrom media
  21. CDROMVOLCTRL Control output volume (struct cdrom_volctrl)
  22. CDROMSUBCHNL Read subchannel data (struct cdrom_subchnl)
  23. CDROMREADMODE2 Read CDROM mode 2 data (2336 Bytes)
  24. (struct cdrom_read)
  25. CDROMREADMODE1 Read CDROM mode 1 data (2048 Bytes)
  26. (struct cdrom_read)
  27. CDROMREADAUDIO (struct cdrom_read_audio)
  28. CDROMEJECT_SW enable(1)/disable(0) auto-ejecting
  29. CDROMMULTISESSION Obtain the start-of-last-session
  30. address of multi session disks
  31. (struct cdrom_multisession)
  32. CDROM_GET_MCN Obtain the "Universal Product Code"
  33. if available (struct cdrom_mcn)
  34. CDROM_GET_UPC Deprecated, use CDROM_GET_MCN instead.
  35. CDROMRESET hard-reset the drive
  36. CDROMVOLREAD Get the drive's volume setting
  37. (struct cdrom_volctrl)
  38. CDROMREADRAW read data in raw mode (2352 Bytes)
  39. (struct cdrom_read)
  40. CDROMREADCOOKED read data in cooked mode
  41. CDROMSEEK seek msf address
  42. CDROMPLAYBLK scsi-cd only, (struct cdrom_blk)
  43. CDROMREADALL read all 2646 bytes
  44. CDROMGETSPINDOWN return 4-bit spindown value
  45. CDROMSETSPINDOWN set 4-bit spindown value
  46. CDROMCLOSETRAY pendant of CDROMEJECT
  47. CDROM_SET_OPTIONS Set behavior options
  48. CDROM_CLEAR_OPTIONS Clear behavior options
  49. CDROM_SELECT_SPEED Set the CD-ROM speed
  50. CDROM_SELECT_DISC Select disc (for juke-boxes)
  51. CDROM_MEDIA_CHANGED Check is media changed
  52. CDROM_TIMED_MEDIA_CHANGE Check if media changed
  53. since given time
  54. (struct cdrom_timed_media_change_info)
  55. CDROM_DRIVE_STATUS Get tray position, etc.
  56. CDROM_DISC_STATUS Get disc type, etc.
  57. CDROM_CHANGER_NSLOTS Get number of slots
  58. CDROM_LOCKDOOR lock or unlock door
  59. CDROM_DEBUG Turn debug messages on/off
  60. CDROM_GET_CAPABILITY get capabilities
  61. CDROMAUDIOBUFSIZ set the audio buffer size
  62. DVD_READ_STRUCT Read structure
  63. DVD_WRITE_STRUCT Write structure
  64. DVD_AUTH Authentication
  65. CDROM_SEND_PACKET send a packet to the drive
  66. CDROM_NEXT_WRITABLE get next writable block
  67. CDROM_LAST_WRITTEN get last block written on disc
  68. ======================== ===============================================
  69. The information that follows was determined from reading kernel source
  70. code. It is likely that some corrections will be made over time.
  71. ------------------------------------------------------------------------------
  72. General:
  73. Unless otherwise specified, all ioctl calls return 0 on success
  74. and -1 with errno set to an appropriate value on error. (Some
  75. ioctls return non-negative data values.)
  76. Unless otherwise specified, all ioctl calls return -1 and set
  77. errno to EFAULT on a failed attempt to copy data to or from user
  78. address space.
  79. Individual drivers may return error codes not listed here.
  80. Unless otherwise specified, all data structures and constants
  81. are defined in <linux/cdrom.h>
  82. ------------------------------------------------------------------------------
  83. CDROMPAUSE
  84. Pause Audio Operation
  85. usage::
  86. ioctl(fd, CDROMPAUSE, 0);
  87. inputs:
  88. none
  89. outputs:
  90. none
  91. error return:
  92. - ENOSYS cd drive not audio-capable.
  93. CDROMRESUME
  94. Resume paused Audio Operation
  95. usage::
  96. ioctl(fd, CDROMRESUME, 0);
  97. inputs:
  98. none
  99. outputs:
  100. none
  101. error return:
  102. - ENOSYS cd drive not audio-capable.
  103. CDROMPLAYMSF
  104. Play Audio MSF
  105. (struct cdrom_msf)
  106. usage::
  107. struct cdrom_msf msf;
  108. ioctl(fd, CDROMPLAYMSF, &msf);
  109. inputs:
  110. cdrom_msf structure, describing a segment of music to play
  111. outputs:
  112. none
  113. error return:
  114. - ENOSYS cd drive not audio-capable.
  115. notes:
  116. - MSF stands for minutes-seconds-frames
  117. - LBA stands for logical block address
  118. - Segment is described as start and end times, where each time
  119. is described as minutes:seconds:frames.
  120. A frame is 1/75 of a second.
  121. CDROMPLAYTRKIND
  122. Play Audio Track/index
  123. (struct cdrom_ti)
  124. usage::
  125. struct cdrom_ti ti;
  126. ioctl(fd, CDROMPLAYTRKIND, &ti);
  127. inputs:
  128. cdrom_ti structure, describing a segment of music to play
  129. outputs:
  130. none
  131. error return:
  132. - ENOSYS cd drive not audio-capable.
  133. notes:
  134. - Segment is described as start and end times, where each time
  135. is described as a track and an index.
  136. CDROMREADTOCHDR
  137. Read TOC header
  138. (struct cdrom_tochdr)
  139. usage::
  140. cdrom_tochdr header;
  141. ioctl(fd, CDROMREADTOCHDR, &header);
  142. inputs:
  143. cdrom_tochdr structure
  144. outputs:
  145. cdrom_tochdr structure
  146. error return:
  147. - ENOSYS cd drive not audio-capable.
  148. CDROMREADTOCENTRY
  149. Read TOC entry
  150. (struct cdrom_tocentry)
  151. usage::
  152. struct cdrom_tocentry entry;
  153. ioctl(fd, CDROMREADTOCENTRY, &entry);
  154. inputs:
  155. cdrom_tocentry structure
  156. outputs:
  157. cdrom_tocentry structure
  158. error return:
  159. - ENOSYS cd drive not audio-capable.
  160. - EINVAL entry.cdte_format not CDROM_MSF or CDROM_LBA
  161. - EINVAL requested track out of bounds
  162. - EIO I/O error reading TOC
  163. notes:
  164. - TOC stands for Table Of Contents
  165. - MSF stands for minutes-seconds-frames
  166. - LBA stands for logical block address
  167. CDROMSTOP
  168. Stop the cdrom drive
  169. usage::
  170. ioctl(fd, CDROMSTOP, 0);
  171. inputs:
  172. none
  173. outputs:
  174. none
  175. error return:
  176. - ENOSYS cd drive not audio-capable.
  177. notes:
  178. - Exact interpretation of this ioctl depends on the device,
  179. but most seem to spin the drive down.
  180. CDROMSTART
  181. Start the cdrom drive
  182. usage::
  183. ioctl(fd, CDROMSTART, 0);
  184. inputs:
  185. none
  186. outputs:
  187. none
  188. error return:
  189. - ENOSYS cd drive not audio-capable.
  190. notes:
  191. - Exact interpretation of this ioctl depends on the device,
  192. but most seem to spin the drive up and/or close the tray.
  193. Other devices ignore the ioctl completely.
  194. CDROMEJECT
  195. - Ejects the cdrom media
  196. usage::
  197. ioctl(fd, CDROMEJECT, 0);
  198. inputs:
  199. none
  200. outputs:
  201. none
  202. error returns:
  203. - ENOSYS cd drive not capable of ejecting
  204. - EBUSY other processes are accessing drive, or door is locked
  205. notes:
  206. - See CDROM_LOCKDOOR, below.
  207. CDROMCLOSETRAY
  208. pendant of CDROMEJECT
  209. usage::
  210. ioctl(fd, CDROMCLOSETRAY, 0);
  211. inputs:
  212. none
  213. outputs:
  214. none
  215. error returns:
  216. - ENOSYS cd drive not capable of closing the tray
  217. - EBUSY other processes are accessing drive, or door is locked
  218. notes:
  219. - See CDROM_LOCKDOOR, below.
  220. CDROMVOLCTRL
  221. Control output volume (struct cdrom_volctrl)
  222. usage::
  223. struct cdrom_volctrl volume;
  224. ioctl(fd, CDROMVOLCTRL, &volume);
  225. inputs:
  226. cdrom_volctrl structure containing volumes for up to 4
  227. channels.
  228. outputs:
  229. none
  230. error return:
  231. - ENOSYS cd drive not audio-capable.
  232. CDROMVOLREAD
  233. Get the drive's volume setting
  234. (struct cdrom_volctrl)
  235. usage::
  236. struct cdrom_volctrl volume;
  237. ioctl(fd, CDROMVOLREAD, &volume);
  238. inputs:
  239. none
  240. outputs:
  241. The current volume settings.
  242. error return:
  243. - ENOSYS cd drive not audio-capable.
  244. CDROMSUBCHNL
  245. Read subchannel data
  246. (struct cdrom_subchnl)
  247. usage::
  248. struct cdrom_subchnl q;
  249. ioctl(fd, CDROMSUBCHNL, &q);
  250. inputs:
  251. cdrom_subchnl structure
  252. outputs:
  253. cdrom_subchnl structure
  254. error return:
  255. - ENOSYS cd drive not audio-capable.
  256. - EINVAL format not CDROM_MSF or CDROM_LBA
  257. notes:
  258. - Format is converted to CDROM_MSF or CDROM_LBA
  259. as per user request on return
  260. CDROMREADRAW
  261. read data in raw mode (2352 Bytes)
  262. (struct cdrom_read)
  263. usage::
  264. union {
  265. struct cdrom_msf msf; /* input */
  266. char buffer[CD_FRAMESIZE_RAW]; /* return */
  267. } arg;
  268. ioctl(fd, CDROMREADRAW, &arg);
  269. inputs:
  270. cdrom_msf structure indicating an address to read.
  271. Only the start values are significant.
  272. outputs:
  273. Data written to address provided by user.
  274. error return:
  275. - EINVAL address less than 0, or msf less than 0:2:0
  276. - ENOMEM out of memory
  277. notes:
  278. - As of 2.6.8.1, comments in <linux/cdrom.h> indicate that this
  279. ioctl accepts a cdrom_read structure, but actual source code
  280. reads a cdrom_msf structure and writes a buffer of data to
  281. the same address.
  282. - MSF values are converted to LBA values via this formula::
  283. lba = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;
  284. CDROMREADMODE1
  285. Read CDROM mode 1 data (2048 Bytes)
  286. (struct cdrom_read)
  287. notes:
  288. Identical to CDROMREADRAW except that block size is
  289. CD_FRAMESIZE (2048) bytes
  290. CDROMREADMODE2
  291. Read CDROM mode 2 data (2336 Bytes)
  292. (struct cdrom_read)
  293. notes:
  294. Identical to CDROMREADRAW except that block size is
  295. CD_FRAMESIZE_RAW0 (2336) bytes
  296. CDROMREADAUDIO
  297. (struct cdrom_read_audio)
  298. usage::
  299. struct cdrom_read_audio ra;
  300. ioctl(fd, CDROMREADAUDIO, &ra);
  301. inputs:
  302. cdrom_read_audio structure containing read start
  303. point and length
  304. outputs:
  305. audio data, returned to buffer indicated by ra
  306. error return:
  307. - EINVAL format not CDROM_MSF or CDROM_LBA
  308. - EINVAL nframes not in range [1 75]
  309. - ENXIO drive has no queue (probably means invalid fd)
  310. - ENOMEM out of memory
  311. CDROMEJECT_SW
  312. enable(1)/disable(0) auto-ejecting
  313. usage::
  314. int val;
  315. ioctl(fd, CDROMEJECT_SW, val);
  316. inputs:
  317. Flag specifying auto-eject flag.
  318. outputs:
  319. none
  320. error return:
  321. - ENOSYS Drive is not capable of ejecting.
  322. - EBUSY Door is locked
  323. CDROMMULTISESSION
  324. Obtain the start-of-last-session address of multi session disks
  325. (struct cdrom_multisession)
  326. usage::
  327. struct cdrom_multisession ms_info;
  328. ioctl(fd, CDROMMULTISESSION, &ms_info);
  329. inputs:
  330. cdrom_multisession structure containing desired
  331. format.
  332. outputs:
  333. cdrom_multisession structure is filled with last_session
  334. information.
  335. error return:
  336. - EINVAL format not CDROM_MSF or CDROM_LBA
  337. CDROM_GET_MCN
  338. Obtain the "Universal Product Code"
  339. if available
  340. (struct cdrom_mcn)
  341. usage::
  342. struct cdrom_mcn mcn;
  343. ioctl(fd, CDROM_GET_MCN, &mcn);
  344. inputs:
  345. none
  346. outputs:
  347. Universal Product Code
  348. error return:
  349. - ENOSYS Drive is not capable of reading MCN data.
  350. notes:
  351. - Source code comments state::
  352. The following function is implemented, although very few
  353. audio discs give Universal Product Code information, which
  354. should just be the Medium Catalog Number on the box. Note,
  355. that the way the code is written on the CD is /not/ uniform
  356. across all discs!
  357. CDROM_GET_UPC
  358. CDROM_GET_MCN (deprecated)
  359. Not implemented, as of 2.6.8.1
  360. CDROMRESET
  361. hard-reset the drive
  362. usage::
  363. ioctl(fd, CDROMRESET, 0);
  364. inputs:
  365. none
  366. outputs:
  367. none
  368. error return:
  369. - EACCES Access denied: requires CAP_SYS_ADMIN
  370. - ENOSYS Drive is not capable of resetting.
  371. CDROMREADCOOKED
  372. read data in cooked mode
  373. usage::
  374. u8 buffer[CD_FRAMESIZE]
  375. ioctl(fd, CDROMREADCOOKED, buffer);
  376. inputs:
  377. none
  378. outputs:
  379. 2048 bytes of data, "cooked" mode.
  380. notes:
  381. Not implemented on all drives.
  382. CDROMREADALL
  383. read all 2646 bytes
  384. Same as CDROMREADCOOKED, but reads 2646 bytes.
  385. CDROMSEEK
  386. seek msf address
  387. usage::
  388. struct cdrom_msf msf;
  389. ioctl(fd, CDROMSEEK, &msf);
  390. inputs:
  391. MSF address to seek to.
  392. outputs:
  393. none
  394. CDROMPLAYBLK
  395. scsi-cd only
  396. (struct cdrom_blk)
  397. usage::
  398. struct cdrom_blk blk;
  399. ioctl(fd, CDROMPLAYBLK, &blk);
  400. inputs:
  401. Region to play
  402. outputs:
  403. none
  404. CDROMGETSPINDOWN
  405. Obsolete, was ide-cd only
  406. usage::
  407. char spindown;
  408. ioctl(fd, CDROMGETSPINDOWN, &spindown);
  409. inputs:
  410. none
  411. outputs:
  412. The value of the current 4-bit spindown value.
  413. CDROMSETSPINDOWN
  414. Obsolete, was ide-cd only
  415. usage::
  416. char spindown
  417. ioctl(fd, CDROMSETSPINDOWN, &spindown);
  418. inputs:
  419. 4-bit value used to control spindown (TODO: more detail here)
  420. outputs:
  421. none
  422. CDROM_SET_OPTIONS
  423. Set behavior options
  424. usage::
  425. int options;
  426. ioctl(fd, CDROM_SET_OPTIONS, options);
  427. inputs:
  428. New values for drive options. The logical 'or' of:
  429. ============== ==================================
  430. CDO_AUTO_CLOSE close tray on first open(2)
  431. CDO_AUTO_EJECT open tray on last release
  432. CDO_USE_FFLAGS use O_NONBLOCK information on open
  433. CDO_LOCK lock tray on open files
  434. CDO_CHECK_TYPE check type on open for data
  435. ============== ==================================
  436. outputs:
  437. Returns the resulting options settings in the
  438. ioctl return value. Returns -1 on error.
  439. error return:
  440. - ENOSYS selected option(s) not supported by drive.
  441. CDROM_CLEAR_OPTIONS
  442. Clear behavior options
  443. Same as CDROM_SET_OPTIONS, except that selected options are
  444. turned off.
  445. CDROM_SELECT_SPEED
  446. Set the CD-ROM speed
  447. usage::
  448. int speed;
  449. ioctl(fd, CDROM_SELECT_SPEED, speed);
  450. inputs:
  451. New drive speed.
  452. outputs:
  453. none
  454. error return:
  455. - ENOSYS speed selection not supported by drive.
  456. CDROM_SELECT_DISC
  457. Select disc (for juke-boxes)
  458. usage::
  459. int disk;
  460. ioctl(fd, CDROM_SELECT_DISC, disk);
  461. inputs:
  462. Disk to load into drive.
  463. outputs:
  464. none
  465. error return:
  466. - EINVAL Disk number beyond capacity of drive
  467. CDROM_MEDIA_CHANGED
  468. Check is media changed
  469. usage::
  470. int slot;
  471. ioctl(fd, CDROM_MEDIA_CHANGED, slot);
  472. inputs:
  473. Slot number to be tested, always zero except for jukeboxes.
  474. May also be special values CDSL_NONE or CDSL_CURRENT
  475. outputs:
  476. Ioctl return value is 0 or 1 depending on whether the media
  477. has been changed, or -1 on error.
  478. error returns:
  479. - ENOSYS Drive can't detect media change
  480. - EINVAL Slot number beyond capacity of drive
  481. - ENOMEM Out of memory
  482. CDROM_DRIVE_STATUS
  483. Get tray position, etc.
  484. usage::
  485. int slot;
  486. ioctl(fd, CDROM_DRIVE_STATUS, slot);
  487. inputs:
  488. Slot number to be tested, always zero except for jukeboxes.
  489. May also be special values CDSL_NONE or CDSL_CURRENT
  490. outputs:
  491. Ioctl return value will be one of the following values
  492. from <linux/cdrom.h>:
  493. =================== ==========================
  494. CDS_NO_INFO Information not available.
  495. CDS_NO_DISC
  496. CDS_TRAY_OPEN
  497. CDS_DRIVE_NOT_READY
  498. CDS_DISC_OK
  499. -1 error
  500. =================== ==========================
  501. error returns:
  502. - ENOSYS Drive can't detect drive status
  503. - EINVAL Slot number beyond capacity of drive
  504. - ENOMEM Out of memory
  505. CDROM_DISC_STATUS
  506. Get disc type, etc.
  507. usage::
  508. ioctl(fd, CDROM_DISC_STATUS, 0);
  509. inputs:
  510. none
  511. outputs:
  512. Ioctl return value will be one of the following values
  513. from <linux/cdrom.h>:
  514. - CDS_NO_INFO
  515. - CDS_AUDIO
  516. - CDS_MIXED
  517. - CDS_XA_2_2
  518. - CDS_XA_2_1
  519. - CDS_DATA_1
  520. error returns:
  521. none at present
  522. notes:
  523. - Source code comments state::
  524. Ok, this is where problems start. The current interface for
  525. the CDROM_DISC_STATUS ioctl is flawed. It makes the false
  526. assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc.
  527. Unfortunately, while this is often the case, it is also
  528. very common for CDs to have some tracks with data, and some
  529. tracks with audio. Just because I feel like it, I declare
  530. the following to be the best way to cope. If the CD has
  531. ANY data tracks on it, it will be returned as a data CD.
  532. If it has any XA tracks, I will return it as that. Now I
  533. could simplify this interface by combining these returns with
  534. the above, but this more clearly demonstrates the problem
  535. with the current interface. Too bad this wasn't designed
  536. to use bitmasks... -Erik
  537. Well, now we have the option CDS_MIXED: a mixed-type CD.
  538. User level programmers might feel the ioctl is not very
  539. useful.
  540. ---david
  541. CDROM_CHANGER_NSLOTS
  542. Get number of slots
  543. usage::
  544. ioctl(fd, CDROM_CHANGER_NSLOTS, 0);
  545. inputs:
  546. none
  547. outputs:
  548. The ioctl return value will be the number of slots in a
  549. CD changer. Typically 1 for non-multi-disk devices.
  550. error returns:
  551. none
  552. CDROM_LOCKDOOR
  553. lock or unlock door
  554. usage::
  555. int lock;
  556. ioctl(fd, CDROM_LOCKDOOR, lock);
  557. inputs:
  558. Door lock flag, 1=lock, 0=unlock
  559. outputs:
  560. none
  561. error returns:
  562. - EDRIVE_CANT_DO_THIS
  563. Door lock function not supported.
  564. - EBUSY
  565. Attempt to unlock when multiple users
  566. have the drive open and not CAP_SYS_ADMIN
  567. notes:
  568. As of 2.6.8.1, the lock flag is a global lock, meaning that
  569. all CD drives will be locked or unlocked together. This is
  570. probably a bug.
  571. The EDRIVE_CANT_DO_THIS value is defined in <linux/cdrom.h>
  572. and is currently (2.6.8.1) the same as EOPNOTSUPP
  573. CDROM_DEBUG
  574. Turn debug messages on/off
  575. usage::
  576. int debug;
  577. ioctl(fd, CDROM_DEBUG, debug);
  578. inputs:
  579. Cdrom debug flag, 0=disable, 1=enable
  580. outputs:
  581. The ioctl return value will be the new debug flag.
  582. error return:
  583. - EACCES Access denied: requires CAP_SYS_ADMIN
  584. CDROM_GET_CAPABILITY
  585. get capabilities
  586. usage::
  587. ioctl(fd, CDROM_GET_CAPABILITY, 0);
  588. inputs:
  589. none
  590. outputs:
  591. The ioctl return value is the current device capability
  592. flags. See CDC_CLOSE_TRAY, CDC_OPEN_TRAY, etc.
  593. CDROMAUDIOBUFSIZ
  594. set the audio buffer size
  595. usage::
  596. int arg;
  597. ioctl(fd, CDROMAUDIOBUFSIZ, val);
  598. inputs:
  599. New audio buffer size
  600. outputs:
  601. The ioctl return value is the new audio buffer size, or -1
  602. on error.
  603. error return:
  604. - ENOSYS Not supported by this driver.
  605. notes:
  606. Not supported by all drivers.
  607. DVD_READ_STRUCT Read structure
  608. usage::
  609. dvd_struct s;
  610. ioctl(fd, DVD_READ_STRUCT, &s);
  611. inputs:
  612. dvd_struct structure, containing:
  613. =================== ==========================================
  614. type specifies the information desired, one of
  615. DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT,
  616. DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA,
  617. DVD_STRUCT_MANUFACT
  618. physical.layer_num desired layer, indexed from 0
  619. copyright.layer_num desired layer, indexed from 0
  620. disckey.agid
  621. =================== ==========================================
  622. outputs:
  623. dvd_struct structure, containing:
  624. =================== ================================
  625. physical for type == DVD_STRUCT_PHYSICAL
  626. copyright for type == DVD_STRUCT_COPYRIGHT
  627. disckey.value for type == DVD_STRUCT_DISCKEY
  628. bca.{len,value} for type == DVD_STRUCT_BCA
  629. manufact.{len,valu} for type == DVD_STRUCT_MANUFACT
  630. =================== ================================
  631. error returns:
  632. - EINVAL physical.layer_num exceeds number of layers
  633. - EIO Received invalid response from drive
  634. DVD_WRITE_STRUCT Write structure
  635. Not implemented, as of 2.6.8.1
  636. DVD_AUTH Authentication
  637. usage::
  638. dvd_authinfo ai;
  639. ioctl(fd, DVD_AUTH, &ai);
  640. inputs:
  641. dvd_authinfo structure. See <linux/cdrom.h>
  642. outputs:
  643. dvd_authinfo structure.
  644. error return:
  645. - ENOTTY ai.type not recognized.
  646. CDROM_SEND_PACKET
  647. send a packet to the drive
  648. usage::
  649. struct cdrom_generic_command cgc;
  650. ioctl(fd, CDROM_SEND_PACKET, &cgc);
  651. inputs:
  652. cdrom_generic_command structure containing the packet to send.
  653. outputs:
  654. none
  655. cdrom_generic_command structure containing results.
  656. error return:
  657. - EIO
  658. command failed.
  659. - EPERM
  660. Operation not permitted, either because a
  661. write command was attempted on a drive which
  662. is opened read-only, or because the command
  663. requires CAP_SYS_RAWIO
  664. - EINVAL
  665. cgc.data_direction not set
  666. CDROM_NEXT_WRITABLE
  667. get next writable block
  668. usage::
  669. long next;
  670. ioctl(fd, CDROM_NEXT_WRITABLE, &next);
  671. inputs:
  672. none
  673. outputs:
  674. The next writable block.
  675. notes:
  676. If the device does not support this ioctl directly, the
  677. ioctl will return CDROM_LAST_WRITTEN + 7.
  678. CDROM_LAST_WRITTEN
  679. get last block written on disc
  680. usage::
  681. long last;
  682. ioctl(fd, CDROM_LAST_WRITTEN, &last);
  683. inputs:
  684. none
  685. outputs:
  686. The last block written on disc
  687. notes:
  688. If the device does not support this ioctl directly, the
  689. result is derived from the disc's table of contents. If the
  690. table of contents can't be read, this ioctl returns an
  691. error.