Browse Source

Plan 9 from Bell Labs 2008-03-22

David du Colombier 13 years ago
parent
commit
9488f67192
6 changed files with 83 additions and 95 deletions
  1. 4 4
      dist/replica/_plan9.db
  2. 4 4
      dist/replica/plan9.db
  3. 5 0
      dist/replica/plan9.log
  4. 7 3
      sys/man/4/cdfs
  5. 46 38
      sys/src/cmd/cdfs/main.c
  6. 17 46
      sys/src/cmd/cdfs/mmc.c

+ 4 - 4
dist/replica/_plan9.db

@@ -172,7 +172,7 @@
 386/bin/calendar - 775 sys sys 1200262736 79060
 386/bin/cat - 775 sys sys 1148500611 37482
 386/bin/cb - 775 sys sys 1168402293 77628
-386/bin/cdfs - 775 sys sys 1206069507 173352
+386/bin/cdfs - 775 sys sys 1206156940 173146
 386/bin/cec - 775 sys sys 1193714267 75896
 386/bin/cfs - 775 sys sys 1190863294 130565
 386/bin/chgrp - 775 sys sys 1168402294 59522
@@ -7722,7 +7722,7 @@ sys/man/4/INDEX - 664 sys sys 1196638942 1026
 sys/man/4/INDEX.html - 664 sys sys 1196638942 5147
 sys/man/4/acme - 664 sys sys 1196638943 10435
 sys/man/4/archfs - 664 sys sys 1196638943 533
-sys/man/4/cdfs - 664 sys sys 1206047086 4636
+sys/man/4/cdfs - 664 sys sys 1206142208 4785
 sys/man/4/cfs - 664 sys sys 1196638943 2136
 sys/man/4/consolefs - 664 sys sys 1196638943 4389
 sys/man/4/cwfs - 664 sys sys 1196638943 6553
@@ -10021,9 +10021,9 @@ sys/src/cmd/cdfs - 20000000775 sys sys 1039727558 0
 sys/src/cmd/cdfs/buf.c - 664 sys sys 1205271166 1923
 sys/src/cmd/cdfs/dat.h - 664 sys sys 1206046829 4619
 sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
-sys/src/cmd/cdfs/main.c - 664 sys sys 1206046865 12396
+sys/src/cmd/cdfs/main.c - 664 sys sys 1206142363 12381
 sys/src/cmd/cdfs/mkfile - 664 sys sys 1204937991 153
-sys/src/cmd/cdfs/mmc.c - 664 sys sys 1206046883 32136
+sys/src/cmd/cdfs/mmc.c - 664 sys sys 1206142343 31376
 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

+ 4 - 4
dist/replica/plan9.db

@@ -172,7 +172,7 @@
 386/bin/calendar - 775 sys sys 1200262736 79060
 386/bin/cat - 775 sys sys 1148500611 37482
 386/bin/cb - 775 sys sys 1168402293 77628
-386/bin/cdfs - 775 sys sys 1206069507 173352
+386/bin/cdfs - 775 sys sys 1206156940 173146
 386/bin/cec - 775 sys sys 1193714267 75896
 386/bin/cfs - 775 sys sys 1190863294 130565
 386/bin/chgrp - 775 sys sys 1168402294 59522
@@ -7722,7 +7722,7 @@ sys/man/4/INDEX - 664 sys sys 1196638942 1026
 sys/man/4/INDEX.html - 664 sys sys 1196638942 5147
 sys/man/4/acme - 664 sys sys 1196638943 10435
 sys/man/4/archfs - 664 sys sys 1196638943 533
-sys/man/4/cdfs - 664 sys sys 1206047086 4636
+sys/man/4/cdfs - 664 sys sys 1206142208 4785
 sys/man/4/cfs - 664 sys sys 1196638943 2136
 sys/man/4/consolefs - 664 sys sys 1196638943 4389
 sys/man/4/cwfs - 664 sys sys 1196638943 6553
@@ -10021,9 +10021,9 @@ sys/src/cmd/cdfs - 20000000775 sys sys 1039727558 0
 sys/src/cmd/cdfs/buf.c - 664 sys sys 1205271166 1923
 sys/src/cmd/cdfs/dat.h - 664 sys sys 1206046829 4619
 sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
