[Libburn] Erase disc fix [with attachment]
Tiago Cogumbreiro
cogumbreiro@linus.uac.pt
Sat, 20 Dec 2003 19:54:15 +0000
--=-dFiYnuJc1cS6GqQsJS2S
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Someone reported that some drives (which aren't compliant to mmc) don't
report the progress status while erasing. This patch fixes this, testing
the unit to see if it's ready. It is advised that users (e.g. frontend
developers) to take this fact in consideration and react conformly. I
think this should be in the docs, thus i'll put that on the next patch
(TAO support hopefully).
PS: now the patch is included as an attachment ;)
Tiago Cogumbreiro
--=-dFiYnuJc1cS6GqQsJS2S
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/.drive.c.swp
? libburn/.libburn.h.swp
? libburn/.sg.c.swp
? libburn/.spc.c.swp
? libburn/.transport.h.swp
? test/.blank.c.swp
? test/test.iso
Index: libburn/drive.c
===================================================================
RCS file: /cvs/burn/burn/libburn/drive.c,v
retrieving revision 1.248
diff -r1.248 drive.c
164c164
< while(d->get_erase_progress(d) == 0)
---
> while(!d->test_unit_ready(d) && d->get_erase_progress(d) == 0)
167c167
< 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)
Index: libburn/sg.c
===================================================================
RCS file: /cvs/burn/burn/libburn/sg.c,v
retrieving revision 1.113
diff -r1.113 sg.c
115a116
> out.test_unit_ready = spc_test_unit_ready;
Index: libburn/spc.c
===================================================================
RCS file: /cvs/burn/burn/libburn/spc.c,v
retrieving revision 1.84
diff -r1.84 spc.c
32c32,45
< 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;
> }
Index: libburn/spc.h
===================================================================
RCS file: /cvs/burn/burn/libburn/spc.h,v
retrieving revision 1.25
diff -r1.25 spc.h
20c20
<
---
> int spc_test_unit_ready(struct burn_drive *d);
Index: libburn/transport.h
===================================================================
RCS file: /cvs/burn/burn/libburn/transport.h,v
retrieving revision 1.103
diff -r1.103 transport.h
137a138
> int (*test_unit_ready) (struct burn_drive *d);
Index: libburn/write.c
===================================================================
RCS file: /cvs/burn/burn/libburn/write.c,v
retrieving revision 1.42
diff -r1.42 write.c
259c259
< int i, tmp = 0;
---
> int i, tmp = 0, last_nwa = -1;
294c294,297
< 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);
295a299
> printf("%d/%d\n", i, sectors - tmp);
297c301,305
<
---
> 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);
Index: test/burniso.c
===================================================================
RCS file: /cvs/burn/burn/test/burniso.c,v
retrieving revision 1.51
diff -r1.51 burniso.c
59c59
< 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);
68c68,69
< while (burn_drive_get_status(drive, &p)) {
---
> while (s = burn_drive_get_status(drive, &p)) {
> printf("status: %d ", s);
--=-dFiYnuJc1cS6GqQsJS2S--