Browse Source

Plan 9 from Bell Labs 2008-05-27

David du Colombier 12 years ago
parent
commit
dcf7b8885b

+ 6 - 6
dist/replica/_plan9.db

@@ -7732,7 +7732,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 1211605477 4940
+sys/man/4/cdfs - 664 sys sys 1211778510 5082
 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
@@ -10032,12 +10032,12 @@ sys/src/cmd/cc/scon.c - 664 sys sys 1138463621 8788
 sys/src/cmd/cc/sub.c - 664 sys sys 1143759345 34268
 sys/src/cmd/cc/y.tab.h - 664 sys sys 1098501521 1680
 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 1211521283 5591
-sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
-sys/src/cmd/cdfs/main.c - 664 sys sys 1211521244 12479
+sys/src/cmd/cdfs/buf.c - 664 sys sys 1211848647 2010
+sys/src/cmd/cdfs/dat.h - 664 sys sys 1211846577 5594
+sys/src/cmd/cdfs/fns.h - 664 sys sys 1211848622 300
+sys/src/cmd/cdfs/main.c - 664 sys sys 1211854425 12465
 sys/src/cmd/cdfs/mkfile - 664 sys sys 1204937991 153
-sys/src/cmd/cdfs/mmc.c - 664 sys sys 1211605562 33101
+sys/src/cmd/cdfs/mmc.c - 664 sys sys 1211854436 33195
 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

+ 6 - 6
dist/replica/plan9.db

@@ -7732,7 +7732,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 1211605477 4940
+sys/man/4/cdfs - 664 sys sys 1211778510 5082
 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
@@ -10032,12 +10032,12 @@ sys/src/cmd/cc/scon.c - 664 sys sys 1138463621 8788
 sys/src/cmd/cc/sub.c - 664 sys sys 1143759345 34268
 sys/src/cmd/cc/y.tab.h - 664 sys sys 1098501521 1680
 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 1211521283 5591
-sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
-sys/src/cmd/cdfs/main.c - 664 sys sys 1211521244 12479
+sys/src/cmd/cdfs/buf.c - 664 sys sys 1211848647 2010
+sys/src/cmd/cdfs/dat.h - 664 sys sys 1211846577 5594
+sys/src/cmd/cdfs/fns.h - 664 sys sys 1211848622 300
+sys/src/cmd/cdfs/main.c - 664 sys sys 1211854425 12465
 sys/src/cmd/cdfs/mkfile - 664 sys sys 1204937991 153
-sys/src/cmd/cdfs/mmc.c - 664 sys sys 1211605562 33101
+sys/src/cmd/cdfs/mmc.c - 664 sys sys 1211854436 33195
 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

+ 12 - 0
dist/replica/plan9.log

@@ -19690,3 +19690,15 @@
 1211745604 1 c sys/src/cmd/rio/mkfile - 664 sys sys 1211744511 437
 1211745604 2 c sys/src/cmd/samterm/mkfile - 664 sys sys 1211744527 469
 1211745604 3 c sys/src/cmd/plumb/mkfile - 664 sys sys 1211744503 298
+1211779805 0 c sys/man/4/cdfs - 664 sys sys 1211778510 5082
+1211846404 0 c sys/src/cmd/cdfs/buf.c - 664 sys sys 1211844938 1967
+1211846404 1 c sys/src/cmd/cdfs/dat.h - 664 sys sys 1211844910 5594
+1211846404 2 c sys/src/cmd/cdfs/fns.h - 664 sys sys 1211844905 300
+1211846404 3 c sys/src/cmd/cdfs/main.c - 664 sys sys 1211844954 12480
+1211846404 4 c sys/src/cmd/cdfs/mmc.c - 664 sys sys 1211844950 33105
+1211848204 0 c sys/src/cmd/cdfs/dat.h - 664 sys sys 1211846577 5594
+1211850004 0 c sys/src/cmd/cdfs/buf.c - 664 sys sys 1211848647 2010
+1211850004 1 c sys/src/cmd/cdfs/fns.h - 664 sys sys 1211848622 300
+1211850004 2 c sys/src/cmd/cdfs/mmc.c - 664 sys sys 1211848670 33103
+1211855406 0 c sys/src/cmd/cdfs/main.c - 664 sys sys 1211854425 12465
+1211855406 1 c sys/src/cmd/cdfs/mmc.c - 664 sys sys 1211854436 33195

