diff options
| author | zk194757 <none@none> | 2007-10-26 10:23:36 -0700 |
|---|---|---|
| committer | zk194757 <none@none> | 2007-10-26 10:23:36 -0700 |
| commit | 4d218355460e094792d6bcc161b586d7389d0d83 (patch) | |
| tree | 070a1e9eb970944f56b0dbbcea1197b04339d21b /usr/src/cmd/cdrw | |
| parent | be63db17a89b97b03fcbcdeba18dce66269e1954 (diff) | |
| download | illumos-joyent-4d218355460e094792d6bcc161b586d7389d0d83.tar.gz | |
6614671 cdrw -iC calculates the LBA incorrectly for DVD+R media
Diffstat (limited to 'usr/src/cmd/cdrw')
| -rw-r--r-- | usr/src/cmd/cdrw/copycd.c | 12 | ||||
| -rw-r--r-- | usr/src/cmd/cdrw/misc_scsi.c | 24 | ||||
| -rw-r--r-- | usr/src/cmd/cdrw/misc_scsi.h | 4 | ||||
| -rw-r--r-- | usr/src/cmd/cdrw/write_audio.c | 11 | ||||
| -rw-r--r-- | usr/src/cmd/cdrw/write_image.c | 15 |
5 files changed, 40 insertions, 26 deletions
diff --git a/usr/src/cmd/cdrw/copycd.c b/usr/src/cmd/cdrw/copycd.c index 62e6b39810..7e5eefee0a 100644 --- a/usr/src/cmd/cdrw/copycd.c +++ b/usr/src/cmd/cdrw/copycd.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -134,7 +134,7 @@ read_data_track_failed: static void ensure_media_space(uint32_t total_nblks, uchar_t end_tno) { - off_t nblks_avail; + uint32_t nblks_avail; uint_t bsize; uint_t leadin_size = 0; @@ -143,14 +143,14 @@ ensure_media_space(uint32_t total_nblks, uchar_t end_tno) if (use_media_stated_capacity) { nblks_avail = get_last_possible_lba(target); - if (nblks_avail <= 0) { + if (nblks_avail == 0) { /* most newer drives use READ FORMAT CAPACITY */ nblks_avail = read_format_capacity(target->d_fd, &bsize); /* if both methods fail no choice but to bail out */ - if (nblks_avail <= 0) { + if (nblks_avail == 0) { err_msg(gettext( "Cannot find out media capacity.\n")); @@ -275,7 +275,7 @@ copy_cd(void) (ti->ti_flags & TI_DAMAGED_TRACK) || (data_cd && audio_cd) || (ti->ti_data_mode == 2)) { - err_msg(gettext("CD format is not supported\n")); + err_msg(gettext("CD format is not supported\n")); exit(1); } if ((ti->ti_flags & TI_NWA_VALID) && @@ -375,7 +375,7 @@ copy_cd(void) get_media_type(target->d_fd); } while ((target == NULL) || ((device_type == DVD_PLUS_W)? check_device(target, CHECK_NO_MEDIA): - check_device(target, CHECK_NO_MEDIA|CHECK_MEDIA_IS_NOT_BLANK))); + check_device(target, CHECK_NO_MEDIA|CHECK_MEDIA_IS_NOT_BLANK))); (void) printf("\n"); (void) setreuid(ruid, 0); diff --git a/usr/src/cmd/cdrw/misc_scsi.c b/usr/src/cmd/cdrw/misc_scsi.c index 56cc433b57..3a83a3bf3d 100644 --- a/usr/src/cmd/cdrw/misc_scsi.c +++ b/usr/src/cmd/cdrw/misc_scsi.c @@ -705,21 +705,35 @@ finalize(cd_device *dev) /* * Find out media capacity. */ -int +uint32_t get_last_possible_lba(cd_device *dev) { uchar_t *di; - int cap; + uint32_t cap; di = (uchar_t *)my_zalloc(DISC_INFO_BLOCK_SIZE); if (!read_disc_info(dev->d_fd, di)) { free(di); return (0); } - if ((di[21] != 0) && (di[21] != 0xff)) { - cap = ((di[21] * 60) + di[22]) * 75; + + /* + * If we have a DVD+R this field is an LBA. If the media is + * a CD-R/W the field is MSF formatted. Otherwise this field + * is not valid and will be zero. + */ + if (device_type == DVD_PLUS) { + if (read_scsi32(&di[20]) != 0xffffffff) { + cap = read_scsi32(&di[20]); + } else { + cap = 0; + } } else { - cap = 0; + if ((di[21] != 0) && (di[21] != 0xff)) { + cap = ((di[21] * 60) + di[22]) * 75; + } else { + cap = 0; + } } free(di); diff --git a/usr/src/cmd/cdrw/misc_scsi.h b/usr/src/cmd/cdrw/misc_scsi.h index b58c88d4bc..da184b7c5d 100644 --- a/usr/src/cmd/cdrw/misc_scsi.h +++ b/usr/src/cmd/cdrw/misc_scsi.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -105,7 +105,7 @@ uchar_t get_data_mode(int fd, uint32_t lba); int prepare_for_write(cd_device *dev, int track_mode, int test_write, int keep_disc_open); int finalize(cd_device *dev); -int get_last_possible_lba(cd_device *dev); +uint32_t get_last_possible_lba(cd_device *dev); int read_audio_through_read_cd(cd_device *dev, uint_t start_lba, uint_t nblks, uchar_t *buf); int eject_media(cd_device *dev); diff --git a/usr/src/cmd/cdrw/write_audio.c b/usr/src/cmd/cdrw/write_audio.c index cf476ddb7b..ca933fd884 100644 --- a/usr/src/cmd/cdrw/write_audio.c +++ b/usr/src/cmd/cdrw/write_audio.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -77,7 +76,7 @@ write_audio(char **argv, int start_argc, int argc) bstreamhandle *h_ptr; int i, nfiles; struct track_info *ti; - int blks_req, blks_avail; + uint32_t blks_req, blks_avail; off_t fsize; /* number of tracks to write */ @@ -108,7 +107,7 @@ write_audio(char **argv, int start_argc, int argc) /* Build information for next invisible track, -1 */ if ((build_track_info(target, -1, ti) == 0) || - ((ti->ti_flags & TI_NWA_VALID) == 0)) { + ((ti->ti_flags & TI_NWA_VALID) == 0)) { err_msg(gettext( "Cannot get writable address for the media.\n")); exit(1); diff --git a/usr/src/cmd/cdrw/write_image.c b/usr/src/cmd/cdrw/write_image.c index cc001d2a63..3c3186c9f6 100644 --- a/usr/src/cmd/cdrw/write_image.c +++ b/usr/src/cmd/cdrw/write_image.c @@ -55,7 +55,7 @@ write_image(void) EXIT_IF_CHECK_FAILED); } else { (void) check_device(target, CHECK_DEVICE_NOT_READY | - EXIT_IF_CHECK_FAILED); + EXIT_IF_CHECK_FAILED); } /* @@ -100,20 +100,21 @@ write_image(void) exit(1); } if (no_size == 0) { - off_t cap; + uint32_t cap; struct track_info *ti; uint_t bsize; ti = (struct track_info *)my_zalloc(sizeof (*ti)); if (write_mode == TAO_MODE) - if (!build_track_info(target, -1, ti)) { - err_msg( - gettext("Unable to find out writable address\n")); - exit(1); + if (!build_track_info(target, -1, ti)) { + err_msg( + gettext("Unable to find out writable " + "address\n")); + exit(1); } if (use_media_stated_capacity) { cap = get_last_possible_lba(target); - if (cap <= 0) { + if (cap == 0) { cap = read_format_capacity(target->d_fd, &bsize); } |