-sys/src/cmd/cdfs/main.c - 664 sys sys 1206046865 12396
+sys/src/cmd/cdfs/main.c - 664 sys sys 1206142363 12381
 sys/src/cmd/cdfs/mkfile - 664 sys sys 1204937991 153
-sys/src/cmd/cdfs/mmc.c - 664 sys sys 1206046883 32136
+sys/src/cmd/cdfs/mmc.c - 664 sys sys 1206142343 31376
 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

+ 5 - 0
dist/replica/plan9.log

@@ -18833,3 +18833,8 @@
 1206046804 2 c sys/src/cmd/cdfs/mmc.c - 664 sys sys 1206046883 32136
 1206048605 0 c sys/man/4/cdfs - 664 sys sys 1206047086 4636
 1206070204 0 c 386/bin/cdfs - 775 sys sys 1206069507 173352
+1206135004 0 c sys/man/4/cdfs - 664 sys sys 1206133845 4648
+1206142203 0 c sys/man/4/cdfs - 664 sys sys 1206142208 4785
+1206142203 1 c sys/src/cmd/cdfs/main.c - 664 sys sys 1206142363 12381
+1206142203 2 c sys/src/cmd/cdfs/mmc.c - 664 sys sys 1206142343 31376
+1206158404 0 c 386/bin/cdfs - 775 sys sys 1206156940 173146

+ 7 - 3
sys/man/4/cdfs

@@ -116,9 +116,9 @@ Blank the entire rewritable disc in the drive.
 .B quickblank
 Blank only the table of contents on the rewritable
 disc in the drive.
-.TP
-.B closetracks
-Close any open tracks on the current disc but do not finalize (fixate) the disc.
+.\" .TP
+.\" .B closetracks
+.\" Close any open tracks on the current disc but do not finalize (fixate) the disc.
 .TP
 .B eject
 Eject the disc in the drive.
@@ -226,6 +226,10 @@ optical disc interface standards
 .IR dossrv (4)),
 .IR mk9660 (8)
 .SH BUGS
+Fixating a BD-R disc records only the first track in the disc's TOC.
+Any other tracks are still there and accessible via
+.IR sd (3).
+.PP
 Packet (incremental) writing is not yet implemented.
 .PP
 There are too many combinations of optical media, approximately

+ 46 - 38
sys/src/cmd/cdfs/main.c

@@ -204,17 +204,55 @@ fsremove(Req *r)
 	}
 }
 
+static char *
+disctype(Drive *drive)
+{
+	char *type, *rw;
+
+	switch (drive->mmctype) {
+	case Mmccd:
+		type = "cd-";
+		break;
+	case Mmcdvdminus:
+	case Mmcdvdplus:
+		type = drive->dvdtype;
+		break;
+	case Mmcbd:
+		type = "bd-";
+		break;
+	case Mmcnone:
+		type = "no disc";
+		break;
+	default:
+		type = "**GOK**";		/* traditional */
+		break;
+	}
+	rw = "";
+	if (drive->mmctype != Mmcnone && drive->dvdtype == nil)
+		if (drive->erasable)
+			rw = "rw";
+		else if (drive->recordable)
+			rw = "r";
+		else
+			rw = "rom";
+	return smprint("%s%s", type, rw);
+}
+
 int
 fillstat(ulong qid, Dir *d)
 {
+	char *ty;
 	Track *t;
+	static char buf[32];
 
 	nulldir(d);
 	d->type = L'M';
 	d->dev = 1;
 	d->length = 0;
-	d->uid = "cd";
-	d->gid = "cd";
+	ty = disctype(drive);
+	strncpy(buf, ty, sizeof buf);
+	free(ty);
+	d->uid = d->gid = buf;
 	d->muid = "";
 	d->qid = (Qid){qid, drive->nchange, 0};
 	d->atime = time(0);
@@ -302,7 +340,7 @@ static void
 readctl(Req *r)
 {
 	int i, isaudio;
-	char *p, *e;
+	char *p, *e, *ty;
 	char s[1024];
 	Msf *m;
 
@@ -334,35 +372,12 @@ readctl(Req *r)
 		drive->maxreadspeed, drive->maxwritespeed);
 
 	if (drive->Scsi.changetime != 0 && drive->ntrack != 0) { /* have disc? */
-		switch (drive->mmctype) {
-		case Mmccd:
-			p = seprint(p, e, "cd-");
-			break;
-		case Mmcdvdminus:
-		case Mmcdvdplus:
-			p = seprint(p, e, "%s", drive->dvdtype);
-			break;
-		case Mmcbd:
-			p = seprint(p, e, "bd-");
-			break;
-		case Mmcnone:
-			p = seprint(p, e, "no disc");
-			break;
-		default:
-			p = seprint(p, e, "**GOK**");
-			break;
-		}
-		if (drive->mmctype != Mmcnone) {
-			if (drive->dvdtype == nil)
-				if (drive->erasable)
-					p = seprint(p, e, "rw");
-				else if (drive->recordable)
-					p = seprint(p, e, "r");
-				else
-					p = seprint(p, e, "rom");
+		ty = disctype(drive);
+		p = seprint(p, e, "%s", ty);
+		free(ty);
+		if (drive->mmctype != Mmcnone)
 			p = seprint(p, e, " next writable sector %lud",
 				getnwa(drive));
-		}
 		seprint(p, e, "\n");
 	}
 	readstr(r, s);
@@ -590,10 +605,6 @@ fsdestroyfid(Fid *fid)
 	}
 }
 
