[Libburn] blank_fix.diff in uniform format

Tiago Cogumbreiro cogumbreiro@linus.uac.pt
Sat, 20 Dec 2003 20:08:13 +0000


--=-0P0LyGcyCekWp/0uHi+2
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Sorry for that diff's format (i'm on a diff computer), here's the
standard on.

Tiago Cogumbreiro

--=-0P0LyGcyCekWp/0uHi+2
Content-Disposition: attachment; filename=blank_fix.diff
Content-Type: text/x-patch; name=blank_fix.diff; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

? libburn/.spc.c.swp
? test/test.iso
Index: libburn/drive.c
===================================================================
RCS file: /cvs/burn/burn/libburn/drive.c,v
retrieving revision 1.248
diff -p -u -r1.248 drive.c
--- libburn/drive.c	19 Dec 2003 02:44:52 -0000	1.248
+++ libburn/drive.c	20 Dec 2003 22:04:24 -0000
@@ -161,10 +161,10 @@ void burn_disc_erase_sync(struct burn_dr
 	d->progress.sectors = 0x10000;
 	d->progress.current_sector = 0;
 	/* read the initial 0 stage */
-	while(d->get_erase_progress(d) == 0)
+	while(!d->test_unit_ready(d) && d->get_erase_progress(d) == 0)
 		usleep(1000);
 	
-	while((d->progress.current_sector = d->get_erase_progress(d)) > 0)
+	while(!d->test_unit_ready(d) && (d->progress.current_sector = d->get_erase_progress(d)) > 0)
 		usleep(1000);
 	
 	d->progress.current_sector = 0x10000;
Index: libburn/sg.c
===================================================================
RCS file: /cvs/burn/burn/libburn/sg.c,v
retrieving revision 1.113
diff -p -u -r1.113 sg.c
--- libburn/sg.c	19 Dec 2003 05:28:52 -0000	1.113
+++ libburn/sg.c	20 Dec 2003 22:04:25 -0000
@@ -113,6 +113,7 @@ static void enumerate_common(char *fname
 	out.unlock = spc_allow;
 	out.read_disc_info = spc_sense_write_params;
 	out.get_erase_progress = spc_get_erase_progress;
+	out.test_unit_ready = spc_test_unit_ready;
 	out.read_toc = mmc_read_toc;
 	out.write = mmc_write;
 	out.erase = mmc_erase;
Index: libburn/spc.c
===================================================================
RCS file: /cvs/burn/burn/libburn/spc.c,v
retrieving revision 1.84
diff -p -u -r1.84 spc.c
--- libburn/spc.c	19 Dec 2003 05:35:46 -0000	1.84
+++ libburn/spc.c	20 Dec 2003 22:04:25 -0000
@@ -29,7 +29,20 @@ static unsigned char SPC_ALLOW[] = { 0x1
 static unsigned char SPC_MODE_SENSE[] = { 0x5a, 0, 0, 0, 0, 0, 0, 16, 0, 0 };
 static unsigned char SPC_MODE_SELECT[] =
 	{ 0x55, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-static unsigned char SPC_REQUEST_SENSE[] = { 0x03, 0, 0, 0, 18, 0};
+static unsigned char SPC_REQUEST_SENSE[] = { 0x03, 0, 0, 0, 18, 0 };
+static unsigned char SPC_TEST_UNIT_READY[] = { 0x00, 0, 0, 0, 0, 0 };
+
+int spc_test_unit_ready(struct burn_drive *d)
+{
+	struct command c;
+	c.oplen = sizeof(SPC_TEST_UNIT_READY);
+	memcpy(c.opcode, SPC_TEST_UNIT_READY, sizeof(SPC_TEST_UNIT_READY));
+	c.dir = NO_TRANSFER;
+	if (d->issue_command(d, &c)) {
+		return (c.sense[2] & 0xF) == 0;
+	}
+	return 0;
+}
 
 void spc_request_sense(struct burn_drive *d, struct buffer *buf)
 {
Index: libburn/spc.h
===================================================================
RCS file: /cvs/burn/burn/libburn/spc.h,v
retrieving revision 1.25
diff -p -u -r1.25 spc.h
--- libburn/spc.h	19 Dec 2003 03:07:39 -0000	1.25
+++ libburn/spc.h	20 Dec 2003 22:04:25 -0000
@@ -17,5 +17,5 @@ void spc_try_write_modes(struct burn_dri
 void spc_request_sense(struct burn_drive *d, struct buffer *buf);
 int spc_block_type(enum burn_block_types b);
 int spc_get_erase_progress(struct burn_drive *d);
-
+int spc_test_unit_ready(struct burn_drive *d);
 #endif /*__SPC*/
Index: libburn/transport.h
===================================================================
RCS file: /cvs/burn/burn/libburn/transport.h,v
retrieving revision 1.103
diff -p -u -r1.103 transport.h
--- libburn/transport.h	19 Dec 2003 05:28:52 -0000	1.103
+++ libburn/transport.h	20 Dec 2003 22:04:26 -0000
@@ -135,6 +135,7 @@ struct burn_drive
 	int (*get_nwa)(struct burn_drive *);
 	void (*close_disc)(struct burn_drive *d, struct burn_write_opts *o);
 	void (*close_session)(struct burn_drive *d, struct burn_write_opts *o);
+	int (*test_unit_ready) (struct burn_drive *d);
 	struct params params;
 	struct scsi_inquiry_data *idata;
 	struct scsi_mode_data *mdata;
Index: libburn/write.c
===================================================================
RCS file: /cvs/burn/burn/libburn/write.c,v
retrieving revision 1.42
diff -p -u -r1.42 write.c
--- libburn/write.c	19 Dec 2003 03:07:39 -0000	1.42
+++ libburn/write.c	20 Dec 2003 22:04:27 -0000
@@ -256,7 +256,7 @@ void burn_write_track(struct burn_write_
 {
 #warning XXX if track is not an even sector size we barf
 	struct burn_drive *d = o->drive;
-	int i, tmp = 0;
+	int i, tmp = 0, last_nwa = -1;
 	int sectors;
 	d->rlba = 0;
 
@@ -291,10 +291,18 @@ printf("track is %d sectors long\n", sec
 
 	if (!nt)
 		tmp = sectors > 150 ? 150 : sectors;
-printf("cutting short by %d sectors\n", tmp);
+	last_nwa = d->get_nwa(d);
+	printf("cutting short by %d sectors\n", tmp);
+	assert(sectors > 0);
+	assert(sectors - tmp > 0);
 	for (i = 0; i < sectors - tmp; i++) {
+		printf("%d/%d\n", i, sectors - tmp);
 		sector_data(o, t, 0);
-		
+		if (last_nwa == d->get_nwa(d)) {
+			printf("Error nwa (%d) didn't change\n", d->get_nwa(d));
+			assert(0);
+		} else
+			last_nwa = d->get_nwa(d);
 		/* update current progress */
 		d->progress.current_sector++;
 	}
Index: test/burniso.c
===================================================================
RCS file: /cvs/burn/burn/test/burniso.c,v
retrieving revision 1.51
diff -p -u -r1.51 burniso.c
--- test/burniso.c	19 Dec 2003 02:44:52 -0000	1.51
+++ test/burniso.c	20 Dec 2003 22:04:28 -0000
@@ -56,7 +56,7 @@ void burn_iso(struct burn_drive *drive, 
 	}
 	o = burn_write_opts_new(drive);
 	burn_write_opts_set_perform_opc(o, 1);
-	burn_write_opts_set_write_type(o, BURN_WRITE_RAW, BURN_BLOCK_RAW16);
+	burn_write_opts_set_write_type(o, BURN_WRITE_RAW, BURN_BLOCK_RAW96R);
 	burn_write_opts_set_simulate(o, 1);
 	burn_write_opts_set_underrun_proof(o, 0);
 
@@ -65,7 +65,8 @@ void burn_iso(struct burn_drive *drive, 
 	burn_write_opts_free(o);
 
 	while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING);
-	while (burn_drive_get_status(drive, &p)) {
+	while (s = burn_drive_get_status(drive, &p)) {
+		printf("status: %d ", s);
 		printf("S: %d/%d ", p.session, p.sessions);
 		printf("T: %d/%d ", p.track, p.tracks);
 		printf("L: %d: %d/%d\n", p.start_sector, p.current_sector, p.sectors);

--=-0P0LyGcyCekWp/0uHi+2--