Plan 9 from Bell Labs’s /usr/web/sources/contrib/ccollins/fs/fs-jukefix.patch

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/n/sources/plan9/sys/src/fs/dev/juke.c:61,66 - /sys/src/fs/dev/juke.c:61,76
  	Sstart,		/* loaded and spinning */
  };
  
+ enum
+ {
+ 	/* element types */
+ 	Eauto = 0,
+ 	Etransport = 1,
+ 	Estorage = 2,
+ 	Eimport =3,
+ 	Etransfer = 4,
+ };
+ 
  extern int FIXEDSIZE;
  
  static	int	wormsense(Device*);
/n/sources/plan9/sys/src/fs/dev/juke.c:69,75 - /sys/src/fs/dev/juke.c:79,85
  static	int	mmove(Juke*, int, int, int, int);
  static	int	bestdrive(Juke*, int);
  static	void	waitready(Device*);
- static	void	element(Juke*, int);
+ static	void	element(Juke*, int, int);
  
  /*
   * mounts and spins up the device
/n/sources/plan9/sys/src/fs/dev/juke.c:276,294 - /sys/src/fs/dev/juke.c:286,302
  	long size;
  
  	w = d->private;
- 	if(w->fixedsize) {
+ 	if(w->fixedsize)
  		size = w->fixedsize;
- 		goto out;
+ 	else {
+ 		v = wormunit(d);
+ 		if(v == 0)
+ 			return 0;
+ 		size = v->max;
+ 		qunlock(v);
+ 		if(FIXEDSIZE) // TODO? push FIXEDSIZE into Device or Juke struct
+ 			w->fixedsize = size;
  	}
- 
- 	v = wormunit(d);
- 	if(v == 0)
- 		return 0;
- 	size = v->max;
- 	qunlock(v);
- 	if(FIXEDSIZE)	// TODO? push FIXEDSIZE into Device or Juke struct
- 		w->fixedsize = size;
- out:
  	if(d->type == Devlworm)
  		return size-1;
  	return size;
/n/sources/plan9/sys/src/fs/dev/juke.c:511,518 - /sys/src/fs/dev/juke.c:519,527
  {
  	Side *v;
  	Juke *w;
- 	long l, m;
+ 	long l;
  	int s;
+ 	long m;
  	uchar cmd[10];
  
  	w = d->private;
/n/sources/plan9/sys/src/fs/dev/juke.c:600,610 - /sys/src/fs/dev/juke.c:609,619
  		if(recur == 0) {
  			recur = 1;
  			print("element from=%d\n", from);
- 			element(w, from);
+ 			element(w, from, Eauto);
  			print("element to=%d\n", to);
- 			element(w, to);
+ 			element(w, to, Eauto);
  			print("element trans=%d\n", trans);
- 			element(w, trans);
+ 			element(w, trans, Etransport);
  			recur = 0;
  		}
  		return 1;
/n/sources/plan9/sys/src/fs/dev/juke.c:638,643 - /sys/src/fs/dev/juke.c:647,655
  	w->dt0 = (buf[4+14]<<8) | buf[4+15];
  	w->ndt = (buf[4+16]<<8) | buf[4+17];
  
+ #ifdef OLD_REVERSE
+ 	w->rot = 1;
+ #else
  	memset(cmd, 0, 6);
  	memset(buf, 0, sizeof(buf));
  	cmd[0] = 0x1a;		/* mode sense */
/n/sources/plan9/sys/src/fs/dev/juke.c:647,654 - /sys/src/fs/dev/juke.c:659,666
  	s = scsiio(w->juke, SCSIread, cmd, sizeof(cmd), buf, sizeof(buf));
  	if(s)
  		panic("geometry #%x\n", s);
- 
  	w->rot = buf[4+2] & 1;
+ #endif
  
  	print("	mt %d %d\n", w->mt0, w->nmt);
  	print("	se %d %d\n", w->se0, w->nse);
/n/sources/plan9/sys/src/fs/dev/juke.c:661,675 - /sys/src/fs/dev/juke.c:673,687
  
  static
  void