+ 4 - 1
sys/man/4/cdfs

@@ -232,7 +232,10 @@ Any other tracks are still there and their data accessible via
 There's no need to fixate data discs, except to prevent adding new tracks.
 .PP
 Closing a just-written DVD-R track can take minutes
-while the drive burns the unused part of the track reservation.
+while the drive burns the unused part of the track reservation
+(for the whole disc).
+Thus only a single DVD-R track can be written on a DVD-R disc;
+use other media if you need more than one track per disc.
 .PP
 There are too many combinations of optical media, approximately
 the cross-product of these tuples:

+ 12 - 8
sys/src/cmd/cdfs/buf.c

@@ -10,7 +10,7 @@
 #include "fns.h"
 
 Buf*
-bopen(long (*fn)(Buf*, void*, long, long), int omode, int bs, int nblock)
+bopen(long (*fn)(Buf*, void*, long, ulong), int omode, int bs, int nblock)
 {
 	Buf *b;
 
@@ -24,15 +24,16 @@ bopen(long (*fn)(Buf*, void*, long, long), int omode, int bs, int nblock)
 	b->nblock = nblock;
 	b->bs = bs;
 	b->omode = omode;
-	b->fn = fn;
+	b->fn = fn;		/* function to read or write bs-byte blocks */
 
 	return b;
 }
 
 long
