kopia lustrzana https://gitlab.com/sane-project/website
82 wiersze
3.6 KiB
HTML
82 wiersze
3.6 KiB
HTML
<!-- received="Thu Sep 2 07:57:26 1999 PDT" -->
|
|
<!-- sent="Thu, 02 Sep 1999 11:05:39 -0400" -->
|
|
<!-- name="Douglas Gilbert" -->
|
|
<!-- email="dgilbert@interlog.com" -->
|
|
<!-- subject="Re: SG_BIG_BUFF, glibc 2.1 weirdness ..." -->
|
|
<!-- id="" -->
|
|
<!-- inreplyto="SG_BIG_BUFF, glibc 2.1 weirdness ..." -->
|
|
<title>sane-devel: Re: SG_BIG_BUFF, glibc 2.1 weirdness ...</title>
|
|
<h1>Re: SG_BIG_BUFF, glibc 2.1 weirdness ...</h1>
|
|
<b>Douglas Gilbert</b> (<a href="mailto:dgilbert@interlog.com"><i>dgilbert@interlog.com</i></a>)<br>
|
|
<i>Thu, 02 Sep 1999 11:05:39 -0400</i>
|
|
<p>
|
|
<ul>
|
|
<li> <b>Messages sorted by:</b> <a href="date.html#9">[ date ]</a><a href="index.html#9">[ thread ]</a><a href="subject.html#9">[ subject ]</a><a href="author.html#9">[ author ]</a>
|
|
<!-- next="start" -->
|
|
<li> <b>Next message:</b> <a href="0010.html">John Garrison: "Scanner help"</a>
|
|
<li> <b>Previous message:</b> <a href="0008.html">Petter Reinholdtsen: "Re: net problem"</a>
|
|
<!-- nextthread="start" -->
|
|
<!-- reply="end" -->
|
|
</ul>
|
|
<!-- body="start" -->
|
|
abel deuring wrote:<br>
|
|
<i>> </i><br>
|
|
<i>> Hi Andreas!</i><br>
|
|
<i>> </i><br>
|
|
<i>> [snip, discussion about SG_BIG_BUFF in Linux]</i><br>
|
|
<i>> </i><br>
|
|
<i>> > > + ioctl(fd, SG_SET_RESERVED_SIZE, &ioctl_val);</i><br>
|
|
<i>> > > + if (0 == ioctl(fd, SG_GET_RESERVED_SIZE, &ioctl_val))</i><br>
|
|
<i>> > > + sanei_scsi_max_request_size = ioctl_val;</i><br>
|
|
<i>> ></i><br>
|
|
<i>> > What exactly happens when the set fails ? Downgrade to maximum possible</i><br>
|
|
<i>> > value, or keep default ?</i><br>
|
|
<i>> </i><br>
|
|
<i>> Don't ask me -- the idea of the get call is to retrieve the actual</i><br>
|
|
<i>> buffer size. We should ask Douglas for the exact behaviour. (BTW, it</i><br>
|
|
<i>> seems that an "else" for the "get" call is missing: if it fails,</i><br>
|
|
<i>> sanei_scsi_open should return an error.)</i><br>
|
|
<br>
|
|
The SG_SET_RESERVED_SIZE ioctl() fails in only a few<br>
|
|
"special cases":<br>
|
|
- the reserved buffer is currently in use (EBUSY)<br>
|
|
- user doesn't have write permission on device (EACCESS)<br>
|
|
- bad pointer given as 3rd argument to ioctl()<br>
|
|
<p>
|
|
Otherwise it will try and obtain the requested amount of<br>
|
|
memory for the "reserved buffer" and if that fails, halve<br>
|
|
the requested amount and try again. When the requested <br>
|
|
amount drops below PAGE_SIZE (4KB on i386) it gives up<br>
|
|
and sets the reserved buffer size to 0. If the ioctl()<br>
|
|
gets past the above 3 "special cases" then it returns 0.<br>
|
|
<p>
|
|
So with this type of algorithm, it becomes important to call<br>
|
|
SG_GET_RESERVED_SIZE after the "SET" to see how much was<br>
|
|
actually allocated. Perhaps this should be made clearer in<br>
|
|
my documentation.<br>
|
|
<p>
|
|
Note that even if the reserved buffer size is 0 (or lower<br>
|
|
than requested) it may still be possible to do a write()<br>
|
|
without a ENOMEM if there is enough memory about when the<br>
|
|
write() is executed. On the other hand, there is only one<br>
|
|
reserved buffer per file descriptor so when it is taken<br>
|
|
(eg during command queuing) then ENOMEM errors are possible<br>
|
|
from subsequent queued write()s.<br>
|
|
<p>
|
|
Doug Gilbert<br>
|
|
<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="0010.html">John Garrison: "Scanner help"</a>
|
|
<li> <b>Previous message:</b> <a href="0008.html">Petter Reinholdtsen: "Re: net problem"</a>
|
|
<!-- nextthread="start" -->
|
|
<!-- reply="end" -->
|
|
</ul>
|