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