Browse Source

Plan 9 from Bell Labs 2008-03-13

David du Colombier 13 years ago
parent
commit
3b46543d39

+ 1 - 2
dist/replica/_plan9.db

@@ -10020,7 +10020,7 @@ sys/src/cmd/cdfs/dat.h - 664 sys sys 1205281336 4538
 sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
 sys/src/cmd/cdfs/main.c - 664 sys sys 1205281456 11687
 sys/src/cmd/cdfs/mkfile - 664 sys sys 1204937991 153
-sys/src/cmd/cdfs/mmc.c - 664 sys sys 1205281492 27209
+sys/src/cmd/cdfs/mmc.c - 664 sys sys 1205295078 27297
 sys/src/cmd/cec - 20000000775 sys sys 1193683647 0
 sys/src/cmd/cec/LICENSE - 664 sys sys 1186248056 1554
 sys/src/cmd/cec/Protocol - 664 sys sys 1186248056 2881
@@ -15869,4 +15869,3 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
-sys/src/cmd/cdfs/mmc.c - 664 sys sys 1205295078 27297

+ 1 - 1
sys/src/9/pc/usbohci.c

@@ -1891,7 +1891,7 @@ interrupt(Ureg *, void *arg)
 			wakeup(&ep->dir[dirin].rend);
 			break;
 		default:
-			panic("cc %lud unimplemented\n", cc);
+			panic("cc %ud unimplemented\n", cc);
 		}
 		ep->dir[dirin].queued--;
 		/* Clean up blocks used for transfers */

+ 4 - 2
sys/src/9/port/dev.c

