]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/FDISK/PARTINFO.C

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / CMD / FDISK / PARTINFO.C
1
2 #include "dos.h" /* AN000 */
3 #include "fdisk.h" /* AN000 */
4 #include "subtype.h" /* AN000 */
5 #include "extern.h" /* AN000 */
6
7 /* \f */
8 char find_free_partition()
9
10 BEGIN
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 */
26 END
27
28 /* \f */
29 char find_partition_type(type)
30
31 unsigned char type;
32
33 BEGIN
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);
49 END
50
51
52
53 /* \f */
54 XFLOAT get_partition_size(type) /* AC000 */
55
56 unsigned char type; /* AC000 */
57
58 BEGIN
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();
74 END
75
76 /* \f */
77 char find_active_partition()
78
79 BEGIN
80
81 unsigned 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);
96 END
97
98
99 /* \f */
100 char find_partition_location(type)
101
102 unsigned char type;
103
104 BEGIN
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 */
120 END
121
122 /* \f */
123 char find_free_ext()
124
125 BEGIN
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 */
141 END
142
143 /* \f */
144 char find_logical_drive()
145
146 BEGIN
147
148 unsigned 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);
162 END
163
164 /* \f */
165 char get_num_logical_dos_drives()
166 BEGIN
167
168 char i;
169 char 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);
184 END
185
186 /* \f */
187 char find_ext_drive(offset)
188
189 char offset;
190
191 BEGIN
192
193 char number_found;
194 char 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 */
220 END
221
222
223 /* \f */
224 char find_previous_drive(offset)
225
226 char offset;
227
228 BEGIN
229
230 char number_found;
231 char last_found;
232 char 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 */
260 END
261
262 \1a