4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <sys/types.h>
34 #include "misc_scsi.h"
43 uchar_t
*toc
, *p
, *conf
;
48 struct track_info
*ti
;
50 msg
= gettext("Cannot read Table of contents\n");
52 get_media_type(target
->d_fd
);
54 (void) printf(gettext("\nDevice : %.8s %.16s\n"),
55 &target
->d_inq
[8], &target
->d_inq
[16]);
56 (void) printf(gettext("Firmware : Rev. %.4s (%.12s)\n"),
57 &target
->d_inq
[32], &target
->d_inq
[36]);
59 if (check_device(target
, CHECK_DEVICE_NOT_READY
)) {
60 (void) check_device(target
, CHECK_NO_MEDIA
|
61 EXIT_IF_CHECK_FAILED
);
62 (void) check_device(target
, CHECK_DEVICE_NOT_READY
|
63 EXIT_IF_CHECK_FAILED
);
68 * Determine the media type by reading the active profile
69 * from the profile list.
71 (void) printf(gettext("Media Type : "));
73 conf
= (uchar_t
*)my_zalloc(MMC_FTR_HDR_LEN
);
75 if (get_configuration(target
->d_fd
, MMC_FTR_PRFL_LIST
,
76 MMC_FTR_HDR_LEN
, conf
))
77 print_profile_name(read_scsi16(&conf
[6]), 0, 1);
79 (void) printf(gettext("UNKNOWN\n"));
84 * Get the start address of the last possible lead out.
86 cap
= get_last_possible_lba(target
);
89 * The start address of the last possible leadout will only
90 * be zero if the disc is full or this drive does not support
91 * this method of determining capacity.
94 cap
= read_format_capacity(target
->d_fd
, &bsize
);
97 * Since both methods of determining the capacity of the
98 * media count the correct number of blocks, just multiply
99 * the capacity by the block size.
101 cap
*= target
->d_blksize
;
103 if (device_type
== CD_RW
) {
104 (void) printf(gettext("Media Capacity : %.2f MB "),
105 ((double)cap
/ONE_MB_BASE2
));
108 * For DVD's make sure we print out "Formatted Media
109 * Capacity". Don't do this for CD-RWs as only
110 * DVDs are formatted.
112 (void) printf(gettext("Formatted Media Capacity : "
113 "%.2f GB "), ((double)cap
/ONE_GB_BASE10
));
116 cap
/= target
->d_blksize
;
117 (void) printf(gettext("(%u blocks)\n"), (uint_t
)cap
);
120 if (!check_device(target
, CHECK_MEDIA_IS_NOT_BLANK
)) {
121 (void) printf(gettext("Media is blank\n"));
125 /* Find out the number of entries in the toc */
126 toc
= (uchar_t
*)my_zalloc(12);
127 if (!read_toc(target
->d_fd
, 0, 1, 4, toc
)) {
130 toc_size
= 256*toc
[0] + toc
[1] + 2;
133 /* allocate enough space for each track entry */
134 toc
= (uchar_t
*)my_zalloc(toc_size
);
136 if (!read_toc(target
->d_fd
, 0, 1, toc_size
, toc
)) {
142 /* l10n_NOTE : Preserve column numbers of '|' character */
143 (void) printf(gettext("Track No. |Type |Start address\n"));
144 (void) printf("----------+--------+-------------\n");
147 /* look at each track and display it's type. */
149 for (p
= &toc
[4]; p
< (toc
+ toc_size
); p
+= 8) {
151 (void) printf(" %-3d |", p
[2]);
153 (void) printf("Leadout |");
154 (void) printf("%s |", (p
[1] & 4) ? gettext("Data ") :
156 (void) printf("%u\n", read_scsi32(&p
[4]));
160 ret
= read_toc(target
->d_fd
, 1, 0, 12, toc
);
161 if ((ret
== 0) || (toc
[1] != 0x0a))
162 /* For ATAPI drives or old Toshiba drives */
163 ret
= read_toc_as_per_8020(target
->d_fd
, 1, 0, 12, toc
);
165 if (ret
&& (toc
[1] == 0x0a)) {
166 (void) printf(gettext("Last session start address: %u\n"),
167 read_scsi32(&toc
[8]));
170 ti
= (struct track_info
*)my_zalloc(sizeof (struct track_info
));
172 if (build_track_info(target
, -1, ti
) && (ti
->ti_flags
& TI_NWA_VALID
)) {
173 (void) printf(gettext("Next writable address: %u\n"),