@@ -125,6 +125,7 @@ devshutdown(void)
 Chan*
 devattach(int tc, char *spec)
 {
+	int n;
 	Chan *c;
 	char *buf;
 
@@ -133,8 +134,9 @@ devattach(int tc, char *spec)
 	c->type = devno(tc, 0);
 	if(spec == nil)
 		spec = "";
-	buf = smalloc(4+strlen(spec)+1);
-	sprint(buf, "#%C%s", tc, spec);
+	n = 1+UTFmax+strlen(spec)+1;
+	buf = smalloc(n);
+	snprint(buf, n, "#%C%s", tc, spec);
 	c->path = newpath(buf);
 	free(buf);
 	return c;

+ 2 - 2
sys/src/9/port/devproc.c

@@ -714,13 +714,13 @@ procread(Chan *c, void *va, long n, vlong off)
 	switch(QID(c->qid)){
 	case Qargs:
 		qlock(&p->debug);
-		j = procargs(p, p->genbuf, sizeof p->genbuf);
+		j = procargs(p, up->genbuf, sizeof up->genbuf);
 		qunlock(&p->debug);
 		if(offset >= j)
 			return 0;
 		if(offset+n > j)
 			n = j-offset;
-		memmove(a, &p->genbuf[offset], n);
+		memmove(a, &up->genbuf[offset], n);
 		return n;
 
 	case Qmem:

+ 15 - 14
sys/src/cmd/cdfs/dat.h

@@ -6,20 +6,20 @@ enum {
 	BScdxa		= 2336,
 	BSmax		= 2352,
 
-	/* scsi peripheral device types */
+	/* scsi peripheral device types, SPC-3 §6.4.2 */
 	TypeDA		= 0,		/* Direct Access (SBC) */
-	TypeSA		= 1,		/* Sequential Access (SSC-2) */
+	TypeSA		= 1,		/* Sequential Access (SSC) */
 	TypeWO		= 4,		/* Worm (SBC)*/
-	TypeCD		= 5,		/* CD/DVD/BD (MMC-3) */
+	TypeCD		= 5,		/* CD/DVD/BD (MMC) */
 	TypeMO		= 7,		/* rewriteable Magneto-Optical (SBC) */
-	TypeMC		= 8,		/* Medium Changer (SMC-2) */
+	TypeMC		= 8,		/* Medium Changer (SMC) */
 
-	/* MMC-3 device types */
-	Subtypenone	= 0,
-	Subtypecd,
-	Subtypedvdminus,
-	Subtypedvdplus,
-	Subtypebd,
+	/* MMC device types */
+	Mmcnone	= 0,
+	Mmccd,
+	Mmcdvdminus,
+	Mmcdvdplus,
+	Mmcbd,
 
 	/* disc or track types */
 	TypeNone	= 0,
@@ -162,14 +162,15 @@ struct Drive
 	QLock;
 	Scsi;
 
+	int	type;			/* scsi peripheral device type */
+
 	/* disc characteristics */
-	int	type;
-	int	subtype;
+	int	mmctype;
 	int	nopen;
 	int	firsttrack;
 	int	ntrack;
-	int	nchange;
-	int	changetime;
+	int	nchange;		/* compare with the members in Scsi */
+	ulong	changetime;		/* " */
 	int	nameok;
 	int	writeok;
 	int	blank;			/* (not used for anything yet) */

+ 33 - 39
sys/src/cmd/cdfs/main.c

@@ -99,8 +99,8 @@ fswalk1(Fid *fid, char *name, Qid *qid)
 			return nil;
 		}
 		if(strcmp(name, "wa") == 0 && drive->writeok &&
-		    (drive->subtype == Subtypenone ||
-		     drive->subtype == Subtypecd)) {
+		    (drive->mmctype == Mmcnone ||
+		     drive->mmctype == Mmccd)) {
 			*qid = (Qid){Qwa, drive->nchange, QTDIR};
 			return nil;
 		}
@@ -151,8 +151,8 @@ fscreate(Req *r)
 		return;
 
 	case Qwa:
-		if (drive->subtype != Subtypenone &&
-		    drive->subtype != Subtypecd) {
+		if (drive->mmctype != Mmcnone &&
+		    drive->mmctype != Mmccd) {
 			respond(r, "audio supported only on cd");
 			return;
 		}
@@ -233,8 +233,8 @@ fillstat(ulong qid, Dir *d)
 
 	case Qwa:
 		if(drive->writeok == 0 ||
-		    drive->subtype != Subtypenone &&
-		    drive->subtype != Subtypecd)
+		    drive->mmctype != Mmcnone &&
+		    drive->mmctype != Mmccd)
 			return 0;
 		d->name = "wa";
 		d->qid.type = QTDIR;
@@ -324,8 +324,10 @@ readctl(Req *r)
 	if(drive->readspeed == drive->writespeed)
 		sprint(s+strlen(s), "speed %d\n", drive->readspeed);
 	else
-		sprint(s+strlen(s), "speed read %d write %d\n", drive->readspeed, drive->writespeed);
-	sprint(s+strlen(s), "maxspeed read %d write %d\n", drive->maxreadspeed, drive->maxwritespeed);
+		sprint(s+strlen(s), "speed read %d write %d\n",
+			drive->readspeed, drive->writespeed);
+	sprint(s+strlen(s), "maxspeed read %d write %d\n",
+		drive->maxreadspeed, drive->maxwritespeed);
 	readstr(r, s);
 }
 
@@ -366,30 +368,26 @@ fsread(Req *r)
 		}
 		a->doff = j;
 
-		r->ofcall.count = p-(uchar*)buf;
-		respond(r, nil);
-		return;
-
+		r->ofcall.count = p - (uchar*)buf;
+		break;
 	case Qwa:
 	case Qwd:
 		r->ofcall.count = 0;
-		respond(r, nil);
-		return;
-
+		break;
 	case Qctl:
 		readctl(r);
-		respond(r, nil);
-		return;
-	}
-
-	/* a disk track; we can only call read for whole blocks */
-	o = ((Aux*)fid->aux)->o;
-	if((count = o->drive->read(o, buf, count, offset)) < 0)
-		respond(r, geterrstr());
-	else{
+		break;
+	default:
+		/* a disk track; we can only call read for whole blocks */
+		o = ((Aux*)fid->aux)->o;
+		if((count = o->drive->read(o, buf, count, offset)) < 0) {
+			respond(r, geterrstr());
+			return;
+		}
 		r->ofcall.count = count;
-		respond(r, nil);
+		break;
 	}
+	respond(r, nil);
 }
 
 static char *Ebadmsg = "bad cdfs control message";
@@ -429,23 +427,21 @@ writectl(void *v, long count)
 					if(r >= 0 || w >= 0)
 						return Ebadmsg;
 					r = w = n;
