Charles.Forsyth20060303-partialeea662d19 years agoHistory
144 lines · 3.1 KB · Text
RawDownload
.TH SCSIIO 2.SH NAMEScsiIO: Scsi \- SCSI device operations.SH SYNOPSIS.EXinclude "scsi.m"; scsiio := load ScsiIO ScsiIO->PATH;Scsi: adt {    inquire:    string;    rawfd:      ref Sys->FD;    nchange:    int;    changetime: int;     open:       fn(devdir: string): ref Scsi;    rawcmd:     fn(s: self ref Scsi, cmd: array of byte,                   data: array of byte, io: int): int;    cmd:        fn(s: self ref Scsi, cmd: array of byte,                   data: array of byte, io: int): int;    ready:      fn(s: self ref Scsi): int;}; Sread, Swrite, Snone: con iota; scsierror:  fn(asc: int, ascq: int): string; init:   fn(verbose: int);.EE.SH DESCRIPTION.B ScsiIOprovides a low-level interface to a SCSI or ATAPI device via.IR sd (3)..PP.B Initmust be called before using any other operation of the module.If.I verboseis non-zerothe module will produce a fairamount of debugging output on file descriptor 2when SCSI commands fail..PP.B Scsi.openattempts to open the file.IB devdir /rawon which to send raw SCSI commands.On success, it reads the device's inquirystring and returns a reference to a.B Scsivalue to represent the connection.It provides the following operations:.TP.IB s .ready()Sends the ``unit ready'' command up to three times,returning zero once the unit responds that it is ready,or \-1 on error..TP.IB s .rawcmd( "cmd, data, io" ).PD 0.TP.IB s .cmd( "cmd, data, io" )Both these functions execute a single SCSI command on the named device.The command data is in the byte array.IR cmd .If.I iois .BR Sread ,a successful operation will store the resulting bytes in.IR data ,up to its length,returning the number of bytes stored.If.I iois.BR Swrite ,the bytes in.I dataare transmitted as the data argument tothe command, and thenumber of bytes written is returned.If.I iois.BR Snone ,.I datais ignored and may be nil..B Rawcmdsimply issues the command andreturns the result;.B cmdworks a bit harder andis the more commonly used routine.It attempts to send the commmand;if it is successful, .B cmdreturns the result.Otherwise,.B cmdsends a request sense command toobtain the reason for the failure,sends a unit ready command inan attempt to bring the unit out of anyinconsistent states, and tries again.It also accounts for media change.If the second try fails,.B cmdreturns an error.On error, both functions return \-1 and set the system error string..PD.PPThe .B nchangeand.B changetimeelements of.B Scsithe number of times a mediachange has been detected, and thefirst time the current media was detected (thefirst time a SCSI command was issuedafter it was inserted).They are maintained by .BR Scsi.cmd .The initial SCSI inquiry result is kept in.BR inquire ..PP.I Scsierrorreturns a textual description of the SCSI statusdenoted by the ASC and ASCQ sense codes.The description is found by consulting.BR /lib/scsicodes ..SH FILES.TF.TP.B /lib/scsicodesList of textual messages corresponding to SCSI error codes;consulted by.BR scsierror ..SH SOURCE.B /appl/lib/scsiio.b.SH SEE ALSO.IR disks (2),.IR sd (3)