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