~ubuntu-branches/ubuntu/gutsy/evms/gutsy

« back to all changes in this revision

Viewing changes to plugins/dos/display.c

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2006-09-14 19:32:30 UTC
  • mfrom: (2.1.13 edgy)
  • Revision ID: james.westby@ubuntu.com-20060914193230-4b1pmy0coqk81sqa
Tags: 2.5.5-18
* Apply patches from upstream:
  * cli_query_segfault.patch, fixes a segfault in the CLI when doing a
    query.
  * cli_reload_options.patch, reloads the right option descriptors after
    a change.
  * ntfs_unmkfs.patch, fixes a bug in the wiping of NTFS file systems.
  * raid5_remove_spare_fix.patch + raid5_remove_spare_fix_2.patch, lets the
    user remove a spare if resync does not run.
  * raid5_algorithm.patch, makes EVMS heed the parity algorithm the user
    selects when creating a RAID-5 array.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 *   (C) Copyright IBM Corp. 2001, 2003
 
4
 *
 
5
 *   This program is free software;  you can redistribute it and/or modify
 
6
 *   it under the terms of the GNU General Public License as published by
 
7
 *   the Free Software Foundation; either version 2 of the License, or
 
8
 *   (at your option) any later version.
 
9
 *
 
10
 *   This program is distributed in the hope that it will be useful,
 
11
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 
13
 *   the GNU General Public License for more details.
 
14
 *
 
15
 *   You should have received a copy of the GNU General Public License
 
16
 *   along with this program;  if not, write to the Free Software
 
17
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
18
 *
 
19
 *   Module: libdos.so
 
20
 *
 
21
 *   File: display.c
 
22
 *
 
23
 */
 
24
 
 
25
#include <stdlib.h>
 
26
#include <stdio.h>
 
27
#include <string.h>
 
28
#include <errno.h>
 
29
 
 
30
#include <plugin.h>
 
31
 
 
32
#include "ptables.h"
 
33
#include "display.h"
 
34
#include "segs.h"
 
35
#include "bsd.h"
 
36
#include "unixware.h"
 
37
#include "solarisX86.h"
 
38
 
 
39
static int   DisplayDiskSeg( DISKSEG *seg )
 
40
{
 
41
        char       Type[21];
 
42
        char       Boot[5] = "    ";
 
43
        u_int16_t  Id;
 
44
        int        rc;
 
45
        u_int32_t  StartLBA;
 
46
        u_int32_t  EndLBA;
 
47
        u_int32_t  SectorCount;
 
48
        SEG_PRIVATE_DATA  *pdata;
 
49
        char       Name[128];
 
50
 
 
51
        if (seg) {
 
52
 
 
53
                pdata       = (SEG_PRIVATE_DATA *) seg->private_data;
 
54
 
 
55
                StartLBA    = seg->start;
 
56
                EndLBA      = seg->start + seg->size -1;
 
57
                SectorCount = seg->size;
 
58
                Id          = pdata->sys_id;
 
59
 
 
60
                if (seg->name) {
 
61
                        strncpy(Name, seg->name, EVMS_NAME_SIZE );
 
62
                }
 
63
                else {
 
64
                        strcpy(Name, "n/a");
 
65
                }
 
66
 
 
67
 
 
68
                if ( pdata->boot_ind & ACTIVE_PARTITION   ) strcpy(Boot,"  * ");
 
69
 
 
70
                switch (seg->data_type) {
 
71
                case   META_DATA_TYPE:
 
72
                        if ( pdata->flags & SEG_IS_EBR )
 
73
                                strcpy(Type, "Meta Data: EBR");
 
74
                        else if ( pdata->flags & SEG_IS_MBR )
 
75
                                strcpy(Type, "Meta Data: MBR");
 
76
                        else
 
77
                                strcpy(Type, "Meta Data");
 
78
                        break;
 
79
 
 
80
                case   DATA_TYPE:
 
81
                        if ( pdata->flags & SEG_IS_LINUX_SWAP_PARTITION)
 
82
                                strcpy(Type, "Data Seg: Linux Swap");
 
83
                        else
 
84
                                strcpy(Type, "Data Seg");
 
85
                        break;
 
86
 
 
87
                case   FREE_SPACE_TYPE:
 
88
                        strcpy(Type, "Free Space");
 
89
                        break;
 
90
 
 
91
                default:
 
92
                        strcpy(Type, "Unknown ");
 
93
                        break;
 
94
                }
 
95
 
 
96
                LOG_DEBUG("%-20s   %-4s   %02X    %08d   %08d   %08d   %s\n", Type, Boot, Id, StartLBA, EndLBA, SectorCount, Name);
 
97
 
 
98
                rc = 0;
 
99
        }
 
100
        else {
 
101
                rc = EPERM;
 
102
        }
 
103
 
 
104
        return rc;
 
105
}
 
106
 
 
107
void  DisplayDiskSegmentList(LOGICALDISK *ld)
 
108
{
 
109
        list_element_t iter;
 
110
        DISKSEG *seg;
 
111
 
 
112
        if (ld==NULL) return;
 
113
        if (ld->parent_objects==NULL) return;
 
114
 
 
115
 
 
116
        LOG_DEBUG("\t\tLogical Disk Segment List ... \n");
 
117
        LOG_DEBUG("Type                   Boot   Id   Start LBA    End LBA    Sectors   SegName\n");
 
118
 
 
119
        LIST_FOR_EACH( ld->parent_objects, iter, seg ) {
 
120
                DisplayDiskSeg(seg);
 
121
        }
 
122
 
 
123
}
 
