kopia lustrzana https://gitlab.com/sane-project/website
122 wiersze
5.5 KiB
HTML
122 wiersze
5.5 KiB
HTML
<!-- 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>> Gerald Turner writes:</i><br>
|
||
<i>> > This function would indeed be nice, but the value is only used once to</i><br>
|
||
<i>> > create this structure:</i><br>
|
||
<i>> > </i><br>
|
||
<i>> > static struct req</i><br>
|
||
<i>> > {</i><br>
|
||
<i>> > int fd;</i><br>
|
||
<i>> > u_int running:1, done:1;</i><br>
|
||
<i>> > SANE_Status status;</i><br>
|
||
<i>> > size_t *dst_len;</i><br>
|
||
<i>> > void *dst;</i><br>
|
||
<i>> > struct</i><br>
|
||
<i>> > {</i><br>
|
||
<i>> > struct sg_header hdr;</i><br>
|
||
<i>> > u_int8_t data[SG_BIG_BUFF];</i><br>
|
||
<i>> > }</i><br>
|
||
<i>> > cdb;</i><br>
|
||
<i>> > struct req *next;</i><br>
|
||
<i>> > }</i><br>
|
||
<i>> </i><br>
|
||
<i>> Not quite true. It appears that SG_BIG_BUFF is also used to set the value:</i><br>
|
||
<i>> </i><br>
|
||
<i>> > #ifdef SG_BIG_BUFF</i><br>
|
||
<i>> > # define MAX_DATA SG_BIG_BUFF</i><br>
|
||
<i>> > #endif</i><br>
|
||
<i>> .</i><br>
|
||
<i>> .</i><br>
|
||
<i>> .</i><br>
|
||
<i>> > int sanei_scsi_max_request_size = MAX_DATA;</i><br>
|
||
<i>> </i><br>
|
||
<i>> so it would be possible to have a function which returns this value. If I</i><br>
|
||
<i>> look farther down in sanei_scsi.c, I see that:</i><br>
|
||
<i>> </i><br>
|
||
<i>> #if USE == LINUX_INTERFACE</i><br>
|
||
<i>> if (first_time)</i><br>
|
||
<i>> {</i><br>
|
||
<i>> char buf[32];</i><br>
|
||
<i>> size_t len;</i><br>
|
||
<i>> int fd;</i><br>
|
||
<i>> </i><br>
|
||
<i>> first_time = 0;</i><br>
|
||
<i>> </i><br>
|
||
<i>> fd = open ("/proc/sys/kernel/sg-big-buff", O_RDONLY);</i><br>
|
||
<i>> if (fd > 0 && (len = read (fd, buf, sizeof (buf) - 1)) > 0)</i><br>
|
||
<i>> {</i><br>
|
||
<i>> buf[len] = '\0';</i><br>
|
||
<i>> sanei_scsi_max_request_size = atoi (buf);</i><br>
|
||
<i>> DBG (1, "sanei_scsi_open: sanei_scsi_max_request_size=%d bytes\n",</i><br>
|
||
<i>> sanei_scsi_max_request_size);</i><br>
|
||
<i>> }</i><br>
|
||
<i>> }</i><br>
|
||
<i>> #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>> so it appears we are already doing what everyone wanted to do (ie have</i><br>
|
||
<i>> dynamic SG_BIG_BUFF for Linux), at least partially. However, we still</i><br>
|
||
<i>> have a fixed value for the size of the buffer in req->cdb.data, which</i><br>
|
||
<i>> can easily be changed to req->cdb->data in all occurrences, and simply</i><br>
|
||
<i>> change the type of cdb.data to be *u_int8_t, and malloc cdb.data in </i><br>
|
||
<i>> sanei_scsi_req_enter() and free it in ??? - where are req structs freed?</i><br>
|
||
<i>> </i><br>
|
||
<i>> I'm not 100% sure this will work, since it is possible that the SCSI IOCTL</i><br>
|
||
<i>> 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>
|