-					what = '?';
 					break;
 				case 'r':
 					if(r >= 0)
 						return Ebadmsg;
 					r = n;
-					what = '?';
 					break;
 				case 'w':
 					if(w >= 0)
 						return Ebadmsg;
 					w = n;
-					what = '?';
 					break;
 				default:
 					return Ebadmsg;
 				}
+				what = '?';
 			}
 		}
 		if(what != '?')
@@ -506,19 +502,17 @@ fsopen(Req *r)
 	case Qdir:
 	case Qwa:
 	case Qwd:
-		if(omode == OREAD)
-			respond(r, nil);
-		else
+		if(omode != OREAD) {
 			respond(r, "permission denied");
-		return;
-
+			return;
+		}
+		break;
 	case Qctl:
-		if(omode&~(OTRUNC|OREAD|OWRITE|ORDWR))
+		if(omode & ~(OTRUNC|OREAD|OWRITE|ORDWR)) {
 			respond(r, "permission denied");
-		else
-			respond(r, nil);
-		return;
-
+			return;
+		}
+		break;
 	default:
 		if(fid->qid.path >= Qtrack+drive->ntrack) {
 			respond(r, "file no longer exists");
@@ -537,9 +531,9 @@ fsopen(Req *r)
 
 		o->nref = 1;
 		((Aux*)fid->aux)->o = o;
-		respond(r, nil);
 		break;
 	}
+	respond(r, nil);
 }
 
 static void

+ 169 - 89
sys/src/cmd/cdfs/mmc.c

@@ -16,7 +16,7 @@ enum
 {
 	Pagesz		= 255,
 
-	Pagwrparams	= 5,		/* write parameters */
+	Pagwrparams	= 5,	/* (cd|dvd)-r(w) device write parameters */
 	Pagcache	= 8,
 	Pagcapmechsts	= 0x2a,
 };
@@ -25,7 +25,7 @@ static Dev mmcdev;
 
 typedef struct Mmcaux Mmcaux;
 struct Mmcaux {
-	uchar	page05[Pagesz];		/* (cd|dvd)-r(w) write parameters */
+	uchar	page05[Pagesz];		/* write parameters */
 	int	page05ok;
 
 	int	pagecmdsz;
@@ -97,15 +97,15 @@ initcdb(uchar *cdb, int len, int cmd)
 	cdb[0] = cmd;
 }
 
-static uchar *
-newcdb(int len, int cmd)
-{
-	uchar *cdb;
-
-	cdb = emalloc(len);
-	cdb[0] = cmd;
-	return cdb;
-}
+//static uchar *
+//newcdb(int len, int cmd)
+//{
+//	uchar *cdb;
+//
+//	cdb = emalloc(len);
+//	cdb[0] = cmd;
+//	return cdb;
+//}
 
 /*
  * SCSI CDBs (cmd arrays) are 6, 10, 12, 16 or 32 bytes long.
@@ -334,6 +334,21 @@ mmcgetspeed(Drive *drive)
 	drive->maxwritespeed = maxwrite;
 }
 
+static int
+getdevtype(Drive *drive)
+{
+	int n;
+	uchar cmd[6], resp[Pagesz];
+
+	initcdb(cmd, sizeof cmd, ScmdInq);
+	cmd[3] = sizeof resp >> 8;
+	cmd[4] = sizeof resp;
+	n = scsi(drive, cmd, sizeof(cmd), resp, sizeof resp, Sread);
+	if (n < 8)
+		return -1;
+	return resp[0] & 037;
+}
+
 Drive*
 mmcprobe(Scsi *scsi)
 {
@@ -349,18 +364,31 @@ mmcprobe(Scsi *scsi)
 	drive->Dev = mmcdev;
 	aux = emalloc(sizeof(Mmcaux));
 	drive->aux = aux;
+	drive->type = getdevtype(drive);
+	if (drive->type != TypeCD) {
+		werrstr("not an mmc device");
+		free(aux);
+		free(drive);
+		return nil;
+	}
+
+	/*
+	 * drive is an mmc device; learn what we can about it
+	 * (as opposed to the disc in it).
+	 */
 
