Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jul 2000 02:21:15 +0300 (EEST)
From:      seva@sevasoft.kiev.ua
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/19789: [PATCH] burncd msinfo command fix for multisession disks and delay track/disk open while data for recording available
Message-ID:  <200007082321.CAA58749@seva.ferroint.com>

next in thread | raw e-mail | index | archive | help

>Number:         19789
>Category:       bin
>Synopsis:       [PATCH] msinfo reports incorrect data for multisession disks
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 08 16:20:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Seva
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
Sevasoft
>Environment:

Multisession CDR, with 2 and more data tracks

>Description:


For correct generation of multisession cd9660 data mkisofs need to known 
nextwritable address of cdr media and start block of LAST data track.
Current burncd reports start address of FIRST track on media
So you get incorrect cd9660 multisession image (you get only files from first
and last sessions, and not middle tracks)

And when you generate iso image on the fly:

mkisofs -C `burncd msinfo` -M /dev/acd0 <args> | burncd <args>

disk becomes opened before mkisofs get directory from previous session, so
cd-writer generates errors about incorred command sequence

>How-To-Repeat:

Try to write multisession disk with 3 data tracks

>Fix:

With this patch I can generate correct multisession disks:

Index: burncd.c
===================================================================
RCS file: /usr/rep/src/usr.sbin/burncd/burncd.c,v
retrieving revision 1.10
diff -u -r1.10 burncd.c
--- burncd.c	2000/03/03 23:17:27	1.10
+++ burncd.c	2000/07/05 09:34:42
@@ -40,7 +40,7 @@
 #include <sys/cdio.h>
 #include <sys/cdrio.h>
 
-#define BLOCKS	16
+#define BLOCKS	500
 
 static int fd, saved_block_size;
 void cleanup(int);
@@ -52,7 +52,7 @@
 	char *devname = "/dev/acd0c";
 	char buf[2352*BLOCKS];
 	int arg, file, addr, count, filesize;
-	int block_size = 0, cdopen = 0, size, tot_size = 0;
+	int block_size = 0, cdopen = 0, trackopen=0, size, tot_size = 0;
 	struct cdr_track track;
 	struct stat stat;
 
@@ -110,14 +110,18 @@
 		}
 		if (!strcmp(argv[arg], "msinfo")) {
 		        struct ioc_read_toc_single_entry entry;
+			struct ioc_toc_header h;
 
+			if (ioctl(fd, CDIOREADTOCHEADER, &h) < 0)
+				err(EX_IOERR, "ioctl(CDIOREADTOCHEADER)");
 			bzero(&entry, sizeof(struct ioc_read_toc_single_entry));
 			entry.address_format = CD_LBA_FORMAT;
+			entry.track = h.ending_track;
 			if (ioctl(fd, CDIOREADTOCENTRY, &entry) < 0) 
 				err(EX_IOERR, "ioctl(CDIOREADTOCENTRY)");
 			if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) 
 				err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)");
-			fprintf(stderr, "%d, %d\n", entry.entry.addr.lba, addr);
+			fprintf(stderr, "%d, %d\n", ntohl(entry.entry.addr.lba), addr);
 			break;
 		}
 		if (!strcmp(argv[arg], "blank")) {
@@ -161,32 +165,39 @@
 		if ((file = open(argv[arg], O_RDONLY, 0)) < 0)
 			err(EX_NOINPUT, "open(%s)", argv[arg]);
 
-		if (!cdopen) {
-			if (ioctl(fd, CDRIOCOPENDISK) < 0)
-        			err(EX_IOERR, "ioctl(CDRIOCOPENDISK)");
-			cdopen = 1;
-		}
-		if (ioctl(fd, CDRIOCOPENTRACK, &track) < 0)
-        		err(EX_IOERR, "ioctl(CDRIOCOPENTRACK)");
-
-		if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) 
-        		err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)");
+		trackopen=0;
 
 		if (fstat(file, &stat) < 0)
 			err(EX_IOERR, "fstat(%s)", argv[arg]);
 		filesize = stat.st_size / 1024;
-		if (!quiet) {
-			fprintf(stderr, "next writeable LBA %d\n", addr);
-			fprintf(stderr, "writing from file %s size %d KB\n",
-				argv[arg], filesize);
-		}
-		lseek(fd, addr * block_size, SEEK_SET);
+
 		size = 0;
 		if (filesize == 0)
 			filesize++;	/* cheat, avoid divide by zero */
 
 		while ((count = read(file, buf, block_size * BLOCKS)) > 0) {	
 			int res;
+
+			if (!cdopen) {
+				if (ioctl(fd, CDRIOCOPENDISK) < 0)
+        				err(EX_IOERR, "ioctl(CDRIOCOPENDISK)");
+				cdopen = 1;
+			}
+
+			if (!trackopen) {
+				if (ioctl(fd, CDRIOCOPENTRACK, &track) < 0)
+        				err(EX_IOERR, "ioctl(CDRIOCOPENTRACK)");
+
+				if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) 
+        				err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)");
+				if (!quiet) {
+					fprintf(stderr, "next writeable LBA %d\n", addr);
+					fprintf(stderr, "writing from file %s size %d KB\n",
+						argv[arg], filesize);
+				}
+				lseek(fd, addr * block_size, SEEK_SET);
+				trackopen=1;
+			};
 			if (count % block_size) {
 				/* pad file to % block_size */
 				bzero(&buf[count], block_size * BLOCKS - count);

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007082321.CAA58749>