summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/FDISK/PARTINFO.C
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/FDISK/PARTINFO.C')
-rw-r--r--v4.0/src/CMD/FDISK/PARTINFO.C262
1 files changed, 262 insertions, 0 deletions
diff --git a/v4.0/src/CMD/FDISK/PARTINFO.C b/v4.0/src/CMD/FDISK/PARTINFO.C
new file mode 100644
index 0000000..040ee5a
--- /dev/null
+++ b/v4.0/src/CMD/FDISK/PARTINFO.C
@@ -0,0 +1,262 @@
1
2#include "dos.h" /* AN000 */
3#include "fdisk.h" /* AN000 */
4#include "subtype.h" /* AN000 */
5#include "extern.h" /* AN000 */
6
7/* */
8char find_free_partition()
9
10BEGIN
11 char i;
12
13 /* Look at all four partition entries for empty partition */
14 for (i = c(0); i < c(4);i++) /* AC000 */
15 BEGIN
16
17 /* if we find an empty one, return which one */
18 if (part_table[cur_disk][i].num_sec == ul(0)) /* AC000 */
19 BEGIN
20 return(i);
21 break;
22 END
23 END
24 /* Did not find one, return NOT_FOUND */
25 return(c(NOT_FOUND)); /* AC000 */
26END
27
28/* */
29char find_partition_type(type)
30
31unsigned char type;
32
33BEGIN
34 char i;
35
36/* Look at all four partition entries for system id byte that matches */
37 for (i = c(0); i < c(4);i++) /* AC000 */
38 BEGIN
39
40 /* if we find a match, do a TRUE return */
41 if (part_table[cur_disk][i].sys_id == type)
42 BEGIN
43 return(TRUE);
44 break;
45 END
46 END
47 /* Did not find one, return FALSE */
48 return(FALSE);
49END
50
51
52
53/* */
54XFLOAT get_partition_size(type) /* AC000 */
55
56unsigned char type; /* AC000 */
57
58BEGIN
59 char i;
60
61 /* Look at all four partition entries for system id byte that matches */
62 for (i = c(0); i < c(4);i++) /* AC000 */
63 BEGIN
64
65 /* if we find a match, get the size */
66 if (part_table[cur_disk][i].sys_id == type)
67 BEGIN
68 /* Get the size of the partition from the array */
69 return(part_table[cur_disk][i].mbytes_used); /* AC000 */
70 END
71 END
72 /* Did not find one, something bad wrong happened */
73 internal_program_error();
74END
75
76/* */
77char find_active_partition()
78
79BEGIN
80
81unsigned char i;
82
83 /* See if there is an active partition */
84 for (i = uc(0); i < uc(4);i++) /* AC000 */
85 BEGIN
86
87 /* if we find an active one, TRUE return */
88 if (part_table[cur_disk][i].boot_ind == uc(ACTIVE)) /* AC000 */
89 BEGIN
90 return(TRUE);
91 break;
92 END
93 END
94 /* Did not find one, return FALSE */
95 return(FALSE);
96END
97
98
99/* */
100char find_partition_location(type)
101
102unsigned char type;
103
104BEGIN
105 char i;
106
107/* Look at all four partition entries for system id byte that matches */
108 for (i = c(0); i < c(4);i++) /* AC000 */
109 BEGIN
110
111 /* if we find a match, do a TRUE return */
112 if (part_table[cur_disk][i].sys_id == type)
113 BEGIN
114 return(i);
115 break;
116 END
117 END
118 /* Did not find one, return */
119 return(c(NOT_FOUND)); /* AC000 */
120END
121
122/* */
123char find_free_ext()
124
125BEGIN
126
127 char i;
128
129 /* Look at all 23 extended entries for empty partition */
130 for (i = c(0); i < c(23);i++) /* AC000 */
131 BEGIN
132
133 /* if we find an empty one, return which one */
134 if (ext_table[cur_disk][i].sys_id == uc(0)) /* AC000 */
135 BEGIN
136 return(i);
137 break;
138 END
139 END
140 return(c(NOT_FOUND)); /* AC000 */
141END
142
143/* */
144char find_logical_drive()
145
146BEGIN
147
148unsigned char i;
149
150 /* See if there is a logical drive defined in Extended Partition */
151 for (i = uc(0); i < uc(23);i++) /* AC000 */
152 BEGIN
153
154 /* See if we find a sys id that is not 0 */
155 if (ext_table[cur_disk][i].sys_id != uc(0)) /* AC000 */
156 BEGIN
157 return(TRUE);
158 break;
159 END
160 END
161 return(FALSE);
162END
163
164/* */
165char get_num_logical_dos_drives()
166BEGIN
167
168char i;
169char number;
170
171 number = c(0); /* AC000 */
172 /* See if there is a logical drive defined in Extended Partition */
173 for (i = c(0); i < c(23);i++) /* AC000 */
174 BEGIN
175
176 /* See if we find a sys id that is DOS */
177 if ((ext_table[cur_disk][i].sys_id == uc(DOS12)) || (ext_table[cur_disk][i].sys_id == uc(DOS16)) ||
178 (ext_table[cur_disk][i].sys_id == uc(DOSNEW))) /* AC000 */
179 BEGIN
180 number++;
181 END
182 END
183 return(number);
184END
185
186/* */
187char find_ext_drive(offset)
188
189char offset;
190
191BEGIN
192
193char number_found;
194char i;
195
196 number_found = c(0); /* AC000 */
197
198 /* Go look for the nth extended drive */
199 for (i=c(0); i < c(23); i++) /* AC000 */
200 BEGIN
201
202 /* See if there is a drive we know about */
203 if ((ext_table[cur_disk][i].sys_id == uc(DOS12)) || (ext_table[cur_disk][i].sys_id == uc(DOS16)) ||
204 (ext_table[cur_disk][i].sys_id == uc(DOSNEW))) /* AC000 */
205 BEGIN
206 /* Is this the one we were looking for ? */
207 if (number_found == offset)
208 BEGIN
209 /* Yes it is, return where we found it */
210 return(i);
211 break;
212 END
213 /* Show we found one and go look for the next */
214 number_found++;
215 END
216 END
217 /* We should never get here */
218 internal_program_error();
219 return(c(INVALID)); /* AC000 */
220END
221
222
223/* */
224char find_previous_drive(offset)
225
226char offset;
227
228BEGIN
229
230char number_found;
231char last_found;
232char i;
233
234 number_found = c(0); /* AC000 */
235 last_found = c(0); /* AC000 */
236
237 /* Go look for the nth extended drive */
238 for (i=c(0); i < c(23); i++) /* AC000 */
239 BEGIN
240
241 /* See if there is a drive */
242 if (ext_table[cur_disk][i].sys_id != uc(0)) /* AC000 */
243 BEGIN
244 /* Is this the one we were looking for ? */
245 if (number_found == offset)
246 BEGIN
247 /* Yes it is, return where we found the previous one */
248 return(last_found);
249 END
250 /* This is the latest one we found, but not the limit, so save it */
251 last_found = i;
252
253 /* Show we found one and go look for the next */
254 number_found++;
255 END
256 END
257 /* We should never get here */
258 internal_program_error();
259 return(c(INVALID)); /* AC000 */
260END
261
262 \ No newline at end of file