-	/* BUG: confirm mmc better! */
 	/* attempt to read CD capabilities page, but it's now legacy */
 	if(mmcgetpage10(drive, Pagcapmechsts, buf) >= 0)
 		aux->pagecmdsz = 10;
 	else if(mmcgetpage6(drive, Pagcapmechsts, buf) >= 0)
 		aux->pagecmdsz = 6;
 	else {
-		werrstr("not an mmc device");
+		werrstr("can't read mode page %d", Pagcapmechsts);
+		free(aux);
 		free(drive);
 		return nil;
 	}
+
 	cap = 0;
 	if(buf[Capwrite] & (Capcdr|Capcdrw|Capdvdr|Capdvdram) ||
 	    buf[Capmisc] & Caprw)
@@ -380,7 +408,6 @@ mmcprobe(Scsi *scsi)
 			fprint(2, "mmcprobe: got page 5, assuming writable\n");
 	} else
 		cap &= ~Cwrite;
-
 	drive->cap = cap;
 
 	mmcgetspeed(drive);
@@ -583,7 +610,7 @@ getdvdstruct(Drive *drive)
 		drive->blankset = 1;
 	}
 	drive->erasableset = drive->recordableset = 1;
-	drive->subtype = (cat >= 8? Subtypedvdplus: Subtypedvdminus);
+	drive->mmctype = (cat >= 8? Mmcdvdplus: Mmcdvdminus);
 	return 0;
 }
 
@@ -627,18 +654,68 @@ getbdstruct(Drive *drive)
 		return -1;
 	}
 	drive->erasableset = drive->recordableset = 1;
-	drive->subtype = Subtypebd;
+	drive->mmctype = Mmcbd;
 	return 0;
 }
 
-static int
-mmcgettoc(Drive *drive)
+static void
+mmcinfertracks(Drive *drive, int first, int last)
 {
+	int i;
 	uchar resp[1024];
-	int i, n, first, last;
 	ulong tot;
 	Track *t;
 
+	/*
+	 * otherwise we need to infer endings from the
+	 * beginnings of other tracks.
+	 */
+	for(i = first; i <= last; i++) {
+		memset(resp, 0, sizeof(resp));
+		if(mmcreadtoc(drive, 0, i, resp, sizeof(resp)) < 0)
+			break;
+		t = &drive->track[i-first];
+		t->mtime = drive->changetime;
+		t->type = TypeData;
+		t->bs = BScdrom;
+		t->beg = bige(resp+8);
+		if(!(resp[5] & 4)) {
+			t->type = TypeAudio;
+			t->bs = BScdda;
+		}
+	}
+
+	if((long)drive->track[0].beg < 0)  /* i've seen negative track 0's */
+		drive->track[0].beg = 0;
+
+	tot = 0;
+	memset(resp, 0, sizeof(resp));
+	/* 0xAA is lead-out */
+	if(mmcreadtoc(drive, 0, 0xAA, resp, sizeof(resp)) < 0)
+		print("bad\n");
+	if(resp[6])
+		tot = bige(resp+8);
+
+	for(i=last; i>=first; i--) {
+		t = &drive->track[i-first];
+		t->end = tot;
+		tot = t->beg;
+		if(t->end <= t->beg) {
+			t->beg = 0;
+			t->end = 0;
+		}
+		/* -2: skip lead out */
+		t->size = (t->end - t->beg - 2) * (vlong)t->bs;
+	}
+}
+
+/* this gets called a lot from main.c's 9P routines */
+static int
+mmcgettoc(Drive *drive)
+{
+	int i, n, first, last;
+	uchar resp[1024];
+
 	/*
 	 * if someone has swapped the cd,
 	 * mmcreadtoc will get ``medium changed'' and the
@@ -650,10 +727,19 @@ mmcgettoc(Drive *drive)
 		drive->ntrack = 0;
 		return 0;
 	}
-
+	/*
+	 * if the disc doesn't appear to be have been changed, and there
+	 * has been a disc in this drive, sometime since cdfs started,
+	 * there's nothing to do (the common case).
+	 */
 	if(drive->nchange == drive->Scsi.nchange && drive->changetime != 0)
 		return 0;
 
+	/*
+	 * the disc in the drive may have just been changed,
+	 * so rescan it and relearn all about it.
+	 */
+
 	drive->ntrack = 0;
 	drive->nameok = 0;
 	drive->nchange = drive->Scsi.nchange;
@@ -703,15 +789,13 @@ mmcgettoc(Drive *drive)
 		}
 	}
 
