/
showboot.c
167 lines (153 loc) · 4.3 KB
/
showboot.c
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
#include <stdio.h>
#include "bootany.h"
#define DISK_READ 2
#define DISK_WRITE 3
extern int bootio(int, char *);
#define SWITCH(var) switch (var)
#define CASE(val) break; case val:
#define ORCASE(val) case val:
#define DEFAULT break; default:
#define EMPTY 0
#define FAT_12 1
#define XENIX 2
#define FAT_16 4
#define EXTEND 5
#define BIGDOS 6
#define HPFS 7
#define NOVELL 0x64
#define PCIX 0x75
#define CP_M 0xDB
#define BBT 0xFF
#define StandardTable 0
#define BootAnyTable 1
main()
{
static char head1[] =
"ÚÄÄÄÄÄÄÂÄÄÄÄÂÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂ"
"ÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄ¿";
static char head2[] =
"³ Part ³Can ³Boot³ Beginning ³ Ending ³"
"Relative ³Number of³";
static char head3[] =
"³ Type ³Boot³Part³Side Cylinder Sector³Side Cylinder Sector³"
"Sectors ³ Sectors ³";
static char head4[] =
"ÃÄÄÄÄÄÄÅÄÄÄÄÅÄÄÄÄÅÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÅÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÅ"
"ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄ´";
static char detail1[] =
"³%6.6s³%4.4s³%4.4s³%3u ³%7u ³%5u ³%3u ³%7u ³%5u ³%8lu ³%8lu ³";
static char detail2[] =
"ÃÄÄÄÄÄÄÅÄÄÄÄÅÄÄÄÄÅÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÅÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÅ"
"ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄ´";
static char foot[] =
"ÀÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁ"
"ÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÙ";
char bootRecord[512];
char buffer[80];
int rc;
int tableType = StandardTable;
if ((rc = BOOTIO(DISK_READ, bootRecord)) == 0)
{
register BootData *bootInfo =
(BootData *)(bootRecord + DataAddr);
register PartitionEntry *part = bootInfo->partEntry;
int i;
printf(head1);
printf(head2);
printf(head3);
printf(head4);
for (i = 0; i < 4; ++i)
{
int type;
char boot;
char *active;
char *typeString;
char *bootString;
long relSectors;
long numSectors;
if (part->bootIndicator == 0 ||
part->bootIndicator == (char)(0x80))
{
type = (int)(part->systemId);
boot = part->bootIndicator;
active = (boot == (char)0x80) ? "YES" : " NO";
}
else
{
active = "NO";
tableType = BootAnyTable;
type = (int)(part->bootIndicator);
boot = part->systemId;
}
SWITCH(type)
{
CASE(EMPTY)
{
typeString = "EMPTY ";
}
CASE(FAT_12)
{
typeString = "DOS-12";
}
CASE(XENIX)
{
typeString = "XENIX ";
}
CASE(FAT_16)
{
typeString = "DOS-16";
}
CASE(EXTEND)
{
typeString = "EXTEND";
}
CASE(BIGDOS)
{
typeString = "BIGDOS";
}
CASE(HPFS)
{
typeString = "HPFS ";
}
CASE(NOVELL)
{
typeString = "NOVELL";
}
CASE(PCIX)
{
typeString = "PCIX ";
}
CASE(CP_M)
{
typeString = "CP/M ";
}
CASE(BBT)
{
typeString = "BBT ";
}
DEFAULT
{
typeString = "??????";
}
}
bootString = (boot == (char)0x80) ? "YES" : " NO";
relSectors = *(long*)(&part->relSectorLow);
numSectors = *(long*)(&part->numSectorsLow);
printf(detail1, typeString, bootString, active,
part->beginHead, part->beginCyl, part->beginSector,
part->endHead, part->endCyl, part->endSector,
relSectors, numSectors);
if (i < 3)
{
printf(detail2);
}
++part;
}
printf(foot);
}
else
{
printf("Error reading boot record - rc = %d\n",rc);
}
}