1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include <sys/types.h> 30 #include <stdlib.h> 31 #include <libintl.h> 32 33 #include "msgs.h" 34 #include "mmc.h" 35 #include "misc_scsi.h" 36 #include "device.h" 37 #include "main.h" 38 #include "util.h" 39 #include "toshiba.h" 40 41 void 42 info(void) 43 { 44 uchar_t *toc, *p; 45 int ret, toc_size; 46 char *msg; 47 struct track_info *ti; 48 49 msg = gettext("Cannot read Table of contents\n"); 50 51 get_media_type(target->d_fd); 52 53 (void) printf(gettext("\nDevice : %.8s %.16s\n"), 54 &target->d_inq[8], &target->d_inq[16]); 55 (void) printf(gettext("Firmware : Rev. %.4s (%.12s)\n"), 56 &target->d_inq[32], &target->d_inq[36]); 57 58 if (check_device(target, CHECK_DEVICE_NOT_READY)) { 59 (void) check_device(target, CHECK_NO_MEDIA | 60 EXIT_IF_CHECK_FAILED); 61 (void) check_device(target, CHECK_DEVICE_NOT_READY | 62 EXIT_IF_CHECK_FAILED); 63 } 64 if (!check_device(target, CHECK_MEDIA_IS_NOT_BLANK)) { 65 (void) printf(gettext("Media is blank\n")); 66 exit(0); 67 } 68 69 /* Find out the number of entries in the toc */ 70 toc = (uchar_t *)my_zalloc(12); 71 if (!read_toc(target->d_fd, 0, 1, 4, toc)) { 72 err_msg(msg); 73 } else { 74 toc_size = 256*toc[0] + toc[1] + 2; 75 free(toc); 76 77 /* allocate enough space for each track entry */ 78 toc = (uchar_t *)my_zalloc(toc_size); 79 80 if (!read_toc(target->d_fd, 0, 1, toc_size, toc)) { 81 err_msg(msg); 82 exit(1); 83 } 84 (void) printf("\n"); 85 86 /* l10n_NOTE : Preserve column numbers of '|' character */ 87 (void) printf(gettext("Track No. |Type |Start address\n")); 88 (void) printf("----------+--------+-------------\n"); 89 90 91 /* look at each track and display it's type. */ 92 93 for (p = &toc[4]; p < (toc + toc_size); p += 8) { 94 if (p[2] != 0xAA) 95 (void) printf(" %-3d |", p[2]); 96 else 97 (void) printf("Leadout |"); 98 (void) printf("%s |", (p[1] & 4) ? gettext("Data ") : 99 gettext("Audio")); 100 (void) printf("%u\n", read_scsi32(&p[4])); 101 } 102 } 103 (void) printf("\n"); 104 ret = read_toc(target->d_fd, 1, 0, 12, toc); 105 if ((ret == 0) || (toc[1] != 0x0a)) 106 /* For ATAPI drives or old Toshiba drives */ 107 ret = read_toc_as_per_8020(target->d_fd, 1, 0, 12, toc); 108 109 if (ret && (toc[1] == 0x0a)) { 110 (void) printf(gettext("Last session start address: %u\n"), 111 read_scsi32(&toc[8])); 112 } 113 free(toc); 114 ti = (struct track_info *)my_zalloc(sizeof (struct track_info)); 115 116 if (build_track_info(target, -1, ti) && (ti->ti_flags & TI_NWA_VALID)) { 117 (void) printf(gettext("Next writable address: %u\n"), 118 ti->ti_nwa); 119 } 120 free(ti); 121 exit(0); 122 } 123