+	drive->mmctype = Mmcnone;
 	getdvdstruct(drive);
 	getbdstruct(drive);
-
-	if (drive->subtype == Subtypenone)
-		drive->subtype = Subtypecd;	/* by default */
+	if (drive->mmctype == Mmcnone)
+		drive->mmctype = Mmccd;		/* by default */
 	if (drive->recordable || drive->erasable)
 		drive->writeok = 1;
-//	if (drive->subtype == Subtypecd && otrack->buf->ndata == 0)
-//		otrack->buf->nblock = CDNblock;
 
 	if (vflag) {
 		fprint(2, "writeok %d", drive->writeok);
@@ -738,52 +822,11 @@ mmcgettoc(Drive *drive)
 		return -1;
 	}
 
-	if(drive->cap & Cwrite) {	/* CDR drives are easy */
+	if(drive->cap & Cwrite)			/* CDR drives are easy */
 		for(i = first; i <= last; i++)
-			mmctrackinfo(drive, i, i-first);
-	} else {
-		/*
-		 * otherwise we need to infer endings from the
-		 * beginnings of other tracks.
-		 */
-		for(i = first; i <= last; i++) {
-			memset(resp, 0, sizeof(resp));
-			if(mmcreadtoc(drive, 0, i, resp, sizeof(resp)) < 0)
-				break;
-			t = &drive->track[i-first];
-			t->mtime = drive->changetime;
-			t->type = TypeData;
-			t->bs = BScdrom;
-			t->beg = bige(resp+8);
-			if(!(resp[5] & 4)) {
-				t->type = TypeAudio;
-				t->bs = BScdda;
-			}
-		}
-
-		if((long)drive->track[0].beg < 0) /* i've seen negative track 0's */
-			drive->track[0].beg = 0;
-
-		tot = 0;
-		memset(resp, 0, sizeof(resp));
-		/* 0xAA is lead-out */
-		if(mmcreadtoc(drive, 0, 0xAA, resp, sizeof(resp)) < 0)
-			print("bad\n");
-		if(resp[6])
-			tot = bige(resp+8);
-
-		for(i=last; i>=first; i--) {
-			t = &drive->track[i-first];
-			t->end = tot;
-			tot = t->beg;
-			if(t->end <= t->beg) {
-				t->beg = 0;
-				t->end = 0;
-			}
-			/* -2: skip lead out */
-			t->size = (t->end - t->beg - 2) * (vlong)t->bs;
-		}
-	}
+			mmctrackinfo(drive, i, i - first);
+	else
+		mmcinfertracks(drive, first, last);
 
 	drive->firsttrack = first;
 	drive->ntrack = last+1-first;
@@ -819,8 +862,8 @@ mmcsetbs(Drive *drive, int bs)
 	p[3] |= 5;			/* dvd default track mode */
 	p[4] = 0x08;			/* mode 1 CD-ROM: 2K user data */
 	p[8] = 0;			/* session format, CD-DA or -ROM (data) */
