kopia lustrzana https://gitlab.com/sane-project/website
182 wiersze
6.4 KiB
HTML
182 wiersze
6.4 KiB
HTML
<!-- received="Mon Apr 5 23:04:04 1999 PDT" -->
|
||
<!-- sent="Tue, 6 Apr 1999 08:03:27 +0200 (MET DST)" -->
|
||
<!-- name="=?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?=" -->
|
||
<!-- email="mikko@securitydynamics.com" -->
|
||
<!-- subject="Bugs & Fixes: FreeBSD, Snapscan, Sane 1.01-4" -->
|
||
<!-- id="" -->
|
||
<!-- inreplyto="" -->
|
||
<title>sane-devel: Bugs & Fixes: FreeBSD, Snapscan, Sane 1.01-4</title>
|
||
<h1>Bugs & Fixes: FreeBSD, Snapscan, Sane 1.01-4</h1>
|
||
<b>=?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?=</b> (<a href="mailto:mikko@securitydynamics.com"><i>mikko@securitydynamics.com</i></a>)<br>
|
||
<i>Tue, 6 Apr 1999 08:03:27 +0200 (MET DST)</i>
|
||
<p>
|
||
<ul>
|
||
<li> <b>Messages sorted by:</b> <a href="date.html#94">[ date ]</a><a href="index.html#94">[ thread ]</a><a href="subject.html#94">[ subject ]</a><a href="author.html#94">[ author ]</a>
|
||
<!-- next="start" -->
|
||
<li> <b>Next message:</b> <a href="0095.html">killian@lucent.com: "Epson GT-7000"</a>
|
||
<li> <b>Previous message:</b> <a href="0093.html">De Clarke: "Bernd's patch for pre 1.01-4 for microtek2"</a>
|
||
<!-- nextthread="start" -->
|
||
<!-- reply="end" -->
|
||
</ul>
|
||
<!-- body="start" -->
|
||
Hi!<br>
|
||
<p>
|
||
I finally got around to changing SCSI-cards and testing if my scanner<br>
|
||
still worked after moving to FreeBSD 3.1. Of course it didn't...<br>
|
||
But after a few sessions with truss and gdb, I can now scan again.<br>
|
||
<p>
|
||
For the records:<br>
|
||
<p>
|
||
FreeBSD 3.1, Adaptec 1542B, AGFA Snapscan 310, sane-pre1.01-4<br>
|
||
<p>
|
||
<p>
|
||
Regards,<br>
|
||
/Mikko<br>
|
||
<p>
|
||
<p>
|
||
Problem 1:<br>
|
||
<p>
|
||
The snapscan backend does not work with FreeBSD 3.1 (the CAM SCSI<br>
|
||
stuff). The reason is that CAM uses a faked fd that has nothing in<br>
|
||
common with a unix file descriptor. Consequently doing a dup2() on<br>
|
||
it will not work too well.<br>
|
||
<p>
|
||
As far as I can see there is no reason to move the scanner to stdin in<br>
|
||
the child process, and just removing the operation indeed made<br>
|
||
scanning work.<br>
|
||
<p>
|
||
NOTE: It was possible to scan with "scanimage", but that is just<br>
|
||
coincidence (the CAM device happens to be at index 0 == STDIN_FILENO)<br>
|
||
<p>
|
||
A quick grep seems to indicate that no other backend suffers<br>
|
||
from this quirk.<br>
|
||
<p>
|
||
<p>
|
||
--- backend/snapscan.c.org Mon Apr 5 14:26:47 1999<br>
|
||
+++ backend/snapscan.c Mon Apr 5 14:35:11 1999<br>
|
||
@@ -2843,10 +2843,8 @@<br>
|
||
and stdout the pipe */<br>
|
||
signal (SIGTERM, handler);<br>
|
||
reader_pss = pss;<br>
|
||
- dup2 (pss->fd, STDIN_FILENO);<br>
|
||
dup2 (pss->rpipe[1], STDOUT_FILENO);<br>
|
||
close (pss->rpipe[0]);<br>
|
||
- pss->fd = STDIN_FILENO;<br>
|
||
reader (pss);<br>
|
||
/* regular exit will cause a SIGPIPE */<br>
|
||
DBG (DL_MINOR_INFO, "Reader process terminating.\n");<br>
|
||
<p>
|
||
<p>
|
||
<p>
|
||
Problem 2:<br>
|
||
<p>
|
||
The CAM code will overflow when using "xscanimage". Every time a<br>
|
||
device is opened, a new slot in a bounded array is allocated. It is<br>
|
||
never re-used, even when the device is closed. A few previews and<br>
|
||
scans in the same "xscanimage" process is all it takes to use up all<br>
|
||
the slots, and start writing outside allocated memory.<br>
|
||
<p>
|
||
There is no need to copy the data from cam_open_device(), it is<br>
|
||
already allocated, and will be freed by cam_close_device(). In fact,<br>
|
||
copying the data will only result in a memory leak.<br>
|
||
<p>
|
||
<p>
|
||
Minor problem 2.1:<br>
|
||
<p>
|
||
The cam_open_device() function requires access to /dev/xpt0, rather<br>
|
||
than (for example) /dev/pass4, where the scanner is, as well as the<br>
|
||
device being called "pass<N>".<br>
|
||
<p>
|
||
Using cam_open_pass() instead goes directly for the pass device,<br>
|
||
saving users the headache of figuring out why it will only work when<br>
|
||
running as "root", even though anyone can read & write /dev/pass4, or<br>
|
||
why it will not work with a symlink.<br>
|
||
<p>
|
||
<p>
|
||
--- sanei/sanei_scsi.c.org Mon Apr 5 14:26:35 1999<br>
|
||
+++ sanei/sanei_scsi.c Mon Apr 5 14:58:17 1999<br>
|
||
@@ -197,7 +197,7 @@<br>
|
||
<br>
|
||
#if USE == FREEBSD_CAM_INTERFACE<br>
|
||
# define CAM_MAXDEVS 128<br>
|
||
-struct cam_device **cam_devices = NULL;<br>
|
||
+struct cam_device *cam_devices[CAM_MAXDEVS] = { NULL };<br>
|
||
#endif<br>
|
||
<br>
|
||
static struct<br>
|
||
@@ -817,23 +817,22 @@<br>
|
||
just '{' unfortunately, this only works if all of<br>
|
||
the '{' are that way. */<br>
|
||
<br>
|
||
- static int unit = -1;<br>
|
||
- struct cam_device* curdev = NULL;<br>
|
||
+ struct cam_device *curdev;<br>
|
||
<br>
|
||
- fake_fd = -1;<br>
|
||
+ fake_fd = 1;<br>
|
||
fd = -1;<br>
|
||
<br>
|
||
- if(cam_devices == NULL) {<br>
|
||
- size_t ary_sz = sizeof(struct cam_device*) * (CAM_MAXDEVS + 1);<br>
|
||
- cam_devices = malloc(ary_sz);<br>
|
||
- bzero(cam_devices, ary_sz);<br>
|
||
- unit = -1; /* redundant, I know. */<br>
|
||
- }<br>
|
||
+ if((curdev = cam_open_pass(dev, O_RDWR, NULL)) != NULL) {<br>
|
||
+ for (fd = 0; fd < CAM_MAXDEVS && cam_devices[fd] != NULL; fd++)<br>
|
||
+ ;<br>
|
||
<br>
|
||
- if((curdev = cam_open_device(dev, O_RDWR)) != NULL) {<br>
|
||
- cam_devices[++unit] = malloc(sizeof(struct cam_device));<br>
|
||
- bcopy(curdev, cam_devices[unit], sizeof(struct cam_device));<br>
|
||
- fd = unit;<br>
|
||
+ if (fd == CAM_MAXDEVS)<br>
|
||
+ {<br>
|
||
+ DBG(1, "sanei_scsi_open: too many CAM devices (%d)\n", fd);<br>
|
||
+ cam_close_device(curdev);<br>
|
||
+ return SANE_STATUS_INVAL;<br>
|
||
+ }<br>
|
||
+ cam_devices[fd] = curdev;<br>
|
||
}<br>
|
||
else {<br>
|
||
DBG(1, "sanei_scsi_open: device %s not found\n",<br>
|
||
@@ -969,7 +968,8 @@<br>
|
||
close (fd);<br>
|
||
<br>
|
||
#if USE == FREEBSD_CAM_INTERFACE<br>
|
||
- cam_close_device(cam_devices[fd]);<br>
|
||
+ cam_close_device(cam_devices[fd]);<br>
|
||
+ cam_devices[fd] = NULL;<br>
|
||
#elif USE == DOMAINOS_INTERFACE<br>
|
||
{<br>
|
||
static int index;<br>
|
||
@@ -1689,7 +1689,7 @@<br>
|
||
char* data_buf;<br>
|
||
size_t data_len;<br>
|
||
<br>
|
||
- if (fd < 0) {<br>
|
||
+ if (fd < 0 || fd > CAM_MAXDEVS || cam_devices[fd] != NULL) {<br>
|
||
fprintf(stderr, "attempt to reference invalid unit %d\n", fd);<br>
|
||
return SANE_STATUS_INVAL;<br>
|
||
}<br>
|
||
<p>
|
||
<p>
|
||
Mikko Tyo"la"ja"rvi________________________________mikko@securitydynamics.com<br>
|
||
SecurityDynamics<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="0095.html">killian@lucent.com: "Epson GT-7000"</a>
|
||
<li> <b>Previous message:</b> <a href="0093.html">De Clarke: "Bernd's patch for pre 1.01-4 for microtek2"</a>
|
||
<!-- nextthread="start" -->
|
||
<!-- reply="end" -->
|
||
</ul>
|