sane-project-website/old-archive/1999-01/0222.html

122 wiersze
5.5 KiB
HTML

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

<!-- received="Tue Jan 26 00:04:40 1999 PST" -->
<!-- sent="Tue, 26 Jan 1999 00:08:21 -0800 (PST)" -->
<!-- name="Gerald Turner" -->
<!-- email="gturner@retina.net" -->
<!-- subject="Re: SG_BIG_BUFF woes on Linux" -->
<!-- id="" -->
<!-- inreplyto="199901260528.WAA01076@andreas.dilger.net" -->
<title>sane-devel: Re: SG_BIG_BUFF woes on Linux</title>
<h1>Re: SG_BIG_BUFF woes on Linux</h1>
<b>Gerald Turner</b> (<a href="mailto:gturner@retina.net"><i>gturner@retina.net</i></a>)<br>
<i>Tue, 26 Jan 1999 00:08:21 -0800 (PST)</i>
<p>
<ul>
<li> <b>Messages sorted by:</b> <a href="date.html#222">[ date ]</a><a href="index.html#222">[ thread ]</a><a href="subject.html#222">[ subject ]</a><a href="author.html#222">[ author ]</a>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0223.html">Mentore #cat# Siesto: "FAQ (Was Re: Parallel port Scanners)"</a>
<li> <b>Previous message:</b> <a href="0221.html">Andreas Dilger: "Re: SG_BIG_BUFF woes on Linux"</a>
<li> <b>In reply to:</b> <a href="0221.html">Andreas Dilger: "Re: SG_BIG_BUFF woes on Linux"</a>
<!-- nextthread="start" -->
<!-- reply="end" -->
</ul>
<!-- body="start" -->
On Mon, 25 Jan 1999, Andreas Dilger wrote:<br>
<p>
<i>&gt; Gerald Turner writes:</i><br>
<i>&gt; &gt; This function would indeed be nice, but the value is only used once to</i><br>
<i>&gt; &gt; create this structure:</i><br>
<i>&gt; &gt; </i><br>
<i>&gt; &gt; static struct req</i><br>
<i>&gt; &gt; {</i><br>
<i>&gt; &gt; int fd;</i><br>
<i>&gt; &gt; u_int running:1, done:1;</i><br>
<i>&gt; &gt; SANE_Status status;</i><br>
<i>&gt; &gt; size_t *dst_len;</i><br>
<i>&gt; &gt; void *dst;</i><br>
<i>&gt; &gt; struct</i><br>
<i>&gt; &gt; {</i><br>
<i>&gt; &gt; struct sg_header hdr;</i><br>
<i>&gt; &gt; u_int8_t data[SG_BIG_BUFF];</i><br>
<i>&gt; &gt; }</i><br>
<i>&gt; &gt; cdb;</i><br>
<i>&gt; &gt; struct req *next;</i><br>
<i>&gt; &gt; }</i><br>
<i>&gt; </i><br>
<i>&gt; Not quite true. It appears that SG_BIG_BUFF is also used to set the value:</i><br>
<i>&gt; </i><br>
<i>&gt; &gt; #ifdef SG_BIG_BUFF</i><br>
<i>&gt; &gt; # define MAX_DATA SG_BIG_BUFF</i><br>
<i>&gt; &gt; #endif</i><br>
<i>&gt; .</i><br>
<i>&gt; .</i><br>
<i>&gt; .</i><br>
<i>&gt; &gt; int sanei_scsi_max_request_size = MAX_DATA;</i><br>
<i>&gt; </i><br>
<i>&gt; so it would be possible to have a function which returns this value. If I</i><br>
<i>&gt; look farther down in sanei_scsi.c, I see that:</i><br>
<i>&gt; </i><br>
<i>&gt; #if USE == LINUX_INTERFACE</i><br>
<i>&gt; if (first_time)</i><br>
<i>&gt; {</i><br>
<i>&gt; char buf[32];</i><br>
<i>&gt; size_t len;</i><br>
<i>&gt; int fd;</i><br>
<i>&gt; </i><br>
<i>&gt; first_time = 0;</i><br>
<i>&gt; </i><br>
<i>&gt; fd = open ("/proc/sys/kernel/sg-big-buff", O_RDONLY);</i><br>
<i>&gt; if (fd &gt; 0 &amp;&amp; (len = read (fd, buf, sizeof (buf) - 1)) &gt; 0)</i><br>
<i>&gt; {</i><br>
<i>&gt; buf[len] = '\0';</i><br>
<i>&gt; sanei_scsi_max_request_size = atoi (buf);</i><br>
<i>&gt; DBG (1, "sanei_scsi_open: sanei_scsi_max_request_size=%d bytes\n",</i><br>
<i>&gt; sanei_scsi_max_request_size);</i><br>
<i>&gt; }</i><br>
<i>&gt; }</i><br>
<i>&gt; #endif</i><br>
<p>
I can't believe I completely overlooked this, it appears that the changes<br>
that I was talking about are already here (Oops!). In the case of Linux<br>
sanei_scsi_max_request_size is set to SG_BIG_BUFF and then later it is set<br>
to /proc/sys/kernel/sg-big-buff, just as I was requesting.<br>
<br>
<p>
<i>&gt; so it appears we are already doing what everyone wanted to do (ie have</i><br>
<i>&gt; dynamic SG_BIG_BUFF for Linux), at least partially. However, we still</i><br>
<i>&gt; have a fixed value for the size of the buffer in req-&gt;cdb.data, which</i><br>
<i>&gt; can easily be changed to req-&gt;cdb-&gt;data in all occurrences, and simply</i><br>
<i>&gt; change the type of cdb.data to be *u_int8_t, and malloc cdb.data in </i><br>
<i>&gt; sanei_scsi_req_enter() and free it in ??? - where are req structs freed?</i><br>
<i>&gt; </i><br>
<i>&gt; I'm not 100% sure this will work, since it is possible that the SCSI IOCTL</i><br>
<i>&gt; which needs the format of the cdb struct as-is. Will have to dig deeper...</i><br>
<p>
Great! I just greped through the source a bit, and it looks like cdb.data<br>
element is only used in two places (both memcpy()) and as for cdb being<br>
used in IOCTL, I don't think so, the cdb.hdr element, is the only part<br>
that probably needs to be as-is. Perhaps the structures could be freed<br>
in sanei_scsi_close(). Of course I may be overlooking something again,<br>
I'm too tired now, but maybe tomorrow, I will actually modify some code<br>
and see if I can get it working this way.<br>
<p>
Thank you,<br>
Gerald Turner<br>
<a href="http://www.retina.net/~gturner/">http://www.retina.net/~gturner/</a><br>
<p>
<p>
<pre>
--
Source code, list archive, and docs: <a href="http://www.mostang.com/sane/">http://www.mostang.com/sane/</a>
To unsubscribe: echo unsubscribe sane-devel | mail <a href="mailto:majordomo@mostang.com">majordomo@mostang.com</a>
</pre>
<!-- body="end" -->
<p>
<ul>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0223.html">Mentore #cat# Siesto: "FAQ (Was Re: Parallel port Scanners)"</a>
<li> <b>Previous message:</b> <a href="0221.html">Andreas Dilger: "Re: SG_BIG_BUFF woes on Linux"</a>
<li> <b>In reply to:</b> <a href="0221.html">Andreas Dilger: "Re: SG_BIG_BUFF woes on Linux"</a>
<!-- nextthread="start" -->
<!-- reply="end" -->
</ul>