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

111 wiersze
4.6 KiB
HTML

<!-- received="Mon Jan 25 21:33:16 1999 PST" -->
<!-- sent="Mon, 25 Jan 1999 22:28:39 -0700 (MST)" -->
<!-- name="Andreas Dilger" -->
<!-- email="adilger@enel.ucalgary.ca" -->
<!-- subject="Re: SG_BIG_BUFF woes on Linux" -->
<!-- id="199901260528.WAA01076@andreas.dilger.net" -->
<!-- inreplyto="Pine.LNX.3.96.990125102334.27890A-100000@cornea.retina.net" -->
<title>sane-devel: Re: SG_BIG_BUFF woes on Linux</title>
<h1>Re: SG_BIG_BUFF woes on Linux</h1>
<b>Andreas Dilger</b> (<a href="mailto:adilger@enel.ucalgary.ca"><i>adilger@enel.ucalgary.ca</i></a>)<br>
<i>Mon, 25 Jan 1999 22:28:39 -0700 (MST)</i>
<p>
<ul>
<li> <b>Messages sorted by:</b> <a href="date.html#221">[ date ]</a><a href="index.html#221">[ thread ]</a><a href="subject.html#221">[ subject ]</a><a href="author.html#221">[ author ]</a>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0222.html">Gerald Turner: "Re: SG_BIG_BUFF woes on Linux"</a>
<li> <b>Previous message:</b> <a href="0220.html">Cory Kempf: "SANE 1.0 broken on FreeBSD-Current"</a>
<!-- nextthread="start" -->
<li> <b>Next in thread:</b> <a href="0222.html">Gerald Turner: "Re: SG_BIG_BUFF woes on Linux"</a>
<li> <b>Reply:</b> <a href="0222.html">Gerald Turner: "Re: SG_BIG_BUFF woes on Linux"</a>
<!-- reply="end" -->
</ul>
<!-- body="start" -->
Gerald Turner writes:<br>
<i>&gt; This function would indeed be nice, but the value is only used once to</i><br>
<i>&gt; create this structure:</i><br>
<i>&gt; </i><br>
<i>&gt; static struct req</i><br>
<i>&gt; {</i><br>
<i>&gt; int fd;</i><br>
<i>&gt; u_int running:1, done:1;</i><br>
<i>&gt; SANE_Status status;</i><br>
<i>&gt; size_t *dst_len;</i><br>
<i>&gt; void *dst;</i><br>
<i>&gt; struct</i><br>
<i>&gt; {</i><br>
<i>&gt; struct sg_header hdr;</i><br>
<i>&gt; u_int8_t data[SG_BIG_BUFF];</i><br>
<i>&gt; }</i><br>
<i>&gt; cdb;</i><br>
<i>&gt; struct req *next;</i><br>
<i>&gt; }</i><br>
<p>
Not quite true. It appears that SG_BIG_BUFF is also used to set the value:<br>
<p>
<i>&gt; #ifdef SG_BIG_BUFF</i><br>
<i>&gt; # define MAX_DATA SG_BIG_BUFF</i><br>
<i>&gt; #endif</i><br>
.<br>
.<br>
.<br>
<i>&gt; int sanei_scsi_max_request_size = MAX_DATA;</i><br>
<p>
so it would be possible to have a function which returns this value. If I<br>
look farther down in sanei_scsi.c, I see that:<br>
<p>
#if USE == LINUX_INTERFACE<br>
if (first_time)<br>
{<br>
char buf[32];<br>
size_t len;<br>
int fd;<br>
<p>
first_time = 0;<br>
<p>
fd = open ("/proc/sys/kernel/sg-big-buff", O_RDONLY);<br>
if (fd &gt; 0 &amp;&amp; (len = read (fd, buf, sizeof (buf) - 1)) &gt; 0)<br>
{<br>
buf[len] = '\0';<br>
sanei_scsi_max_request_size = atoi (buf);<br>
DBG (1, "sanei_scsi_open: sanei_scsi_max_request_size=%d bytes\n",<br>
sanei_scsi_max_request_size);<br>
}<br>
}<br>
#endif<br>
<p>
so it appears we are already doing what everyone wanted to do (ie have<br>
dynamic SG_BIG_BUFF for Linux), at least partially. However, we still<br>
have a fixed value for the size of the buffer in req-&gt;cdb.data, which<br>
can easily be changed to req-&gt;cdb-&gt;data in all occurrences, and simply<br>
change the type of cdb.data to be *u_int8_t, and malloc cdb.data in <br>
sanei_scsi_req_enter() and free it in ??? - where are req structs freed?<br>
<p>
I'm not 100% sure this will work, since it is possible that the SCSI IOCTL<br>
which needs the format of the cdb struct as-is. Will have to dig deeper...<br>
<p>
Cheers, Andreas<br>
<pre>
--
Andreas Dilger University of Calgary \ "If a man ate a pound of pasta and
Micronet Research Group \ a pound of antipasto, would they
Dept of Electrical &amp; Computer Engineering \ cancel out, leaving him still
&lt;<a href="http://www-mddsp.enel.ucalgary.ca/People/adilger/">http://www-mddsp.enel.ucalgary.ca/People/adilger/</a>&gt; hungry?" -- Dogbert
<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="0222.html">Gerald Turner: "Re: SG_BIG_BUFF woes on Linux"</a>
<li> <b>Previous message:</b> <a href="0220.html">Cory Kempf: "SANE 1.0 broken on FreeBSD-Current"</a>
<!-- nextthread="start" -->
<li> <b>Next in thread:</b> <a href="0222.html">Gerald Turner: "Re: SG_BIG_BUFF woes on Linux"</a>
<li> <b>Reply:</b> <a href="0222.html">Gerald Turner: "Re: SG_BIG_BUFF woes on Linux"</a>
<!-- reply="end" -->
</ul>