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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
|
/*
*
* (C) Copyright IBM Corp. 2001, 2003
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Module: libdos.so
*
* File: display.c
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <plugin.h>
#include "ptables.h"
#include "display.h"
#include "segs.h"
#include "bsd.h"
#include "unixware.h"
#include "solarisX86.h"
static int DisplayDiskSeg( DISKSEG *seg )
{
char Type[21];
char Boot[5] = " ";
u_int16_t Id;
int rc;
u_int32_t StartLBA;
u_int32_t EndLBA;
u_int32_t SectorCount;
SEG_PRIVATE_DATA *pdata;
char Name[128];
if (seg) {
pdata = (SEG_PRIVATE_DATA *) seg->private_data;
StartLBA = seg->start;
EndLBA = seg->start + seg->size -1;
SectorCount = seg->size;
Id = pdata->sys_id;
if (seg->name) {
strncpy(Name, seg->name, EVMS_NAME_SIZE );
}
else {
strcpy(Name, "n/a");
}
if ( pdata->boot_ind & ACTIVE_PARTITION ) strcpy(Boot," * ");
switch (seg->data_type) {
case META_DATA_TYPE:
if ( pdata->flags & SEG_IS_EBR )
strcpy(Type, "Meta Data: EBR");
else if ( pdata->flags & SEG_IS_MBR )
strcpy(Type, "Meta Data: MBR");
else
strcpy(Type, "Meta Data");
break;
case DATA_TYPE:
if ( pdata->flags & SEG_IS_LINUX_SWAP_PARTITION)
strcpy(Type, "Data Seg: Linux Swap");
else
strcpy(Type, "Data Seg");
break;
case FREE_SPACE_TYPE:
strcpy(Type, "Free Space");
break;
default:
strcpy(Type, "Unknown ");
break;
}
LOG_DEBUG("%-20s %-4s %02X %08d %08d %08d %s\n", Type, Boot, Id, StartLBA, EndLBA, SectorCount, Name);
rc = 0;
}
else {
rc = EPERM;
}
return rc;
}
void DisplayDiskSegmentList(LOGICALDISK *ld)
{
list_element_t iter;
DISKSEG *seg;
if (ld==NULL) return;
if (ld->parent_objects==NULL) return;
LOG_DEBUG("\t\tLogical Disk Segment List ... \n");
LOG_DEBUG("Type Boot Id Start LBA End LBA Sectors SegName\n");
LIST_FOR_EACH( ld->parent_objects, iter, seg ) {
DisplayDiskSeg(seg);
}
}
void DisplayPartitionRecord( Partition_Record *part ,
int table_index,
boolean logical_partition )
{
char Type[21];
char Boot[5] = " ";
u_int16_t Id;
u_int32_t StartLBA;
u_int32_t EndLBA;
u_int32_t SectorCount;
StartLBA = (u_int32_t) DISK_TO_CPU32(START_LBA(part));
EndLBA = (u_int32_t) DISK_TO_CPU32(START_LBA(part))+DISK_TO_CPU32(NR_SECTS(part));
SectorCount = DISK_TO_CPU32(NR_SECTS(part));
Id = SYS_IND(part);
if (EndLBA) --EndLBA;
if (BOOT_IND(part)) strcpy(Boot," * ");
switch (Id) {
case OPENBSD_PARTITION:
case FREEBSD_PARTITION:
case NETBSD_PARTITION:
case BSDI_PARTITION:
strcpy(Type, "BSD");
break;
case LINUX_SWAP_PARTITION:
strcpy(Type, "Linux Swap/Solaris");
break;
case LINUX_RAID_PARTITION:
strcpy(Type, "Linux RAID");
break;
case LINUX_LVM_PARTITION:
strcpy(Type, "Linux LVM");
break;
case LINUX_EXT2_PARTITION:
strcpy(Type, "Linux");
break;
case LINUX_EXTENDED_PARTITION:
strcpy(Type, "Linux Extd");
break;
case UNIXWARE_PARTITION:
strcpy(Type, "UnixWare");
break;
case DOS_EXTENDED_PARTITION:
strcpy(Type, "DOS Extd");
break;
case WIN98_EXTENDED_PARTITION:
strcpy(Type, "Win95 Extd");
break;
case HPFSNTFS_PARTITION:
strcpy(Type, "Hpfs/Ntfs");
break;
case HIDDEN_OS2_PARTITION:
strcpy(Type, "OS2 Hidden C");
break;
case OS2_BOOT_MGR_PARTITION:
strcpy(Type,"OS2 Boot Mgr");
break;
case OS2_LVM_SIGNATURE_PARTITION:
strcpy(Type,"OS2 LVM");
break;
case HIDDEN_OS2_LVM_SIGNATURE_PARTITION:
strcpy(Type,"OS2 Hidden LVM");
break;
case SMALL_FAT16_PARTITION:
case LARGE_FAT16_PARTITION:
strcpy(Type,"FAT16");
break;
case UNUSED_PARTITION_ENTRY:
strcpy(Type, "Unused Entry");
break;
case GPT_ENTIRE_DISK_PARTITION:
strcpy(Type, "GPT-ENTIRE-DISK");
break;
case GPT_ESP_PARTITION:
strcpy(Type, "GPT-ESP");
break;
default:
strcpy(Type,"n/a");
break;
}
LOG_DEBUG("%-20s %-4s %02X %08d %08d %08d\n", Type, Boot, Id, StartLBA, EndLBA, SectorCount);
}
void DisplayPartitionTable(LOGICALDISK *ld, Partition_Record *partptr , boolean mbr)
{
int i;
Partition_Record *part = partptr;
if (mbr==TRUE)
LOG_DEBUG("\t\tMaster Boot Record \n");
else
LOG_DEBUG("\t\tExtended Boot Record\n");
LOG_DEBUG("Type Boot Id Start LBA End LBA Sectors\n");
for (i=0; i<4; i++) {
if (mbr==TRUE)
DisplayPartitionRecord( part, i, FALSE );
else
DisplayPartitionRecord( part, i, TRUE );
++part;
}
}
|