1 | /*␊ |
2 | * Copyright (c) 2002-2005 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * ␊ |
5 | * This file contains Original Code and/or Modifications of Original Code␊ |
6 | * as defined in and that are subject to the Apple Public Source License␊ |
7 | * Version 2.0 (the 'License'). You may not use this file except in␊ |
8 | * compliance with the License. Please obtain a copy of the License at␊ |
9 | * http://www.opensource.apple.com/apsl/ and read it before using this␊ |
10 | * file.␊ |
11 | * ␊ |
12 | * The Original Code and all software distributed under the License are␊ |
13 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
16 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.␊ |
17 | * Please see the License for the specific language governing rights and␊ |
18 | * limitations under the License.␊ |
19 | * ␊ |
20 | * Copyright (c) 1997 Tobias Weingartner␊ |
21 | * All rights reserved.␊ |
22 | *␊ |
23 | * Redistribution and use in source and binary forms, with or without␊ |
24 | * modification, are permitted provided that the following conditions␊ |
25 | * are met:␊ |
26 | * 1. Redistributions of source code must retain the above copyright␊ |
27 | * notice, this list of conditions and the following disclaimer.␊ |
28 | * 2. Redistributions in binary form must reproduce the above copyright␊ |
29 | * notice, this list of conditions and the following disclaimer in the␊ |
30 | * documentation and/or other materials provided with the distribution.␊ |
31 | * 3. All advertising materials mentioning features or use of this software␊ |
32 | * must display the following acknowledgement:␊ |
33 | * This product includes software developed by Tobias Weingartner.␊ |
34 | * 4. The name of the author may not be used to endorse or promote products␊ |
35 | * derived from this software without specific prior written permission.␊ |
36 | *␊ |
37 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR␊ |
38 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES␊ |
39 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.␊ |
40 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,␊ |
41 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT␊ |
42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,␊ |
43 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY␊ |
44 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT␊ |
45 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF␊ |
46 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.␊ |
47 | */␊ |
48 | ␊ |
49 | #include <stdio.h>␊ |
50 | #include <ctype.h>␊ |
51 | #include <memory.h>␊ |
52 | #include <stdlib.h>␊ |
53 | #include <unistd.h>␊ |
54 | #include <signal.h>␊ |
55 | #include <sys/fcntl.h>␊ |
56 | #include "disk.h"␊ |
57 | #include "misc.h"␊ |
58 | #include "user.h"␊ |
59 | #include "part.h"␊ |
60 | #include "cmd.h"␊ |
61 | #include "auto.h"␊ |
62 | ␊ |
63 | #define MAX(a, b) ((a) >= (b) ? (a) : (b))␊ |
64 | ␊ |
65 | int␊ |
66 | Xerase(cmd, disk, mbr, tt, offset)␊ |
67 | ␉cmd_t *cmd;␊ |
68 | ␉disk_t *disk;␊ |
69 | ␉mbr_t *mbr;␊ |
70 | ␉mbr_t *tt;␊ |
71 | ␉int offset;␊ |
72 | {␊ |
73 | bzero(mbr->part, sizeof(mbr->part));␊ |
74 | ␉mbr->signature = MBR_SIGNATURE;␊ |
75 | ␉return (CMD_DIRTY);␊ |
76 | }␊ |
77 | ␊ |
78 | int␊ |
79 | Xreinit(cmd, disk, mbr, tt, offset)␊ |
80 | ␉cmd_t *cmd;␊ |
81 | ␉disk_t *disk;␊ |
82 | ␉mbr_t *mbr;␊ |
83 | ␉mbr_t *tt;␊ |
84 | ␉int offset;␊ |
85 | {␊ |
86 | ␉/* Copy template MBR */␊ |
87 | ␉MBR_make(tt);␊ |
88 | ␉MBR_parse(disk, offset, 0, mbr);␊ |
89 | ␊ |
90 | ␉MBR_init(disk, mbr);␊ |
91 | ␊ |
92 | ␉/* Tell em we did something */␊ |
93 | ␉printf("In memory copy is initialized to:\n");␊ |
94 | ␉printf("Offset: %d\t", offset);␊ |
95 | ␉MBR_print(mbr);␊ |
96 | ␉printf("Use 'write' to update disk.\n");␊ |
97 | ␊ |
98 | ␉return (CMD_DIRTY);␊ |
99 | }␊ |
100 | ␊ |
101 | int␊ |
102 | Xauto(cmd, disk, mbr, tt, offset)␊ |
103 | ␉cmd_t *cmd;␊ |
104 | ␉disk_t *disk;␊ |
105 | ␉mbr_t *mbr;␊ |
106 | ␉mbr_t *tt;␊ |
107 | ␉int offset;␊ |
108 | {␊ |
109 | ␉if (cmd->args[0] == '\0') {␊ |
110 | ␉ printf("usage: auto <style>\n");␊ |
111 | ␉ printf(" where style is one of:\n");␊ |
112 | ␉ AUTO_print_styles(stdout);␊ |
113 | ␉ return (CMD_CONT);␊ |
114 | ␉}␊ |
115 | ␊ |
116 | if (AUTO_init(disk, cmd->args, mbr) != AUTO_OK) {␊ |
117 | ␉ return (CMD_CONT);␊ |
118 | ␉}␊ |
119 | ␉MBR_make(mbr);␊ |
120 | ␉return (CMD_DIRTY);␊ |
121 | }␊ |
122 | ␊ |
123 | int␊ |
124 | Xdisk(cmd, disk, mbr, tt, offset)␊ |
125 | ␉cmd_t *cmd;␊ |
126 | ␉disk_t *disk;␊ |
127 | ␉mbr_t *mbr;␊ |
128 | ␉mbr_t *tt;␊ |
129 | ␉int offset;␊ |
130 | {␊ |
131 | ␉int maxcyl = 1024;␊ |
132 | ␉int maxhead = 256;␊ |
133 | ␉int maxsec = 63;␊ |
134 | ␊ |
135 | ␉/* Print out disk info */␊ |
136 | ␉DISK_printmetrics(disk);␊ |
137 | ␊ |
138 | #if defined (__powerpc__) || defined (__mips__)␊ |
139 | ␉maxcyl = 9999999;␊ |
140 | ␉maxhead = 9999999;␊ |
141 | ␉maxsec = 9999999;␊ |
142 | #endif␊ |
143 | ␊ |
144 | ␉/* Ask for new info */␊ |
145 | ␉if (ask_yn("Change disk geometry?", 0)) {␊ |
146 | ␉␉disk->real->cylinders = ask_num("BIOS Cylinders", ASK_DEC,␊ |
147 | ␉␉ disk->real->cylinders, 1, maxcyl, NULL);␊ |
148 | ␉␉disk->real->heads = ask_num("BIOS Heads", ASK_DEC,␊ |
149 | ␉␉ disk->real->heads, 1, maxhead, NULL);␊ |
150 | ␉␉disk->real->sectors = ask_num("BIOS Sectors", ASK_DEC,␊ |
151 | ␉␉ disk->real->sectors, 1, maxsec, NULL);␊ |
152 | ␊ |
153 | ␉␉disk->real->size = disk->real->cylinders * disk->real->heads␊ |
154 | ␉␉␉* disk->real->sectors;␊ |
155 | ␉}␊ |
156 | ␊ |
157 | ␉return (CMD_CONT);␊ |
158 | }␊ |
159 | ␊ |
160 | int␊ |
161 | Xedit(cmd, disk, mbr, tt, offset)␊ |
162 | ␉cmd_t *cmd;␊ |
163 | ␉disk_t *disk;␊ |
164 | ␉mbr_t *mbr;␊ |
165 | ␉mbr_t *tt;␊ |
166 | ␉int offset;␊ |
167 | {␊ |
168 | ␉int pn, num, ret;␊ |
169 | ␉prt_t *pp;␊ |
170 | ␊ |
171 | ␉ret = CMD_CONT;␊ |
172 | ␊ |
173 | ␉if (!isdigit(cmd->args[0])) {␊ |
174 | ␉␉printf("Invalid argument: %s <partition number>\n", cmd->cmd);␊ |
175 | ␉␉return (ret);␊ |
176 | ␉}␊ |
177 | ␉pn = atoi(cmd->args) - 1;␊ |
178 | ␊ |
179 | ␉if (pn < 0 || pn > 3) {␊ |
180 | ␉␉printf("Invalid partition number.\n");␊ |
181 | ␉␉return (ret);␊ |
182 | ␉}␊ |
183 | ␊ |
184 | ␉/* Print out current table entry */␊ |
185 | ␉pp = &mbr->part[pn];␊ |
186 | ␉PRT_print(0, NULL);␊ |
187 | ␉PRT_print(pn, pp);␊ |
188 | ␊ |
189 | #define␉EDIT(p, f, v, n, m, h)␉␉␉␉\␊ |
190 | ␉if ((num = ask_num(p, f, v, n, m, h)) != v)␉\␊ |
191 | ␉␉ret = CMD_DIRTY;␉␉␉\␊ |
192 | ␉v = num;␊ |
193 | ␊ |
194 | ␉/* Ask for partition type */␊ |
195 | ␉EDIT("Partition id ('0' to disable) ", ASK_HEX, pp->id, 0, 0xFF, PRT_printall);␊ |
196 | ␊ |
197 | ␉/* Unused, so just zero out */␊ |
198 | ␉if (pp->id == DOSPTYP_UNUSED) {␊ |
199 | ␉␉memset(pp, 0, sizeof(*pp));␊ |
200 | ␉␉printf("Partition %d is disabled.\n", pn + 1);␊ |
201 | ␉␉return (ret);␊ |
202 | ␉}␊ |
203 | ␊ |
204 | ␉/* Change table entry */␊ |
205 | ␉if (ask_yn("Do you wish to edit in CHS mode?", 0)) {␊ |
206 | ␉␉int maxcyl, maxhead, maxsect;␊ |
207 | ␊ |
208 | ␉␉/* Shorter */␊ |
209 | ␉␉maxcyl = disk->real->cylinders - 1;␊ |
210 | ␉␉maxhead = disk->real->heads - 1;␊ |
211 | ␉␉maxsect = disk->real->sectors;␊ |
212 | ␊ |
213 | ␉␉/* Get data */␊ |
214 | ␉␉EDIT("BIOS Starting cylinder", ASK_DEC, pp->scyl, 0, maxcyl, NULL);␊ |
215 | ␉␉EDIT("BIOS Starting head", ASK_DEC, pp->shead, 0, maxhead, NULL);␊ |
216 | ␉␉EDIT("BIOS Starting sector", ASK_DEC, pp->ssect, 1, maxsect, NULL);␊ |
217 | ␉␉EDIT("BIOS Ending cylinder", ASK_DEC, pp->ecyl, 0, maxcyl, NULL);␊ |
218 | ␉␉EDIT("BIOS Ending head", ASK_DEC, pp->ehead, 0, maxhead, NULL);␊ |
219 | ␉␉EDIT("BIOS Ending sector", ASK_DEC, pp->esect, 1, maxsect, NULL);␊ |
220 | ␉␉/* Fix up off/size values */␊ |
221 | ␉␉PRT_fix_BN(disk, pp, pn);␊ |
222 | ␉␉/* Fix up CHS values for LBA */␊ |
223 | ␉␉PRT_fix_CHS(disk, pp, pn);␊ |
224 | ␉} else {␊ |
225 | ␉␉u_int m;␊ |
226 | ␊ |
227 | ␉␉if (pn == 0) {␊ |
228 | ␉␉␉pp->bs = 63 + offset;␊ |
229 | ␉␉} else {␊ |
230 | ␉␉␉if (mbr->part[pn-1].id != 0) {␊ |
231 | ␉␉␉␉pp->bs = mbr->part[pn-1].bs + mbr->part[pn-1].ns;␊ |
232 | ␉␉␉}␊ |
233 | ␉␉}␊ |
234 | ␉␉/* Get data */␊ |
235 | ␉␉EDIT("Partition offset", ASK_DEC, pp->bs, 0,␊ |
236 | ␉␉ disk->real->size, NULL);␊ |
237 | ␉␉m = MAX(pp->ns, disk->real->size - pp->bs);␊ |
238 | ␉␉if ( m > disk->real->size - pp->bs) {␊ |
239 | ␉␉␉/* dont have default value extend beyond end of disk */␊ |
240 | ␉␉␉m = disk->real->size - pp->bs;␊ |
241 | ␉␉}␊ |
242 | ␉␉pp->ns = m;␊ |
243 | ␉␉EDIT("Partition size", ASK_DEC, pp->ns, 1,␊ |
244 | ␉␉ m, NULL);␊ |
245 | ␊ |
246 | ␉␉/* Fix up CHS values */␊ |
247 | ␉␉PRT_fix_CHS(disk, pp, pn);␊ |
248 | ␉}␊ |
249 | #undef EDIT␊ |
250 | ␉return (ret);␊ |
251 | }␊ |
252 | ␊ |
253 | int␊ |
254 | Xsetpid(cmd, disk, mbr, tt, offset)␊ |
255 | ␉cmd_t *cmd;␊ |
256 | ␉disk_t *disk;␊ |
257 | ␉mbr_t *mbr;␊ |
258 | ␉mbr_t *tt;␊ |
259 | ␉int offset;␊ |
260 | {␊ |
261 | ␉int pn, num, ret;␊ |
262 | ␉prt_t *pp;␊ |
263 | ␊ |
264 | ␉ret = CMD_CONT;␊ |
265 | ␊ |
266 | ␉if (!isdigit(cmd->args[0])) {␊ |
267 | ␉␉printf("Invalid argument: %s <partition number>\n", cmd->cmd);␊ |
268 | ␉␉return (ret);␊ |
269 | ␉}␊ |
270 | ␉pn = atoi(cmd->args) - 1;␊ |
271 | ␊ |
272 | ␉if (pn < 0 || pn > 3) {␊ |
273 | ␉␉printf("Invalid partition number.\n");␊ |
274 | ␉␉return (ret);␊ |
275 | ␉}␊ |
276 | ␊ |
277 | ␉/* Print out current table entry */␊ |
278 | ␉pp = &mbr->part[pn];␊ |
279 | ␉PRT_print(0, NULL);␊ |
280 | ␉PRT_print(pn, pp);␊ |
281 | ␊ |
282 | #define␉EDIT(p, f, v, n, m, h)␉␉␉␉\␊ |
283 | ␉if ((num = ask_num(p, f, v, n, m, h)) != v)␉\␊ |
284 | ␉␉ret = CMD_DIRTY;␉␉␉\␊ |
285 | ␉v = num;␊ |
286 | ␊ |
287 | ␉/* Ask for partition type */␊ |
288 | ␉EDIT("Partition id ('0' to disable) ", ASK_HEX, pp->id, 0, 0xFF, PRT_printall);␊ |
289 | ␊ |
290 | #undef EDIT␊ |
291 | ␉return (ret);␊ |
292 | }␊ |
293 | int␊ |
294 | Xselect(cmd, disk, mbr, tt, offset)␊ |
295 | ␉cmd_t *cmd;␊ |
296 | ␉disk_t *disk;␊ |
297 | ␉mbr_t *mbr;␊ |
298 | ␉mbr_t *tt;␊ |
299 | ␉int offset;␊ |
300 | {␊ |
301 | ␉static int firstoff = 0;␊ |
302 | ␉int off;␊ |
303 | ␉int pn;␊ |
304 | ␊ |
305 | ␉if (!isdigit(cmd->args[0])) {␊ |
306 | ␉␉printf("Invalid argument: %s <partition number>\n", cmd->cmd);␊ |
307 | ␉␉return (CMD_CONT);␊ |
308 | ␉}␊ |
309 | ␊ |
310 | ␉pn = atoi(cmd->args) - 1;␊ |
311 | ␉if (pn < 0 || pn > 3) {␊ |
312 | ␉␉printf("Invalid partition number.\n");␊ |
313 | ␉␉return (CMD_CONT);␊ |
314 | ␉}␊ |
315 | ␊ |
316 | ␉off = mbr->part[pn].bs;␊ |
317 | ␊ |
318 | ␉/* Sanity checks */␊ |
319 | ␉if ((mbr->part[pn].id != DOSPTYP_EXTEND) &&␊ |
320 | ␉ (mbr->part[pn].id != DOSPTYP_EXTENDL)) {␊ |
321 | ␉␉printf("Partition %d is not an extended partition.\n", pn + 1);␊ |
322 | ␉␉return (CMD_CONT);␊ |
323 | ␉}␊ |
324 | ␊ |
325 | ␉if (firstoff == 0)␊ |
326 | ␉␉firstoff = off;␊ |
327 | ␊ |
328 | ␉if (!off) {␊ |
329 | ␉␉printf("Loop to offset 0! Not selected.\n");␊ |
330 | ␉␉return (CMD_CONT);␊ |
331 | ␉} else {␊ |
332 | ␉␉printf("Selected extended partition %d\n", pn + 1);␊ |
333 | ␉␉printf("New MBR at offset %d.\n", off);␊ |
334 | ␉}␊ |
335 | ␊ |
336 | ␉/* Recursion is beautifull! */␊ |
337 | ␉USER_modify(disk, tt, off, firstoff);␊ |
338 | ␉return (CMD_CONT);␊ |
339 | }␊ |
340 | ␊ |
341 | int␊ |
342 | Xprint(cmd, disk, mbr, tt, offset)␊ |
343 | ␉cmd_t *cmd;␊ |
344 | ␉disk_t *disk;␊ |
345 | ␉mbr_t *mbr;␊ |
346 | ␉mbr_t *tt;␊ |
347 | ␉int offset;␊ |
348 | {␊ |
349 | ␊ |
350 | ␉DISK_printmetrics(disk);␊ |
351 | ␉printf("Offset: %d\t", offset);␊ |
352 | ␉MBR_print(mbr);␊ |
353 | ␊ |
354 | ␉return (CMD_CONT);␊ |
355 | }␊ |
356 | ␊ |
357 | int␊ |
358 | Xwrite(cmd, disk, mbr, tt, offset)␊ |
359 | ␉cmd_t *cmd;␊ |
360 | ␉disk_t *disk;␊ |
361 | ␉mbr_t *mbr;␊ |
362 | ␉mbr_t *tt;␊ |
363 | ␉int offset;␊ |
364 | {␊ |
365 | ␉int fd;␊ |
366 | ␉int shared = 0;␊ |
367 | ␊ |
368 | ␉fd = DISK_openshared(disk->name, O_RDWR, &shared);␊ |
369 | ␉if(shared) {␊ |
370 | ␉ if(!ask_yn("Device could not be accessed exclusively.\nA reboot will be needed for changes to take effect. OK?", 0)) {␊ |
371 | ␉ close(fd);␊ |
372 | ␉ printf("MBR unchanged\n");␊ |
373 | ␉ return (CMD_CONT);␊ |
374 | ␉ }␊ |
375 | ␉}␊ |
376 | ␊ |
377 | ␉printf("Writing MBR at offset %d.\n", offset);␊ |
378 | ␊ |
379 | ␉MBR_make(mbr);␊ |
380 | ␉MBR_write(disk, fd, mbr);␊ |
381 | ␉close(fd);␊ |
382 | ␉return (CMD_CLEAN);␊ |
383 | }␊ |
384 | ␊ |
385 | int␊ |
386 | Xquit(cmd, disk, r, tt, offset)␊ |
387 | ␉cmd_t *cmd;␊ |
388 | ␉disk_t *disk;␊ |
389 | ␉mbr_t *r;␊ |
390 | ␉mbr_t *tt;␊ |
391 | ␉int offset;␊ |
392 | {␊ |
393 | ␊ |
394 | ␉/* Nothing to do here */␊ |
395 | ␉return (CMD_SAVE);␊ |
396 | }␊ |
397 | ␊ |
398 | int␊ |
399 | Xabort(cmd, disk, mbr, tt, offset)␊ |
400 | ␉cmd_t *cmd;␊ |
401 | ␉disk_t *disk;␊ |
402 | ␉mbr_t *mbr;␊ |
403 | ␉mbr_t *tt;␊ |
404 | ␉int offset;␊ |
405 | {␊ |
406 | ␉exit(0);␊ |
407 | ␊ |
408 | ␉/* NOTREACHED */␊ |
409 | ␉return (CMD_CONT);␊ |
410 | }␊ |
411 | ␊ |
412 | ␊ |
413 | int␊ |
414 | Xexit(cmd, disk, mbr, tt, offset)␊ |
415 | ␉cmd_t *cmd;␊ |
416 | ␉disk_t *disk;␊ |
417 | ␉mbr_t *mbr;␊ |
418 | ␉mbr_t *tt;␊ |
419 | ␉int offset;␊ |
420 | {␊ |
421 | ␊ |
422 | ␉/* Nothing to do here */␊ |
423 | ␉return (CMD_EXIT);␊ |
424 | }␊ |
425 | ␊ |
426 | int␊ |
427 | Xhelp(cmd, disk, mbr, tt, offset)␊ |
428 | ␉cmd_t *cmd;␊ |
429 | ␉disk_t *disk;␊ |
430 | ␉mbr_t *mbr;␊ |
431 | ␉mbr_t *tt;␊ |
432 | ␉int offset;␊ |
433 | {␊ |
434 | ␉cmd_table_t *cmd_table = cmd->table;␊ |
435 | ␉int i;␊ |
436 | ␊ |
437 | ␉/* Hmm, print out cmd_table here... */␊ |
438 | ␉for (i = 0; cmd_table[i].cmd != NULL; i++)␊ |
439 | ␉␉printf("\t%s\t\t%s\n", cmd_table[i].cmd, cmd_table[i].help);␊ |
440 | ␉return (CMD_CONT);␊ |
441 | }␊ |
442 | ␊ |
443 | int␊ |
444 | Xupdate(cmd, disk, mbr, tt, offset)␊ |
445 | ␉cmd_t *cmd;␊ |
446 | ␉disk_t *disk;␊ |
447 | ␉mbr_t *mbr;␊ |
448 | ␉mbr_t *tt;␊ |
449 | ␉int offset;␊ |
450 | {␊ |
451 | ␉extern char *mbr_binary;␊ |
452 | ␉/* Update code */␊ |
453 | ␉memcpy(mbr->code, mbr_binary, MBR_CODE_SIZE);␊ |
454 | ␉printf("Machine code updated.\n");␊ |
455 | ␉return (CMD_DIRTY);␊ |
456 | }␊ |
457 | ␊ |
458 | int␊ |
459 | Xflag(cmd, disk, mbr, tt, offset)␊ |
460 | ␉cmd_t *cmd;␊ |
461 | ␉disk_t *disk;␊ |
462 | ␉mbr_t *mbr;␊ |
463 | ␉mbr_t *tt;␊ |
464 | ␉int offset;␊ |
465 | {␊ |
466 | ␉int i, pn = -1;␊ |
467 | ␊ |
468 | ␉/* Parse partition table entry number */␊ |
469 | ␉if (!isdigit(cmd->args[0])) {␊ |
470 | ␉␉printf("Invalid argument: %s <partition number>\n", cmd->cmd);␊ |
471 | ␉␉return (CMD_CONT);␊ |
472 | ␉}␊ |
473 | ␉pn = atoi(cmd->args) - 1;␊ |
474 | ␊ |
475 | ␉if (pn < 0 || pn > 3) {␊ |
476 | ␉␉printf("Invalid partition number.\n");␊ |
477 | ␉␉return (CMD_CONT);␊ |
478 | ␉}␊ |
479 | ␊ |
480 | ␉/* Set active flag */␊ |
481 | ␉for (i = 0; i < 4; i++) {␊ |
482 | ␉␉if (i == pn)␊ |
483 | ␉␉␉mbr->part[i].flag = DOSACTIVE;␊ |
484 | ␉␉else␊ |
485 | ␉␉␉mbr->part[i].flag = 0x00;␊ |
486 | ␉}␊ |
487 | ␊ |
488 | ␉printf("Partition %d marked active.\n", pn + 1);␊ |
489 | ␉return (CMD_DIRTY);␊ |
490 | }␊ |
491 | ␊ |
492 | int␊ |
493 | Xmanual(cmd, disk, mbr, tt, offset)␊ |
494 | ␉cmd_t *cmd;␊ |
495 | ␉disk_t *disk;␊ |
496 | ␉mbr_t *mbr;␊ |
497 | ␉mbr_t *tt;␊ |
498 | ␉int offset;␊ |
499 | {␊ |
500 | ␉system("man 8 fdisk");␊ |
501 | ␉return (CMD_CONT);␊ |
502 | }␊ |
503 | |