scsi-generic.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. Notes on Linux SCSI Generic (sg) driver
  2. ---------------------------------------
  3. 20020126
  4. Introduction
  5. ============
  6. The SCSI Generic driver (sg) is one of the four "high level" SCSI device
  7. drivers along with sd, st and sr (disk, tape and CDROM respectively). Sg
  8. is more generalized (but lower level) than its siblings and tends to be
  9. used on SCSI devices that don't fit into the already serviced categories.
  10. Thus sg is used for scanners, CD writers and reading audio CDs digitally
  11. amongst other things.
  12. Rather than document the driver's interface here, version information
  13. is provided plus pointers (i.e. URLs) where to find documentation
  14. and examples.
  15. Major versions of the sg driver
  16. ===============================
  17. There are three major versions of sg found in the linux kernel (lk):
  18. - sg version 1 (original) from 1992 to early 1999 (lk 2.2.5) .
  19. It is based in the sg_header interface structure.
  20. - sg version 2 from lk 2.2.6 in the 2.2 series. It is based on
  21. an extended version of the sg_header interface structure.
  22. - sg version 3 found in the lk 2.4 series (and the lk 2.5 series).
  23. It adds the sg_io_hdr interface structure.
  24. Sg driver documentation
  25. =======================
  26. The most recent documentation of the sg driver is kept at the Linux
  27. Documentation Project's (LDP) site:
  28. http://www.tldp.org/HOWTO/SCSI-Generic-HOWTO
  29. This describes the sg version 3 driver found in the lk 2.4 series.
  30. The LDP renders documents in single and multiple page HTML, postscript
  31. and pdf. This document can also be found at:
  32. http://www.torque.net/sg/p/sg_v3_ho.html
  33. Documentation for the version 2 sg driver found in the lk 2.2 series can
  34. be found at http://www.torque.net/sg/p/scsi-generic.txt . A larger version
  35. is at: http://www.torque.net/sg/p/scsi-generic_long.txt .
  36. The original documentation for the sg driver (prior to lk 2.2.6) can be
  37. found at http://www.torque.net/sg/p/original/SCSI-Programming-HOWTO.txt
  38. and in the LDP archives.
  39. A changelog with brief notes can be found in the
  40. /usr/src/linux/include/scsi/sg.h file. Note that the glibc maintainers copy
  41. and edit this file (removing its changelog for example) before placing it
  42. in /usr/include/scsi/sg.h . Driver debugging information and other notes
  43. can be found at the top of the /usr/src/linux/drivers/scsi/sg.c file.
  44. A more general description of the Linux SCSI subsystem of which sg is a
  45. part can be found at http://www.tldp.org/HOWTO/SCSI-2.4-HOWTO .
  46. Example code and utilities
  47. ==========================
  48. There are two packages of sg utilities:
  49. - sg3_utils for the sg version 3 driver found in lk 2.4
  50. - sg_utils for the sg version 2 (and original) driver found in lk 2.2
  51. and earlier
  52. Both packages will work in the lk 2.4 series however sg3_utils offers more
  53. capabilities. They can be found at: http://www.torque.net/sg and
  54. freshmeat.net
  55. Another approach is to look at the applications that use the sg driver.
  56. These include cdrecord, cdparanoia, SANE and cdrdao.
  57. Mapping of Linux kernel versions to sg driver versions
  58. ======================================================
  59. Here is a list of linux kernels in the 2.4 series that had new version
  60. of the sg driver:
  61. lk 2.4.0 : sg version 3.1.17
  62. lk 2.4.7 : sg version 3.1.19
  63. lk 2.4.10 : sg version 3.1.20 **
  64. lk 2.4.17 : sg version 3.1.22
  65. ** There were 3 changes to sg version 3.1.20 by third parties in the
  66. next six linux kernel versions.
  67. For reference here is a list of linux kernels in the 2.2 series that had
  68. new version of the sg driver:
  69. lk 2.2.0 : original sg version [with no version number]
  70. lk 2.2.6 : sg version 2.1.31
  71. lk 2.2.8 : sg version 2.1.32
  72. lk 2.2.10 : sg version 2.1.34 [SG_GET_VERSION_NUM ioctl first appeared]
  73. lk 2.2.14 : sg version 2.1.36
  74. lk 2.2.16 : sg version 2.1.38
  75. lk 2.2.17 : sg version 2.1.39
  76. lk 2.2.20 : sg version 2.1.40
  77. The lk 2.5 development series has recently commenced and it currently
  78. contains sg version 3.5.23 which is functionally equivalent to sg
  79. version 3.1.22 found in lk 2.4.17 .
  80. Douglas Gilbert
  81. 26th January 2002
  82. dgilbert@interlog.com