124
 
 
125
 
 
126
void  DisplayPartitionRecord( Partition_Record          *part ,
 
127
                              int                        table_index,
 
128
                              boolean                    logical_partition )
 
129
{
 
130
        char          Type[21];
 
131
        char          Boot[5] = "    ";
 
132
        u_int16_t     Id;
 
133
        u_int32_t     StartLBA;
 
134
        u_int32_t     EndLBA;
 
135
        u_int32_t     SectorCount;
 
136
 
 
137
 
 
138
 
 
139
        StartLBA    = (u_int32_t) DISK_TO_CPU32(START_LBA(part));
 
140
        EndLBA      = (u_int32_t) DISK_TO_CPU32(START_LBA(part))+DISK_TO_CPU32(NR_SECTS(part));
 
141
        SectorCount = DISK_TO_CPU32(NR_SECTS(part));
 
142
        Id          = SYS_IND(part);
 
143
 
 
144
        if (EndLBA) --EndLBA;
 
145
 
 
146
        if (BOOT_IND(part))   strcpy(Boot,"  * ");
 
147
 
 
148
        switch (Id) {
 
149
        
 
150
        case OPENBSD_PARTITION:
 
151
        case FREEBSD_PARTITION:
 
152
        case NETBSD_PARTITION:
 
153
        case BSDI_PARTITION:
 
154
                strcpy(Type, "BSD");
 
155
                break;
 
156
        case LINUX_SWAP_PARTITION:
 
157
                strcpy(Type, "Linux Swap/Solaris");
 
158
                break;
 
159
        case LINUX_RAID_PARTITION:
 
160
                strcpy(Type, "Linux RAID");
 
161
                break;
 
162
        case LINUX_LVM_PARTITION:
 
163
                strcpy(Type, "Linux LVM");
 
164
                break;
 
165
        case LINUX_EXT2_PARTITION:
 
166
                strcpy(Type, "Linux");
 
167
                break;
 
168
        case LINUX_EXTENDED_PARTITION:
 
169
                strcpy(Type, "Linux Extd");
 
170
                break;
 
171
        case UNIXWARE_PARTITION:
 
172
                strcpy(Type, "UnixWare");
 
173
                break;
 
174
        case DOS_EXTENDED_PARTITION:
 
175
                strcpy(Type, "DOS Extd");
 
176
                break;
 
177
        case WIN98_EXTENDED_PARTITION:
 
178
                strcpy(Type, "Win95 Extd");
 
179
                break;
 
180
        case HPFSNTFS_PARTITION:
 
181
                strcpy(Type, "Hpfs/Ntfs");
 
182
                break;
 
183
        case HIDDEN_OS2_PARTITION:
 
184
                strcpy(Type, "OS2 Hidden C");
 
185
                break;
 
186
        case OS2_BOOT_MGR_PARTITION:
 
187
                strcpy(Type,"OS2 Boot Mgr");
 
188
                break;
 
189
        case OS2_LVM_SIGNATURE_PARTITION:
 
190
                strcpy(Type,"OS2 LVM");
 
191
                break;
 
192
        case HIDDEN_OS2_LVM_SIGNATURE_PARTITION:
 
193
                strcpy(Type,"OS2 Hidden LVM");
 
194
                break;
 
195
        case SMALL_FAT16_PARTITION:
 
196
        case LARGE_FAT16_PARTITION:
 
197
                strcpy(Type,"FAT16");
 
198
                break;
 
199
        case UNUSED_PARTITION_ENTRY:
 
200
                strcpy(Type, "Unused Entry");
 
201
                break;
 
202
        case GPT_ENTIRE_DISK_PARTITION:
 
203
                strcpy(Type, "GPT-ENTIRE-DISK");
 
204
                break;
 
205
        case GPT_ESP_PARTITION:
 
206
                strcpy(Type, "GPT-ESP");
 
207
                break;
 
208
        default:
 
209
                strcpy(Type,"n/a");
 
210
                break;
 
211
        }
 
212
 
 
213
        LOG_DEBUG("%-20s   %-4s   %02X    %08d   %08d   %08d\n", Type, Boot, Id, StartLBA, EndLBA, SectorCount);
 
214
}
 
215
 
 
216
 
 
217
void  DisplayPartitionTable(LOGICALDISK *ld, Partition_Record *partptr , boolean mbr)
 
218
{
 
219
        int  i;
 
220
        Partition_Record *part = partptr;
 
221
 
 
222
 
 
223
        if (mbr==TRUE)
 
224
                LOG_DEBUG("\t\tMaster Boot Record \n");
 
225
        else
 
226
                LOG_DEBUG("\t\tExtended Boot Record\n");
 
227
 
 
228
        LOG_DEBUG("Type                   Boot   Id   Start LBA    End LBA    Sectors\n");
 
229
 
 
230
        for (i=0; i<4; i++) {
 
231
 
 
232
                if (mbr==TRUE)
 
233
                        DisplayPartitionRecord( part, i, FALSE );
 
234
                else
 
235
                        DisplayPartitionRecord( part, i, TRUE  );
 
236
                ++part;
 
237
        }
 
238
 
 
239
 
 
240
}
 
241
 
 
242
 
 
243