forwarded generic SCSI fixes

Heiko Eissfeldt (heiko@colossus.escape.de)
Wed, 26 Jun 1996 21:34:08 +0200 (MEST)


Hi Linuxers,

some errors in the generic SCSI driver were brought to
my attention by Massimo Dal Zotto <dz@cs.unitn.it>.

Error codes were not transparently returned to the application.

Heiko

Here are the patches:
--- sg.c.or Tue May 7 14:54:25 1996
+++ sg.c Wed Jun 26 00:39:24 1996
@@ -230,7 +230,7 @@
* Now copy the result back to the user buffer.
*/
device->header.pack_len=device->header.reply_len;
- device->header.result=0;
+
if (count>=sizeof(struct sg_header))
{
memcpy_tofs(buf,&device->header,sizeof(struct sg_header));
@@ -242,7 +242,7 @@
}
}
else
- count=0;
+ count= device->header.result==0 ? 0 : -EIO;

/*
* Clean up, and release the device so that we can send another
@@ -276,12 +276,7 @@
* wrong.
*/
memcpy(device->header.sense_buffer, SCpnt->sense_buffer, sizeof(SCpnt->sense_buffer));
- if (SCpnt->sense_buffer[0])
- {
- device->header.result=EIO;
- }
- else
- device->header.result=SCpnt->result;
+ device->header.result=SCpnt->result;

/*
* Now wake up the process that is waiting for the