3 openscsi, closescsi, scsiready, scsi, scsicmd, scsierror \- SCSI device operations
22 Scsi* openscsi(char *devdir)
25 void closescsi(Scsi *s)
28 int scsiready(Scsi *s)
31 int scsi(Scsi *s, uchar *cmd, int ncmd,
33 void *data, int ndata, int dir)
36 int scsicmd(Scsi *s, uchar *cmd, int ncmd,
38 void *data, int ndata, int dir)
41 char* scsierror(int asc, int ascq)
46 These routines provide an interface
47 to a SCSI or ATAPI device via
51 attempts to open the file
53 and use it to send raw SCSI commands.
54 On success, it reads the device's inquiry
55 string and stores it in
61 closes the connection and frees the
66 sends the ``unit ready'' command up to three times,
67 returning zero if the unit responds that it is ready,
71 returns a textual description of the SCSI status
72 denoted by the ASC and ASCQ sense codes.
73 The description is found by consulting
74 .BR /sys/lib/scsicodes .
75 The returned string will be overwritten by
82 execute a single SCSI command on the named device.
92 a successful operation
97 returning the number of bytes stored.
106 are transmitted as the data argument to
108 number of bytes written is returned.
123 simply issues the command and
126 works a bit harder and
127 is the more commonly used routine.
129 attempts to send the command;
137 sends a request sense command to
138 obtain the reason for the failure,
139 sends a unit ready command in
140 an attempt to bring the unit out of any
141 inconsistent states, and tries again.
142 If the second try fails,
145 sense and unit ready commands
151 with a reason for failure.
161 record the number of times a media
162 change has been detected, and the
163 time when the current media was
164 inserted into the drive (really the
165 first time a SCSI command was issued
166 after it was inserted).
167 They are maintained by
173 these commands will produce a fair
174 amount of debugging output on file descriptor 2
175 when SCSI commands fail.
178 .B /sys/lib/scsicodes
179 List of textual messages corresponding to SCSI error codes;
183 .B /sys/src/libdisk/scsi.c