[sane-devel] make errors with 1.07

abel deuring a.deuring@satzbau-gmbh.de
Sat, 09 Mar 2002 20:06:21 +0100


john meshkoff wrote:
> 
> abel deuring wrote:
> > That's my fault. When I fiddled with the error handling in sanei_scsi.c,
> > I forgot that old versions of sg.h did not have the fields host_status,
> > driver_status and target_status.
> >
> > As a quick fix, you can change the lines 2079 ff in sanei_scsi.c from:
> >
> > if (   req->sgdata.cdb.hdr.host_status == DID_NO_CONNECT
> >     || req->sgdata.cdb.hdr.host_status == DID_BUS_BUSY
> >     || req->sgdata.cdb.hdr.host_status == DID_TIME_OUT
> >     || req->sgdata.cdb.hdr.driver_status == DRIVER_BUSY
> >     || req->sgdata.cdb.hdr.target_status == 0x04) /* BUSY */
> > /* if (req->sgdata.cdb.hdr.result == EBUSY) */
> >   status = SANE_STATUS_DEVICE_BUSY;
> >
> > to
> >
> > /* if (   req->sgdata.cdb.hdr.host_status == DID_NO_CONNECT
> >     || req->sgdata.cdb.hdr.host_status == DID_BUS_BUSY
> >     || req->sgdata.cdb.hdr.host_status == DID_TIME_OUT
> >     || req->sgdata.cdb.hdr.driver_status == DRIVER_BUSY
> >     || req->sgdata.cdb.hdr.target_status == 0x04) BUSY */
> > if (req->sgdata.cdb.hdr.result == EBUSY)
> >   status = SANE_STATUS_DEVICE_BUSY;
> >
> 
>         I'm no programmer, but I think I can handle that.
> 
> > For a general fix, this should be done with configure, I think.
> >
> 
>         I don't quite understand what that would entail.

John,

sorry, I was mixing "two audiences" in my mail; I didn't intend to
bother you with the innards of configure. What I meant is: If the patch
above for you, I'd like to get some help from somebody who has some
experience in, errrm, "configuring the configure script" (Henning?) so
that configure automatically checks, which version of sg.h is available.
Then we can use the fields host_status etc, if they are available, while
other people who like you prefer to use an older version of the Linux
kernel and its associated C header files will be able to compile recent
versions of Sane without stumbling over a compiler error.

> 
> > The information from host_status and friends is quite useful, both for a
> > better error handling and for diagnosis, if sanei_scsi has a bug or if
> > something goes wrong inside the kernel, so I'd like to use these fields
> > if possible. The problem is that I am not very familiar with configure
> > -- is it possible to include a test like the following in configure?
> 
>         I don't know how to "include a test like the following in configure"; a
> hint would be helpful, but see below
> 
> >
> > - try to compile the test program:
> 
> would compiling the test program be done like this: 'gcc -o test
> test.c'?

Right, that should work. But what I meant is that the test program
should be compiled automatically by the configure script; if the
compilation is successful, configure should add a line "#define
HAVE_SG_TARGET_STATUS" to config.h; if the compilation fails, configure
should not add this line to config.h.

> 
> >
> > #include <sys/types.h>
> > #include <scsi/sg.h>
> > int main(int argc, char **argv)
> > {
> >   struct sg_header hdr;
> >   hdr.target_status = 1;
> >   return 0;
> > }
> >
> > - if the succeeds, define HAVE_SG_TARGET_STATUS ; enclose the lines
> > above (and a preceding DBG statement) in #ifdef HAVE_SG_TARGET_STATUS .
> >
> 
>         I've downloaded a C course from
> 
> http://www.strath.ac.uk/IT/Docs/Ccourse/ccourse.html
> 
> And will study it and try to figure out these instructions;

Uhhh, I hope that's not necessary if you only want to get Sane
installed; just moving the comment delimiters a bit around at line 2079
of sanei/sanei_scsi.c as described above is hopefully enough. But of
course I don't want to discorage you from learning C -- programming can
be fun ;) 

Abel