Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: ioctl: convert to ReST

Rename the iio documentation files to ReST, add an
index for them and adjust in order to produce a nice html
output via the Sphinx build system.

The cdrom.txt and hdio.txt have their own particular syntax.
In order to speedup the conversion, I used a small ancillary
perl script:

my $d;
$d .= $_ while(<>);
$d =~ s/(\nCDROM\S+)\s+(\w[^\n]*)/$1\n\t$2\n/g;
$d =~ s/(\nHDIO\S+)\s+(\w[^\n]*)/$1\n\t$2\n/g;
$d =~ s/(\n\s*usage:)[\s\n]*(\w[^\n]*)/$1:\n\n\t $2\n/g;
$d =~ s/(\n\s*)(E\w+[\s\n]*\w[^\n]*)/$1- $2/g;
$d =~ s/(\n\s*)(inputs|outputs|notes):\s*(\w[^\n]*)/$1$2:\n\t\t$3\n/g;
print $d;

It basically add blank lines on a few interesting places. The
script is not perfect: still several things require manual work,
but it saved quite some time doing some obvious stuff.

At its new index.rst, let's add a :orphan: while this is not linked to
the main index.rst file, in order to avoid build warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

+1841 -1280
+1
Documentation/ioctl/botching-up-ioctls.txt Documentation/ioctl/botching-up-ioctls.rst
··· 1 + ================================= 1 2 (How to avoid) Botching up ioctls 2 3 ================================= 3 4
+1233
Documentation/ioctl/cdrom.rst
··· 1 + ============================ 2 + Summary of CDROM ioctl calls 3 + ============================ 4 + 5 + - Edward A. Falk <efalk@google.com> 6 + 7 + November, 2004 8 + 9 + This document attempts to describe the ioctl(2) calls supported by 10 + the CDROM layer. These are by-and-large implemented (as of Linux 2.6) 11 + in drivers/cdrom/cdrom.c and drivers/block/scsi_ioctl.c 12 + 13 + ioctl values are listed in <linux/cdrom.h>. As of this writing, they 14 + are as follows: 15 + 16 + ====================== =============================================== 17 + CDROMPAUSE Pause Audio Operation 18 + CDROMRESUME Resume paused Audio Operation 19 + CDROMPLAYMSF Play Audio MSF (struct cdrom_msf) 20 + CDROMPLAYTRKIND Play Audio Track/index (struct cdrom_ti) 21 + CDROMREADTOCHDR Read TOC header (struct cdrom_tochdr) 22 + CDROMREADTOCENTRY Read TOC entry (struct cdrom_tocentry) 23 + CDROMSTOP Stop the cdrom drive 24 + CDROMSTART Start the cdrom drive 25 + CDROMEJECT Ejects the cdrom media 26 + CDROMVOLCTRL Control output volume (struct cdrom_volctrl) 27 + CDROMSUBCHNL Read subchannel data (struct cdrom_subchnl) 28 + CDROMREADMODE2 Read CDROM mode 2 data (2336 Bytes) 29 + (struct cdrom_read) 30 + CDROMREADMODE1 Read CDROM mode 1 data (2048 Bytes) 31 + (struct cdrom_read) 32 + CDROMREADAUDIO (struct cdrom_read_audio) 33 + CDROMEJECT_SW enable(1)/disable(0) auto-ejecting 34 + CDROMMULTISESSION Obtain the start-of-last-session 35 + address of multi session disks 36 + (struct cdrom_multisession) 37 + CDROM_GET_MCN Obtain the "Universal Product Code" 38 + if available (struct cdrom_mcn) 39 + CDROM_GET_UPC Deprecated, use CDROM_GET_MCN instead. 40 + CDROMRESET hard-reset the drive 41 + CDROMVOLREAD Get the drive's volume setting 42 + (struct cdrom_volctrl) 43 + CDROMREADRAW read data in raw mode (2352 Bytes) 44 + (struct cdrom_read) 45 + CDROMREADCOOKED read data in cooked mode 46 + CDROMSEEK seek msf address 47 + CDROMPLAYBLK scsi-cd only, (struct cdrom_blk) 48 + CDROMREADALL read all 2646 bytes 49 + CDROMGETSPINDOWN return 4-bit spindown value 50 + CDROMSETSPINDOWN set 4-bit spindown value 51 + CDROMCLOSETRAY pendant of CDROMEJECT 52 + CDROM_SET_OPTIONS Set behavior options 53 + CDROM_CLEAR_OPTIONS Clear behavior options 54 + CDROM_SELECT_SPEED Set the CD-ROM speed 55 + CDROM_SELECT_DISC Select disc (for juke-boxes) 56 + CDROM_MEDIA_CHANGED Check is media changed 57 + CDROM_DRIVE_STATUS Get tray position, etc. 58 + CDROM_DISC_STATUS Get disc type, etc. 59 + CDROM_CHANGER_NSLOTS Get number of slots 60 + CDROM_LOCKDOOR lock or unlock door 61 + CDROM_DEBUG Turn debug messages on/off 62 + CDROM_GET_CAPABILITY get capabilities 63 + CDROMAUDIOBUFSIZ set the audio buffer size 64 + DVD_READ_STRUCT Read structure 65 + DVD_WRITE_STRUCT Write structure 66 + DVD_AUTH Authentication 67 + CDROM_SEND_PACKET send a packet to the drive 68 + CDROM_NEXT_WRITABLE get next writable block 69 + CDROM_LAST_WRITTEN get last block written on disc 70 + ====================== =============================================== 71 + 72 + 73 + The information that follows was determined from reading kernel source 74 + code. It is likely that some corrections will be made over time. 75 + 76 + ------------------------------------------------------------------------------ 77 + 78 + General: 79 + 80 + Unless otherwise specified, all ioctl calls return 0 on success 81 + and -1 with errno set to an appropriate value on error. (Some 82 + ioctls return non-negative data values.) 83 + 84 + Unless otherwise specified, all ioctl calls return -1 and set 85 + errno to EFAULT on a failed attempt to copy data to or from user 86 + address space. 87 + 88 + Individual drivers may return error codes not listed here. 89 + 90 + Unless otherwise specified, all data structures and constants 91 + are defined in <linux/cdrom.h> 92 + 93 + ------------------------------------------------------------------------------ 94 + 95 + 96 + CDROMPAUSE 97 + Pause Audio Operation 98 + 99 + 100 + usage:: 101 + 102 + ioctl(fd, CDROMPAUSE, 0); 103 + 104 + 105 + inputs: 106 + none 107 + 108 + 109 + outputs: 110 + none 111 + 112 + 113 + error return: 114 + - ENOSYS cd drive not audio-capable. 115 + 116 + 117 + CDROMRESUME 118 + Resume paused Audio Operation 119 + 120 + 121 + usage:: 122 + 123 + ioctl(fd, CDROMRESUME, 0); 124 + 125 + 126 + inputs: 127 + none 128 + 129 + 130 + outputs: 131 + none 132 + 133 + 134 + error return: 135 + - ENOSYS cd drive not audio-capable. 136 + 137 + 138 + CDROMPLAYMSF 139 + Play Audio MSF 140 + 141 + (struct cdrom_msf) 142 + 143 + 144 + usage:: 145 + 146 + struct cdrom_msf msf; 147 + 148 + ioctl(fd, CDROMPLAYMSF, &msf); 149 + 150 + inputs: 151 + cdrom_msf structure, describing a segment of music to play 152 + 153 + 154 + outputs: 155 + none 156 + 157 + 158 + error return: 159 + - ENOSYS cd drive not audio-capable. 160 + 161 + notes: 162 + - MSF stands for minutes-seconds-frames 163 + - LBA stands for logical block address 164 + - Segment is described as start and end times, where each time 165 + is described as minutes:seconds:frames. 166 + A frame is 1/75 of a second. 167 + 168 + 169 + CDROMPLAYTRKIND 170 + Play Audio Track/index 171 + 172 + (struct cdrom_ti) 173 + 174 + 175 + usage:: 176 + 177 + struct cdrom_ti ti; 178 + 179 + ioctl(fd, CDROMPLAYTRKIND, &ti); 180 + 181 + inputs: 182 + cdrom_ti structure, describing a segment of music to play 183 + 184 + 185 + outputs: 186 + none 187 + 188 + 189 + error return: 190 + - ENOSYS cd drive not audio-capable. 191 + 192 + notes: 193 + - Segment is described as start and end times, where each time 194 + is described as a track and an index. 195 + 196 + 197 + 198 + CDROMREADTOCHDR 199 + Read TOC header 200 + 201 + (struct cdrom_tochdr) 202 + 203 + 204 + usage:: 205 + 206 + cdrom_tochdr header; 207 + 208 + ioctl(fd, CDROMREADTOCHDR, &header); 209 + 210 + inputs: 211 + cdrom_tochdr structure 212 + 213 + 214 + outputs: 215 + cdrom_tochdr structure 216 + 217 + 218 + error return: 219 + - ENOSYS cd drive not audio-capable. 220 + 221 + 222 + 223 + CDROMREADTOCENTRY 224 + Read TOC entry 225 + 226 + (struct cdrom_tocentry) 227 + 228 + 229 + usage:: 230 + 231 + struct cdrom_tocentry entry; 232 + 233 + ioctl(fd, CDROMREADTOCENTRY, &entry); 234 + 235 + inputs: 236 + cdrom_tocentry structure 237 + 238 + 239 + outputs: 240 + cdrom_tocentry structure 241 + 242 + 243 + error return: 244 + - ENOSYS cd drive not audio-capable. 245 + - EINVAL entry.cdte_format not CDROM_MSF or CDROM_LBA 246 + - EINVAL requested track out of bounds 247 + - EIO I/O error reading TOC 248 + 249 + notes: 250 + - TOC stands for Table Of Contents 251 + - MSF stands for minutes-seconds-frames 252 + - LBA stands for logical block address 253 + 254 + 255 + 256 + CDROMSTOP 257 + Stop the cdrom drive 258 + 259 + 260 + usage:: 261 + 262 + ioctl(fd, CDROMSTOP, 0); 263 + 264 + 265 + inputs: 266 + none 267 + 268 + 269 + outputs: 270 + none 271 + 272 + 273 + error return: 274 + - ENOSYS cd drive not audio-capable. 275 + 276 + notes: 277 + - Exact interpretation of this ioctl depends on the device, 278 + but most seem to spin the drive down. 279 + 280 + 281 + CDROMSTART 282 + Start the cdrom drive 283 + 284 + 285 + usage:: 286 + 287 + ioctl(fd, CDROMSTART, 0); 288 + 289 + 290 + inputs: 291 + none 292 + 293 + 294 + outputs: 295 + none 296 + 297 + 298 + error return: 299 + - ENOSYS cd drive not audio-capable. 300 + 301 + notes: 302 + - Exact interpretation of this ioctl depends on the device, 303 + but most seem to spin the drive up and/or close the tray. 304 + Other devices ignore the ioctl completely. 305 + 306 + 307 + CDROMEJECT 308 + - Ejects the cdrom media 309 + 310 + 311 + usage:: 312 + 313 + ioctl(fd, CDROMEJECT, 0); 314 + 315 + 316 + inputs: 317 + none 318 + 319 + 320 + outputs: 321 + none 322 + 323 + 324 + error returns: 325 + - ENOSYS cd drive not capable of ejecting 326 + - EBUSY other processes are accessing drive, or door is locked 327 + 328 + notes: 329 + - See CDROM_LOCKDOOR, below. 330 + 331 + 332 + 333 + 334 + CDROMCLOSETRAY 335 + pendant of CDROMEJECT 336 + 337 + 338 + usage:: 339 + 340 + ioctl(fd, CDROMCLOSETRAY, 0); 341 + 342 + 343 + inputs: 344 + none 345 + 346 + 347 + outputs: 348 + none 349 + 350 + 351 + error returns: 352 + - ENOSYS cd drive not capable of closing the tray 353 + - EBUSY other processes are accessing drive, or door is locked 354 + 355 + notes: 356 + - See CDROM_LOCKDOOR, below. 357 + 358 + 359 + 360 + 361 + CDROMVOLCTRL 362 + Control output volume (struct cdrom_volctrl) 363 + 364 + 365 + usage:: 366 + 367 + struct cdrom_volctrl volume; 368 + 369 + ioctl(fd, CDROMVOLCTRL, &volume); 370 + 371 + inputs: 372 + cdrom_volctrl structure containing volumes for up to 4 373 + channels. 374 + 375 + outputs: 376 + none 377 + 378 + 379 + error return: 380 + - ENOSYS cd drive not audio-capable. 381 + 382 + 383 + 384 + CDROMVOLREAD 385 + Get the drive's volume setting 386 + 387 + (struct cdrom_volctrl) 388 + 389 + 390 + usage:: 391 + 392 + struct cdrom_volctrl volume; 393 + 394 + ioctl(fd, CDROMVOLREAD, &volume); 395 + 396 + inputs: 397 + none 398 + 399 + 400 + outputs: 401 + The current volume settings. 402 + 403 + 404 + error return: 405 + - ENOSYS cd drive not audio-capable. 406 + 407 + 408 + 409 + CDROMSUBCHNL 410 + Read subchannel data 411 + 412 + (struct cdrom_subchnl) 413 + 414 + 415 + usage:: 416 + 417 + struct cdrom_subchnl q; 418 + 419 + ioctl(fd, CDROMSUBCHNL, &q); 420 + 421 + inputs: 422 + cdrom_subchnl structure 423 + 424 + 425 + outputs: 426 + cdrom_subchnl structure 427 + 428 + 429 + error return: 430 + - ENOSYS cd drive not audio-capable. 431 + - EINVAL format not CDROM_MSF or CDROM_LBA 432 + 433 + notes: 434 + - Format is converted to CDROM_MSF or CDROM_LBA 435 + as per user request on return 436 + 437 + 438 + 439 + CDROMREADRAW 440 + read data in raw mode (2352 Bytes) 441 + 442 + (struct cdrom_read) 443 + 444 + usage:: 445 + 446 + union { 447 + 448 + struct cdrom_msf msf; /* input */ 449 + char buffer[CD_FRAMESIZE_RAW]; /* return */ 450 + } arg; 451 + ioctl(fd, CDROMREADRAW, &arg); 452 + 453 + inputs: 454 + cdrom_msf structure indicating an address to read. 455 + 456 + Only the start values are significant. 457 + 458 + outputs: 459 + Data written to address provided by user. 460 + 461 + 462 + error return: 463 + - EINVAL address less than 0, or msf less than 0:2:0 464 + - ENOMEM out of memory 465 + 466 + notes: 467 + - As of 2.6.8.1, comments in <linux/cdrom.h> indicate that this 468 + ioctl accepts a cdrom_read structure, but actual source code 469 + reads a cdrom_msf structure and writes a buffer of data to 470 + the same address. 471 + 472 + - MSF values are converted to LBA values via this formula:: 473 + 474 + lba = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; 475 + 476 + 477 + 478 + 479 + CDROMREADMODE1 480 + Read CDROM mode 1 data (2048 Bytes) 481 + 482 + (struct cdrom_read) 483 + 484 + notes: 485 + Identical to CDROMREADRAW except that block size is 486 + CD_FRAMESIZE (2048) bytes 487 + 488 + 489 + 490 + CDROMREADMODE2 491 + Read CDROM mode 2 data (2336 Bytes) 492 + 493 + (struct cdrom_read) 494 + 495 + notes: 496 + Identical to CDROMREADRAW except that block size is 497 + CD_FRAMESIZE_RAW0 (2336) bytes 498 + 499 + 500 + 501 + CDROMREADAUDIO 502 + (struct cdrom_read_audio) 503 + 504 + usage:: 505 + 506 + struct cdrom_read_audio ra; 507 + 508 + ioctl(fd, CDROMREADAUDIO, &ra); 509 + 510 + inputs: 511 + cdrom_read_audio structure containing read start 512 + point and length 513 + 514 + outputs: 515 + audio data, returned to buffer indicated by ra 516 + 517 + 518 + error return: 519 + - EINVAL format not CDROM_MSF or CDROM_LBA 520 + - EINVAL nframes not in range [1 75] 521 + - ENXIO drive has no queue (probably means invalid fd) 522 + - ENOMEM out of memory 523 + 524 + 525 + CDROMEJECT_SW 526 + enable(1)/disable(0) auto-ejecting 527 + 528 + 529 + usage:: 530 + 531 + int val; 532 + 533 + ioctl(fd, CDROMEJECT_SW, val); 534 + 535 + inputs: 536 + Flag specifying auto-eject flag. 537 + 538 + 539 + outputs: 540 + none 541 + 542 + 543 + error return: 544 + - ENOSYS Drive is not capable of ejecting. 545 + - EBUSY Door is locked 546 + 547 + 548 + 549 + 550 + CDROMMULTISESSION 551 + Obtain the start-of-last-session address of multi session disks 552 + 553 + (struct cdrom_multisession) 554 + 555 + usage:: 556 + 557 + struct cdrom_multisession ms_info; 558 + 559 + ioctl(fd, CDROMMULTISESSION, &ms_info); 560 + 561 + inputs: 562 + cdrom_multisession structure containing desired 563 + 564 + format. 565 + 566 + outputs: 567 + cdrom_multisession structure is filled with last_session 568 + information. 569 + 570 + error return: 571 + - EINVAL format not CDROM_MSF or CDROM_LBA 572 + 573 + 574 + CDROM_GET_MCN 575 + Obtain the "Universal Product Code" 576 + if available 577 + 578 + (struct cdrom_mcn) 579 + 580 + 581 + usage:: 582 + 583 + struct cdrom_mcn mcn; 584 + 585 + ioctl(fd, CDROM_GET_MCN, &mcn); 586 + 587 + inputs: 588 + none 589 + 590 + 591 + outputs: 592 + Universal Product Code 593 + 594 + 595 + error return: 596 + - ENOSYS Drive is not capable of reading MCN data. 597 + 598 + notes: 599 + - Source code comments state:: 600 + 601 + The following function is implemented, although very few 602 + audio discs give Universal Product Code information, which 603 + should just be the Medium Catalog Number on the box. Note, 604 + that the way the code is written on the CD is /not/ uniform 605 + across all discs! 606 + 607 + 608 + 609 + 610 + CDROM_GET_UPC 611 + CDROM_GET_MCN (deprecated) 612 + 613 + 614 + Not implemented, as of 2.6.8.1 615 + 616 + 617 + 618 + CDROMRESET 619 + hard-reset the drive 620 + 621 + 622 + usage:: 623 + 624 + ioctl(fd, CDROMRESET, 0); 625 + 626 + 627 + inputs: 628 + none 629 + 630 + 631 + outputs: 632 + none 633 + 634 + 635 + error return: 636 + - EACCES Access denied: requires CAP_SYS_ADMIN 637 + - ENOSYS Drive is not capable of resetting. 638 + 639 + 640 + 641 + 642 + CDROMREADCOOKED 643 + read data in cooked mode 644 + 645 + 646 + usage:: 647 + 648 + u8 buffer[CD_FRAMESIZE] 649 + 650 + ioctl(fd, CDROMREADCOOKED, buffer); 651 + 652 + inputs: 653 + none 654 + 655 + 656 + outputs: 657 + 2048 bytes of data, "cooked" mode. 658 + 659 + 660 + notes: 661 + Not implemented on all drives. 662 + 663 + 664 + 665 + 666 + 667 + CDROMREADALL 668 + read all 2646 bytes 669 + 670 + 671 + Same as CDROMREADCOOKED, but reads 2646 bytes. 672 + 673 + 674 + 675 + CDROMSEEK 676 + seek msf address 677 + 678 + 679 + usage:: 680 + 681 + struct cdrom_msf msf; 682 + 683 + ioctl(fd, CDROMSEEK, &msf); 684 + 685 + inputs: 686 + MSF address to seek to. 687 + 688 + 689 + outputs: 690 + none 691 + 692 + 693 + 694 + 695 + CDROMPLAYBLK 696 + scsi-cd only 697 + 698 + (struct cdrom_blk) 699 + 700 + 701 + usage:: 702 + 703 + struct cdrom_blk blk; 704 + 705 + ioctl(fd, CDROMPLAYBLK, &blk); 706 + 707 + inputs: 708 + Region to play 709 + 710 + 711 + outputs: 712 + none 713 + 714 + 715 + 716 + 717 + CDROMGETSPINDOWN 718 + usage:: 719 + 720 + char spindown; 721 + 722 + ioctl(fd, CDROMGETSPINDOWN, &spindown); 723 + 724 + inputs: 725 + none 726 + 727 + 728 + outputs: 729 + The value of the current 4-bit spindown value. 730 + 731 + 732 + 733 + 734 + 735 + CDROMSETSPINDOWN 736 + usage:: 737 + 738 + char spindown 739 + 740 + ioctl(fd, CDROMSETSPINDOWN, &spindown); 741 + 742 + inputs: 743 + 4-bit value used to control spindown (TODO: more detail here) 744 + 745 + 746 + outputs: 747 + none 748 + 749 + 750 + 751 + 752 + 753 + 754 + CDROM_SET_OPTIONS 755 + Set behavior options 756 + 757 + 758 + usage:: 759 + 760 + int options; 761 + 762 + ioctl(fd, CDROM_SET_OPTIONS, options); 763 + 764 + inputs: 765 + New values for drive options. The logical 'or' of: 766 + 767 + ============== ================================== 768 + CDO_AUTO_CLOSE close tray on first open(2) 769 + CDO_AUTO_EJECT open tray on last release 770 + CDO_USE_FFLAGS use O_NONBLOCK information on open 771 + CDO_LOCK lock tray on open files 772 + CDO_CHECK_TYPE check type on open for data 773 + ============== ================================== 774 + 775 + outputs: 776 + Returns the resulting options settings in the 777 + ioctl return value. Returns -1 on error. 778 + 779 + error return: 780 + - ENOSYS selected option(s) not supported by drive. 781 + 782 + 783 + 784 + 785 + CDROM_CLEAR_OPTIONS 786 + Clear behavior options 787 + 788 + 789 + Same as CDROM_SET_OPTIONS, except that selected options are 790 + turned off. 791 + 792 + 793 + 794 + CDROM_SELECT_SPEED 795 + Set the CD-ROM speed 796 + 797 + 798 + usage:: 799 + 800 + int speed; 801 + 802 + ioctl(fd, CDROM_SELECT_SPEED, speed); 803 + 804 + inputs: 805 + New drive speed. 806 + 807 + 808 + outputs: 809 + none 810 + 811 + 812 + error return: 813 + - ENOSYS speed selection not supported by drive. 814 + 815 + 816 + 817 + CDROM_SELECT_DISC 818 + Select disc (for juke-boxes) 819 + 820 + 821 + usage:: 822 + 823 + int disk; 824 + 825 + ioctl(fd, CDROM_SELECT_DISC, disk); 826 + 827 + inputs: 828 + Disk to load into drive. 829 + 830 + 831 + outputs: 832 + none 833 + 834 + 835 + error return: 836 + - EINVAL Disk number beyond capacity of drive 837 + 838 + 839 + 840 + CDROM_MEDIA_CHANGED 841 + Check is media changed 842 + 843 + 844 + usage:: 845 + 846 + int slot; 847 + 848 + ioctl(fd, CDROM_MEDIA_CHANGED, slot); 849 + 850 + inputs: 851 + Slot number to be tested, always zero except for jukeboxes. 852 + 853 + May also be special values CDSL_NONE or CDSL_CURRENT 854 + 855 + outputs: 856 + Ioctl return value is 0 or 1 depending on whether the media 857 + 858 + has been changed, or -1 on error. 859 + 860 + error returns: 861 + - ENOSYS Drive can't detect media change 862 + - EINVAL Slot number beyond capacity of drive 863 + - ENOMEM Out of memory 864 + 865 + 866 + 867 + CDROM_DRIVE_STATUS 868 + Get tray position, etc. 869 + 870 + 871 + usage:: 872 + 873 + int slot; 874 + 875 + ioctl(fd, CDROM_DRIVE_STATUS, slot); 876 + 877 + inputs: 878 + Slot number to be tested, always zero except for jukeboxes. 879 + 880 + May also be special values CDSL_NONE or CDSL_CURRENT 881 + 882 + outputs: 883 + Ioctl return value will be one of the following values 884 + 885 + from <linux/cdrom.h>: 886 + 887 + =================== ========================== 888 + CDS_NO_INFO Information not available. 889 + CDS_NO_DISC 890 + CDS_TRAY_OPEN 891 + CDS_DRIVE_NOT_READY 892 + CDS_DISC_OK 893 + -1 error 894 + =================== ========================== 895 + 896 + error returns: 897 + - ENOSYS Drive can't detect drive status 898 + - EINVAL Slot number beyond capacity of drive 899 + - ENOMEM Out of memory 900 + 901 + 902 + 903 + 904 + CDROM_DISC_STATUS 905 + Get disc type, etc. 906 + 907 + 908 + usage:: 909 + 910 + ioctl(fd, CDROM_DISC_STATUS, 0); 911 + 912 + 913 + inputs: 914 + none 915 + 916 + 917 + outputs: 918 + Ioctl return value will be one of the following values 919 + 920 + from <linux/cdrom.h>: 921 + 922 + - CDS_NO_INFO 923 + - CDS_AUDIO 924 + - CDS_MIXED 925 + - CDS_XA_2_2 926 + - CDS_XA_2_1 927 + - CDS_DATA_1 928 + 929 + error returns: 930 + none at present 931 + 932 + notes: 933 + - Source code comments state:: 934 + 935 + 936 + Ok, this is where problems start. The current interface for 937 + the CDROM_DISC_STATUS ioctl is flawed. It makes the false 938 + assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. 939 + Unfortunately, while this is often the case, it is also 940 + very common for CDs to have some tracks with data, and some 941 + tracks with audio. Just because I feel like it, I declare 942 + the following to be the best way to cope. If the CD has 943 + ANY data tracks on it, it will be returned as a data CD. 944 + If it has any XA tracks, I will return it as that. Now I 945 + could simplify this interface by combining these returns with 946 + the above, but this more clearly demonstrates the problem 947 + with the current interface. Too bad this wasn't designed 948 + to use bitmasks... -Erik 949 + 950 + Well, now we have the option CDS_MIXED: a mixed-type CD. 951 + User level programmers might feel the ioctl is not very 952 + useful. 953 + ---david 954 + 955 + 956 + 957 + 958 + CDROM_CHANGER_NSLOTS 959 + Get number of slots 960 + 961 + 962 + usage:: 963 + 964 + ioctl(fd, CDROM_CHANGER_NSLOTS, 0); 965 + 966 + 967 + inputs: 968 + none 969 + 970 + 971 + outputs: 972 + The ioctl return value will be the number of slots in a 973 + CD changer. Typically 1 for non-multi-disk devices. 974 + 975 + error returns: 976 + none 977 + 978 + 979 + 980 + CDROM_LOCKDOOR 981 + lock or unlock door 982 + 983 + 984 + usage:: 985 + 986 + int lock; 987 + 988 + ioctl(fd, CDROM_LOCKDOOR, lock); 989 + 990 + inputs: 991 + Door lock flag, 1=lock, 0=unlock 992 + 993 + 994 + outputs: 995 + none 996 + 997 + 998 + error returns: 999 + - EDRIVE_CANT_DO_THIS 1000 + 1001 + Door lock function not supported. 1002 + - EBUSY 1003 + 1004 + Attempt to unlock when multiple users 1005 + have the drive open and not CAP_SYS_ADMIN 1006 + 1007 + notes: 1008 + As of 2.6.8.1, the lock flag is a global lock, meaning that 1009 + all CD drives will be locked or unlocked together. This is 1010 + probably a bug. 1011 + 1012 + The EDRIVE_CANT_DO_THIS value is defined in <linux/cdrom.h> 1013 + and is currently (2.6.8.1) the same as EOPNOTSUPP 1014 + 1015 + 1016 + 1017 + CDROM_DEBUG 1018 + Turn debug messages on/off 1019 + 1020 + 1021 + usage:: 1022 + 1023 + int debug; 1024 + 1025 + ioctl(fd, CDROM_DEBUG, debug); 1026 + 1027 + inputs: 1028 + Cdrom debug flag, 0=disable, 1=enable 1029 + 1030 + 1031 + outputs: 1032 + The ioctl return value will be the new debug flag. 1033 + 1034 + 1035 + error return: 1036 + - EACCES Access denied: requires CAP_SYS_ADMIN 1037 + 1038 + 1039 + 1040 + CDROM_GET_CAPABILITY 1041 + get capabilities 1042 + 1043 + 1044 + usage:: 1045 + 1046 + ioctl(fd, CDROM_GET_CAPABILITY, 0); 1047 + 1048 + 1049 + inputs: 1050 + none 1051 + 1052 + 1053 + outputs: 1054 + The ioctl return value is the current device capability 1055 + flags. See CDC_CLOSE_TRAY, CDC_OPEN_TRAY, etc. 1056 + 1057 + 1058 + 1059 + CDROMAUDIOBUFSIZ 1060 + set the audio buffer size 1061 + 1062 + 1063 + usage:: 1064 + 1065 + int arg; 1066 + 1067 + ioctl(fd, CDROMAUDIOBUFSIZ, val); 1068 + 1069 + inputs: 1070 + New audio buffer size 1071 + 1072 + 1073 + outputs: 1074 + The ioctl return value is the new audio buffer size, or -1 1075 + on error. 1076 + 1077 + error return: 1078 + - ENOSYS Not supported by this driver. 1079 + 1080 + notes: 1081 + Not supported by all drivers. 1082 + 1083 + 1084 + 1085 + 1086 + DVD_READ_STRUCT Read structure 1087 + 1088 + usage:: 1089 + 1090 + dvd_struct s; 1091 + 1092 + ioctl(fd, DVD_READ_STRUCT, &s); 1093 + 1094 + inputs: 1095 + dvd_struct structure, containing: 1096 + 1097 + =================== ========================================== 1098 + type specifies the information desired, one of 1099 + DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT, 1100 + DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA, 1101 + DVD_STRUCT_MANUFACT 1102 + physical.layer_num desired layer, indexed from 0 1103 + copyright.layer_num desired layer, indexed from 0 1104 + disckey.agid 1105 + =================== ========================================== 1106 + 1107 + outputs: 1108 + dvd_struct structure, containing: 1109 + 1110 + =================== ================================ 1111 + physical for type == DVD_STRUCT_PHYSICAL 1112 + copyright for type == DVD_STRUCT_COPYRIGHT 1113 + disckey.value for type == DVD_STRUCT_DISCKEY 1114 + bca.{len,value} for type == DVD_STRUCT_BCA 1115 + manufact.{len,valu} for type == DVD_STRUCT_MANUFACT 1116 + =================== ================================ 1117 + 1118 + error returns: 1119 + - EINVAL physical.layer_num exceeds number of layers 1120 + - EIO Received invalid response from drive 1121 + 1122 + 1123 + 1124 + DVD_WRITE_STRUCT Write structure 1125 + 1126 + Not implemented, as of 2.6.8.1 1127 + 1128 + 1129 + 1130 + DVD_AUTH Authentication 1131 + 1132 + usage:: 1133 + 1134 + dvd_authinfo ai; 1135 + 1136 + ioctl(fd, DVD_AUTH, &ai); 1137 + 1138 + inputs: 1139 + dvd_authinfo structure. See <linux/cdrom.h> 1140 + 1141 + 1142 + outputs: 1143 + dvd_authinfo structure. 1144 + 1145 + 1146 + error return: 1147 + - ENOTTY ai.type not recognized. 1148 + 1149 + 1150 + 1151 + CDROM_SEND_PACKET 1152 + send a packet to the drive 1153 + 1154 + 1155 + usage:: 1156 + 1157 + struct cdrom_generic_command cgc; 1158 + 1159 + ioctl(fd, CDROM_SEND_PACKET, &cgc); 1160 + 1161 + inputs: 1162 + cdrom_generic_command structure containing the packet to send. 1163 + 1164 + 1165 + outputs: 1166 + none 1167 + 1168 + cdrom_generic_command structure containing results. 1169 + 1170 + error return: 1171 + - EIO 1172 + 1173 + command failed. 1174 + - EPERM 1175 + 1176 + Operation not permitted, either because a 1177 + write command was attempted on a drive which 1178 + is opened read-only, or because the command 1179 + requires CAP_SYS_RAWIO 1180 + - EINVAL 1181 + 1182 + cgc.data_direction not set 1183 + 1184 + 1185 + 1186 + CDROM_NEXT_WRITABLE 1187 + get next writable block 1188 + 1189 + 1190 + usage:: 1191 + 1192 + long next; 1193 + 1194 + ioctl(fd, CDROM_NEXT_WRITABLE, &next); 1195 + 1196 + inputs: 1197 + none 1198 + 1199 + 1200 + outputs: 1201 + The next writable block. 1202 + 1203 + 1204 + notes: 1205 + If the device does not support this ioctl directly, the 1206 + 1207 + ioctl will return CDROM_LAST_WRITTEN + 7. 1208 + 1209 + 1210 + 1211 + CDROM_LAST_WRITTEN 1212 + get last block written on disc 1213 + 1214 + 1215 + usage:: 1216 + 1217 + long last; 1218 + 1219 + ioctl(fd, CDROM_LAST_WRITTEN, &last); 1220 + 1221 + inputs: 1222 + none 1223 + 1224 + 1225 + outputs: 1226 + The last block written on disc 1227 + 1228 + 1229 + notes: 1230 + If the device does not support this ioctl directly, the 1231 + result is derived from the disc's table of contents. If the 1232 + table of contents can't be read, this ioctl returns an 1233 + error.
-967
Documentation/ioctl/cdrom.txt
··· 1 - Summary of CDROM ioctl calls. 2 - ============================ 3 - 4 - Edward A. Falk <efalk@google.com> 5 - 6 - November, 2004 7 - 8 - This document attempts to describe the ioctl(2) calls supported by 9 - the CDROM layer. These are by-and-large implemented (as of Linux 2.6) 10 - in drivers/cdrom/cdrom.c and drivers/block/scsi_ioctl.c 11 - 12 - ioctl values are listed in <linux/cdrom.h>. As of this writing, they 13 - are as follows: 14 - 15 - CDROMPAUSE Pause Audio Operation 16 - CDROMRESUME Resume paused Audio Operation 17 - CDROMPLAYMSF Play Audio MSF (struct cdrom_msf) 18 - CDROMPLAYTRKIND Play Audio Track/index (struct cdrom_ti) 19 - CDROMREADTOCHDR Read TOC header (struct cdrom_tochdr) 20 - CDROMREADTOCENTRY Read TOC entry (struct cdrom_tocentry) 21 - CDROMSTOP Stop the cdrom drive 22 - CDROMSTART Start the cdrom drive 23 - CDROMEJECT Ejects the cdrom media 24 - CDROMVOLCTRL Control output volume (struct cdrom_volctrl) 25 - CDROMSUBCHNL Read subchannel data (struct cdrom_subchnl) 26 - CDROMREADMODE2 Read CDROM mode 2 data (2336 Bytes) 27 - (struct cdrom_read) 28 - CDROMREADMODE1 Read CDROM mode 1 data (2048 Bytes) 29 - (struct cdrom_read) 30 - CDROMREADAUDIO (struct cdrom_read_audio) 31 - CDROMEJECT_SW enable(1)/disable(0) auto-ejecting 32 - CDROMMULTISESSION Obtain the start-of-last-session 33 - address of multi session disks 34 - (struct cdrom_multisession) 35 - CDROM_GET_MCN Obtain the "Universal Product Code" 36 - if available (struct cdrom_mcn) 37 - CDROM_GET_UPC Deprecated, use CDROM_GET_MCN instead. 38 - CDROMRESET hard-reset the drive 39 - CDROMVOLREAD Get the drive's volume setting 40 - (struct cdrom_volctrl) 41 - CDROMREADRAW read data in raw mode (2352 Bytes) 42 - (struct cdrom_read) 43 - CDROMREADCOOKED read data in cooked mode 44 - CDROMSEEK seek msf address 45 - CDROMPLAYBLK scsi-cd only, (struct cdrom_blk) 46 - CDROMREADALL read all 2646 bytes 47 - CDROMGETSPINDOWN return 4-bit spindown value 48 - CDROMSETSPINDOWN set 4-bit spindown value 49 - CDROMCLOSETRAY pendant of CDROMEJECT 50 - CDROM_SET_OPTIONS Set behavior options 51 - CDROM_CLEAR_OPTIONS Clear behavior options 52 - CDROM_SELECT_SPEED Set the CD-ROM speed 53 - CDROM_SELECT_DISC Select disc (for juke-boxes) 54 - CDROM_MEDIA_CHANGED Check is media changed 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 - 70 - The information that follows was determined from reading kernel source 71 - code. It is likely that some corrections will be made over time. 72 - 73 - 74 - 75 - 76 - 77 - 78 - 79 - General: 80 - 81 - Unless otherwise specified, all ioctl calls return 0 on success 82 - and -1 with errno set to an appropriate value on error. (Some 83 - ioctls return non-negative data values.) 84 - 85 - Unless otherwise specified, all ioctl calls return -1 and set 86 - errno to EFAULT on a failed attempt to copy data to or from user 87 - address space. 88 - 89 - Individual drivers may return error codes not listed here. 90 - 91 - Unless otherwise specified, all data structures and constants 92 - are defined in <linux/cdrom.h> 93 - 94 - 95 - 96 - 97 - CDROMPAUSE Pause Audio Operation 98 - 99 - usage: 100 - 101 - ioctl(fd, CDROMPAUSE, 0); 102 - 103 - inputs: none 104 - 105 - outputs: none 106 - 107 - error return: 108 - ENOSYS cd drive not audio-capable. 109 - 110 - 111 - CDROMRESUME Resume paused Audio Operation 112 - 113 - usage: 114 - 115 - ioctl(fd, CDROMRESUME, 0); 116 - 117 - inputs: none 118 - 119 - outputs: none 120 - 121 - error return: 122 - ENOSYS cd drive not audio-capable. 123 - 124 - 125 - CDROMPLAYMSF Play Audio MSF (struct cdrom_msf) 126 - 127 - usage: 128 - 129 - struct cdrom_msf msf; 130 - ioctl(fd, CDROMPLAYMSF, &msf); 131 - 132 - inputs: 133 - cdrom_msf structure, describing a segment of music to play 134 - 135 - outputs: none 136 - 137 - error return: 138 - ENOSYS cd drive not audio-capable. 139 - 140 - notes: 141 - MSF stands for minutes-seconds-frames 142 - LBA stands for logical block address 143 - 144 - Segment is described as start and end times, where each time 145 - is described as minutes:seconds:frames. A frame is 1/75 of 146 - a second. 147 - 148 - 149 - CDROMPLAYTRKIND Play Audio Track/index (struct cdrom_ti) 150 - 151 - usage: 152 - 153 - struct cdrom_ti ti; 154 - ioctl(fd, CDROMPLAYTRKIND, &ti); 155 - 156 - inputs: 157 - cdrom_ti structure, describing a segment of music to play 158 - 159 - outputs: none 160 - 161 - error return: 162 - ENOSYS cd drive not audio-capable. 163 - 164 - notes: 165 - Segment is described as start and end times, where each time 166 - is described as a track and an index. 167 - 168 - 169 - 170 - CDROMREADTOCHDR Read TOC header (struct cdrom_tochdr) 171 - 172 - usage: 173 - 174 - cdrom_tochdr header; 175 - ioctl(fd, CDROMREADTOCHDR, &header); 176 - 177 - inputs: 178 - cdrom_tochdr structure 179 - 180 - outputs: 181 - cdrom_tochdr structure 182 - 183 - error return: 184 - ENOSYS cd drive not audio-capable. 185 - 186 - 187 - 188 - CDROMREADTOCENTRY Read TOC entry (struct cdrom_tocentry) 189 - 190 - usage: 191 - 192 - struct cdrom_tocentry entry; 193 - ioctl(fd, CDROMREADTOCENTRY, &entry); 194 - 195 - inputs: 196 - cdrom_tocentry structure 197 - 198 - outputs: 199 - cdrom_tocentry structure 200 - 201 - error return: 202 - ENOSYS cd drive not audio-capable. 203 - EINVAL entry.cdte_format not CDROM_MSF or CDROM_LBA 204 - EINVAL requested track out of bounds 205 - EIO I/O error reading TOC 206 - 207 - notes: 208 - TOC stands for Table Of Contents 209 - MSF stands for minutes-seconds-frames 210 - LBA stands for logical block address 211 - 212 - 213 - 214 - CDROMSTOP Stop the cdrom drive 215 - 216 - usage: 217 - 218 - ioctl(fd, CDROMSTOP, 0); 219 - 220 - inputs: none 221 - 222 - outputs: none 223 - 224 - error return: 225 - ENOSYS cd drive not audio-capable. 226 - 227 - notes: 228 - Exact interpretation of this ioctl depends on the device, 229 - but most seem to spin the drive down. 230 - 231 - 232 - CDROMSTART Start the cdrom drive 233 - 234 - usage: 235 - 236 - ioctl(fd, CDROMSTART, 0); 237 - 238 - inputs: none 239 - 240 - outputs: none 241 - 242 - error return: 243 - ENOSYS cd drive not audio-capable. 244 - 245 - notes: 246 - Exact interpretation of this ioctl depends on the device, 247 - but most seem to spin the drive up and/or close the tray. 248 - Other devices ignore the ioctl completely. 249 - 250 - 251 - CDROMEJECT Ejects the cdrom media 252 - 253 - usage: 254 - 255 - ioctl(fd, CDROMEJECT, 0); 256 - 257 - inputs: none 258 - 259 - outputs: none 260 - 261 - error returns: 262 - ENOSYS cd drive not capable of ejecting 263 - EBUSY other processes are accessing drive, or door is locked 264 - 265 - notes: 266 - See CDROM_LOCKDOOR, below. 267 - 268 - 269 - 270 - CDROMCLOSETRAY pendant of CDROMEJECT 271 - 272 - usage: 273 - 274 - ioctl(fd, CDROMCLOSETRAY, 0); 275 - 276 - inputs: none 277 - 278 - outputs: none 279 - 280 - error returns: 281 - ENOSYS cd drive not capable of closing the tray 282 - EBUSY other processes are accessing drive, or door is locked 283 - 284 - notes: 285 - See CDROM_LOCKDOOR, below. 286 - 287 - 288 - 289 - CDROMVOLCTRL Control output volume (struct cdrom_volctrl) 290 - 291 - usage: 292 - 293 - struct cdrom_volctrl volume; 294 - ioctl(fd, CDROMVOLCTRL, &volume); 295 - 296 - inputs: 297 - cdrom_volctrl structure containing volumes for up to 4 298 - channels. 299 - 300 - outputs: none 301 - 302 - error return: 303 - ENOSYS cd drive not audio-capable. 304 - 305 - 306 - 307 - CDROMVOLREAD Get the drive's volume setting 308 - (struct cdrom_volctrl) 309 - 310 - usage: 311 - 312 - struct cdrom_volctrl volume; 313 - ioctl(fd, CDROMVOLREAD, &volume); 314 - 315 - inputs: none 316 - 317 - outputs: 318 - The current volume settings. 319 - 320 - error return: 321 - ENOSYS cd drive not audio-capable. 322 - 323 - 324 - 325 - CDROMSUBCHNL Read subchannel data (struct cdrom_subchnl) 326 - 327 - usage: 328 - 329 - struct cdrom_subchnl q; 330 - ioctl(fd, CDROMSUBCHNL, &q); 331 - 332 - inputs: 333 - cdrom_subchnl structure 334 - 335 - outputs: 336 - cdrom_subchnl structure 337 - 338 - error return: 339 - ENOSYS cd drive not audio-capable. 340 - EINVAL format not CDROM_MSF or CDROM_LBA 341 - 342 - notes: 343 - Format is converted to CDROM_MSF or CDROM_LBA 344 - as per user request on return 345 - 346 - 347 - 348 - CDROMREADRAW read data in raw mode (2352 Bytes) 349 - (struct cdrom_read) 350 - 351 - usage: 352 - 353 - union { 354 - struct cdrom_msf msf; /* input */ 355 - char buffer[CD_FRAMESIZE_RAW]; /* return */ 356 - } arg; 357 - ioctl(fd, CDROMREADRAW, &arg); 358 - 359 - inputs: 360 - cdrom_msf structure indicating an address to read. 361 - Only the start values are significant. 362 - 363 - outputs: 364 - Data written to address provided by user. 365 - 366 - error return: 367 - EINVAL address less than 0, or msf less than 0:2:0 368 - ENOMEM out of memory 369 - 370 - notes: 371 - As of 2.6.8.1, comments in <linux/cdrom.h> indicate that this 372 - ioctl accepts a cdrom_read structure, but actual source code 373 - reads a cdrom_msf structure and writes a buffer of data to 374 - the same address. 375 - 376 - MSF values are converted to LBA values via this formula: 377 - 378 - lba = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; 379 - 380 - 381 - 382 - 383 - CDROMREADMODE1 Read CDROM mode 1 data (2048 Bytes) 384 - (struct cdrom_read) 385 - 386 - notes: 387 - Identical to CDROMREADRAW except that block size is 388 - CD_FRAMESIZE (2048) bytes 389 - 390 - 391 - 392 - CDROMREADMODE2 Read CDROM mode 2 data (2336 Bytes) 393 - (struct cdrom_read) 394 - 395 - notes: 396 - Identical to CDROMREADRAW except that block size is 397 - CD_FRAMESIZE_RAW0 (2336) bytes 398 - 399 - 400 - 401 - CDROMREADAUDIO (struct cdrom_read_audio) 402 - 403 - usage: 404 - 405 - struct cdrom_read_audio ra; 406 - ioctl(fd, CDROMREADAUDIO, &ra); 407 - 408 - inputs: 409 - cdrom_read_audio structure containing read start 410 - point and length 411 - 412 - outputs: 413 - audio data, returned to buffer indicated by ra 414 - 415 - error return: 416 - EINVAL format not CDROM_MSF or CDROM_LBA 417 - EINVAL nframes not in range [1 75] 418 - ENXIO drive has no queue (probably means invalid fd) 419 - ENOMEM out of memory 420 - 421 - 422 - CDROMEJECT_SW enable(1)/disable(0) auto-ejecting 423 - 424 - usage: 425 - 426 - int val; 427 - ioctl(fd, CDROMEJECT_SW, val); 428 - 429 - inputs: 430 - Flag specifying auto-eject flag. 431 - 432 - outputs: none 433 - 434 - error return: 435 - ENOSYS Drive is not capable of ejecting. 436 - EBUSY Door is locked 437 - 438 - 439 - 440 - 441 - CDROMMULTISESSION Obtain the start-of-last-session 442 - address of multi session disks 443 - (struct cdrom_multisession) 444 - usage: 445 - 446 - struct cdrom_multisession ms_info; 447 - ioctl(fd, CDROMMULTISESSION, &ms_info); 448 - 449 - inputs: 450 - cdrom_multisession structure containing desired 451 - format. 452 - 453 - outputs: 454 - cdrom_multisession structure is filled with last_session 455 - information. 456 - 457 - error return: 458 - EINVAL format not CDROM_MSF or CDROM_LBA 459 - 460 - 461 - CDROM_GET_MCN Obtain the "Universal Product Code" 462 - if available (struct cdrom_mcn) 463 - 464 - usage: 465 - 466 - struct cdrom_mcn mcn; 467 - ioctl(fd, CDROM_GET_MCN, &mcn); 468 - 469 - inputs: none 470 - 471 - outputs: 472 - Universal Product Code 473 - 474 - error return: 475 - ENOSYS Drive is not capable of reading MCN data. 476 - 477 - notes: 478 - Source code comments state: 479 - 480 - The following function is implemented, although very few 481 - audio discs give Universal Product Code information, which 482 - should just be the Medium Catalog Number on the box. Note, 483 - that the way the code is written on the CD is /not/ uniform 484 - across all discs! 485 - 486 - 487 - 488 - 489 - CDROM_GET_UPC CDROM_GET_MCN (deprecated) 490 - 491 - Not implemented, as of 2.6.8.1 492 - 493 - 494 - 495 - CDROMRESET hard-reset the drive 496 - 497 - usage: 498 - 499 - ioctl(fd, CDROMRESET, 0); 500 - 501 - inputs: none 502 - 503 - outputs: none 504 - 505 - error return: 506 - EACCES Access denied: requires CAP_SYS_ADMIN 507 - ENOSYS Drive is not capable of resetting. 508 - 509 - 510 - 511 - 512 - CDROMREADCOOKED read data in cooked mode 513 - 514 - usage: 515 - 516 - u8 buffer[CD_FRAMESIZE] 517 - ioctl(fd, CDROMREADCOOKED, buffer); 518 - 519 - inputs: none 520 - 521 - outputs: 522 - 2048 bytes of data, "cooked" mode. 523 - 524 - notes: 525 - Not implemented on all drives. 526 - 527 - 528 - 529 - 530 - CDROMREADALL read all 2646 bytes 531 - 532 - Same as CDROMREADCOOKED, but reads 2646 bytes. 533 - 534 - 535 - 536 - CDROMSEEK seek msf address 537 - 538 - usage: 539 - 540 - struct cdrom_msf msf; 541 - ioctl(fd, CDROMSEEK, &msf); 542 - 543 - inputs: 544 - MSF address to seek to. 545 - 546 - outputs: none 547 - 548 - 549 - 550 - CDROMPLAYBLK scsi-cd only, (struct cdrom_blk) 551 - 552 - usage: 553 - 554 - struct cdrom_blk blk; 555 - ioctl(fd, CDROMPLAYBLK, &blk); 556 - 557 - inputs: 558 - Region to play 559 - 560 - outputs: none 561 - 562 - 563 - 564 - CDROMGETSPINDOWN 565 - 566 - usage: 567 - 568 - char spindown; 569 - ioctl(fd, CDROMGETSPINDOWN, &spindown); 570 - 571 - inputs: none 572 - 573 - outputs: 574 - The value of the current 4-bit spindown value. 575 - 576 - 577 - 578 - 579 - CDROMSETSPINDOWN 580 - 581 - usage: 582 - 583 - char spindown 584 - ioctl(fd, CDROMSETSPINDOWN, &spindown); 585 - 586 - inputs: 587 - 4-bit value used to control spindown (TODO: more detail here) 588 - 589 - outputs: none 590 - 591 - 592 - 593 - 594 - 595 - CDROM_SET_OPTIONS Set behavior options 596 - 597 - usage: 598 - 599 - int options; 600 - ioctl(fd, CDROM_SET_OPTIONS, options); 601 - 602 - inputs: 603 - New values for drive options. The logical 'or' of: 604 - CDO_AUTO_CLOSE close tray on first open(2) 605 - CDO_AUTO_EJECT open tray on last release 606 - CDO_USE_FFLAGS use O_NONBLOCK information on open 607 - CDO_LOCK lock tray on open files 608 - CDO_CHECK_TYPE check type on open for data 609 - 610 - outputs: 611 - Returns the resulting options settings in the 612 - ioctl return value. Returns -1 on error. 613 - 614 - error return: 615 - ENOSYS selected option(s) not supported by drive. 616 - 617 - 618 - 619 - 620 - CDROM_CLEAR_OPTIONS Clear behavior options 621 - 622 - Same as CDROM_SET_OPTIONS, except that selected options are 623 - turned off. 624 - 625 - 626 - 627 - CDROM_SELECT_SPEED Set the CD-ROM speed 628 - 629 - usage: 630 - 631 - int speed; 632 - ioctl(fd, CDROM_SELECT_SPEED, speed); 633 - 634 - inputs: 635 - New drive speed. 636 - 637 - outputs: none 638 - 639 - error return: 640 - ENOSYS speed selection not supported by drive. 641 - 642 - 643 - 644 - CDROM_SELECT_DISC Select disc (for juke-boxes) 645 - 646 - usage: 647 - 648 - int disk; 649 - ioctl(fd, CDROM_SELECT_DISC, disk); 650 - 651 - inputs: 652 - Disk to load into drive. 653 - 654 - outputs: none 655 - 656 - error return: 657 - EINVAL Disk number beyond capacity of drive 658 - 659 - 660 - 661 - CDROM_MEDIA_CHANGED Check is media changed 662 - 663 - usage: 664 - 665 - int slot; 666 - ioctl(fd, CDROM_MEDIA_CHANGED, slot); 667 - 668 - inputs: 669 - Slot number to be tested, always zero except for jukeboxes. 670 - May also be special values CDSL_NONE or CDSL_CURRENT 671 - 672 - outputs: 673 - Ioctl return value is 0 or 1 depending on whether the media 674 - has been changed, or -1 on error. 675 - 676 - error returns: 677 - ENOSYS Drive can't detect media change 678 - EINVAL Slot number beyond capacity of drive 679 - ENOMEM Out of memory 680 - 681 - 682 - 683 - CDROM_DRIVE_STATUS Get tray position, etc. 684 - 685 - usage: 686 - 687 - int slot; 688 - ioctl(fd, CDROM_DRIVE_STATUS, slot); 689 - 690 - inputs: 691 - Slot number to be tested, always zero except for jukeboxes. 692 - May also be special values CDSL_NONE or CDSL_CURRENT 693 - 694 - outputs: 695 - Ioctl return value will be one of the following values 696 - from <linux/cdrom.h>: 697 - 698 - CDS_NO_INFO Information not available. 699 - CDS_NO_DISC 700 - CDS_TRAY_OPEN 701 - CDS_DRIVE_NOT_READY 702 - CDS_DISC_OK 703 - -1 error 704 - 705 - error returns: 706 - ENOSYS Drive can't detect drive status 707 - EINVAL Slot number beyond capacity of drive 708 - ENOMEM Out of memory 709 - 710 - 711 - 712 - 713 - CDROM_DISC_STATUS Get disc type, etc. 714 - 715 - usage: 716 - 717 - ioctl(fd, CDROM_DISC_STATUS, 0); 718 - 719 - inputs: none 720 - 721 - outputs: 722 - Ioctl return value will be one of the following values 723 - from <linux/cdrom.h>: 724 - CDS_NO_INFO 725 - CDS_AUDIO 726 - CDS_MIXED 727 - CDS_XA_2_2 728 - CDS_XA_2_1 729 - CDS_DATA_1 730 - 731 - error returns: none at present 732 - 733 - notes: 734 - Source code comments state: 735 - 736 - Ok, this is where problems start. The current interface for 737 - the CDROM_DISC_STATUS ioctl is flawed. It makes the false 738 - assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. 739 - Unfortunately, while this is often the case, it is also 740 - very common for CDs to have some tracks with data, and some 741 - tracks with audio. Just because I feel like it, I declare 742 - the following to be the best way to cope. If the CD has 743 - ANY data tracks on it, it will be returned as a data CD. 744 - If it has any XA tracks, I will return it as that. Now I 745 - could simplify this interface by combining these returns with 746 - the above, but this more clearly demonstrates the problem 747 - with the current interface. Too bad this wasn't designed 748 - to use bitmasks... -Erik 749 - 750 - Well, now we have the option CDS_MIXED: a mixed-type CD. 751 - User level programmers might feel the ioctl is not very 752 - useful. 753 - ---david 754 - 755 - 756 - 757 - 758 - CDROM_CHANGER_NSLOTS Get number of slots 759 - 760 - usage: 761 - 762 - ioctl(fd, CDROM_CHANGER_NSLOTS, 0); 763 - 764 - inputs: none 765 - 766 - outputs: 767 - The ioctl return value will be the number of slots in a 768 - CD changer. Typically 1 for non-multi-disk devices. 769 - 770 - error returns: none 771 - 772 - 773 - 774 - CDROM_LOCKDOOR lock or unlock door 775 - 776 - usage: 777 - 778 - int lock; 779 - ioctl(fd, CDROM_LOCKDOOR, lock); 780 - 781 - inputs: 782 - Door lock flag, 1=lock, 0=unlock 783 - 784 - outputs: none 785 - 786 - error returns: 787 - EDRIVE_CANT_DO_THIS Door lock function not supported. 788 - EBUSY Attempt to unlock when multiple users 789 - have the drive open and not CAP_SYS_ADMIN 790 - 791 - notes: 792 - As of 2.6.8.1, the lock flag is a global lock, meaning that 793 - all CD drives will be locked or unlocked together. This is 794 - probably a bug. 795 - 796 - The EDRIVE_CANT_DO_THIS value is defined in <linux/cdrom.h> 797 - and is currently (2.6.8.1) the same as EOPNOTSUPP 798 - 799 - 800 - 801 - CDROM_DEBUG Turn debug messages on/off 802 - 803 - usage: 804 - 805 - int debug; 806 - ioctl(fd, CDROM_DEBUG, debug); 807 - 808 - inputs: 809 - Cdrom debug flag, 0=disable, 1=enable 810 - 811 - outputs: 812 - The ioctl return value will be the new debug flag. 813 - 814 - error return: 815 - EACCES Access denied: requires CAP_SYS_ADMIN 816 - 817 - 818 - 819 - CDROM_GET_CAPABILITY get capabilities 820 - 821 - usage: 822 - 823 - ioctl(fd, CDROM_GET_CAPABILITY, 0); 824 - 825 - inputs: none 826 - 827 - outputs: 828 - The ioctl return value is the current device capability 829 - flags. See CDC_CLOSE_TRAY, CDC_OPEN_TRAY, etc. 830 - 831 - 832 - 833 - CDROMAUDIOBUFSIZ set the audio buffer size 834 - 835 - usage: 836 - 837 - int arg; 838 - ioctl(fd, CDROMAUDIOBUFSIZ, val); 839 - 840 - inputs: 841 - New audio buffer size 842 - 843 - outputs: 844 - The ioctl return value is the new audio buffer size, or -1 845 - on error. 846 - 847 - error return: 848 - ENOSYS Not supported by this driver. 849 - 850 - notes: 851 - Not supported by all drivers. 852 - 853 - 854 - 855 - DVD_READ_STRUCT Read structure 856 - 857 - usage: 858 - 859 - dvd_struct s; 860 - ioctl(fd, DVD_READ_STRUCT, &s); 861 - 862 - inputs: 863 - dvd_struct structure, containing: 864 - type specifies the information desired, one of 865 - DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT, 866 - DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA, 867 - DVD_STRUCT_MANUFACT 868 - physical.layer_num desired layer, indexed from 0 869 - copyright.layer_num desired layer, indexed from 0 870 - disckey.agid 871 - 872 - outputs: 873 - dvd_struct structure, containing: 874 - physical for type == DVD_STRUCT_PHYSICAL 875 - copyright for type == DVD_STRUCT_COPYRIGHT 876 - disckey.value for type == DVD_STRUCT_DISCKEY 877 - bca.{len,value} for type == DVD_STRUCT_BCA 878 - manufact.{len,valu} for type == DVD_STRUCT_MANUFACT 879 - 880 - error returns: 881 - EINVAL physical.layer_num exceeds number of layers 882 - EIO Received invalid response from drive 883 - 884 - 885 - 886 - DVD_WRITE_STRUCT Write structure 887 - 888 - Not implemented, as of 2.6.8.1 889 - 890 - 891 - 892 - DVD_AUTH Authentication 893 - 894 - usage: 895 - 896 - dvd_authinfo ai; 897 - ioctl(fd, DVD_AUTH, &ai); 898 - 899 - inputs: 900 - dvd_authinfo structure. See <linux/cdrom.h> 901 - 902 - outputs: 903 - dvd_authinfo structure. 904 - 905 - error return: 906 - ENOTTY ai.type not recognized. 907 - 908 - 909 - 910 - CDROM_SEND_PACKET send a packet to the drive 911 - 912 - usage: 913 - 914 - struct cdrom_generic_command cgc; 915 - ioctl(fd, CDROM_SEND_PACKET, &cgc); 916 - 917 - inputs: 918 - cdrom_generic_command structure containing the packet to send. 919 - 920 - outputs: none 921 - cdrom_generic_command structure containing results. 922 - 923 - error return: 924 - EIO command failed. 925 - EPERM Operation not permitted, either because a 926 - write command was attempted on a drive which 927 - is opened read-only, or because the command 928 - requires CAP_SYS_RAWIO 929 - EINVAL cgc.data_direction not set 930 - 931 - 932 - 933 - CDROM_NEXT_WRITABLE get next writable block 934 - 935 - usage: 936 - 937 - long next; 938 - ioctl(fd, CDROM_NEXT_WRITABLE, &next); 939 - 940 - inputs: none 941 - 942 - outputs: 943 - The next writable block. 944 - 945 - notes: 946 - If the device does not support this ioctl directly, the 947 - ioctl will return CDROM_LAST_WRITTEN + 7. 948 - 949 - 950 - 951 - CDROM_LAST_WRITTEN get last block written on disc 952 - 953 - usage: 954 - 955 - long last; 956 - ioctl(fd, CDROM_LAST_WRITTEN, &last); 957 - 958 - inputs: none 959 - 960 - outputs: 961 - The last block written on disc 962 - 963 - notes: 964 - If the device does not support this ioctl directly, the 965 - result is derived from the disc's table of contents. If the 966 - table of contents can't be read, this ioctl returns an 967 - error.
+580 -309
Documentation/ioctl/hdio.txt Documentation/ioctl/hdio.rst
··· 1 - Summary of HDIO_ ioctl calls. 2 - ============================ 1 + ============================== 2 + Summary of `HDIO_` ioctl calls 3 + ============================== 3 4 4 - Edward A. Falk <efalk@google.com> 5 + - Edward A. Falk <efalk@google.com> 5 6 6 - November, 2004 7 + November, 2004 7 8 8 9 This document attempts to describe the ioctl(2) calls supported by 9 10 the HD/IDE layer. These are by-and-large implemented (as of Linux 2.6) ··· 15 14 16 15 ioctls that pass argument pointers to user space: 17 16 17 + ======================= ======================================= 18 18 HDIO_GETGEO get device geometry 19 19 HDIO_GET_UNMASKINTR get current unmask setting 20 20 HDIO_GET_MULTCOUNT get current IDE blockmode setting ··· 38 36 HDIO_DRIVE_TASK execute task and special drive command 39 37 HDIO_DRIVE_CMD execute a special drive command 40 38 HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK 39 + ======================= ======================================= 41 40 42 41 ioctls that pass non-pointer values: 43 42 43 + ======================= ======================================= 44 44 HDIO_SET_MULTCOUNT change IDE blockmode 45 45 HDIO_SET_UNMASKINTR permit other irqs during I/O 46 46 HDIO_SET_KEEPSETTINGS keep ioctl settings on reset ··· 61 57 62 58 HDIO_SET_IDE_SCSI Set scsi emulation mode on/off 63 59 HDIO_SET_SCSI_IDE not implemented yet 60 + ======================= ======================================= 64 61 65 62 66 63 The information that follows was determined from reading kernel source 67 64 code. It is likely that some corrections will be made over time. 68 65 69 - 70 - 71 - 72 - 73 - 66 + ------------------------------------------------------------------------------ 74 67 75 68 General: 76 69 ··· 81 80 Unless otherwise specified, all data structures and constants 82 81 are defined in <linux/hdreg.h> 83 82 83 + ------------------------------------------------------------------------------ 84 + 85 + HDIO_GETGEO 86 + get device geometry 84 87 85 88 86 - HDIO_GETGEO get device geometry 87 - 88 - usage: 89 + usage:: 89 90 90 91 struct hd_geometry geom; 92 + 91 93 ioctl(fd, HDIO_GETGEO, &geom); 92 94 93 95 94 - inputs: none 96 + inputs: 97 + none 98 + 99 + 95 100 96 101 outputs: 102 + hd_geometry structure containing: 97 103 98 - hd_geometry structure containing: 99 104 105 + ========= ================================== 100 106 heads number of heads 101 107 sectors number of sectors/track 102 108 cylinders number of cylinders, mod 65536 103 109 start starting sector of this partition. 110 + ========= ================================== 104 111 105 112 106 113 error returns: 107 - EINVAL if the device is not a disk drive or floppy drive, 108 - or if the user passes a null pointer 114 + - EINVAL 115 + 116 + if the device is not a disk drive or floppy drive, 117 + or if the user passes a null pointer 109 118 110 119 111 120 notes: 121 + Not particularly useful with modern disk drives, whose geometry 122 + is a polite fiction anyway. Modern drives are addressed 123 + purely by sector number nowadays (lba addressing), and the 124 + drive geometry is an abstraction which is actually subject 125 + to change. Currently (as of Nov 2004), the geometry values 126 + are the "bios" values -- presumably the values the drive had 127 + when Linux first booted. 112 128 113 - Not particularly useful with modern disk drives, whose geometry 114 - is a polite fiction anyway. Modern drives are addressed 115 - purely by sector number nowadays (lba addressing), and the 116 - drive geometry is an abstraction which is actually subject 117 - to change. Currently (as of Nov 2004), the geometry values 118 - are the "bios" values -- presumably the values the drive had 119 - when Linux first booted. 129 + In addition, the cylinders field of the hd_geometry is an 130 + unsigned short, meaning that on most architectures, this 131 + ioctl will not return a meaningful value on drives with more 132 + than 65535 tracks. 120 133 121 - In addition, the cylinders field of the hd_geometry is an 122 - unsigned short, meaning that on most architectures, this 123 - ioctl will not return a meaningful value on drives with more 124 - than 65535 tracks. 125 - 126 - The start field is unsigned long, meaning that it will not 127 - contain a meaningful value for disks over 219 Gb in size. 128 - 134 + The start field is unsigned long, meaning that it will not 135 + contain a meaningful value for disks over 219 Gb in size. 129 136 130 137 131 138 132 - HDIO_GET_UNMASKINTR get current unmask setting 133 139 134 - usage: 140 + HDIO_GET_UNMASKINTR 141 + get current unmask setting 142 + 143 + 144 + usage:: 135 145 136 146 long val; 147 + 137 148 ioctl(fd, HDIO_GET_UNMASKINTR, &val); 138 149 139 - inputs: none 150 + inputs: 151 + none 152 + 153 + 140 154 141 155 outputs: 142 - The value of the drive's current unmask setting 156 + The value of the drive's current unmask setting 143 157 144 158 145 159 146 - HDIO_SET_UNMASKINTR permit other irqs during I/O 147 160 148 - usage: 161 + 162 + HDIO_SET_UNMASKINTR 163 + permit other irqs during I/O 164 + 165 + 166 + usage:: 149 167 150 168 unsigned long val; 169 + 151 170 ioctl(fd, HDIO_SET_UNMASKINTR, val); 152 171 153 172 inputs: 154 - New value for unmask flag 155 - 156 - outputs: none 157 - 158 - error return: 159 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 160 - EACCES Access denied: requires CAP_SYS_ADMIN 161 - EINVAL value out of range [0 1] 162 - EBUSY Controller busy 173 + New value for unmask flag 163 174 164 175 165 - 166 - 167 - HDIO_GET_MULTCOUNT get current IDE blockmode setting 168 - 169 - usage: 170 - 171 - long val; 172 - ioctl(fd, HDIO_GET_MULTCOUNT, &val); 173 - 174 - inputs: none 175 176 176 177 outputs: 177 - The value of the current IDE block mode setting. This 178 - controls how many sectors the drive will transfer per 179 - interrupt. 178 + none 180 179 181 180 182 181 183 - HDIO_SET_MULTCOUNT change IDE blockmode 182 + error return: 183 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 184 + - EACCES Access denied: requires CAP_SYS_ADMIN 185 + - EINVAL value out of range [0 1] 186 + - EBUSY Controller busy 184 187 185 - usage: 188 + 189 + 190 + 191 + HDIO_GET_MULTCOUNT 192 + get current IDE blockmode setting 193 + 194 + 195 + usage:: 196 + 197 + long val; 198 + 199 + ioctl(fd, HDIO_GET_MULTCOUNT, &val); 200 + 201 + inputs: 202 + none 203 + 204 + 205 + 206 + outputs: 207 + The value of the current IDE block mode setting. This 208 + controls how many sectors the drive will transfer per 209 + interrupt. 210 + 211 + 212 + 213 + HDIO_SET_MULTCOUNT 214 + change IDE blockmode 215 + 216 + 217 + usage:: 186 218 187 219 int val; 220 + 188 221 ioctl(fd, HDIO_SET_MULTCOUNT, val); 189 222 190 223 inputs: 191 - New value for IDE block mode setting. This controls how many 192 - sectors the drive will transfer per interrupt. 224 + New value for IDE block mode setting. This controls how many 225 + sectors the drive will transfer per interrupt. 193 226 194 - outputs: none 227 + outputs: 228 + none 229 + 230 + 195 231 196 232 error return: 197 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 198 - EACCES Access denied: requires CAP_SYS_ADMIN 199 - EINVAL value out of range supported by disk. 200 - EBUSY Controller busy or blockmode already set. 201 - EIO Drive did not accept new block mode. 233 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 234 + - EACCES Access denied: requires CAP_SYS_ADMIN 235 + - EINVAL value out of range supported by disk. 236 + - EBUSY Controller busy or blockmode already set. 237 + - EIO Drive did not accept new block mode. 202 238 203 239 notes: 204 - 205 - Source code comments read: 240 + Source code comments read:: 206 241 207 242 This is tightly woven into the driver->do_special cannot 208 243 touch. DON'T do it again until a total personality rewrite 209 244 is committed. 210 245 211 246 If blockmode has already been set, this ioctl will fail with 212 - EBUSY 247 + -EBUSY 213 248 214 249 215 250 216 - HDIO_GET_QDMA get use-qdma flag 251 + HDIO_GET_QDMA 252 + get use-qdma flag 253 + 217 254 218 255 Not implemented, as of 2.6.8.1 219 256 220 257 221 258 222 - HDIO_SET_XFER set transfer rate via proc 259 + HDIO_SET_XFER 260 + set transfer rate via proc 261 + 223 262 224 263 Not implemented, as of 2.6.8.1 225 264 226 265 227 266 228 - HDIO_OBSOLETE_IDENTITY OBSOLETE, DO NOT USE 267 + HDIO_OBSOLETE_IDENTITY 268 + OBSOLETE, DO NOT USE 269 + 229 270 230 271 Same as HDIO_GET_IDENTITY (see below), except that it only 231 272 returns the first 142 bytes of drive identity information. 232 273 233 274 234 275 235 - HDIO_GET_IDENTITY get IDE identification info 276 + HDIO_GET_IDENTITY 277 + get IDE identification info 236 278 237 - usage: 279 + 280 + usage:: 238 281 239 282 unsigned char identity[512]; 283 + 240 284 ioctl(fd, HDIO_GET_IDENTITY, identity); 241 285 242 - inputs: none 286 + inputs: 287 + none 288 + 289 + 243 290 244 291 outputs: 245 - 246 - ATA drive identity information. For full description, see 247 - the IDENTIFY DEVICE and IDENTIFY PACKET DEVICE commands in 248 - the ATA specification. 292 + ATA drive identity information. For full description, see 293 + the IDENTIFY DEVICE and IDENTIFY PACKET DEVICE commands in 294 + the ATA specification. 249 295 250 296 error returns: 251 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 252 - ENOMSG IDENTIFY DEVICE information not available 297 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 298 + - ENOMSG IDENTIFY DEVICE information not available 253 299 254 300 notes: 301 + Returns information that was obtained when the drive was 302 + probed. Some of this information is subject to change, and 303 + this ioctl does not re-probe the drive to update the 304 + information. 255 305 256 - Returns information that was obtained when the drive was 257 - probed. Some of this information is subject to change, and 258 - this ioctl does not re-probe the drive to update the 259 - information. 260 - 261 - This information is also available from /proc/ide/hdX/identify 262 - 306 + This information is also available from /proc/ide/hdX/identify 263 307 264 308 265 - HDIO_GET_KEEPSETTINGS get keep-settings-on-reset flag 266 309 267 - usage: 310 + HDIO_GET_KEEPSETTINGS 311 + get keep-settings-on-reset flag 312 + 313 + 314 + usage:: 268 315 269 316 long val; 317 + 270 318 ioctl(fd, HDIO_GET_KEEPSETTINGS, &val); 271 319 272 - inputs: none 320 + inputs: 321 + none 322 + 323 + 273 324 274 325 outputs: 275 - The value of the current "keep settings" flag 326 + The value of the current "keep settings" flag 327 + 328 + 276 329 277 330 notes: 278 - 279 - When set, indicates that kernel should restore settings 280 - after a drive reset. 281 - 331 + When set, indicates that kernel should restore settings 332 + after a drive reset. 282 333 283 334 284 - HDIO_SET_KEEPSETTINGS keep ioctl settings on reset 285 335 286 - usage: 336 + HDIO_SET_KEEPSETTINGS 337 + keep ioctl settings on reset 338 + 339 + 340 + usage:: 287 341 288 342 long val; 343 + 289 344 ioctl(fd, HDIO_SET_KEEPSETTINGS, val); 290 345 291 346 inputs: 292 - New value for keep_settings flag 347 + New value for keep_settings flag 293 348 294 - outputs: none 349 + 350 + 351 + outputs: 352 + none 353 + 354 + 295 355 296 356 error return: 297 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 298 - EACCES Access denied: requires CAP_SYS_ADMIN 299 - EINVAL value out of range [0 1] 300 - EBUSY Controller busy 357 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 358 + - EACCES Access denied: requires CAP_SYS_ADMIN 359 + - EINVAL value out of range [0 1] 360 + - EBUSY Controller busy 301 361 302 362 303 363 304 - HDIO_GET_32BIT get current io_32bit setting 364 + HDIO_GET_32BIT 365 + get current io_32bit setting 305 366 306 - usage: 367 + 368 + usage:: 307 369 308 370 long val; 371 + 309 372 ioctl(fd, HDIO_GET_32BIT, &val); 310 373 311 - inputs: none 374 + inputs: 375 + none 376 + 377 + 312 378 313 379 outputs: 314 - The value of the current io_32bit setting 380 + The value of the current io_32bit setting 381 + 382 + 315 383 316 384 notes: 317 - 318 - 0=16-bit, 1=32-bit, 2,3 = 32bit+sync 319 - 385 + 0=16-bit, 1=32-bit, 2,3 = 32bit+sync 320 386 321 387 322 - HDIO_GET_NOWERR get ignore-write-error flag 323 388 324 - usage: 389 + 390 + 391 + HDIO_GET_NOWERR 392 + get ignore-write-error flag 393 + 394 + 395 + usage:: 325 396 326 397 long val; 398 + 327 399 ioctl(fd, HDIO_GET_NOWERR, &val); 328 400 329 - inputs: none 401 + inputs: 402 + none 403 + 404 + 330 405 331 406 outputs: 332 - The value of the current ignore-write-error flag 407 + The value of the current ignore-write-error flag 333 408 334 409 335 410 336 - HDIO_GET_DMA get use-dma flag 337 411 338 - usage: 412 + 413 + HDIO_GET_DMA 414 + get use-dma flag 415 + 416 + 417 + usage:: 339 418 340 419 long val; 420 + 341 421 ioctl(fd, HDIO_GET_DMA, &val); 342 422 343 - inputs: none 423 + inputs: 424 + none 425 + 426 + 344 427 345 428 outputs: 346 - The value of the current use-dma flag 429 + The value of the current use-dma flag 347 430 348 431 349 432 350 - HDIO_GET_NICE get nice flags 351 433 352 - usage: 434 + 435 + HDIO_GET_NICE 436 + get nice flags 437 + 438 + 439 + usage:: 353 440 354 441 long nice; 442 + 355 443 ioctl(fd, HDIO_GET_NICE, &nice); 356 444 357 - inputs: none 445 + inputs: 446 + none 447 + 448 + 358 449 359 450 outputs: 451 + The drive's "nice" values. 360 452 361 - The drive's "nice" values. 453 + 362 454 363 455 notes: 456 + Per-drive flags which determine when the system will give more 457 + bandwidth to other devices sharing the same IDE bus. 364 458 365 - Per-drive flags which determine when the system will give more 366 - bandwidth to other devices sharing the same IDE bus. 367 - See <linux/hdreg.h>, near symbol IDE_NICE_DSC_OVERLAP. 368 - 369 - 459 + See <linux/hdreg.h>, near symbol IDE_NICE_DSC_OVERLAP. 370 460 371 461 372 - HDIO_SET_NICE set nice flags 373 462 374 - usage: 463 + 464 + HDIO_SET_NICE 465 + set nice flags 466 + 467 + 468 + usage:: 375 469 376 470 unsigned long nice; 471 + 377 472 ... 378 473 ioctl(fd, HDIO_SET_NICE, nice); 379 474 380 475 inputs: 381 - bitmask of nice flags. 476 + bitmask of nice flags. 382 477 383 - outputs: none 478 + 479 + 480 + outputs: 481 + none 482 + 483 + 384 484 385 485 error returns: 386 - EACCES Access denied: requires CAP_SYS_ADMIN 387 - EPERM Flags other than DSC_OVERLAP and NICE_1 set. 388 - EPERM DSC_OVERLAP specified but not supported by drive 486 + - EACCES Access denied: requires CAP_SYS_ADMIN 487 + - EPERM Flags other than DSC_OVERLAP and NICE_1 set. 488 + - EPERM DSC_OVERLAP specified but not supported by drive 389 489 390 490 notes: 491 + This ioctl sets the DSC_OVERLAP and NICE_1 flags from values 492 + provided by the user. 391 493 392 - This ioctl sets the DSC_OVERLAP and NICE_1 flags from values 393 - provided by the user. 394 - 395 - Nice flags are listed in <linux/hdreg.h>, starting with 396 - IDE_NICE_DSC_OVERLAP. These values represent shifts. 397 - 494 + Nice flags are listed in <linux/hdreg.h>, starting with 495 + IDE_NICE_DSC_OVERLAP. These values represent shifts. 398 496 399 497 400 498 401 499 402 - HDIO_GET_WCACHE get write cache mode on|off 403 500 404 - usage: 501 + HDIO_GET_WCACHE 502 + get write cache mode on|off 503 + 504 + 505 + usage:: 405 506 406 507 long val; 508 + 407 509 ioctl(fd, HDIO_GET_WCACHE, &val); 408 510 409 - inputs: none 511 + inputs: 512 + none 513 + 514 + 410 515 411 516 outputs: 412 - The value of the current write cache mode 517 + The value of the current write cache mode 413 518 414 519 415 520 416 - HDIO_GET_ACOUSTIC get acoustic value 417 521 418 - usage: 522 + 523 + HDIO_GET_ACOUSTIC 524 + get acoustic value 525 + 526 + 527 + usage:: 419 528 420 529 long val; 530 + 421 531 ioctl(fd, HDIO_GET_ACOUSTIC, &val); 422 532 423 - inputs: none 533 + inputs: 534 + none 535 + 536 + 424 537 425 538 outputs: 426 - The value of the current acoustic settings 539 + The value of the current acoustic settings 540 + 541 + 427 542 428 543 notes: 544 + See HDIO_SET_ACOUSTIC 429 545 430 - See HDIO_SET_ACOUSTIC 546 + 431 547 432 548 433 549 434 550 HDIO_GET_ADDRESS 551 + usage:: 435 552 436 - usage: 437 553 438 554 long val; 555 + 439 556 ioctl(fd, HDIO_GET_ADDRESS, &val); 440 557 441 - inputs: none 558 + inputs: 559 + none 560 + 561 + 442 562 443 563 outputs: 444 - The value of the current addressing mode: 445 - 0 = 28-bit 446 - 1 = 48-bit 447 - 2 = 48-bit doing 28-bit 448 - 3 = 64-bit 564 + The value of the current addressing mode: 565 + 566 + = =================== 567 + 0 28-bit 568 + 1 48-bit 569 + 2 48-bit doing 28-bit 570 + 3 64-bit 571 + = =================== 449 572 450 573 451 574 452 - HDIO_GET_BUSSTATE get the bus state of the hwif 575 + HDIO_GET_BUSSTATE 576 + get the bus state of the hwif 453 577 454 - usage: 578 + 579 + usage:: 455 580 456 581 long state; 582 + 457 583 ioctl(fd, HDIO_SCAN_HWIF, &state); 458 584 459 - inputs: none 585 + inputs: 586 + none 587 + 588 + 460 589 461 590 outputs: 462 - Current power state of the IDE bus. One of BUSSTATE_OFF, 463 - BUSSTATE_ON, or BUSSTATE_TRISTATE 591 + Current power state of the IDE bus. One of BUSSTATE_OFF, 592 + BUSSTATE_ON, or BUSSTATE_TRISTATE 464 593 465 594 error returns: 466 - EACCES Access denied: requires CAP_SYS_ADMIN 595 + - EACCES Access denied: requires CAP_SYS_ADMIN 467 596 468 597 469 598 470 599 471 - HDIO_SET_BUSSTATE set the bus state of the hwif 600 + HDIO_SET_BUSSTATE 601 + set the bus state of the hwif 472 602 473 - usage: 603 + 604 + usage:: 474 605 475 606 int state; 607 + 476 608 ... 477 609 ioctl(fd, HDIO_SCAN_HWIF, state); 478 610 479 611 inputs: 480 - Desired IDE power state. One of BUSSTATE_OFF, BUSSTATE_ON, 481 - or BUSSTATE_TRISTATE 612 + Desired IDE power state. One of BUSSTATE_OFF, BUSSTATE_ON, 613 + or BUSSTATE_TRISTATE 482 614 483 - outputs: none 615 + outputs: 616 + none 617 + 618 + 484 619 485 620 error returns: 486 - EACCES Access denied: requires CAP_SYS_RAWIO 487 - EOPNOTSUPP Hardware interface does not support bus power control 621 + - EACCES Access denied: requires CAP_SYS_RAWIO 622 + - EOPNOTSUPP Hardware interface does not support bus power control 488 623 489 624 490 625 491 626 492 - HDIO_TRISTATE_HWIF execute a channel tristate 627 + HDIO_TRISTATE_HWIF 628 + execute a channel tristate 629 + 493 630 494 631 Not implemented, as of 2.6.8.1. See HDIO_SET_BUSSTATE 495 632 496 633 497 634 498 - HDIO_DRIVE_RESET execute a device reset 635 + HDIO_DRIVE_RESET 636 + execute a device reset 499 637 500 - usage: 638 + 639 + usage:: 501 640 502 641 int args[3] 642 + 503 643 ... 504 644 ioctl(fd, HDIO_DRIVE_RESET, args); 505 645 506 - inputs: none 646 + inputs: 647 + none 507 648 508 - outputs: none 649 + 650 + 651 + outputs: 652 + none 653 + 654 + 509 655 510 656 error returns: 511 - EACCES Access denied: requires CAP_SYS_ADMIN 512 - ENXIO No such device: phy dead or ctl_addr == 0 513 - EIO I/O error: reset timed out or hardware error 657 + - EACCES Access denied: requires CAP_SYS_ADMIN 658 + - ENXIO No such device: phy dead or ctl_addr == 0 659 + - EIO I/O error: reset timed out or hardware error 514 660 515 661 notes: 516 662 517 - Execute a reset on the device as soon as the current IO 518 - operation has completed. 663 + - Execute a reset on the device as soon as the current IO 664 + operation has completed. 519 665 520 - Executes an ATAPI soft reset if applicable, otherwise 521 - executes an ATA soft reset on the controller. 666 + - Executes an ATAPI soft reset if applicable, otherwise 667 + executes an ATA soft reset on the controller. 522 668 523 669 524 670 525 - HDIO_DRIVE_TASKFILE execute raw taskfile 671 + HDIO_DRIVE_TASKFILE 672 + execute raw taskfile 526 673 527 - Note: If you don't have a copy of the ANSI ATA specification 528 - handy, you should probably ignore this ioctl. 529 674 530 - Execute an ATA disk command directly by writing the "taskfile" 531 - registers of the drive. Requires ADMIN and RAWIO access 532 - privileges. 675 + Note: 676 + If you don't have a copy of the ANSI ATA specification 677 + handy, you should probably ignore this ioctl. 533 678 534 - usage: 679 + - Execute an ATA disk command directly by writing the "taskfile" 680 + registers of the drive. Requires ADMIN and RAWIO access 681 + privileges. 682 + 683 + usage:: 535 684 536 685 struct { 686 + 537 687 ide_task_request_t req_task; 538 688 u8 outbuf[OUTPUT_SIZE]; 539 689 u8 inbuf[INPUT_SIZE]; ··· 700 548 701 549 (See below for details on memory area passed to ioctl.) 702 550 551 + ============ =================================================== 703 552 io_ports[8] values to be written to taskfile registers 704 553 hob_ports[8] high-order bytes, for extended commands. 705 554 out_flags flags indicating which registers are valid ··· 710 557 out_size size of output buffer 711 558 outbuf buffer of data to be transmitted to disk 712 559 inbuf buffer of data to be received from disk (see [1]) 560 + ============ =================================================== 713 561 714 562 outputs: 715 563 564 + =========== ==================================================== 716 565 io_ports[] values returned in the taskfile registers 717 566 hob_ports[] high-order bytes, for extended commands. 718 567 out_flags flags indicating which registers are valid (see [2]) 719 568 in_flags flags indicating which registers should be returned 720 569 outbuf buffer of data to be transmitted to disk (see [1]) 721 570 inbuf buffer of data to be received from disk 571 + =========== ==================================================== 722 572 723 573 error returns: 724 - EACCES CAP_SYS_ADMIN or CAP_SYS_RAWIO privilege not set. 725 - ENOMSG Device is not a disk drive. 726 - ENOMEM Unable to allocate memory for task 727 - EFAULT req_cmd == TASKFILE_IN_OUT (not implemented as of 2.6.8) 728 - EPERM req_cmd == TASKFILE_MULTI_OUT and drive 729 - multi-count not yet set. 730 - EIO Drive failed the command. 574 + - EACCES CAP_SYS_ADMIN or CAP_SYS_RAWIO privilege not set. 575 + - ENOMSG Device is not a disk drive. 576 + - ENOMEM Unable to allocate memory for task 577 + - EFAULT req_cmd == TASKFILE_IN_OUT (not implemented as of 2.6.8) 578 + - EPERM 579 + 580 + req_cmd == TASKFILE_MULTI_OUT and drive 581 + multi-count not yet set. 582 + - EIO Drive failed the command. 731 583 732 584 notes: 733 585 ··· 773 615 Command is passed to the disk drive via the ide_task_request_t 774 616 structure, which contains these fields: 775 617 618 + ============ =============================================== 776 619 io_ports[8] values for the taskfile registers 777 620 hob_ports[8] high-order bytes, for extended commands 778 621 out_flags flags indicating which entries in the 779 - io_ports[] and hob_ports[] arrays 622 + io_ports[] and hob_ports[] arrays 780 623 contain valid values. Type ide_reg_valid_t. 781 624 in_flags flags indicating which entries in the 782 - io_ports[] and hob_ports[] arrays 625 + io_ports[] and hob_ports[] arrays 783 626 are expected to contain valid values 784 627 on return. 785 628 data_phase See below 786 629 req_cmd Command type, see below 787 630 out_size output (user->drive) buffer size, bytes 788 631 in_size input (drive->user) buffer size, bytes 632 + ============ =============================================== 789 633 790 634 When out_flags is zero, the following registers are loaded. 791 635 636 + ============ =============================================== 792 637 HOB_FEATURE If the drive supports LBA48 793 638 HOB_NSECTOR If the drive supports LBA48 794 639 HOB_SECTOR If the drive supports LBA48 ··· 805 644 SELECT First, masked with 0xE0 if LBA48, 0xEF 806 645 otherwise; then, or'ed with the default 807 646 value of SELECT. 647 + ============ =============================================== 808 648 809 649 If any bit in out_flags is set, the following registers are loaded. 810 650 651 + ============ =============================================== 811 652 HOB_DATA If out_flags.b.data is set. HOB_DATA will 812 653 travel on DD8-DD15 on little endian machines 813 654 and on DD0-DD7 on big endian machines. ··· 827 664 HCYL If out_flags.b.hcyl is set 828 665 SELECT Or'ed with the default value of SELECT and 829 666 loaded regardless of out_flags.b.select. 667 + ============ =============================================== 830 668 831 669 Taskfile registers are read back from the drive into 832 670 {io|hob}_ports[] after the command completes iff one of the ··· 838 674 2. One or more than one bits are set in out_flags. 839 675 3. The requested data_phase is TASKFILE_NO_DATA. 840 676 677 + ============ =============================================== 841 678 HOB_DATA If in_flags.b.data is set. It will contain 842 679 DD8-DD15 on little endian machines and 843 680 DD0-DD7 on big endian machines. ··· 854 689 SECTOR 855 690 LCYL 856 691 HCYL 692 + ============ =============================================== 857 693 858 694 The data_phase field describes the data transfer to be 859 695 performed. Value is one of: 860 696 697 + =================== ======================================== 861 698 TASKFILE_IN 862 699 TASKFILE_MULTI_IN 863 700 TASKFILE_OUT ··· 875 708 TASKFILE_P_OUT unimplemented 876 709 TASKFILE_P_OUT_DMA unimplemented 877 710 TASKFILE_P_OUT_DMAQ unimplemented 711 + =================== ======================================== 878 712 879 713 The req_cmd field classifies the command type. It may be 880 714 one of: 881 715 716 + ======================== ======================================= 882 717 IDE_DRIVE_TASK_NO_DATA 883 718 IDE_DRIVE_TASK_SET_XFER unimplemented 884 719 IDE_DRIVE_TASK_IN 885 720 IDE_DRIVE_TASK_OUT unimplemented 886 721 IDE_DRIVE_TASK_RAW_WRITE 722 + ======================== ======================================= 887 723 888 724 [6] Do not access {in|out}_flags->all except for resetting 889 725 all the bits. Always access individual bit fields. ->all ··· 896 726 897 727 898 728 899 - HDIO_DRIVE_CMD execute a special drive command 729 + HDIO_DRIVE_CMD 730 + execute a special drive command 731 + 900 732 901 733 Note: If you don't have a copy of the ANSI ATA specification 902 734 handy, you should probably ignore this ioctl. 903 735 904 - usage: 736 + usage:: 905 737 906 738 u8 args[4+XFER_SIZE]; 739 + 907 740 ... 908 741 ioctl(fd, HDIO_DRIVE_CMD, args); 909 742 910 743 inputs: 744 + Commands other than WIN_SMART: 911 745 912 - Commands other than WIN_SMART 746 + ======= ======= 913 747 args[0] COMMAND 914 748 args[1] NSECTOR 915 749 args[2] FEATURE 916 750 args[3] NSECTOR 751 + ======= ======= 917 752 918 - WIN_SMART 753 + WIN_SMART: 754 + 755 + ======= ======= 919 756 args[0] COMMAND 920 757 args[1] SECTOR 921 758 args[2] FEATURE 922 759 args[3] NSECTOR 760 + ======= ======= 923 761 924 762 outputs: 763 + args[] buffer is filled with register values followed by any 925 764 926 - args[] buffer is filled with register values followed by any 765 + 927 766 data returned by the disk. 767 + 768 + ======== ==================================================== 928 769 args[0] status 929 770 args[1] error 930 771 args[2] NSECTOR 931 772 args[3] undefined 932 773 args[4+] NSECTOR * 512 bytes of data returned by the command. 774 + ======== ==================================================== 933 775 934 776 error returns: 935 - EACCES Access denied: requires CAP_SYS_RAWIO 936 - ENOMEM Unable to allocate memory for task 937 - EIO Drive reports error 777 + - EACCES Access denied: requires CAP_SYS_RAWIO 778 + - ENOMEM Unable to allocate memory for task 779 + - EIO Drive reports error 938 780 939 781 notes: 940 782 ··· 971 789 972 790 973 791 974 - HDIO_DRIVE_TASK execute task and special drive command 792 + HDIO_DRIVE_TASK 793 + execute task and special drive command 794 + 975 795 976 796 Note: If you don't have a copy of the ANSI ATA specification 977 797 handy, you should probably ignore this ioctl. 978 798 979 - usage: 799 + usage:: 980 800 981 801 u8 args[7]; 802 + 982 803 ... 983 804 ioctl(fd, HDIO_DRIVE_TASK, args); 984 805 985 806 inputs: 807 + Taskfile register values: 986 808 987 - Taskfile register values: 809 + ======= ======= 988 810 args[0] COMMAND 989 811 args[1] FEATURE 990 812 args[2] NSECTOR ··· 996 810 args[4] LCYL 997 811 args[5] HCYL 998 812 args[6] SELECT 813 + ======= ======= 999 814 1000 815 outputs: 816 + Taskfile register values: 1001 817 1002 - Taskfile register values: 818 + 819 + ======= ======= 1003 820 args[0] status 1004 821 args[1] error 1005 822 args[2] NSECTOR ··· 1010 821 args[4] LCYL 1011 822 args[5] HCYL 1012 823 args[6] SELECT 824 + ======= ======= 1013 825 1014 826 error returns: 1015 - EACCES Access denied: requires CAP_SYS_RAWIO 1016 - ENOMEM Unable to allocate memory for task 1017 - ENOMSG Device is not a disk drive. 1018 - EIO Drive failed the command. 827 + - EACCES Access denied: requires CAP_SYS_RAWIO 828 + - ENOMEM Unable to allocate memory for task 829 + - ENOMSG Device is not a disk drive. 830 + - EIO Drive failed the command. 1019 831 1020 832 notes: 1021 833 ··· 1026 836 1027 837 1028 838 1029 - HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK 839 + HDIO_DRIVE_CMD_AEB 840 + HDIO_DRIVE_TASK 841 + 1030 842 1031 843 Not implemented, as of 2.6.8.1 1032 844 1033 845 1034 846 1035 - HDIO_SET_32BIT change io_32bit flags 847 + HDIO_SET_32BIT 848 + change io_32bit flags 1036 849 1037 - usage: 850 + 851 + usage:: 1038 852 1039 853 int val; 854 + 1040 855 ioctl(fd, HDIO_SET_32BIT, val); 1041 856 1042 857 inputs: 1043 - New value for io_32bit flag 858 + New value for io_32bit flag 1044 859 1045 - outputs: none 860 + 861 + 862 + outputs: 863 + none 864 + 865 + 1046 866 1047 867 error return: 1048 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1049 - EACCES Access denied: requires CAP_SYS_ADMIN 1050 - EINVAL value out of range [0 3] 1051 - EBUSY Controller busy 868 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 869 + - EACCES Access denied: requires CAP_SYS_ADMIN 870 + - EINVAL value out of range [0 3] 871 + - EBUSY Controller busy 1052 872 1053 873 1054 874 1055 875 1056 - HDIO_SET_NOWERR change ignore-write-error flag 876 + HDIO_SET_NOWERR 877 + change ignore-write-error flag 1057 878 1058 - usage: 879 + 880 + usage:: 1059 881 1060 882 int val; 883 + 1061 884 ioctl(fd, HDIO_SET_NOWERR, val); 1062 885 1063 886 inputs: 1064 - New value for ignore-write-error flag. Used for ignoring 887 + New value for ignore-write-error flag. Used for ignoring 888 + 889 + 1065 890 WRERR_STAT 1066 891 1067 - outputs: none 892 + outputs: 893 + none 894 + 895 + 1068 896 1069 897 error return: 1070 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1071 - EACCES Access denied: requires CAP_SYS_ADMIN 1072 - EINVAL value out of range [0 1] 1073 - EBUSY Controller busy 898 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 899 + - EACCES Access denied: requires CAP_SYS_ADMIN 900 + - EINVAL value out of range [0 1] 901 + - EBUSY Controller busy 1074 902 1075 903 1076 904 1077 - HDIO_SET_DMA change use-dma flag 905 + HDIO_SET_DMA 906 + change use-dma flag 1078 907 1079 - usage: 908 + 909 + usage:: 1080 910 1081 911 long val; 912 + 1082 913 ioctl(fd, HDIO_SET_DMA, val); 1083 914 1084 915 inputs: 1085 - New value for use-dma flag 916 + New value for use-dma flag 1086 917 1087 - outputs: none 918 + 919 + 920 + outputs: 921 + none 922 + 923 + 1088 924 1089 925 error return: 1090 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1091 - EACCES Access denied: requires CAP_SYS_ADMIN 1092 - EINVAL value out of range [0 1] 1093 - EBUSY Controller busy 926 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 927 + - EACCES Access denied: requires CAP_SYS_ADMIN 928 + - EINVAL value out of range [0 1] 929 + - EBUSY Controller busy 1094 930 1095 931 1096 932 1097 - HDIO_SET_PIO_MODE reconfig interface to new speed 933 + HDIO_SET_PIO_MODE 934 + reconfig interface to new speed 1098 935 1099 - usage: 936 + 937 + usage:: 1100 938 1101 939 long val; 940 + 1102 941 ioctl(fd, HDIO_SET_PIO_MODE, val); 1103 942 1104 943 inputs: 1105 - New interface speed. 944 + New interface speed. 1106 945 1107 - outputs: none 946 + 947 + 948 + outputs: 949 + none 950 + 951 + 1108 952 1109 953 error return: 1110 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1111 - EACCES Access denied: requires CAP_SYS_ADMIN 1112 - EINVAL value out of range [0 255] 1113 - EBUSY Controller busy 954 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 955 + - EACCES Access denied: requires CAP_SYS_ADMIN 956 + - EINVAL value out of range [0 255] 957 + - EBUSY Controller busy 1114 958 1115 959 1116 960 1117 - HDIO_SCAN_HWIF register and (re)scan interface 961 + HDIO_SCAN_HWIF 962 + register and (re)scan interface 1118 963 1119 - usage: 964 + 965 + usage:: 1120 966 1121 967 int args[3] 968 + 1122 969 ... 1123 970 ioctl(fd, HDIO_SCAN_HWIF, args); 1124 971 1125 972 inputs: 973 + 974 + ======= ========================= 1126 975 args[0] io address to probe 976 + 977 + 1127 978 args[1] control address to probe 1128 979 args[2] irq number 980 + ======= ========================= 1129 981 1130 - outputs: none 982 + outputs: 983 + none 984 + 985 + 1131 986 1132 987 error returns: 1133 - EACCES Access denied: requires CAP_SYS_RAWIO 1134 - EIO Probe failed. 988 + - EACCES Access denied: requires CAP_SYS_RAWIO 989 + - EIO Probe failed. 1135 990 1136 991 notes: 1137 - 1138 - This ioctl initializes the addresses and irq for a disk 1139 - controller, probes for drives, and creates /proc/ide 1140 - interfaces as appropriate. 1141 - 992 + This ioctl initializes the addresses and irq for a disk 993 + controller, probes for drives, and creates /proc/ide 994 + interfaces as appropriate. 1142 995 1143 996 1144 - HDIO_UNREGISTER_HWIF unregister interface 1145 997 1146 - usage: 998 + HDIO_UNREGISTER_HWIF 999 + unregister interface 1000 + 1001 + 1002 + usage:: 1147 1003 1148 1004 int index; 1005 + 1149 1006 ioctl(fd, HDIO_UNREGISTER_HWIF, index); 1150 1007 1151 1008 inputs: 1152 - index index of hardware interface to unregister 1009 + index index of hardware interface to unregister 1153 1010 1154 - outputs: none 1011 + 1012 + 1013 + outputs: 1014 + none 1015 + 1016 + 1155 1017 1156 1018 error returns: 1157 - EACCES Access denied: requires CAP_SYS_RAWIO 1019 + - EACCES Access denied: requires CAP_SYS_RAWIO 1158 1020 1159 1021 notes: 1022 + This ioctl removes a hardware interface from the kernel. 1160 1023 1161 - This ioctl removes a hardware interface from the kernel. 1162 - 1163 - Currently (2.6.8) this ioctl silently fails if any drive on 1164 - the interface is busy. 1165 - 1024 + Currently (2.6.8) this ioctl silently fails if any drive on 1025 + the interface is busy. 1166 1026 1167 1027 1168 - HDIO_SET_WCACHE change write cache enable-disable 1169 1028 1170 - usage: 1029 + HDIO_SET_WCACHE 1030 + change write cache enable-disable 1031 + 1032 + 1033 + usage:: 1171 1034 1172 1035 int val; 1036 + 1173 1037 ioctl(fd, HDIO_SET_WCACHE, val); 1174 1038 1175 1039 inputs: 1176 - New value for write cache enable 1040 + New value for write cache enable 1177 1041 1178 - outputs: none 1042 + 1043 + 1044 + outputs: 1045 + none 1046 + 1047 + 1179 1048 1180 1049 error return: 1181 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1182 - EACCES Access denied: requires CAP_SYS_ADMIN 1183 - EINVAL value out of range [0 1] 1184 - EBUSY Controller busy 1050 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1051 + - EACCES Access denied: requires CAP_SYS_ADMIN 1052 + - EINVAL value out of range [0 1] 1053 + - EBUSY Controller busy 1185 1054 1186 1055 1187 1056 1188 - HDIO_SET_ACOUSTIC change acoustic behavior 1057 + HDIO_SET_ACOUSTIC 1058 + change acoustic behavior 1189 1059 1190 - usage: 1060 + 1061 + usage:: 1191 1062 1192 1063 int val; 1064 + 1193 1065 ioctl(fd, HDIO_SET_ACOUSTIC, val); 1194 1066 1195 1067 inputs: 1196 - New value for drive acoustic settings 1068 + New value for drive acoustic settings 1197 1069 1198 - outputs: none 1070 + 1071 + 1072 + outputs: 1073 + none 1074 + 1075 + 1199 1076 1200 1077 error return: 1201 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1202 - EACCES Access denied: requires CAP_SYS_ADMIN 1203 - EINVAL value out of range [0 254] 1204 - EBUSY Controller busy 1078 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1079 + - EACCES Access denied: requires CAP_SYS_ADMIN 1080 + - EINVAL value out of range [0 254] 1081 + - EBUSY Controller busy 1205 1082 1206 1083 1207 1084 1208 - HDIO_SET_QDMA change use-qdma flag 1085 + HDIO_SET_QDMA 1086 + change use-qdma flag 1087 + 1209 1088 1210 1089 Not implemented, as of 2.6.8.1 1211 1090 1212 1091 1213 1092 1214 - HDIO_SET_ADDRESS change lba addressing modes 1093 + HDIO_SET_ADDRESS 1094 + change lba addressing modes 1215 1095 1216 - usage: 1096 + 1097 + usage:: 1217 1098 1218 1099 int val; 1100 + 1219 1101 ioctl(fd, HDIO_SET_ADDRESS, val); 1220 1102 1221 1103 inputs: 1222 - New value for addressing mode 1223 - 0 = 28-bit 1224 - 1 = 48-bit 1225 - 2 = 48-bit doing 28-bit 1104 + New value for addressing mode 1226 1105 1227 - outputs: none 1106 + = =================== 1107 + 0 28-bit 1108 + 1 48-bit 1109 + 2 48-bit doing 28-bit 1110 + = =================== 1111 + 1112 + outputs: 1113 + none 1114 + 1115 + 1228 1116 1229 1117 error return: 1230 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1231 - EACCES Access denied: requires CAP_SYS_ADMIN 1232 - EINVAL value out of range [0 2] 1233 - EBUSY Controller busy 1234 - EIO Drive does not support lba48 mode. 1118 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1119 + - EACCES Access denied: requires CAP_SYS_ADMIN 1120 + - EINVAL value out of range [0 2] 1121 + - EBUSY Controller busy 1122 + - EIO Drive does not support lba48 mode. 1235 1123 1236 1124 1237 1125 HDIO_SET_IDE_SCSI 1126 + usage:: 1238 1127 1239 - usage: 1240 1128 1241 1129 long val; 1130 + 1242 1131 ioctl(fd, HDIO_SET_IDE_SCSI, val); 1243 1132 1244 1133 inputs: 1245 - New value for scsi emulation mode (?) 1134 + New value for scsi emulation mode (?) 1246 1135 1247 - outputs: none 1136 + 1137 + 1138 + outputs: 1139 + none 1140 + 1141 + 1248 1142 1249 1143 error return: 1250 - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1251 - EACCES Access denied: requires CAP_SYS_ADMIN 1252 - EINVAL value out of range [0 1] 1253 - EBUSY Controller busy 1144 + - EINVAL (bdev != bdev->bd_contains) (not sure what this means) 1145 + - EACCES Access denied: requires CAP_SYS_ADMIN 1146 + - EINVAL value out of range [0 1] 1147 + - EBUSY Controller busy 1254 1148 1255 1149 1256 1150 1257 1151 HDIO_SET_SCSI_IDE 1258 - 1259 1152 Not implemented, as of 2.6.8.1 1260 - 1261 -
+16
Documentation/ioctl/index.rst
··· 1 + :orphan: 2 + 3 + ====== 4 + IOCTLs 5 + ====== 6 + 7 + .. toctree:: 8 + :maxdepth: 1 9 + 10 + ioctl-number 11 + 12 + botching-up-ioctls 13 + ioctl-decoding 14 + 15 + cdrom 16 + hdio
+10 -3
Documentation/ioctl/ioctl-decoding.txt Documentation/ioctl/ioctl-decoding.rst
··· 1 + ============================== 2 + Decoding an IOCTL Magic Number 3 + ============================== 4 + 1 5 To decode a hex IOCTL code: 2 6 3 7 Most architectures use this generic format, but check 4 8 include/ARCH/ioctl.h for specifics, e.g. powerpc 5 9 uses 3 bits to encode read/write and 13 bits for size. 6 10 7 - bits meaning 11 + ====== ================================== 12 + bits meaning 13 + ====== ================================== 8 14 31-30 00 - no parameters: uses _IO macro 9 15 10 - read: _IOR 10 16 01 - write: _IOW ··· 22 16 unique to each driver 23 17 24 18 7-0 function # 19 + ====== ================================== 25 20 26 21 27 22 So for example 0x82187201 is a read with arg length of 0x218, 28 - character 'r' function 1. Grepping the source reveals this is: 23 + character 'r' function 1. Grepping the source reveals this is:: 29 24 30 - #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2]) 25 + #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2])
+1 -1
drivers/gpu/drm/drm_ioctl.c
··· 730 730 * }; 731 731 * 732 732 * Please make sure that you follow all the best practices from 733 - * ``Documentation/ioctl/botching-up-ioctls.txt``. Note that drm_ioctl() 733 + * ``Documentation/ioctl/botching-up-ioctls.rst``. Note that drm_ioctl() 734 734 * automatically zero-extends structures, hence make sure you can add more stuff 735 735 * at the end, i.e. don't put a variable sized array there. 736 736 *