-	switch(drive->subtype) {
-	case Subtypecd:
+	switch(drive->mmctype) {
+	case Mmccd:
 		p[3] = (p[3] & ~0x07)|0x04; /* data track, uninterrupted */
 		switch(bs){
 		case BScdrom:
@@ -839,13 +882,13 @@ mmcsetbs(Drive *drive, int bs)
 			assert(0);
 		}
 		break;
-	case Subtypedvdminus:
-	case Subtypedvdplus:
-	case Subtypebd:
+	case Mmcdvdminus:
+	case Mmcdvdplus:
+	case Mmcbd:
 		break;
 	default:
 		fprint(2, "%s: unknown disc sub-type %d\n",
-			argv0, drive->subtype);
+			argv0, drive->mmctype);
 		break;
 	}
 	if(mmcsetpage(drive, Pagwrparams, p) < 0) {
@@ -896,7 +939,7 @@ mmcread(Buf *buf, void *v, long nblock, long off)
 	 * we'll try plain `read (12)'.
 	 */
 	memset(cmd, 0, sizeof(cmd));
-	if (drive->type == TypeCD) {
+	if (drive->type == TypeCD && drive->mmctype == Mmccd) {
 		cmd[0] = ScmdReadcd;
 		cmd[2] = off>>24;
 		cmd[3] = off>>16;
@@ -979,20 +1022,44 @@ mmcopenrd(Drive *drive, int trackno)
 static int
 format(Drive *drive)
 {
+	ulong nblks, blksize;
 	uchar *fmtdesc;
 	uchar cmd[6], parms[4+8];
 
+	if (drive->recordable && drive->mmctype != Mmcbd) {
+		werrstr("don't format write-once cd or dvd media");
+		return -1;
+	}
 	initcdb(cmd, sizeof cmd, ScmdFormat);	/* format unit */
 	cmd[1] = 0x10 | 1;		/* format data, mmc format code */
 
 	memset(parms, 0, sizeof parms);
+	/* format list header */
 	parms[1] = 2;			/* immediate return; don't wait */
 	parms[3] = 8;			/* format descriptor length */
 
 	fmtdesc = parms + 4;
-	PUTBELONG(fmtdesc, ~0ul);
 	fmtdesc[4] = 0;			/* full format */
-	PUTBE24(fmtdesc + 5, BScdrom);
+
+	nblks = 0;
+	blksize = BScdrom;
+	switch (drive->mmctype) {
+	case Mmccd:
+		nblks = 0;
+		break;
+	case Mmcdvdplus:
+		/* format type 0 is optional but equiv to format type 0x26 */
+		fmtdesc[4] = 0x26 << 2;
+		nblks = ~0ul;
+		blksize = 0;
+		break;
+	}
+
+	PUTBELONG(fmtdesc, nblks);
+	PUTBE24(fmtdesc + 5, blksize);
+
+//	print("format parameters:\n");
+//	hexdump(parms, sizeof parms);
 
 	if(vflag)
 		print("%lld ns: format\n", nsec());
@@ -1109,6 +1176,7 @@ mmcxclose(Drive *drive, int clf, int trackno)
 
 	memset(cmd, 0, sizeof(cmd));
 	cmd[0] = ScmdClosetracksess;
+	/* cmd[1] & 1 is the immediate bit */
 	cmd[2] = clf;				/* close function */
 	if(clf == Closetrack)
 		cmd[5] = trackno;
@@ -1129,10 +1197,14 @@ mmcsynccache(Drive *drive)
 		print("mmcsynccache: bytes = %lld blocks = %ld, mmcnwa 0x%luX\n",
 			aux->ntotby, aux->ntotbk, aux->mmcnwa);
 	}
-	/* rsc: seems not to work on some drives */
-	/* don't issue on dvd+rw */
-	if (drive->subtype != Subtypedvdplus || !drive->erasable)
+	/* rsc: seems not to work on some drives. */
+	/* so ignore return code & don't issue on dvd+rw. */
+	if (drive->mmctype != Mmcdvdplus || !drive->erasable)
+{
+fprint(2, "closing track (not dvd+rw)...\n");
  		mmcxclose(drive, Closetrack, 0xFF);
+fprint(2, "... done.\n");
+}
 }
 
 /*
@@ -1177,21 +1249,28 @@ mmcfixate(Drive *drive)
 	p = aux->page05;
 	/* zero multi-session field: next session not allowed */
 	p[3] &= ~0xC0;
-	if(mmcsetpage(drive, Pagwrparams, p) < 0)
-		return -1;
+	/* try to set it but don't freak out if it fails */
+	mmcsetpage(drive, Pagwrparams, p);
 
-	/* rsc: seems not to work on some drives */
-	/* don't issue on dvd+rw */
-//	if (drive->subtype != Subtypedvdplus || !drive->erasable)
+	/* rsc: seems not to work on some drives. */
+	/* so ignore return code & don't issue on dvd+rw. */
+//	if (drive->mmctype != Mmcdvdplus || !drive->erasable)
 //		mmcxclose(drive, Closetrack, 0xFF);
+fprint(2, "closing session and maybe finalizing...\n");
 	r = mmcxclose(drive, Closesessfinal, 0);
+fprint(2, "... done.\n");
+	if (r < 0)
+		return r;
 	/*
 	 * Closesessfinal only closes & doesn't finalize on dvd+r and bd-r.
 	 */
-	if ((drive->subtype == Subtypedvdplus || drive->subtype == Subtypebd) &&
+	if ((drive->mmctype == Mmcdvdplus || drive->mmctype == Mmcbd) &&
 	    !drive->erasable)
+{
+fprint(2, "finalizing dvd+r or bd-r... (won't print `done').\n");
 		return mmcxclose(drive, Closedvdrbdfinal, 0);
-	return r;
+}
+	return 0;
 }
 
 static int
@@ -1203,6 +1282,7 @@ mmcblank(Drive *drive, int quick)
 
 	memset(cmd, 0, sizeof(cmd));
 	cmd[0] = ScmdBlank;		/* blank cd-rw media */
+	/* immediate bit is 0x10 */
 	/* cmd[1] = 0 means blank the whole disc; = 1 just the header */
 	cmd[1] = quick ? 0x01 : 0x00;
 

+ 0 - 2
sys/src/cmd/ndb/convDNS2M.c

@@ -104,7 +104,6 @@ pv4addr(uchar *p, uchar *ep, char *name)
 	parseip(ip, name);
 	v6tov4(p, ip);
 	return p + 4;
-
 }
 
 static uchar*
@@ -114,7 +113,6 @@ pv6addr(uchar *p, uchar *ep, char *name)
 		return ep+1;
 	parseip(p, name);
 	return p + IPaddrlen;
-
 }
 
 static uchar*

