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