Subject: Re: amanda
To: maximum entropy <entropy@zippy.bernstein.com>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-pkg
Date: 01/27/2000 16:33:02
--W/nzBZO5zC0uMSeA
Content-Type: text/plain; charset=us-ascii

On Thu, Jan 27, 2000 at 06:00:57AM -0500, maximum entropy wrote:
> Thanks.  With your configuration I still have no luck:
> 
> $ chio ielem
> $ chio status
> picker 0: <FULL>
> slot 0: <FULL>
> slot 1: <FULL>
> slot 2: <FULL>
> slot 3: <FULL>
> slot 4: <FULL>
> slot 5: <FULL>
> slot 6: <FULL>
> slot 7: <FULL>
> slot 8: <FULL>
> slot 9: <FULL>
> slot 10: <FULL>
> slot 11: <FULL>
> portal 0: <INEAB,EXENAB>
> drive 0: <ACCESS>
> $ amtape manuel reset
> amtape: could not reset changer: changer status query failed: 0xffffffff Invalid argument

I think I've found the problem, a field in the structure is not initialized.
Could you try the attached file in place of
amanda-server/patches/patch-ai ? (you need to re-run makepatchsum)

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

--W/nzBZO5zC0uMSeA
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;

--W/nzBZO5zC0uMSeA--