diff options
| author | ec158148 <none@none> | 2008-07-03 10:56:55 -0700 |
|---|---|---|
| committer | ec158148 <none@none> | 2008-07-03 10:56:55 -0700 |
| commit | 4df0f9a378789b084a55c575805f07ef00d35fe5 (patch) | |
| tree | 941c6167ab44d44fcd8e91317e6f4dca76275a1a /usr/src/cmd/cdrw | |
| parent | 4d28e670862e4fde8bb48759a13931fbb4e145b3 (diff) | |
| download | illumos-joyent-4df0f9a378789b084a55c575805f07ef00d35fe5.tar.gz | |
PSARC 2008/314 6307982 cdrw should not require -C to detect media size
6307982 cdrw should not require -C to detect media size
Diffstat (limited to 'usr/src/cmd/cdrw')
| -rw-r--r-- | usr/src/cmd/cdrw/copycd.c | 37 | ||||
| -rw-r--r-- | usr/src/cmd/cdrw/main.c | 8 | ||||
| -rw-r--r-- | usr/src/cmd/cdrw/main.h | 1 | ||||
| -rw-r--r-- | usr/src/cmd/cdrw/write_audio.c | 15 | ||||
| -rw-r--r-- | usr/src/cmd/cdrw/write_image.c | 47 |
5 files changed, 49 insertions, 59 deletions
diff --git a/usr/src/cmd/cdrw/copycd.c b/usr/src/cmd/cdrw/copycd.c index 7e5eefee0a..f6ff7d965d 100644 --- a/usr/src/cmd/cdrw/copycd.c +++ b/usr/src/cmd/cdrw/copycd.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -140,7 +140,7 @@ ensure_media_space(uint32_t total_nblks, uchar_t end_tno) get_media_type(target->d_fd); - if (use_media_stated_capacity) { + if (device_type == CD_RW) { nblks_avail = get_last_possible_lba(target); if (nblks_avail == 0) { @@ -149,31 +149,26 @@ ensure_media_space(uint32_t total_nblks, uchar_t end_tno) nblks_avail = read_format_capacity(target->d_fd, &bsize); - /* if both methods fail no choice but to bail out */ + /* if both methods fail, fall back on defaults */ if (nblks_avail == 0) { - - err_msg(gettext( - "Cannot find out media capacity.\n")); - exit(1); + err_msg(gettext("Unable to determine media " + "capacity. Defaulting to 650 MB (74 minute)" + " disc.\n")); + nblks_avail = MAX_CD_BLKS; } leadin_size = end_tno*300; } } else { - if (device_type == CD_RW) { - nblks_avail = MAX_CD_BLKS; - } else { - /* - * For DVD drives use read_format_capacity as default - * retrieve the media size, it can be 3.6, 3.9, 4.2, - * 4.7, or 9.2 GB - */ - nblks_avail = - read_format_capacity(target->d_fd, &bsize); + /* + * For DVD drives use read_format_capacity as default + * retrieve the media size, it can be 3.6, 3.9, 4.2, + * 4.7, or 9.2 GB + */ + nblks_avail = read_format_capacity(target->d_fd, &bsize); - /* sanity check. if not reasonable default to 4.7 GB */ - if (nblks_avail < MAX_CD_BLKS) { - nblks_avail = MAX_DVD_BLKS; - } + /* sanity check. if not reasonable default to 4.7 GB */ + if (nblks_avail < MAX_CD_BLKS) { + nblks_avail = MAX_DVD_BLKS; } } diff --git a/usr/src/cmd/cdrw/main.c b/usr/src/cmd/cdrw/main.c index cf495e8334..12d6bf60c3 100644 --- a/usr/src/cmd/cdrw/main.c +++ b/usr/src/cmd/cdrw/main.c @@ -47,7 +47,6 @@ * global flags */ int debug = 0; -int use_media_stated_capacity = 0; int keep_disc_open = 0; int requested_speed = 0; int simulation = 0; @@ -267,7 +266,12 @@ main(int argc, char **argv) operations++; break; case 'C': - use_media_stated_capacity = 1; + /* + * cdrw now attempts to use the stated medium capacity + * by default, so this option no longer has any effect. + * It remains in the interface for backwards + * compatibility only. + */ break; case 'd': tgtdev = optarg; diff --git a/usr/src/cmd/cdrw/main.h b/usr/src/cmd/cdrw/main.h index db3a4156bf..58337381fb 100644 --- a/usr/src/cmd/cdrw/main.h +++ b/usr/src/cmd/cdrw/main.h @@ -37,7 +37,6 @@ extern "C" { extern int debug; -extern int use_media_stated_capacity; extern int keep_disc_open; extern int requested_speed; extern int simulation; diff --git a/usr/src/cmd/cdrw/write_audio.c b/usr/src/cmd/cdrw/write_audio.c index ca933fd884..bed1da8b49 100644 --- a/usr/src/cmd/cdrw/write_audio.c +++ b/usr/src/cmd/cdrw/write_audio.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -112,16 +112,13 @@ write_audio(char **argv, int start_argc, int argc) "Cannot get writable address for the media.\n")); exit(1); } - if (use_media_stated_capacity) { - blks_avail = get_last_possible_lba(target); - if (blks_avail == 0) { - err_msg(gettext("Cannot find out media capacity\n")); - exit(1); - } + if ((blks_avail = get_last_possible_lba(target)) == 0) { + err_msg(gettext("Unable to determine media capacity. " + "Defaulting to 650 MB (74 minute) disc.\n")); + blks_avail = MAX_CD_BLKS; + } else { /* LBA is always one less */ blks_avail++; - } else { - blks_avail = MAX_CD_BLKS; } /* * Actual number of blocks available based on nwa (next writable diff --git a/usr/src/cmd/cdrw/write_image.c b/usr/src/cmd/cdrw/write_image.c index e5e97d1808..e41aa90612 100644 --- a/usr/src/cmd/cdrw/write_image.c +++ b/usr/src/cmd/cdrw/write_image.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -112,36 +112,31 @@ write_image(void) "address\n")); exit(1); } - if (use_media_stated_capacity) { - cap = get_last_possible_lba(target); - if (cap <= 0) { - cap = read_format_capacity(target->d_fd, - &bsize); + if (device_type == CD_RW) { + if ((cap = get_last_possible_lba(target)) <= 0) { + if ((cap = read_format_capacity(target->d_fd, + &bsize)) <= 0) { + err_msg(gettext("Unable to determine " + "media capacity. Defaulting to " + "650 MB (74 minute) disc.\n")); + cap = MAX_CD_BLKS; + } } } else { /* - * For DVD drives use read_format_capacity to retrieve - * the media size, it could be 3.6, 3.9, 4.2, 4.7, 9.2 + * For DVD drives use read_format_capacity to + * find media size, it can be 3.6, 3.9, 4.2, + * 4.7, 9.2 */ - if (device_type == CD_RW) { - cap = MAX_CD_BLKS; - } else { - /* - * For DVD drives use read_format_capacity to - * find media size, it can be 3.6, 3.9, 4.2, - * 4.7, 9.2 - */ - cap = read_format_capacity(target->d_fd, - &bsize); - /* sanity if not reasonable default to 4.7 GB */ - if (cap < MAX_CD_BLKS) - cap = MAX_DVD_BLKS; - } - } - if (cap == 0) { - err_msg(gettext("Unable to find out media capacity\n")); - exit(1); + cap = read_format_capacity(target->d_fd, + &bsize); + /* + * Sanity check; Default to 4.7 GB if cap unreasonable + */ + if (cap < MAX_CD_BLKS) + cap = MAX_DVD_BLKS; } + if (device_type == CD_RW) cap = (cap + 1 - ti->ti_start_address) * 2048; else |