- element(Juke *w, int e)
+ element(Juke *w, int e, int type)
  {
  	uchar cmd[12], buf[8+8+88];
  	int s, t;
  
- //loop:
  	memset(cmd, 0, sizeof(cmd));
  	memset(buf, 0, sizeof(buf));
  	cmd[0] = 0xb8;		/* read element status */
+ 	cmd[1] = type & 0xf; /* type */
  	cmd[2] = e>>8;		/* starting element */
  	cmd[3] = e;
  	cmd[5] = 1;		/* number of elements */
/n/sources/plan9/sys/src/fs/dev/juke.c:683,689 - /sys/src/fs/dev/juke.c:695,701
  
  	s = (buf[0]<<8) | buf[1];
  	if(s != e) {
- 		print("element = %d\n", s);
+ 		print("element = %d, != %d\n", s, e);
  		goto bad;
  	}
  	if(buf[3] != 1) {
/n/sources/plan9/sys/src/fs/dev/juke.c:690,706 - /sys/src/fs/dev/juke.c:702,719
  		print("number reported = %d\n", buf[3]);
  		goto bad;
  	}
+ 
  	s = (buf[8+8+0]<<8) | buf[8+8+1];
  	if(s != e) {
  		print("element1 = %d\n", s);
  		goto bad;
- 	}
+ 	}	
  
  	switch(buf[8+0]) {	/* element type */
  	default:
  		print("unknown element %d: %d\n", e, buf[8+0]);
  		goto bad;
- 	case 1:			/* transport */
+ 	case Etransport:			/* transport */
  		s = e - w->mt0;
  		if(s < 0 || s >= w->nmt)
  			goto bad;
/n/sources/plan9/sys/src/fs/dev/juke.c:709,715 - /sys/src/fs/dev/juke.c:722,728
  				(buf[8+8+10]<<8) | buf[8+8+11],
  				(buf[8+8+9]>>6) & 1);
  		break;
- 	case 2:			/* storage */
+ 	case Estorage:			/* storage */
  		s = e - w->se0;
  		if(s < 0 || s >= w->nse)
  			goto bad;
/n/sources/plan9/sys/src/fs/dev/juke.c:718,725 - /sys/src/fs/dev/juke.c:731,745
  			w->side[s].status = Sunload;
  		if(w->rot)
  			w->side[w->nse+s].status = w->side[s].status;
+ 
+ 		if (w->side[s].status == Sunload) {
+ 			print("media %d full\n", s);
+ 		} else {
+ 			print("media %d empty\n", s);
+ 		}
+ 
  		break;
- 	case 3:			/* import/export */
+ 	case Eimport:			/* import/export */
  		s = e - w->ie0;
  		if(s < 0 || s >= w->nie)
  			goto bad;
/n/sources/plan9/sys/src/fs/dev/juke.c:728,734 - /sys/src/fs/dev/juke.c:748,754
  			(buf[8+8+10]<<8) | buf[8+8+11],
  			(buf[8+8+9]>>6) & 1);
  		break;
- 	case 4:			/* data transfer */
+ 	case Etransfer:			/* data transfer */
  		s = e - w->dt0;
  		if(s < 0 || s >= w->ndt)
  			goto bad;
/n/sources/plan9/sys/src/fs/dev/juke.c:770,779 - /sys/src/fs/dev/juke.c:790,797
  		break;
  	}
  	return;
- 
  bad:
- //	panic("element");
- 	return;
+ 	panic("element");
  }
  
  static
/n/sources/plan9/sys/src/fs/dev/juke.c:784,796 - /sys/src/fs/dev/juke.c:802,814
  
  	/* mark empty shelves */
  	for(i=0; i<w->nse; i++)
- 		element(w, w->se0+i);
+ 		element(w, w->se0+i, Estorage);
  	for(i=0; i<w->nmt; i++)
- 		element(w, w->mt0+i);
+ 		element(w, w->mt0+i, Etransport);
  	for(i=0; i<w->nie; i++)
- 		element(w, w->ie0+i);
+ 		element(w, w->ie0+i, Eimport);
  	for(i=0; i<w->ndt; i++)
- 		element(w, w->dt0+i);
+ 		element(w, w->dt0+i, Etransfer);
  
  	f = 0;
  	for(i=0; i<w->nse; i++) {
/n/sources/plan9/sys/src/fs/dev/juke.c:820,826 - /sys/src/fs/dev/juke.c:838,844
  	switch(d->type) {
  	default:
  		print("juke platter not (devmcat of) dev(l)worm: %Z\n", d);
- 		goto bad;
+ 		panic("jinit: type");
  
  	case Devmcat:
  		/*
/n/sources/plan9/sys/src/fs/dev/juke.c:842,856 - /sys/src/fs/dev/juke.c:860,870
  		if(d->private) {
  			print("juke platter private pointer set %p\n",
  				d->private);
- 			goto bad;
+ 			panic("jinit: private");
  		}
  		d->private = w;
  		break;
  	}
- 	return;
- 
- bad:
- 	panic("jinit");
  }
  
  Side*
/n/sources/plan9/sys/src/fs/dev/juke.c:1130,1136 - /sys/src/fs/dev/juke.c:1144,1150
  int
  dowcp(void)
  {
- 	return 0;
+ 	return	0;
  }
  
  /*
/n/sources/plan9/sys/src/fs/dev/juke.c:1143,1149 - /sys/src/fs/dev/juke.c:1157,1162
  	long t;
  	Side *v;
  	Juke *w;
- 
  
  	t = toytime() - TWORM;
  	for(w=jukelist; w; w=w->link) {

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.