1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <stdio.h> 30*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 31*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 32*7c478bd9Sstevel@tonic-gate #include <limits.h> 33*7c478bd9Sstevel@tonic-gate #include <unistd.h> 34*7c478bd9Sstevel@tonic-gate #include <libintl.h> 35*7c478bd9Sstevel@tonic-gate #include <locale.h> 36*7c478bd9Sstevel@tonic-gate #include <volmgt.h> 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #include "msgs.h" 39*7c478bd9Sstevel@tonic-gate #include "device.h" 40*7c478bd9Sstevel@tonic-gate #include "util.h" 41*7c478bd9Sstevel@tonic-gate #include "main.h" 42*7c478bd9Sstevel@tonic-gate #include "options.h" 43*7c478bd9Sstevel@tonic-gate #include "mmc.h" 44*7c478bd9Sstevel@tonic-gate #include "misc_scsi.h" 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * global flags 48*7c478bd9Sstevel@tonic-gate */ 49*7c478bd9Sstevel@tonic-gate int debug = 0; 50*7c478bd9Sstevel@tonic-gate int use_media_stated_capacity = 0; 51*7c478bd9Sstevel@tonic-gate int keep_disc_open = 0; 52*7c478bd9Sstevel@tonic-gate int requested_speed = 0; 53*7c478bd9Sstevel@tonic-gate int simulation = 0; 54*7c478bd9Sstevel@tonic-gate int verbose = 0; 55*7c478bd9Sstevel@tonic-gate char *image_file = NULL; 56*7c478bd9Sstevel@tonic-gate char *blanking_type = NULL; 57*7c478bd9Sstevel@tonic-gate int audio_type = AUDIO_TYPE_NONE; 58*7c478bd9Sstevel@tonic-gate int extract_track_no = 0; 59*7c478bd9Sstevel@tonic-gate char *extract_file = NULL; 60*7c478bd9Sstevel@tonic-gate char *alt_tmp_dir = NULL; 61*7c478bd9Sstevel@tonic-gate char *copy_src = NULL; 62*7c478bd9Sstevel@tonic-gate int vol_running = 0; 63*7c478bd9Sstevel@tonic-gate int cflag = 0; 64*7c478bd9Sstevel@tonic-gate int tflag = 0; 65*7c478bd9Sstevel@tonic-gate uid_t ruid, cur_uid; 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate /* 68*7c478bd9Sstevel@tonic-gate * global variables 69*7c478bd9Sstevel@tonic-gate */ 70*7c478bd9Sstevel@tonic-gate cd_device *target = NULL; /* Default target device */ 71*7c478bd9Sstevel@tonic-gate static char *tgtdev = NULL; 72*7c478bd9Sstevel@tonic-gate int device_type = CD_RW; /* Default to CD/RW */ 73*7c478bd9Sstevel@tonic-gate int write_mode = TAO_MODE; /* Default to track at once */ 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate static void 76*7c478bd9Sstevel@tonic-gate print_usage(void) 77*7c478bd9Sstevel@tonic-gate { 78*7c478bd9Sstevel@tonic-gate err_msg(gettext("USAGE:\n")); 79*7c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -i [ -vSCO ] [ -d device ] [ -p speed ]")); 80*7c478bd9Sstevel@tonic-gate err_msg(gettext(" [ image-file ]\n")); 81*7c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -a [ -vSCO ] [ -d device ] [ -p speed ]")); 82*7c478bd9Sstevel@tonic-gate err_msg(gettext(" [ -T audio-type ] audio-file1 audio-file2 ...\n")); 83*7c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -x [ -v ] [ -d device ] [ -T audio-type ]")); 84*7c478bd9Sstevel@tonic-gate err_msg(gettext(" track-number audio-file\n")); 85*7c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -c [ -cSC ] [ -d device ] [ -p speed ]")); 86*7c478bd9Sstevel@tonic-gate err_msg(gettext(" [ -m tmp-dir ] [ -s src-device ]\n")); 87*7c478bd9Sstevel@tonic-gate err_msg( 88*7c478bd9Sstevel@tonic-gate gettext("\tcdrw -b [ -v ] [ -d device ] all | session | fast\n")); 89*7c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -M [ -v ] [ -d device ]\n")); 90*7c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -L [v] [ -d device ]\n")); 91*7c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -l [ -v ]\n")); 92*7c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -h\n")); 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate exit(2); 95*7c478bd9Sstevel@tonic-gate } 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate static void 98*7c478bd9Sstevel@tonic-gate check_invalid_option(options *specified, char *opstr) 99*7c478bd9Sstevel@tonic-gate { 100*7c478bd9Sstevel@tonic-gate options c_op; 101*7c478bd9Sstevel@tonic-gate int ret; 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate set_options_mask(&c_op, opstr); 104*7c478bd9Sstevel@tonic-gate if ((ret = compare_options_mask(&c_op, specified)) != 0) { 105*7c478bd9Sstevel@tonic-gate err_msg( 106*7c478bd9Sstevel@tonic-gate gettext("Option %c is not defined for this operation.\n"), 107*7c478bd9Sstevel@tonic-gate (char)ret); 108*7c478bd9Sstevel@tonic-gate print_usage(); 109*7c478bd9Sstevel@tonic-gate } 110*7c478bd9Sstevel@tonic-gate } 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate int 113*7c478bd9Sstevel@tonic-gate setup_target(int flag) 114*7c478bd9Sstevel@tonic-gate { 115*7c478bd9Sstevel@tonic-gate char *devpath; 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate if (tgtdev != NULL) { 118*7c478bd9Sstevel@tonic-gate devpath = (char *)my_zalloc(PATH_MAX); 119*7c478bd9Sstevel@tonic-gate if (lookup_device(tgtdev, devpath)) { 120*7c478bd9Sstevel@tonic-gate target = get_device(tgtdev, devpath); 121*7c478bd9Sstevel@tonic-gate } 122*7c478bd9Sstevel@tonic-gate free(devpath); 123*7c478bd9Sstevel@tonic-gate if (target == NULL) { 124*7c478bd9Sstevel@tonic-gate return (0); 125*7c478bd9Sstevel@tonic-gate } 126*7c478bd9Sstevel@tonic-gate return (1); 127*7c478bd9Sstevel@tonic-gate } 128*7c478bd9Sstevel@tonic-gate return (scan_for_cd_device(flag, &target)); 129*7c478bd9Sstevel@tonic-gate } 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate void 132*7c478bd9Sstevel@tonic-gate main(int argc, char **argv) 133*7c478bd9Sstevel@tonic-gate { 134*7c478bd9Sstevel@tonic-gate int c; 135*7c478bd9Sstevel@tonic-gate int operations; 136*7c478bd9Sstevel@tonic-gate options specified_ops; 137*7c478bd9Sstevel@tonic-gate int aflag, iflag, Mflag, Lflag, lflag, bflag, xflag; 138*7c478bd9Sstevel@tonic-gate int ret; 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 143*7c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 144*7c478bd9Sstevel@tonic-gate #endif 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate ruid = getuid(); 150*7c478bd9Sstevel@tonic-gate cur_uid = geteuid(); 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate if (check_auth(ruid) != 1) { 153*7c478bd9Sstevel@tonic-gate err_msg(gettext( 154*7c478bd9Sstevel@tonic-gate "Authorization failed, Cannot access disks.\n")); 155*7c478bd9Sstevel@tonic-gate exit(1); 156*7c478bd9Sstevel@tonic-gate } 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate if ((cur_uid == 0) && (ruid != 0)) { 159*7c478bd9Sstevel@tonic-gate priv_change_needed = 1; 160*7c478bd9Sstevel@tonic-gate lower_priv(); 161*7c478bd9Sstevel@tonic-gate } 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate vol_running = volmgt_running(); 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate tgtdev = NULL; 166*7c478bd9Sstevel@tonic-gate operations = 0; 167*7c478bd9Sstevel@tonic-gate set_options_mask(&specified_ops, ""); 168*7c478bd9Sstevel@tonic-gate iflag = Mflag = Lflag = lflag = bflag = aflag = xflag = cflag = 0; 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, "abcCd:hiLlm:MOp:s:ST:vVx")) != EOF) { 171*7c478bd9Sstevel@tonic-gate add_option(&specified_ops, c); 172*7c478bd9Sstevel@tonic-gate switch (c) { 173*7c478bd9Sstevel@tonic-gate case 'a': 174*7c478bd9Sstevel@tonic-gate aflag = 1; 175*7c478bd9Sstevel@tonic-gate operations++; 176*7c478bd9Sstevel@tonic-gate break; 177*7c478bd9Sstevel@tonic-gate case 'b': 178*7c478bd9Sstevel@tonic-gate bflag = 1; 179*7c478bd9Sstevel@tonic-gate operations++; 180*7c478bd9Sstevel@tonic-gate break; 181*7c478bd9Sstevel@tonic-gate case 'c': 182*7c478bd9Sstevel@tonic-gate cflag = 1; 183*7c478bd9Sstevel@tonic-gate operations++; 184*7c478bd9Sstevel@tonic-gate break; 185*7c478bd9Sstevel@tonic-gate case 'C': 186*7c478bd9Sstevel@tonic-gate use_media_stated_capacity = 1; 187*7c478bd9Sstevel@tonic-gate break; 188*7c478bd9Sstevel@tonic-gate case 'd': 189*7c478bd9Sstevel@tonic-gate tgtdev = optarg; 190*7c478bd9Sstevel@tonic-gate break; 191*7c478bd9Sstevel@tonic-gate case 'h': 192*7c478bd9Sstevel@tonic-gate print_usage(); /* will not return */ 193*7c478bd9Sstevel@tonic-gate break; 194*7c478bd9Sstevel@tonic-gate case 'i': 195*7c478bd9Sstevel@tonic-gate iflag = 1; 196*7c478bd9Sstevel@tonic-gate operations++; 197*7c478bd9Sstevel@tonic-gate break; 198*7c478bd9Sstevel@tonic-gate case 'L': 199*7c478bd9Sstevel@tonic-gate Lflag = 1; 200*7c478bd9Sstevel@tonic-gate operations++; 201*7c478bd9Sstevel@tonic-gate break; 202*7c478bd9Sstevel@tonic-gate case 'l': 203*7c478bd9Sstevel@tonic-gate lflag = 1; 204*7c478bd9Sstevel@tonic-gate operations++; 205*7c478bd9Sstevel@tonic-gate break; 206*7c478bd9Sstevel@tonic-gate case 'm': 207*7c478bd9Sstevel@tonic-gate alt_tmp_dir = optarg; 208*7c478bd9Sstevel@tonic-gate break; 209*7c478bd9Sstevel@tonic-gate case 'M': 210*7c478bd9Sstevel@tonic-gate Mflag = 1; 211*7c478bd9Sstevel@tonic-gate operations++; 212*7c478bd9Sstevel@tonic-gate break; 213*7c478bd9Sstevel@tonic-gate case 'O': 214*7c478bd9Sstevel@tonic-gate keep_disc_open = 1; 215*7c478bd9Sstevel@tonic-gate break; 216*7c478bd9Sstevel@tonic-gate case 'p': 217*7c478bd9Sstevel@tonic-gate requested_speed = atoi(optarg); 218*7c478bd9Sstevel@tonic-gate break; 219*7c478bd9Sstevel@tonic-gate case 's': 220*7c478bd9Sstevel@tonic-gate copy_src = optarg; 221*7c478bd9Sstevel@tonic-gate break; 222*7c478bd9Sstevel@tonic-gate case 'S': 223*7c478bd9Sstevel@tonic-gate simulation++; 224*7c478bd9Sstevel@tonic-gate break; 225*7c478bd9Sstevel@tonic-gate case 'T': 226*7c478bd9Sstevel@tonic-gate audio_type = get_audio_type(optarg); 227*7c478bd9Sstevel@tonic-gate if (audio_type == -1) { 228*7c478bd9Sstevel@tonic-gate err_msg(gettext("Unknown audio type %s\n"), 229*7c478bd9Sstevel@tonic-gate optarg); 230*7c478bd9Sstevel@tonic-gate exit(1); 231*7c478bd9Sstevel@tonic-gate } 232*7c478bd9Sstevel@tonic-gate break; 233*7c478bd9Sstevel@tonic-gate case 'v': 234*7c478bd9Sstevel@tonic-gate verbose++; 235*7c478bd9Sstevel@tonic-gate break; 236*7c478bd9Sstevel@tonic-gate case 'V': 237*7c478bd9Sstevel@tonic-gate /* 238*7c478bd9Sstevel@tonic-gate * more verbose. this will print out debug comments 239*7c478bd9Sstevel@tonic-gate */ 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate debug++; 242*7c478bd9Sstevel@tonic-gate break; 243*7c478bd9Sstevel@tonic-gate case 'x': 244*7c478bd9Sstevel@tonic-gate xflag++; 245*7c478bd9Sstevel@tonic-gate operations++; 246*7c478bd9Sstevel@tonic-gate break; 247*7c478bd9Sstevel@tonic-gate default: 248*7c478bd9Sstevel@tonic-gate print_usage(); 249*7c478bd9Sstevel@tonic-gate } 250*7c478bd9Sstevel@tonic-gate } 251*7c478bd9Sstevel@tonic-gate if (operations == 0) { 252*7c478bd9Sstevel@tonic-gate err_msg(gettext("No operation specified.\n")); 253*7c478bd9Sstevel@tonic-gate exit(1); 254*7c478bd9Sstevel@tonic-gate } 255*7c478bd9Sstevel@tonic-gate if (operations != 1) { 256*7c478bd9Sstevel@tonic-gate err_msg(gettext("More than one operation specified.\n")); 257*7c478bd9Sstevel@tonic-gate exit(1); 258*7c478bd9Sstevel@tonic-gate } 259*7c478bd9Sstevel@tonic-gate 260*7c478bd9Sstevel@tonic-gate if (lflag) { 261*7c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "lhvV"); 262*7c478bd9Sstevel@tonic-gate list(); 263*7c478bd9Sstevel@tonic-gate } 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate /* 266*7c478bd9Sstevel@tonic-gate * we'll allow the user to specify the source device (-s) when 267*7c478bd9Sstevel@tonic-gate * extracting audio. 268*7c478bd9Sstevel@tonic-gate */ 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate if (xflag && copy_src) 271*7c478bd9Sstevel@tonic-gate tgtdev = copy_src; 272*7c478bd9Sstevel@tonic-gate 273*7c478bd9Sstevel@tonic-gate /* 274*7c478bd9Sstevel@tonic-gate * This will scan for all CD devices when xflag or Mflag 275*7c478bd9Sstevel@tonic-gate * (extract audio, list toc) commands are used, providing 276*7c478bd9Sstevel@tonic-gate * no CD-RW devices are found. Since these commands can 277*7c478bd9Sstevel@tonic-gate * be used without a CD writer. 278*7c478bd9Sstevel@tonic-gate */ 279*7c478bd9Sstevel@tonic-gate 280*7c478bd9Sstevel@tonic-gate if (xflag || Mflag) { 281*7c478bd9Sstevel@tonic-gate ret = setup_target(SCAN_ALL_CDS); 282*7c478bd9Sstevel@tonic-gate } else { 283*7c478bd9Sstevel@tonic-gate ret = setup_target(SCAN_WRITERS); 284*7c478bd9Sstevel@tonic-gate } 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate if (ret == 0) { 287*7c478bd9Sstevel@tonic-gate 288*7c478bd9Sstevel@tonic-gate if (tgtdev != NULL) { 289*7c478bd9Sstevel@tonic-gate err_msg(gettext( 290*7c478bd9Sstevel@tonic-gate "Cannot find device %s.\n"), tgtdev); 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate } 293*7c478bd9Sstevel@tonic-gate 294*7c478bd9Sstevel@tonic-gate if (vol_running) { 295*7c478bd9Sstevel@tonic-gate err_msg(gettext( 296*7c478bd9Sstevel@tonic-gate "No CD writers found or no media in the drive.\n")); 297*7c478bd9Sstevel@tonic-gate } else { 298*7c478bd9Sstevel@tonic-gate if (cur_uid != 0) { 299*7c478bd9Sstevel@tonic-gate err_msg(gettext( 300*7c478bd9Sstevel@tonic-gate "Volume manager is not running.\n")); 301*7c478bd9Sstevel@tonic-gate err_msg(gettext( 302*7c478bd9Sstevel@tonic-gate "Please start volume manager or run cdrw as root to access all devices.\n")); 303*7c478bd9Sstevel@tonic-gate } else { 304*7c478bd9Sstevel@tonic-gate err_msg(gettext( 305*7c478bd9Sstevel@tonic-gate "No CD writers found.\n")); 306*7c478bd9Sstevel@tonic-gate } 307*7c478bd9Sstevel@tonic-gate } 308*7c478bd9Sstevel@tonic-gate exit(1); 309*7c478bd9Sstevel@tonic-gate 310*7c478bd9Sstevel@tonic-gate } else if (ret != 1) { 311*7c478bd9Sstevel@tonic-gate err_msg(gettext("More than one CD device found.\n")); 312*7c478bd9Sstevel@tonic-gate err_msg(gettext("Specify one using -d option.\n")); 313*7c478bd9Sstevel@tonic-gate err_msg(gettext( 314*7c478bd9Sstevel@tonic-gate "Or use -l option to list all the CD devices found\n")); 315*7c478bd9Sstevel@tonic-gate exit(1); 316*7c478bd9Sstevel@tonic-gate } 317*7c478bd9Sstevel@tonic-gate (void) check_device(target, CHECK_TYPE_NOT_CDROM|EXIT_IF_CHECK_FAILED); 318*7c478bd9Sstevel@tonic-gate 319*7c478bd9Sstevel@tonic-gate if (check_device(target, CHECK_NO_MEDIA) == 0) { 320*7c478bd9Sstevel@tonic-gate int retry; 321*7c478bd9Sstevel@tonic-gate for (retry = 0; retry < 5; retry++) { 322*7c478bd9Sstevel@tonic-gate if (check_device(target, CHECK_DEVICE_NOT_READY) == 0) 323*7c478bd9Sstevel@tonic-gate break; 324*7c478bd9Sstevel@tonic-gate (void) sleep(3); 325*7c478bd9Sstevel@tonic-gate } 326*7c478bd9Sstevel@tonic-gate } 327*7c478bd9Sstevel@tonic-gate 328*7c478bd9Sstevel@tonic-gate if (aflag) { 329*7c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "ahvSCOdpTV"); 330*7c478bd9Sstevel@tonic-gate if (optind == argc) { 331*7c478bd9Sstevel@tonic-gate err_msg(gettext("No audio files specified.\n")); 332*7c478bd9Sstevel@tonic-gate exit(1); 333*7c478bd9Sstevel@tonic-gate } 334*7c478bd9Sstevel@tonic-gate write_audio(argv, optind, argc); 335*7c478bd9Sstevel@tonic-gate } 336*7c478bd9Sstevel@tonic-gate if (Mflag) { 337*7c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "MhvdV"); 338*7c478bd9Sstevel@tonic-gate info(); 339*7c478bd9Sstevel@tonic-gate } 340*7c478bd9Sstevel@tonic-gate if (iflag) { 341*7c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "ihvSCOdpV"); 342*7c478bd9Sstevel@tonic-gate if (optind == (argc - 1)) { 343*7c478bd9Sstevel@tonic-gate image_file = argv[optind]; 344*7c478bd9Sstevel@tonic-gate write_image(); 345*7c478bd9Sstevel@tonic-gate } 346*7c478bd9Sstevel@tonic-gate if (optind == argc) 347*7c478bd9Sstevel@tonic-gate write_image(); 348*7c478bd9Sstevel@tonic-gate err_msg(gettext("Command line parsing error.\n")); 349*7c478bd9Sstevel@tonic-gate err_msg(gettext("Only one image-file can be specified.\n")); 350*7c478bd9Sstevel@tonic-gate exit(1); 351*7c478bd9Sstevel@tonic-gate } 352*7c478bd9Sstevel@tonic-gate if (bflag) { 353*7c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "bhvdV"); 354*7c478bd9Sstevel@tonic-gate if (optind != (argc - 1)) { 355*7c478bd9Sstevel@tonic-gate err_msg(gettext("Command line parsing error.\n")); 356*7c478bd9Sstevel@tonic-gate print_usage(); 357*7c478bd9Sstevel@tonic-gate } 358*7c478bd9Sstevel@tonic-gate blanking_type = argv[argc - 1]; 359*7c478bd9Sstevel@tonic-gate blank(); 360*7c478bd9Sstevel@tonic-gate } 361*7c478bd9Sstevel@tonic-gate if (xflag) { 362*7c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "xhpvdsTV"); 363*7c478bd9Sstevel@tonic-gate if (optind != (argc - 2)) { 364*7c478bd9Sstevel@tonic-gate err_msg(gettext("Command line parsing error.\n")); 365*7c478bd9Sstevel@tonic-gate print_usage(); 366*7c478bd9Sstevel@tonic-gate } 367*7c478bd9Sstevel@tonic-gate extract_track_no = atoi(argv[argc - 2]); 368*7c478bd9Sstevel@tonic-gate extract_file = argv[argc - 1]; 369*7c478bd9Sstevel@tonic-gate extract_audio(); 370*7c478bd9Sstevel@tonic-gate } 371*7c478bd9Sstevel@tonic-gate if (cflag) { 372*7c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "chvSCdpmsV"); 373*7c478bd9Sstevel@tonic-gate copy_cd(); 374*7c478bd9Sstevel@tonic-gate } 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate /* 377*7c478bd9Sstevel@tonic-gate * Open a closed disk, we do this by erasing the track tail 378*7c478bd9Sstevel@tonic-gate * and then re-finalizing with an open leadout. 379*7c478bd9Sstevel@tonic-gate */ 380*7c478bd9Sstevel@tonic-gate if (Lflag) { 381*7c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "LvdV"); 382*7c478bd9Sstevel@tonic-gate (void) check_device(target, CHECK_NO_MEDIA | 383*7c478bd9Sstevel@tonic-gate CHECK_DEVICE_NOT_READY | EXIT_IF_CHECK_FAILED); 384*7c478bd9Sstevel@tonic-gate 385*7c478bd9Sstevel@tonic-gate /* no need to erase blank media */ 386*7c478bd9Sstevel@tonic-gate if (!check_device(target, CHECK_MEDIA_IS_NOT_BLANK)) 387*7c478bd9Sstevel@tonic-gate exit(0); 388*7c478bd9Sstevel@tonic-gate 389*7c478bd9Sstevel@tonic-gate blanking_type = "leadout"; 390*7c478bd9Sstevel@tonic-gate blank(); 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate write_init(TRACK_MODE_DATA); 393*7c478bd9Sstevel@tonic-gate (void) close_track(target->d_fd, 0, 1, 1); 394*7c478bd9Sstevel@tonic-gate (void) finalize(target); 395*7c478bd9Sstevel@tonic-gate (void) printf(gettext("done.\n")); 396*7c478bd9Sstevel@tonic-gate exit(0); 397*7c478bd9Sstevel@tonic-gate } 398*7c478bd9Sstevel@tonic-gate 399*7c478bd9Sstevel@tonic-gate } 400