xref: /titanic_44/usr/src/cmd/rmformat/rmformat.h (revision ea8dc4b6d2251b437950c0056bc626b311c73c27)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_RMFORMAT_H
28 #define	_RMFORMAT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * This file contents the definitions for rmformat utility
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <stdio.h>
41 #include <strings.h>
42 #include <sys/stat.h>
43 #include <stdlib.h>
44 #include <errno.h>
45 #include <sys/param.h>
46 #include <unistd.h>
47 #include <limits.h>
48 #include <volmgt.h>
49 #include <sys/vtoc.h>
50 #include <locale.h>
51 #include <libintl.h>
52 #include <dirent.h>
53 #include <sys/dkio.h>
54 #include <sys/dktp/fdisk.h>
55 #include <sys/smedia.h>
56 #include <sys/efi_partition.h>
57 
58 #ifdef	DEBUG
59 #define	DPRINTF(str)			(void) printf(str)
60 #define	DPRINTF1(str, a)		(void) printf(str, a)
61 #define	DPRINTF2(str, a, b)		(void) printf(str, a, b)
62 #define	DPRINTF3(str, a, b, c)		(void) printf(str, a, b, c)
63 #define	DPRINTF4(str, a, b, c, d)	(void) printf(str, a, b, c, d)
64 #else
65 #define	DPRINTF(str)
66 #define	DPRINTF1(str, a)
67 #define	DPRINTF2(str, a, b)
68 #define	DPRINTF3(str, a, b, c)
69 #define	DPRINTF4(str, a, b, c, d)
70 #endif
71 
72 #define	PERROR(string)	my_perror(gettext(string))
73 
74 /* Little endian and big endian */
75 #ifdef sparc
76 #define	les(val)	((((val)&0xFF)<<8)|(((val)>>8)&0xFF))
77 #define	lel(val)	(((unsigned)(les((val)&0x0000FFFF))<<16) | \
78 			(les((unsigned)((val)&0xffff0000)>>16)))
79 #else	/* !sparc */
80 #define	les(val)	(val)
81 #define	lel(val)	(val)
82 #endif /* sparc */
83 
84 /* To avoid misalign access in sparc */
85 #ifdef sparc
86 #define	GET_32(addr)       \
87 	((*((uint8_t *)((char *)addr)) << 24) | \
88 	(*((uint8_t *)(((char *)addr)+1)) << 16) |\
89 	(*((uint8_t *)(((char *)addr)+2)) << 8) | \
90 	(*((uint8_t *)(((char *)addr)+3))))
91 
92 #else
93 #define	GET_32(addr) (*(uint32_t *)addr)
94 #endif
95 
96 #define	VERIFY_READ 1
97 #define	VERIFY_WRITE 2
98 
99 /* w_flag and others */
100 #define	WP_MSG_0 "Medium is already write protected\n"
101 #define	WP_MSG_1 "Medium is password protected : use -W option.\n"
102 #define	WP_MSG_2 "Medium is Read Write protected : use -R option.\n"
103 #define	WP_MSG_3 "Medium is not Write protected\n"
104 
105 /* W_flag */
106 #define	WP_MSG_4 "Medium is Read Write protected.\n"
107 #define	WP_MSG_5 "Changing to write protect with password.\n"
108 #define	WP_MSG_6 "Medium is already password protected\n"
109 #define	WP_MSG_7 "Medium is not password protected\n"
110 
111 /* R_flag */
112 
113 /* Misc */
114 #define	WP_MSG_8 "Medium is password write protected\n"
115 #define	WP_MSG_9 "Changing to Read Write protected\n"
116 #define	WP_MSG_10 "Wrong password or access denied\n"
117 #define	WP_UNKNOWN "Error, can not determine the state of the medium\n"
118 #define	WP_ERROR   "Error, write protect operation failed\n"
119 
120 /*
121  * Condition to be checked for a device
122  */
123 #define	CHECK_TYPE_NOT_CDROM		1
124 #define	CHECK_DEVICE_NOT_READY		2
125 #define	CHECK_DEVICE_NOT_WRITABLE	4
126 #define	CHECK_NO_MEDIA			8
127 #define	CHECK_MEDIA_IS_NOT_WRITABLE	0x10
128 #define	CHECK_MEDIA_IS_NOT_BLANK	0x20
129 #define	CHECK_MEDIA_IS_NOT_ERASABLE	0x40
130 #define	CHECK_DEVICE_IS_CD_WRITABLE	0x100
131 #define	CHECK_DEVICE_IS_DVD_WRITABLE	0x200
132 #define	CHECK_DEVICE_IS_DVD_READABLE	0x400
133 
134 #define	INQUIRY_DATA_LENGTH		96
135 #define	DVD_CONFIG_SIZE			0x20
136 
137 int uscsi_error;	/* used for debugging failed uscsi */
138 
139 /* fdisk related structures */
140 
141 struct fdisk_part {
142 	uint8_t    bootid;   /* Bootable? (Active/Inactive) */
143 	uint8_t    systid; /* OS type */
144 	uint32_t   relsect; /* Beginning of partition */
145 	uint32_t   numsect;
146 };
147 
148 struct fdisk_info {
149 	struct fdisk_part part[FD_NUMPART];
150 };
151 
152 typedef struct device {
153 	char		*d_node;
154 	char		*d_name;
155 	int		d_fd;
156 	uchar_t		*d_inq;
157 } device_t;
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* _RMFORMAT_H */
164