17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*0c83a891Snakanon * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <stdio.h> 307c478bd9Sstevel@tonic-gate #include <stdlib.h> 317c478bd9Sstevel@tonic-gate #include <sys/types.h> 327c478bd9Sstevel@tonic-gate #include <limits.h> 337c478bd9Sstevel@tonic-gate #include <unistd.h> 347c478bd9Sstevel@tonic-gate #include <libintl.h> 357c478bd9Sstevel@tonic-gate #include <locale.h> 367c478bd9Sstevel@tonic-gate #include <volmgt.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #include "msgs.h" 397c478bd9Sstevel@tonic-gate #include "device.h" 407c478bd9Sstevel@tonic-gate #include "util.h" 417c478bd9Sstevel@tonic-gate #include "main.h" 427c478bd9Sstevel@tonic-gate #include "options.h" 437c478bd9Sstevel@tonic-gate #include "mmc.h" 447c478bd9Sstevel@tonic-gate #include "misc_scsi.h" 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * global flags 487c478bd9Sstevel@tonic-gate */ 497c478bd9Sstevel@tonic-gate int debug = 0; 507c478bd9Sstevel@tonic-gate int use_media_stated_capacity = 0; 517c478bd9Sstevel@tonic-gate int keep_disc_open = 0; 527c478bd9Sstevel@tonic-gate int requested_speed = 0; 537c478bd9Sstevel@tonic-gate int simulation = 0; 547c478bd9Sstevel@tonic-gate int verbose = 0; 557c478bd9Sstevel@tonic-gate char *image_file = NULL; 567c478bd9Sstevel@tonic-gate char *blanking_type = NULL; 577c478bd9Sstevel@tonic-gate int audio_type = AUDIO_TYPE_NONE; 587c478bd9Sstevel@tonic-gate int extract_track_no = 0; 597c478bd9Sstevel@tonic-gate char *extract_file = NULL; 607c478bd9Sstevel@tonic-gate char *alt_tmp_dir = NULL; 617c478bd9Sstevel@tonic-gate char *copy_src = NULL; 627c478bd9Sstevel@tonic-gate int vol_running = 0; 637c478bd9Sstevel@tonic-gate int cflag = 0; 647c478bd9Sstevel@tonic-gate int tflag = 0; 657c478bd9Sstevel@tonic-gate uid_t ruid, cur_uid; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * global variables 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate cd_device *target = NULL; /* Default target device */ 717c478bd9Sstevel@tonic-gate static char *tgtdev = NULL; 727c478bd9Sstevel@tonic-gate int device_type = CD_RW; /* Default to CD/RW */ 737c478bd9Sstevel@tonic-gate int write_mode = TAO_MODE; /* Default to track at once */ 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate static void 767c478bd9Sstevel@tonic-gate print_usage(void) 777c478bd9Sstevel@tonic-gate { 787c478bd9Sstevel@tonic-gate err_msg(gettext("USAGE:\n")); 797c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -i [ -vSCO ] [ -d device ] [ -p speed ]")); 807c478bd9Sstevel@tonic-gate err_msg(gettext(" [ image-file ]\n")); 817c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -a [ -vSCO ] [ -d device ] [ -p speed ]")); 827c478bd9Sstevel@tonic-gate err_msg(gettext(" [ -T audio-type ] audio-file1 audio-file2 ...\n")); 837c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -x [ -v ] [ -d device ] [ -T audio-type ]")); 847c478bd9Sstevel@tonic-gate err_msg(gettext(" track-number audio-file\n")); 857c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -c [ -cSC ] [ -d device ] [ -p speed ]")); 867c478bd9Sstevel@tonic-gate err_msg(gettext(" [ -m tmp-dir ] [ -s src-device ]\n")); 877c478bd9Sstevel@tonic-gate err_msg( 887c478bd9Sstevel@tonic-gate gettext("\tcdrw -b [ -v ] [ -d device ] all | session | fast\n")); 897c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -M [ -v ] [ -d device ]\n")); 907c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -L [v] [ -d device ]\n")); 917c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -l [ -v ]\n")); 927c478bd9Sstevel@tonic-gate err_msg(gettext("\tcdrw -h\n")); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate exit(2); 957c478bd9Sstevel@tonic-gate } 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate static void 987c478bd9Sstevel@tonic-gate check_invalid_option(options *specified, char *opstr) 997c478bd9Sstevel@tonic-gate { 1007c478bd9Sstevel@tonic-gate options c_op; 1017c478bd9Sstevel@tonic-gate int ret; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate set_options_mask(&c_op, opstr); 1047c478bd9Sstevel@tonic-gate if ((ret = compare_options_mask(&c_op, specified)) != 0) { 1057c478bd9Sstevel@tonic-gate err_msg( 1067c478bd9Sstevel@tonic-gate gettext("Option %c is not defined for this operation.\n"), 1077c478bd9Sstevel@tonic-gate (char)ret); 1087c478bd9Sstevel@tonic-gate print_usage(); 1097c478bd9Sstevel@tonic-gate } 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate int 1137c478bd9Sstevel@tonic-gate setup_target(int flag) 1147c478bd9Sstevel@tonic-gate { 1157c478bd9Sstevel@tonic-gate char *devpath; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate if (tgtdev != NULL) { 1187c478bd9Sstevel@tonic-gate devpath = (char *)my_zalloc(PATH_MAX); 1197c478bd9Sstevel@tonic-gate if (lookup_device(tgtdev, devpath)) { 1207c478bd9Sstevel@tonic-gate target = get_device(tgtdev, devpath); 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate free(devpath); 1237c478bd9Sstevel@tonic-gate if (target == NULL) { 1247c478bd9Sstevel@tonic-gate return (0); 1257c478bd9Sstevel@tonic-gate } 1267c478bd9Sstevel@tonic-gate return (1); 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate return (scan_for_cd_device(flag, &target)); 1297c478bd9Sstevel@tonic-gate } 1307c478bd9Sstevel@tonic-gate 131*0c83a891Snakanon int 1327c478bd9Sstevel@tonic-gate main(int argc, char **argv) 1337c478bd9Sstevel@tonic-gate { 1347c478bd9Sstevel@tonic-gate int c; 1357c478bd9Sstevel@tonic-gate int operations; 1367c478bd9Sstevel@tonic-gate options specified_ops; 1377c478bd9Sstevel@tonic-gate int aflag, iflag, Mflag, Lflag, lflag, bflag, xflag; 1387c478bd9Sstevel@tonic-gate int ret; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 1437c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 1447c478bd9Sstevel@tonic-gate #endif 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate ruid = getuid(); 1507c478bd9Sstevel@tonic-gate cur_uid = geteuid(); 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate if (check_auth(ruid) != 1) { 1537c478bd9Sstevel@tonic-gate err_msg(gettext( 1547c478bd9Sstevel@tonic-gate "Authorization failed, Cannot access disks.\n")); 1557c478bd9Sstevel@tonic-gate exit(1); 1567c478bd9Sstevel@tonic-gate } 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate if ((cur_uid == 0) && (ruid != 0)) { 1597c478bd9Sstevel@tonic-gate priv_change_needed = 1; 1607c478bd9Sstevel@tonic-gate lower_priv(); 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate vol_running = volmgt_running(); 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate tgtdev = NULL; 1667c478bd9Sstevel@tonic-gate operations = 0; 1677c478bd9Sstevel@tonic-gate set_options_mask(&specified_ops, ""); 1687c478bd9Sstevel@tonic-gate iflag = Mflag = Lflag = lflag = bflag = aflag = xflag = cflag = 0; 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, "abcCd:hiLlm:MOp:s:ST:vVx")) != EOF) { 1717c478bd9Sstevel@tonic-gate add_option(&specified_ops, c); 1727c478bd9Sstevel@tonic-gate switch (c) { 1737c478bd9Sstevel@tonic-gate case 'a': 1747c478bd9Sstevel@tonic-gate aflag = 1; 1757c478bd9Sstevel@tonic-gate operations++; 1767c478bd9Sstevel@tonic-gate break; 1777c478bd9Sstevel@tonic-gate case 'b': 1787c478bd9Sstevel@tonic-gate bflag = 1; 1797c478bd9Sstevel@tonic-gate operations++; 1807c478bd9Sstevel@tonic-gate break; 1817c478bd9Sstevel@tonic-gate case 'c': 1827c478bd9Sstevel@tonic-gate cflag = 1; 1837c478bd9Sstevel@tonic-gate operations++; 1847c478bd9Sstevel@tonic-gate break; 1857c478bd9Sstevel@tonic-gate case 'C': 1867c478bd9Sstevel@tonic-gate use_media_stated_capacity = 1; 1877c478bd9Sstevel@tonic-gate break; 1887c478bd9Sstevel@tonic-gate case 'd': 1897c478bd9Sstevel@tonic-gate tgtdev = optarg; 1907c478bd9Sstevel@tonic-gate break; 1917c478bd9Sstevel@tonic-gate case 'h': 1927c478bd9Sstevel@tonic-gate print_usage(); /* will not return */ 1937c478bd9Sstevel@tonic-gate break; 1947c478bd9Sstevel@tonic-gate case 'i': 1957c478bd9Sstevel@tonic-gate iflag = 1; 1967c478bd9Sstevel@tonic-gate operations++; 1977c478bd9Sstevel@tonic-gate break; 1987c478bd9Sstevel@tonic-gate case 'L': 1997c478bd9Sstevel@tonic-gate Lflag = 1; 2007c478bd9Sstevel@tonic-gate operations++; 2017c478bd9Sstevel@tonic-gate break; 2027c478bd9Sstevel@tonic-gate case 'l': 2037c478bd9Sstevel@tonic-gate lflag = 1; 2047c478bd9Sstevel@tonic-gate operations++; 2057c478bd9Sstevel@tonic-gate break; 2067c478bd9Sstevel@tonic-gate case 'm': 2077c478bd9Sstevel@tonic-gate alt_tmp_dir = optarg; 2087c478bd9Sstevel@tonic-gate break; 2097c478bd9Sstevel@tonic-gate case 'M': 2107c478bd9Sstevel@tonic-gate Mflag = 1; 2117c478bd9Sstevel@tonic-gate operations++; 2127c478bd9Sstevel@tonic-gate break; 2137c478bd9Sstevel@tonic-gate case 'O': 2147c478bd9Sstevel@tonic-gate keep_disc_open = 1; 2157c478bd9Sstevel@tonic-gate break; 2167c478bd9Sstevel@tonic-gate case 'p': 2177c478bd9Sstevel@tonic-gate requested_speed = atoi(optarg); 2187c478bd9Sstevel@tonic-gate break; 2197c478bd9Sstevel@tonic-gate case 's': 2207c478bd9Sstevel@tonic-gate copy_src = optarg; 2217c478bd9Sstevel@tonic-gate break; 2227c478bd9Sstevel@tonic-gate case 'S': 2237c478bd9Sstevel@tonic-gate simulation++; 2247c478bd9Sstevel@tonic-gate break; 2257c478bd9Sstevel@tonic-gate case 'T': 2267c478bd9Sstevel@tonic-gate audio_type = get_audio_type(optarg); 2277c478bd9Sstevel@tonic-gate if (audio_type == -1) { 2287c478bd9Sstevel@tonic-gate err_msg(gettext("Unknown audio type %s\n"), 2297c478bd9Sstevel@tonic-gate optarg); 2307c478bd9Sstevel@tonic-gate exit(1); 2317c478bd9Sstevel@tonic-gate } 2327c478bd9Sstevel@tonic-gate break; 2337c478bd9Sstevel@tonic-gate case 'v': 2347c478bd9Sstevel@tonic-gate verbose++; 2357c478bd9Sstevel@tonic-gate break; 2367c478bd9Sstevel@tonic-gate case 'V': 2377c478bd9Sstevel@tonic-gate /* 2387c478bd9Sstevel@tonic-gate * more verbose. this will print out debug comments 2397c478bd9Sstevel@tonic-gate */ 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate debug++; 2427c478bd9Sstevel@tonic-gate break; 2437c478bd9Sstevel@tonic-gate case 'x': 2447c478bd9Sstevel@tonic-gate xflag++; 2457c478bd9Sstevel@tonic-gate operations++; 2467c478bd9Sstevel@tonic-gate break; 2477c478bd9Sstevel@tonic-gate default: 2487c478bd9Sstevel@tonic-gate print_usage(); 2497c478bd9Sstevel@tonic-gate } 2507c478bd9Sstevel@tonic-gate } 2517c478bd9Sstevel@tonic-gate if (operations == 0) { 2527c478bd9Sstevel@tonic-gate err_msg(gettext("No operation specified.\n")); 2537c478bd9Sstevel@tonic-gate exit(1); 2547c478bd9Sstevel@tonic-gate } 2557c478bd9Sstevel@tonic-gate if (operations != 1) { 2567c478bd9Sstevel@tonic-gate err_msg(gettext("More than one operation specified.\n")); 2577c478bd9Sstevel@tonic-gate exit(1); 2587c478bd9Sstevel@tonic-gate } 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate if (lflag) { 2617c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "lhvV"); 2627c478bd9Sstevel@tonic-gate list(); 2637c478bd9Sstevel@tonic-gate } 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate /* 2667c478bd9Sstevel@tonic-gate * we'll allow the user to specify the source device (-s) when 2677c478bd9Sstevel@tonic-gate * extracting audio. 2687c478bd9Sstevel@tonic-gate */ 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate if (xflag && copy_src) 2717c478bd9Sstevel@tonic-gate tgtdev = copy_src; 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate /* 2747c478bd9Sstevel@tonic-gate * This will scan for all CD devices when xflag or Mflag 2757c478bd9Sstevel@tonic-gate * (extract audio, list toc) commands are used, providing 2767c478bd9Sstevel@tonic-gate * no CD-RW devices are found. Since these commands can 2777c478bd9Sstevel@tonic-gate * be used without a CD writer. 2787c478bd9Sstevel@tonic-gate */ 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate if (xflag || Mflag) { 2817c478bd9Sstevel@tonic-gate ret = setup_target(SCAN_ALL_CDS); 2827c478bd9Sstevel@tonic-gate } else { 2837c478bd9Sstevel@tonic-gate ret = setup_target(SCAN_WRITERS); 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate if (ret == 0) { 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate if (tgtdev != NULL) { 2897c478bd9Sstevel@tonic-gate err_msg(gettext( 2907c478bd9Sstevel@tonic-gate "Cannot find device %s.\n"), tgtdev); 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate } 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate if (vol_running) { 2957c478bd9Sstevel@tonic-gate err_msg(gettext( 2967c478bd9Sstevel@tonic-gate "No CD writers found or no media in the drive.\n")); 2977c478bd9Sstevel@tonic-gate } else { 2987c478bd9Sstevel@tonic-gate if (cur_uid != 0) { 2997c478bd9Sstevel@tonic-gate err_msg(gettext( 3007c478bd9Sstevel@tonic-gate "Volume manager is not running.\n")); 3017c478bd9Sstevel@tonic-gate err_msg(gettext( 3027c478bd9Sstevel@tonic-gate "Please start volume manager or run cdrw as root to access all devices.\n")); 3037c478bd9Sstevel@tonic-gate } else { 3047c478bd9Sstevel@tonic-gate err_msg(gettext( 3057c478bd9Sstevel@tonic-gate "No CD writers found.\n")); 3067c478bd9Sstevel@tonic-gate } 3077c478bd9Sstevel@tonic-gate } 3087c478bd9Sstevel@tonic-gate exit(1); 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate } else if (ret != 1) { 3117c478bd9Sstevel@tonic-gate err_msg(gettext("More than one CD device found.\n")); 3127c478bd9Sstevel@tonic-gate err_msg(gettext("Specify one using -d option.\n")); 3137c478bd9Sstevel@tonic-gate err_msg(gettext( 3147c478bd9Sstevel@tonic-gate "Or use -l option to list all the CD devices found\n")); 3157c478bd9Sstevel@tonic-gate exit(1); 3167c478bd9Sstevel@tonic-gate } 3177c478bd9Sstevel@tonic-gate (void) check_device(target, CHECK_TYPE_NOT_CDROM|EXIT_IF_CHECK_FAILED); 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate if (check_device(target, CHECK_NO_MEDIA) == 0) { 3207c478bd9Sstevel@tonic-gate int retry; 3217c478bd9Sstevel@tonic-gate for (retry = 0; retry < 5; retry++) { 3227c478bd9Sstevel@tonic-gate if (check_device(target, CHECK_DEVICE_NOT_READY) == 0) 3237c478bd9Sstevel@tonic-gate break; 3247c478bd9Sstevel@tonic-gate (void) sleep(3); 3257c478bd9Sstevel@tonic-gate } 3267c478bd9Sstevel@tonic-gate } 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate if (aflag) { 3297c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "ahvSCOdpTV"); 3307c478bd9Sstevel@tonic-gate if (optind == argc) { 3317c478bd9Sstevel@tonic-gate err_msg(gettext("No audio files specified.\n")); 3327c478bd9Sstevel@tonic-gate exit(1); 3337c478bd9Sstevel@tonic-gate } 3347c478bd9Sstevel@tonic-gate write_audio(argv, optind, argc); 3357c478bd9Sstevel@tonic-gate } 3367c478bd9Sstevel@tonic-gate if (Mflag) { 3377c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "MhvdV"); 3387c478bd9Sstevel@tonic-gate info(); 3397c478bd9Sstevel@tonic-gate } 3407c478bd9Sstevel@tonic-gate if (iflag) { 3417c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "ihvSCOdpV"); 3427c478bd9Sstevel@tonic-gate if (optind == (argc - 1)) { 3437c478bd9Sstevel@tonic-gate image_file = argv[optind]; 3447c478bd9Sstevel@tonic-gate write_image(); 3457c478bd9Sstevel@tonic-gate } 3467c478bd9Sstevel@tonic-gate if (optind == argc) 3477c478bd9Sstevel@tonic-gate write_image(); 3487c478bd9Sstevel@tonic-gate err_msg(gettext("Command line parsing error.\n")); 3497c478bd9Sstevel@tonic-gate err_msg(gettext("Only one image-file can be specified.\n")); 3507c478bd9Sstevel@tonic-gate exit(1); 3517c478bd9Sstevel@tonic-gate } 3527c478bd9Sstevel@tonic-gate if (bflag) { 3537c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "bhvdV"); 3547c478bd9Sstevel@tonic-gate if (optind != (argc - 1)) { 3557c478bd9Sstevel@tonic-gate err_msg(gettext("Command line parsing error.\n")); 3567c478bd9Sstevel@tonic-gate print_usage(); 3577c478bd9Sstevel@tonic-gate } 3587c478bd9Sstevel@tonic-gate blanking_type = argv[argc - 1]; 3597c478bd9Sstevel@tonic-gate blank(); 3607c478bd9Sstevel@tonic-gate } 3617c478bd9Sstevel@tonic-gate if (xflag) { 3627c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "xhpvdsTV"); 3637c478bd9Sstevel@tonic-gate if (optind != (argc - 2)) { 3647c478bd9Sstevel@tonic-gate err_msg(gettext("Command line parsing error.\n")); 3657c478bd9Sstevel@tonic-gate print_usage(); 3667c478bd9Sstevel@tonic-gate } 3677c478bd9Sstevel@tonic-gate extract_track_no = atoi(argv[argc - 2]); 3687c478bd9Sstevel@tonic-gate extract_file = argv[argc - 1]; 3697c478bd9Sstevel@tonic-gate extract_audio(); 3707c478bd9Sstevel@tonic-gate } 3717c478bd9Sstevel@tonic-gate if (cflag) { 3727c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "chvSCdpmsV"); 3737c478bd9Sstevel@tonic-gate copy_cd(); 3747c478bd9Sstevel@tonic-gate } 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate /* 3777c478bd9Sstevel@tonic-gate * Open a closed disk, we do this by erasing the track tail 3787c478bd9Sstevel@tonic-gate * and then re-finalizing with an open leadout. 3797c478bd9Sstevel@tonic-gate */ 3807c478bd9Sstevel@tonic-gate if (Lflag) { 3817c478bd9Sstevel@tonic-gate check_invalid_option(&specified_ops, "LvdV"); 3827c478bd9Sstevel@tonic-gate (void) check_device(target, CHECK_NO_MEDIA | 3837c478bd9Sstevel@tonic-gate CHECK_DEVICE_NOT_READY | EXIT_IF_CHECK_FAILED); 3847c478bd9Sstevel@tonic-gate 3857c478bd9Sstevel@tonic-gate /* no need to erase blank media */ 3867c478bd9Sstevel@tonic-gate if (!check_device(target, CHECK_MEDIA_IS_NOT_BLANK)) 3877c478bd9Sstevel@tonic-gate exit(0); 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate blanking_type = "leadout"; 3907c478bd9Sstevel@tonic-gate blank(); 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate write_init(TRACK_MODE_DATA); 3937c478bd9Sstevel@tonic-gate (void) close_track(target->d_fd, 0, 1, 1); 3947c478bd9Sstevel@tonic-gate (void) finalize(target); 3957c478bd9Sstevel@tonic-gate (void) printf(gettext("done.\n")); 3967c478bd9Sstevel@tonic-gate exit(0); 3977c478bd9Sstevel@tonic-gate } 398*0c83a891Snakanon return (0); 3997c478bd9Sstevel@tonic-gate } 400