-bread(Buf *b, void *v, long n, long off)
+bread(Buf *b, void *v, long n, vlong off)
 {
-	long m, noff;
+	long m;
+	vlong noff;
 
 	assert(b->omode == OREAD);
 
@@ -40,13 +41,16 @@ bread(Buf *b, void *v, long n, long off)
 	if(b->off > off || off >= b->off+b->ndata) {
 		noff = off - off % b->bs;
 		if(vflag)
-			fprint(2, "try refill at %ld\n", noff);
-		if((m = b->fn(b, b->data, b->nblock, noff/b->bs)) <= 0)
+			fprint(2, "try refill at %lld...", noff);
+		if((m = b->fn(b, b->data, b->nblock, noff/b->bs)) <= 0) {
+			if (vflag)
+				fprint(2, "failed\n");
 			return m;
+		}
 		b->ndata = b->bs * m;
 		b->off = noff;
 		if(vflag)
-			fprint(2, "refill %ld at %ld\n", b->ndata, b->off);
+			fprint(2, "got %ld\n", b->ndata);
 	}
 
 //	fprint(2, "read %ld at %ld\n", n, off);
@@ -104,7 +108,7 @@ bterm(Buf *b)
 {
 	/* DVD & BD prefer full ecc blocks (tracks), but can cope with less */
 	if(b->omode == OWRITE && b->ndata)
-		b->fn(b, b->data, (b->ndata+b->bs-1)/b->bs, b->off); 
+		b->fn(b, b->data, (b->ndata + b->bs - 1)/b->bs, 0); 
 
 	free(b->data);
 	free(b);

+ 3 - 3
sys/src/cmd/cdfs/dat.h

@@ -177,7 +177,7 @@ struct Dev
 {
 	Otrack*	(*openrd)(Drive *d, int trackno);
 	Otrack*	(*create)(Drive *d, int bs);
-	long	(*read)(Otrack *t, void *v, long n, long off);
+	long	(*read)(Otrack *t, void *v, long n, vlong off);
 	long	(*write)(Otrack *t, void *v, long n);
 	void	(*close)(Otrack *t);
 	int	(*gettoc)(Drive*);
@@ -225,12 +225,12 @@ struct Drive
 struct Buf
 {
 	uchar	*data;		/* buffer */
-	long	off;		/* data[0] at offset off in file */
+	vlong	off;		/* data[0] at offset off in file */
 	int	bs;		/* block size */
 	long	ndata;		/* no. valid bytes in data */
 	int	nblock;		/* total buffer size in blocks */
 	int	omode;		/* OREAD, OWRITE */
-	long	(*fn)(Buf*, void*, long, long);	/* read, write */
+	long	(*fn)(Buf*, void*, long, ulong); /* read, write */
 
 	/* used only by client */
 	Otrack	*otrack;

+ 7 - 7
sys/src/cmd/cdfs/fns.h

@@ -1,9 +1,9 @@
-Drive* mmcprobe(Scsi*);
-char*	geterrstr(void);
-Buf*	bopen(long (*)(Buf*, void*, long, long), int, int, int);
+Buf*	bopen(long (*)(Buf*, void*, long, ulong), int, int, int);
+long	bread(Buf*, void*, long, vlong);
 void	bterm(Buf*);
-long	bread(Buf*, void*, long, long);
+long	bufread(Otrack*, void*, long, vlong);
+long	bufwrite(Otrack*, void*, long);
 long	bwrite(Buf*, void*, long);
-long bufread(Otrack*, void*, long, long);
-long bufwrite(Otrack*, void*, long);
-void *emalloc(ulong);
+void	*emalloc(ulong);
+char*	geterrstr(void);
+Drive*	mmcprobe(Scsi*);

+ 2 - 3
sys/src/cmd/cdfs/main.c

@@ -46,10 +46,9 @@ emalloc(ulong sz)
 {
 	void *v;
 
-	v = malloc(sz);
+	v = mallocz(sz, 1);
 	if(v == nil)
 		sysfatal("malloc %lud fails", sz);
-	memset(v, 0, sz);
 	return v;
 }
 
@@ -647,7 +646,7 @@ checktoc(Drive *drive)
 }
 
 long
-bufread(Otrack *t, void *v, long n, long off)
+bufread(Otrack *t, void *v, long n, vlong off)
 {
 	return bread(t->buf, v, n, off);
 }

+ 7 - 4
sys/src/cmd/cdfs/mmc.c

@@ -332,9 +332,10 @@ mmcgetspeed(Drive *drive)
 	int n, maxread, curread, maxwrite, curwrite;
 	uchar buf[Pagesz];
 
+	memset(buf, 0, 22);
 	n = mmcgetpage(drive, Pagcapmechsts, buf);	/* legacy page */
-	maxread = (buf[8]<<8)|buf[9];
-	curread = (buf[14]<<8)|buf[15];
+	maxread =   (buf[8]<<8)|buf[9];
+	curread =  (buf[14]<<8)|buf[15];
 	maxwrite = (buf[18]<<8)|buf[19];
 	curwrite = (buf[20]<<8)|buf[21];
 
@@ -543,6 +544,8 @@ mmctrackinfo(Drive *drive, int t, int i)
 	/* t == getinvistrack(): invisible track */
 	if(t == Invistrack || resp[7] & 1) {	/* invis or nwa valid? */
 		aux->mmcnwa = bige(&resp[12]);
+		if ((long)aux->mmcnwa < 0)	/* implausible? */
+			aux->mmcnwa = 0;
 		if (vflag)
 			print(" nwa %lud", aux->mmcnwa);
 	}
@@ -965,7 +968,7 @@ mmcsetbs(Drive *drive, int bs)
 
 /* off is a block number */
 static long
-mmcread(Buf *buf, void *v, long nblock, long off)
+mmcread(Buf *buf, void *v, long nblock, ulong off)
 {
 	int bs;
 	long n, nn;
@@ -1164,7 +1167,7 @@ mmcxwrite(Otrack *o, void *v, long nblk)
 }
 
 static long
-mmcwrite(Buf *buf, void *v, long nblk, long)
+mmcwrite(Buf *buf, void *v, long nblk, ulong)
 {
 	return mmcxwrite(buf->otrack, v, nblk);
 }