-/*
- * should it be possible on -r or -rw disc to have a mode of 0666,
- * or do we have to use the wd/x interface?
- */
 static void
 checktoc(Drive *drive)
 {
@@ -610,9 +621,6 @@ checktoc(Drive *drive)
 			t->mode = 0;
 		else
 			t->mode = 0444;
-		/*
-		 * set mode to 0666 if the drive and disc are both capable?
-		 */
 		sprint(t->name, "?%.3d", i);
 		switch(t->type){
 		case TypeNone:
@@ -629,7 +637,7 @@ checktoc(Drive *drive)
 			t->name[0] = '\0';
 			break;
 		default:
-			print("unknown type %d\n", t->type);
+			print("unknown track type %d\n", t->type);
 			break;
 		}
 	}

+ 17 - 46
sys/src/cmd/cdfs/mmc.c

@@ -704,6 +704,9 @@ getbdstruct(Drive *drive)
 	return 0;
 }
 
+/*
+ * infer endings from the beginnings of other tracks.
+ */
 static void
 mmcinfertracks(Drive *drive, int first, int last)
 {
@@ -712,10 +715,8 @@ mmcinfertracks(Drive *drive, int first, int last)
 	ulong tot;
 	Track *t;
 
-	/*
-	 * otherwise we need to infer endings from the
-	 * beginnings of other tracks.
-	 */
+	if (vflag)
+		print("inferring tracks\n");
 	for(i = first; i <= last; i++) {
 		memset(resp, 0, sizeof(resp));
 		if(mmcreadtoc(drive, 0, i, resp, sizeof(resp)) < 0)
@@ -877,6 +878,10 @@ mmcgettoc(Drive *drive)
 		for(i = first; i <= last; i++)
 			mmctrackinfo(drive, i, i - first);
 	else
+		/*
+		 * otherwise we need to infer endings from the
+		 * beginnings of other tracks.
+		 */
 		mmcinfertracks(drive, first, last);
 
 	drive->firsttrack = first;
@@ -1273,6 +1278,7 @@ mmcxclose(Drive *drive, int clf, int trackno)
 	return scsi(drive, cmd, sizeof(cmd), cmd, 0, Snone);
 }
 
+/* flush drive cache, close current track */
 void
 mmcsynccache(Drive *drive)
 {
@@ -1281,23 +1287,22 @@ mmcsynccache(Drive *drive)
 	Mmcaux *aux;
 
 	memset(cmd, 0, sizeof(cmd));
-	cmd[0] = ScmdSynccache;		/* flush */
+	cmd[0] = ScmdSynccache;			/* flush */
 	scsi(drive, cmd, sizeof(cmd), cmd, 0, Snone);
 	if(vflag) {
 		aux = drive->aux;
 		print("mmcsynccache: bytes = %lld blocks = %ld, mmcnwa 0x%luX\n",
 			aux->ntotby, aux->ntotbk, aux->mmcnwa);
 	}
+
 	invis = getinvistrack(drive);
 	if (invis < 0)
 		invis = Invistrack;
 	/*
 	 * rsc: seems not to work on some drives.
 	 * so ignore return code & don't issue on dvd+rw.
-	 * try skipping it on bd too.
 	 */
-	if((drive->mmctype != Mmcdvdplus || !drive->erasable) &&
-	    drive->mmctype != Mmcbd) {
+	if(drive->mmctype != Mmcdvdplus || !drive->erasable) {
 		if (vflag)
 			fprint(2, "closing invisible track %d (not dvd+rw)...\n",
 				invis);
@@ -1328,26 +1333,12 @@ mmcclose(Otrack *o)
 	free(o);
 }
 
-/*
- * just close the current tracks.
- */
 static int
-closetracks(Drive *drive)
+setonesess(Drive *drive)
 {
-	int r, invis;
 	uchar *p;
 	Mmcaux *aux;
 
-	if (drive->mmctype == Mmcdvdplus && drive->erasable) {
-		werrstr("dvd+rw can't close tracks without finalizing");
-		return -1;
-	}
-	if((drive->cap & Cwrite) == 0) {
-		werrstr("drive not a writer");
-		return -1;
-	}
-	drive->nchange = -1;		/* force reread toc */
-
 	/* page 5 is legacy and now read-only; see MMC-6 §7.5.4.1 */
 	aux = drive->aux;
 	p = aux->page05;
@@ -1356,18 +1347,7 @@ closetracks(Drive *drive)
 	 * zero multi-session field: next session not allowed.
 	 */
 	p[3] &= ~0xC0;
-	/* try to set it but don't freak out if it fails */
-	mmcsetpage(drive, Pagwrparams, p);
-
-	invis = getinvistrack(drive);
-	if (invis < 0)
-		invis = Invistrack;
-	if (vflag)
-		fprint(2, "closing invis track %d...\n", invis);
-	r = mmcxclose(drive, Closetrack, invis);
-	if (vflag)
-		fprint(2, "... done.\n");
-	return r;
+	return mmcsetpage(drive, Pagwrparams, p);
 }
 
 /*
@@ -1377,8 +1357,6 @@ static int
 mmcfixate(Drive *drive)
 {
 	int r;
-	uchar *p;
-	Mmcaux *aux;
 
 	if((drive->cap & Cwrite) == 0) {
 		werrstr("not a writer");
@@ -1386,13 +1364,7 @@ mmcfixate(Drive *drive)
 	}
 	drive->nchange = -1;		/* force reread toc */
 
-	/* page 5 is legacy and now read-only */
-	aux = drive->aux;
-	p = aux->page05;
-	/* zero multi-session field: next session not allowed */
-	p[3] &= ~0xC0;
-	/* try to set it but don't freak out if it fails */
-	mmcsetpage(drive, Pagwrparams, p);
+	setonesess(drive);
 
 	/* skip explicit close session on bd-r */
 	if (drive->mmctype != Mmcbd || drive->erasable) {
@@ -1406,6 +1378,7 @@ mmcfixate(Drive *drive)
 	}
 	/*
 	 * Closesessfinal only closes & doesn't finalize on dvd+r and bd-r.
+	 * Closedvdrbdfinal closes & finalizes dvd+r and bd-r.
 	 */
 	if ((drive->mmctype == Mmcdvdplus || drive->mmctype == Mmcbd) &&
 	    !drive->erasable) {
@@ -1455,8 +1428,6 @@ mmcctl(Drive *drive, int argc, char **argv)
 		return e(mmcblank(drive, 0));
 	if(strcmp(cmd, "quickblank") == 0)
 		return e(mmcblank(drive, 1));
-	if(strcmp(cmd, "closetracks") == 0)
-		return e(closetracks(drive));
 	if(strcmp(cmd, "eject") == 0)
 		return e(start(drive, 2));
 	if(strcmp(cmd, "ingest") == 0)