+ 14 - 13
sys/src/cmd/ndb/mkfile

@@ -1,3 +1,4 @@
+# cs & dns mkfile
 </$objtype/mkfile
 
 TARG =	\
@@ -45,18 +46,18 @@ $O.testipinfo: testipinfo.$O ipinfo.$O
 	$LD -o $target $prereq
 
 push: $O.dns $O.dnsdebug $O.dnstcp
-	import castro / /n/castro
-	cp $O.dns /n/castro/$objtype/bin/ndb/dns
-	cp $O.dnsdebug /n/castro/$objtype/bin/ndb/dnsdebug
-	cp $O.dnstcp /n/castro/$objtype/bin/ndb/dnstcp
-	unmount /n/castro
-	import divisadero / /n/divisadero
-	cp $O.dns /n/divisadero/$objtype/bin/ndb/dns
-	cp $O.dnsdebug /n/divisadero/$objtype/bin/ndb/dnsdebug
-	cp $O.dnstcp /n/divisadero/$objtype/bin/ndb/dnstcp
-	unmount /n/divisadero
-
-cs.safeinstall: $O.cs
+	import lookout / /n/lookout
+	cp $O.dns /n/lookout/$objtype/bin/ndb/dns
+	cp $O.dnsdebug /n/lookout/$objtype/bin/ndb/dnsdebug
+	cp $O.dnstcp /n/lookout/$objtype/bin/ndb/dnstcp
+	unmount /n/lookout
+	import boundary / /n/boundary
+	cp $O.dns /n/boundary/$objtype/bin/ndb/dns
+	cp $O.dnsdebug /n/boundary/$objtype/bin/ndb/dnsdebug
+	cp $O.dnstcp /n/boundary/$objtype/bin/ndb/dnstcp
+	unmount /n/boundary
+
+cs.safeinstall:V: $O.cs
 	if(test -e $BIN/ooocs)
 		mv $BIN/ooocs $BIN/oooocs
 	if(test -e $BIN/oocs)
@@ -66,7 +67,7 @@ cs.safeinstall: $O.cs
 	mv $BIN/cs $BIN/ocs
 	cp $O.cs $BIN/cs
 
-dns.safeinstall: $O.dns
+dns.safeinstall:V: $O.dns
 	if(test -e $BIN/ooodns)
 		mv $BIN/ooodns $BIN/oooodns
 	if(test -e $BIN/oodns)