Subject: Re: Amanda patches
To: Bill Squier <groo@cs.stevens-tech.edu>
From: Manuel Bouyer <bouyer@asim.lip6.fr>
List: tech-pkg
Date: 03/07/2000 09:36:11
--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii

On Mon, Mar 06, 2000 at 04:21:38PM -0500, Bill Squier wrote:
> PR pkg/8651 has been outstanding for a while, and I've been applying a patch
> from my private patch tree to get around it.  I cleaned it up so it should work
> on both -current and older systems.
> 
> I took the cheap and easy route and patched scsi-chio.c to use the *old* ioctl
> on newer systems.  Can those with SCSI changers running 1.[34].x as well as
> post-comdex -current (>= 1.4M) test the new package and make sure it works
> for you?  Unfortunately I do not own a scsi tape changer.

Some time ago I posted patches to tech-pkg that uses the new ioctl, but I don't
think the last version (<20000127163302.A17359@antioche.lip6.fr>) has been
tested by anyone :( 
I attached the patch.

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
--

--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-ai

$NetBSD: patch-ad,v 1.1 1999/04/21 14:14:33 agc Exp $

--- changer-src/scsi-chio.c.orig	Wed Jul  8 06:04:04 1998
+++ changer-src/scsi-chio.c	Thu Jan 27 16:28:15 2000
@@ -119,26 +119,27 @@
  */
 int isempty(int fd, int slot)
 {
+struct changer_element_status_request ces_rq;
 struct changer_element_status  ces;
-int                            i,rc;
-int type=CHET_ST;
+int                            rc;
 
     get_changer_info(fd);
 
-    ces.ces_type = type;
-    ces.ces_data = malloc(changer_info.cp_nslots);
+    ces_rq.cesr_type = CHET_ST;
+    ces_rq.cesr_unit = slot;
+    ces_rq.cesr_count = 1;
+    ces_rq.cesr_flags = 0;
+    ces_rq.cesr_data = &ces;
+    ces_rq.cesr_vendor_data = NULL;
 
     rc = ioctl(fd, CHIOGSTATUS, &ces);
     if (rc) {
-	fprintf(stderr,"%s: changer status query failed: 0x%x %s\n",
+	fprintf(stderr,"%s: changer status query failed (isempty): 0x%x %s\n",
 			get_pname(), rc,strerror(errno));
 	return -1;
     }
 
-    i = ces.ces_data[slot] & CESTATUS_FULL;
-
-    free(ces.ces_data);
-    return !i;
+    return ((ces.ces_flags & CESTATUS_FULL) == 0);
 }
 
 /*
@@ -146,26 +147,31 @@
  */
 int find_empty(int fd)
 {
-struct changer_element_status  ces;
-int                            i,rc;
-int type=CHET_ST;
+struct changer_element_status_request ces_rq;
+int                            rc, i;
 
     get_changer_info(fd);
 
-    ces.ces_type = type;
-    ces.ces_data = malloc(changer_info.cp_nslots);
+    ces_rq.cesr_type = CHET_ST;
+    ces_rq.cesr_unit = 0;
+    ces_rq.cesr_count = changer_info.cp_nslots;
+    ces_rq.cesr_flags = 0;
+    ces_rq.cesr_data = malloc(sizeof(struct changer_element_status) *
+	changer_info.cp_nslots);
+    ces_rq.cesr_vendor_data = NULL;
 
-    rc = ioctl(fd,CHIOGSTATUS,&ces);
+    rc = ioctl(fd,CHIOGSTATUS,&ces_rq);
     if (rc) {
-	fprintf(stderr,"%s: changer status query failed: 0x%x %s\n",
+	fprintf(stderr,"%s: changer status query failed (find_empty): 0x%x %s\n",
 			get_pname(), rc, strerror(errno));
 	return -1;
     }
 
     i = 0; 
-    while ((i < changer_info.cp_nslots)&&(ces.ces_data[i] & CESTATUS_FULL))
+    while ((i < changer_info.cp_nslots) &&
+	(ces_rq.cesr_data[i].ces_flags & CESTATUS_FULL))
 	i++;
-    free(ces.ces_data);
+    free(ces_rq.cesr_data);
     return i;
 }
 
@@ -174,26 +180,27 @@
  */
 int drive_loaded(int fd, int drivenum)
 {
+struct changer_element_status_request ces_rq;
 struct changer_element_status  ces;
-int                            i,rc;
-int type=CHET_DT;
+int                            rc;
 
     get_changer_info(fd);
 
-    ces.ces_type = type;
-    ces.ces_data = malloc(changer_info.cp_ndrives);
+    ces_rq.cesr_type = CHET_DT;
+    ces_rq.cesr_unit = drivenum;
+    ces_rq.cesr_count = 1;
+    ces_rq.cesr_flags = 0;
+    ces_rq.cesr_data = &ces;
+    ces_rq.cesr_vendor_data = NULL;
 
-    rc = ioctl(fd, CHIOGSTATUS, &ces);
+    rc = ioctl(fd, CHIOGSTATUS, &ces_rq);
     if (rc) {
-	fprintf(stderr,"%s: drive status query failed: 0x%x %s\n",
+	fprintf(stderr,"%s: drive status query failed (drive_loaded): 0x%x %s\n",
 			get_pname(), rc, strerror(errno));
 	return -1;
     }
 
-    i = (ces.ces_data[drivenum] & CESTATUS_FULL);
-
-    free(ces.ces_data);
-    return i;
+    return (ces.ces_flags & CESTATUS_FULL);
 }
 
 
@@ -202,7 +209,7 @@
  */
 int unload(int fd, int drive, int slot)
 {
-struct changer_move  move;
+struct changer_move_request  move;
 int rc;
 
     move.cm_fromtype = CHET_DT;
@@ -226,7 +233,7 @@
  */
 int load(int fd, int drive, int slot)
 {
-struct changer_move  move;
+struct changer_move_request  move;
 int rc;
 
     move.cm_fromtype = CHET_ST;

--IS0zKkzwUGydFO0o--