1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun======================================= 4*4882a593SmuzhiyunNotes on Linux SCSI Generic (sg) driver 5*4882a593Smuzhiyun======================================= 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun 20020126 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunIntroduction 10*4882a593Smuzhiyun============ 11*4882a593SmuzhiyunThe SCSI Generic driver (sg) is one of the four "high level" SCSI device 12*4882a593Smuzhiyundrivers along with sd, st and sr (disk, tape and CDROM respectively). Sg 13*4882a593Smuzhiyunis more generalized (but lower level) than its siblings and tends to be 14*4882a593Smuzhiyunused on SCSI devices that don't fit into the already serviced categories. 15*4882a593SmuzhiyunThus sg is used for scanners, CD writers and reading audio CDs digitally 16*4882a593Smuzhiyunamongst other things. 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunRather than document the driver's interface here, version information 19*4882a593Smuzhiyunis provided plus pointers (i.e. URLs) where to find documentation 20*4882a593Smuzhiyunand examples. 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunMajor versions of the sg driver 24*4882a593Smuzhiyun=============================== 25*4882a593SmuzhiyunThere are three major versions of sg found in the linux kernel (lk): 26*4882a593Smuzhiyun - sg version 1 (original) from 1992 to early 1999 (lk 2.2.5) . 27*4882a593Smuzhiyun It is based in the sg_header interface structure. 28*4882a593Smuzhiyun - sg version 2 from lk 2.2.6 in the 2.2 series. It is based on 29*4882a593Smuzhiyun an extended version of the sg_header interface structure. 30*4882a593Smuzhiyun - sg version 3 found in the lk 2.4 series (and the lk 2.5 series). 31*4882a593Smuzhiyun It adds the sg_io_hdr interface structure. 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunSg driver documentation 35*4882a593Smuzhiyun======================= 36*4882a593SmuzhiyunThe most recent documentation of the sg driver is kept at the Linux 37*4882a593SmuzhiyunDocumentation Project's (LDP) site: 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun- http://www.tldp.org/HOWTO/SCSI-Generic-HOWTO 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunThis describes the sg version 3 driver found in the lk 2.4 series. 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunThe LDP renders documents in single and multiple page HTML, postscript 44*4882a593Smuzhiyunand pdf. This document can also be found at: 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun- http://sg.danny.cz/sg/p/sg_v3_ho.html 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunDocumentation for the version 2 sg driver found in the lk 2.2 series can 49*4882a593Smuzhiyunbe found at http://sg.danny.cz/sg/. A larger version 50*4882a593Smuzhiyunis at: http://sg.danny.cz/sg/p/scsi-generic_long.txt. 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunThe original documentation for the sg driver (prior to lk 2.2.6) can be 53*4882a593Smuzhiyunfound at http://www.torque.net/sg/p/original/SCSI-Programming-HOWTO.txt 54*4882a593Smuzhiyunand in the LDP archives. 55*4882a593Smuzhiyun 56*4882a593SmuzhiyunA changelog with brief notes can be found in the 57*4882a593Smuzhiyun/usr/src/linux/include/scsi/sg.h file. Note that the glibc maintainers copy 58*4882a593Smuzhiyunand edit this file (removing its changelog for example) before placing it 59*4882a593Smuzhiyunin /usr/include/scsi/sg.h . Driver debugging information and other notes 60*4882a593Smuzhiyuncan be found at the top of the /usr/src/linux/drivers/scsi/sg.c file. 61*4882a593Smuzhiyun 62*4882a593SmuzhiyunA more general description of the Linux SCSI subsystem of which sg is a 63*4882a593Smuzhiyunpart can be found at http://www.tldp.org/HOWTO/SCSI-2.4-HOWTO . 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun 66*4882a593SmuzhiyunExample code and utilities 67*4882a593Smuzhiyun========================== 68*4882a593SmuzhiyunThere are two packages of sg utilities: 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun ========= ========================================================== 71*4882a593Smuzhiyun sg3_utils for the sg version 3 driver found in lk 2.4 72*4882a593Smuzhiyun sg_utils for the sg version 2 (and original) driver found in lk 2.2 73*4882a593Smuzhiyun and earlier 74*4882a593Smuzhiyun ========= ========================================================== 75*4882a593Smuzhiyun 76*4882a593SmuzhiyunBoth packages will work in the lk 2.4 series however sg3_utils offers more 77*4882a593Smuzhiyuncapabilities. They can be found at: http://sg.danny.cz/sg/sg3_utils.html and 78*4882a593Smuzhiyunfreecode.com 79*4882a593Smuzhiyun 80*4882a593SmuzhiyunAnother approach is to look at the applications that use the sg driver. 81*4882a593SmuzhiyunThese include cdrecord, cdparanoia, SANE and cdrdao. 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun 84*4882a593SmuzhiyunMapping of Linux kernel versions to sg driver versions 85*4882a593Smuzhiyun====================================================== 86*4882a593SmuzhiyunHere is a list of linux kernels in the 2.4 series that had new version 87*4882a593Smuzhiyunof the sg driver: 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun - lk 2.4.0 : sg version 3.1.17 90*4882a593Smuzhiyun - lk 2.4.7 : sg version 3.1.19 91*4882a593Smuzhiyun - lk 2.4.10 : sg version 3.1.20 [#]_ 92*4882a593Smuzhiyun - lk 2.4.17 : sg version 3.1.22 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun.. [#] There were 3 changes to sg version 3.1.20 by third parties in the 95*4882a593Smuzhiyun next six linux kernel versions. 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunFor reference here is a list of linux kernels in the 2.2 series that had 98*4882a593Smuzhiyunnew version of the sg driver: 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun - lk 2.2.0 : original sg version [with no version number] 101*4882a593Smuzhiyun - lk 2.2.6 : sg version 2.1.31 102*4882a593Smuzhiyun - lk 2.2.8 : sg version 2.1.32 103*4882a593Smuzhiyun - lk 2.2.10 : sg version 2.1.34 [SG_GET_VERSION_NUM ioctl first appeared] 104*4882a593Smuzhiyun - lk 2.2.14 : sg version 2.1.36 105*4882a593Smuzhiyun - lk 2.2.16 : sg version 2.1.38 106*4882a593Smuzhiyun - lk 2.2.17 : sg version 2.1.39 107*4882a593Smuzhiyun - lk 2.2.20 : sg version 2.1.40 108*4882a593Smuzhiyun 109*4882a593SmuzhiyunThe lk 2.5 development series has recently commenced and it currently 110*4882a593Smuzhiyuncontains sg version 3.5.23 which is functionally equivalent to sg 111*4882a593Smuzhiyunversion 3.1.22 found in lk 2.4.17. 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun 114*4882a593SmuzhiyunDouglas Gilbert 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun26th January 2002 117*4882a593Smuzhiyun 118*4882a593Smuzhiyundgilbert@interlog.com 119