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

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / CMD / FDISK / C_MENUS.C
1
2 #include "dos.h" /* AN000 */
3 #include "fdisk.h" /* AN000 */
4 #include "extern.h" /* AN000 */
5 #include "subtype.h" /* AN000 */
6 #include "fdiskmsg.h" /* AN000 */
7 #include "stdio.h"
8
9 /* \f */
10 /******************* START OF SPECIFICATIONS *******************/
11 /* */
12 /* SUBROUTINE NAME: CREATE_PARTITION */
13 /* */
14 /* DESCRIPTIVE NAME: Create DOS related partition(s) */
15 /* */
16 /* FUNCTION: */
17 /* This routine verifies if there are free partitions, */
18 /* posts an status message if there is not, otherwise */
19 /* prints a screen asking what type of partition to */
20 /* be created, and passes control to the requested */
21 /* function. */
22 /* */
23 /* NOTES: This is a screen control module only, no data is */
24 /* modified. Routine also will only allow 1 DOS and */
25 /* 1 Ext DOS partitions per disk, if one already exists,*/
26 /* then status message is displayed when the create */
27 /* option for that type partition is selected */
28 /* */
29 /* The following screen in managed */
30 /* */
31 /* ³0000000000111111111122222222223333333333³ */
32 /* ³0123456789012345678901234567890123456789³ */
33 /* ÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ */
34 /* 00³ ³ */
35 /* 01³ ³ */
36 /* 02³ ³ */
37 /* 03³ ³ */
38 /* 04³Create DOS Partition ³ */
39 /* 05³ ³ */
40 /* 06³Current Fixed Disk Drive: # ³ */
41 /* 07³ ³ */
42 /* 08³Choose one of the following: ³ */
43 /* 09³ ³ */
44 /* 10³ 1. Create Primary DOS partition ³ */
45 /* 11³ 2. Create EXTENDED DOS partition ³ */
46 /* 12³ 3. Create logical DOS drive(s) in ³ */
47 /* 13³ the EXTENDED DOS partition ³ */
48 /* 14³ ³ */
49 /* 15³ ³ */
50 /* 16³ ³ */
51 /* 17³ ³ */
52 /* 18³Enter choice: [ ] ³ */
53 /* 19³ ³ */
54 /* 20³ ³ */
55 /* 21³ ³ */
56 /* 22³ ³ */
57 /* 23³Press ESC to return to FDISK Options ³ */
58 /* ÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ */
59 /* */
60 /* ENTRY POINTS: create_partition */
61 /* LINKAGE: create_partition(); */
62 /* */
63 /* INPUT: None */
64 /* */
65 /* EXIT-NORMAL: ERROR=FALSE */
66 /* */
67 /* EXIT-ERROR: ERROR=TRUE */
68 /* GOTO internal_program_error if case statement */
69 /* failure when branching to requested function */
70 /* */
71 /* EFFECTS: No data directly modified by this routine, but */
72 /* child routines will modify data. */
73 /* */
74 /* INTERNAL REFERENCES: */
75 /* ROUTINES: */
76 /* find_free_partition */
77 /* dos_create_partition */
78 /* ext_create_partition */
79 /* volume_create */
80 /* internal_program_error */
81 /* find_partition_type */
82 /* get_num_input */
83 /* display */
84 /* wait_for_ESC */
85 /* clear_screen */
86 /* */
87 /* EXTERNAL REFERENCES: */
88 /* ROUTINES: */
89 /* */
90 /******************** END OF SPECIFICATIONS ********************/
91
92 /* \f */
93 void create_partition()
94
95 BEGIN
96
97 char input;
98 char default_value;
99 char max_input;
100
101
102
103
104 input = c(NUL); /* AC000 */
105 clear_screen(u(0),u(0),u(24),u(79)); /* AC000 */
106 /* put up heading and ESC */
107 display(menu_8);
108 display(menu_11);
109
110 /* Setup current drive msg */
111 insert[0]=cur_disk+1+'0';
112 display(menu_5);
113
114 /* See if there are free partitions */
115 if (find_free_partition() != ((char)(NOT_FOUND))) /* AC000 */
116 BEGIN
117 /* display menu */
118 display(menu_3); /* AN000 */
119 display(menu_9);
120
121 /* ############# ADD CODE HERE FOR THIS FUNCTION ############## */
122 /* Do something about highlighting the available options and */
123 /* setting up defaults */
124 default_value = c(1); /* AC000 */
125 /* ############################################################ */
126 /* setup default for prompt */
127 insert[0] = c('1'); /* AC000 */
128 display(menu_7);
129 display(menu_10);
130
131 max_input = c(3); /* AC000 */
132
133 input = get_num_input(default_value,max_input,input_row,input_col);
134
135 /* Go branch to the requested function */
136 switch(input)
137 BEGIN
138 case '1': dos_create_partition();
139 break;
140
141 case '2':
142 if ((cur_disk == c(1)) || (find_partition_type(uc(DOS12))) || (find_partition_type(uc(DOS16))) ||
143 (find_partition_type(uc(DOSNEW)))) /* AN000 */ /* AC000 */
144 ext_create_partition();
145 else
146 BEGIN /* AN000 */
147 /* don't have a primary partition yet, can't create an ext */
148 display(error_19); /* AN000 */
149 clear_screen(u(17),u(0),u(17),u(79)); /* AN000 */
150 wait_for_ESC(); /* AN000 */
151 END /* AN000 */
152 break;
153
154 case '3':
155 BEGIN
156 if (find_partition_type(uc(EXTENDED))) /* AC000 */
157 volume_create();
158 else /* AN000 */
159 BEGIN /* AN000 */
160 display(error_35); /* AN000 */
161 clear_screen(u(17),u(0),u(17),u(79)); /* AN000 */
162 wait_for_ESC(); /* AN000 */
163 END /* AN000 */
164 break;
165 END
166
167 case ESC: break;
168
169 default: internal_program_error();
170 END
171 END
172 else
173 BEGIN
174
175 /* Display prompt telling there is no avail partition */
176 display(error_10);
177 input = wait_for_ESC();
178 END
179 /* clear the screen before going back to main menu */
180 clear_screen(u(0),u(0),u(24),u(79)); /* AC000 */
181 return;
182 END
183
184
185 /* \f */
186 /******************* START OF SPECIFICATIONS *******************/
187 /* */
188 /* SUBROUTINE NAME: DOS_CREATE_PARTITION */
189 /* */
190 /* DESCRIPTIVE NAME: Create default DOS partition on disk */
191 /* */
192 /* FUNCTION: User is prompted to see if he wishes to use to */
193 /* set up a DOS partition in the maximum available */
194 /* size (limited to 32mb). If option is selected */
195 /* than partition is created and marked active. The */
196 /* partition is scanned to insure there are enough */
197 /* contiguous good sectors for DOS. */
198 /* */
199 /* NOTES: Screen can be exited via the ESC command before */
200 /* partition is created and nothing will change */
201 /* */
202 /* The following screen is managed: */
203 /* */
204 /* ³0000000000111111111122222222223333333333³ */
205 /* ³0123456789012345678901234567890123456789³ */
206 /* ÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ */
207 /* 00³ ³ */
208 /* 01³ ³ */
209 /* 02³ ³ */
210 /* 03³ ³ */
211 /* 04³Create DOS Partition ³ */
212 /* 05³ ³ */
213 /* 06³Current Fixed Disk Drive: # ³ */
214 /* 07³ ³ */
215 /* 08³Do you wish to use the maximum size ³ */
216 /* 09³for a DOS partition and make the DOS ³ */
217 /* 10³partition active (Y/N).........? [Y] ³ */
218 /* 11³ ³ */
219 /* 12³ ³ */
220 /* 13³ ³ */
221 /* 14³ ³ */
222 /* 15³ ³ */
223 /* 16³ ³ */
224 /* 17³ ³ */
225 /* 18³ ³ */
226 /* 19³ ³ */
227 /* 20³ ³ */
228 /* 21³ ³ */
229 /* 22³ ³ */
230 /* 23³Press ESC to return to FDISK Options ³ */
231 /* ÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ */
232 /* */
233 /* ENTRY POINTS: dos_create_partition */
234 /* LINKAGE: dos_create_partition(); */
235 /* NEAR CALL */
236 /* */
237 /* INPUT: None */
238 /* */
239 /* EXIT-NORMAL: ERROR=FALSE */
240 /* */
241 /* EXIT-ERROR: ERROR=TRUE */
242 /* GOTO internal_program_error if case statement */
243 /* failure when branching to requested function */
244 /* */
245 /* EFFECTS: No data directly modified by this routine, but */
246 /* child routines will modify data. */
247 /* */
248 /* INTERNAL REFERENCES: */
249 /* ROUTINES: */
250 /* clear_screen */
251 /* display */
252 /* get_yn_input */
253 /* wait_for_ESC */
254 /* input_dos_create */
255 /* make_partition */
256 /* check_bad_tracks */
257 /* */
258 /* */
259 /* EXTERNAL REFERENCES: */
260 /* ROUTINES: */
261 /* */
262 /******************** END OF SPECIFICATIONS ********************/
263
264 /* \f */
265 void dos_create_partition()
266
267
268 BEGIN
269
270 char input;
271 char temp;
272 char second_disk_flag; /* AN000 */
273
274
275
276 second_disk_flag = (FLAG)FALSE; /* AN000 */
277 input = c(NUL); /* AC000 */
278 /* clear off screen */
279 clear_screen(u(0),u(0),u(24),u(79)); /* AC000 */
280
281 /* Put up header */
282 display(menu_12);
283
284 /* Set up current disk message */
285 insert[0] = cur_disk+1+'0';
286 display(menu_5);
287
288 /* Display ESC prompt */
289 display(menu_11);
290
291 /* See if already exists */
292 if ((!find_partition_type(uc(DOS12))) && (!find_partition_type(uc(DOS16))) && (!find_partition_type(uc(DOSNEW)))) /* AC000 */
293
294 BEGIN
295 /* Display prompt, depending on what disk */
296 if (cur_disk == c(0)) /* AC000 */
297 /* Put up make active partition message */
298 display(menu_13);
299 else
300 BEGIN
301 /* Second disk, so don;t put up prompt mentioning active partition */
302 second_disk_flag = (FLAG)TRUE; /* AN000 */
303 display(menu_45); /* AC000 */
304 END
305 /* Get Y/N input */
306 input = get_yn_input(c(Yes),input_row,input_col); /* AC000 AC011 */
307
308 /* Go handle input */
309 switch(input)
310 BEGIN
311 case 1: /* AC000 */
312 if ( second_disk_flag == (FLAG)FALSE)
313 BEGIN
314 /* Go get the biggest area left */
315 temp = find_part_free_space(c(PRIMARY)); /* AC000 */
316 make_partition(free_space[temp].space,temp,uc(ACTIVE),c(PRIMARY)); /* AC000 */
317 reboot_flag = (FLAG)TRUE; /* AC000 */
318 if (number_of_drives == uc(1)) /* AN000 */
319 BEGIN /* AN000 */
320 write_info_to_disk();
321 reboot_system(); /* AC000 */
322 END /* AN000 */
323 clear_screen(u(16),u(0),u(23),u(79)); /* AN000 */
324 display(status_12); /* AN000 */
325 wait_for_ESC();
326 break;
327 END
328 else
329 BEGIN /* AN000 */
330 /* Go get the biggest area left */ /* AN000 */
331 temp = find_part_free_space(c(PRIMARY)); /* AN000 */
332 make_partition(free_space[temp].space,temp,uc(NUL),c(PRIMARY)); /* AN000 */
333 reboot_flag = (FLAG)TRUE; /* AN000 */
334 clear_screen(u(16),u(0),u(23),u(79)); /* AN000 */
335 display(status_12); /* AN000 */
336 wait_for_ESC();
337 break;
338 END
339
340 case 0: input_dos_create(); /* AC000 */
341 break;
342
343 case ESC: break; /* take no action */
344
345 default : internal_program_error();
346 END
347 END
348 else
349 BEGIN
350 /* Display partition table-it will return if no partitions there */
351 table_display();
352
353 /* Primary partition already exists message */
354 display(error_8);
355 wait_for_ESC();
356 END
357 return;
358 END
359
360
361 /* \f */
362 /******************* START OF SPECIFICATIONS *******************/
363 /* */
364 /* SUBROUTINE NAME: INPUT_DOS_CREATE */
365 /* */
366 /* DESCRIPTIVE NAME: Create DOS partition on disk */
367 /* */
368 /* FUNCTION: Gets user specified size for partition (maximum */
369 /* is 32mb or largest contiguous freespace, which- */
370 /* ever is smaller). Default is largest avail free */
371 /* space. Partition is created to default size,unless*/
372 /* user enters different size, but is not marked */
373 /* active. User specified size must be smaller or */
374 /* equal to the default size */
375 /* */
376 /* NOTES: Screen can be exited via the ESC command before */
377 /* partition is created and nothing will change */
378 /* */
379 /* The following screen is managed */
380 /* */
381 /* ³0000000000111111111122222222223333333333³ */
382 /* ³0123456789012345678901234567890123456789³ */
383 /* ÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ */
384 /* 00³ ³ */
385 /* 01³ ³ */
386 /* 02³ ³ */
387 /* 03³ ³ */
388 /* 04³Create DOS partition ³ */
389 /* 05³ ³ */
390 /* 06³Current Fixed Disk Drive: # ³ */
391 /* 07³ ³ */
392 /* 08³Partition Status Type Start End Size³ */
393 /* 09³ ³ */
394 /* 10³ ³ */
395 /* 11³ ³ */
396 /* 12³ ³ */
397 /* 13³ ³ */
398 /* 14³Total disk space is #### cylinders. ³ */
399 /* 15³Maximum space available for partition ³ */
400 /* 16³is #### cylinders. ³ */
401 /* 17³ ³ */
402 /* 18³Enter partition size............: [####]³ */
403 /* 19³ ³ */
404 /* 20³ ³ */
405 /* 21³ ³ */
406 /* 22³ ³ */
407 /* 23³Press ESC to return to FDISK Options ³ */
408 /* ÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ */
409 /* */
410 /* ENTRY POINTS: input_dos_create */
411 /* LINKAGE: input_dos_create(); */
412 /* NEAR CALL */
413 /* */
414 /* INPUT: None */
415 /* */
416 /* EXIT-NORMAL: ERROR=FALSE */
417 /* */
418 /* EXIT-ERROR: ERROR=TRUE */
419 /* GOTO internal_program_error if case statement */
420 /* failure when branching to requested function */
421 /* */
422 /* EFFECTS: No data directly modified by this routine, but */
423 /* child routines will modify data. */
424 /* */
425 /* INTERNAL REFERENCES: */
426 /* ROUTINES: */
427 /* clear_screen */
428 /* table_display */
429 /* get_num_input */
430 /* display */
431 /* wait_for_ESC */
432 /* make_partition */
433 /* check_bad_tracks */
434 /* */
435 /* EXTERNAL REFERENCES: */
436 /* ROUTINES: */
437 /* */
438 /******************** END OF SPECIFICATIONS ********************/
439
440 /* \f */
441 void input_dos_create()
442
443 BEGIN
444
445 unsigned input;
446 unsigned default_entry;
447 char temp;
448 char location;
449
450 input = u(NUL); /* AC000 */
451 /* clear off screen */
452 clear_screen(u(0),u(0),u(24),u(79)); /* AC000 */
453
454 /* Put up heading */
455 display(menu_12);
456
457 /* Setup and print current disk */
458 insert[0] = cur_disk+1+'0';
459 display(menu_5);
460
461 /* Print ESC prompt */
462 display(menu_11);
463
464 /* Display partition table-it will return if no partitions there */
465 table_display();
466
467 sprintf(insert,"%4.0d",total_mbytes[cur_disk]);
468 display(menu_15);
469
470 /* Get the free space */
471 temp = find_part_free_space(c(PRIMARY)); /* AC000 */
472
473 /* Is there any ?*/
474 if (free_space[temp].mbytes_unused != u(0)) /* AC000 */
475
476 BEGIN
477 /* Display disk space */
478 sprintf(insert,"%4.0d",total_mbytes[cur_disk]);
479 display(menu_15);
480
481 /* Setup and print max partition size */
482
483 sprintf(insert,"%4.0d%3.0d%%",
484 free_space[temp].mbytes_unused,
485 free_space[temp].percent_unused);
486 display(menu_16);
487
488 /* Force repeats on the input until something valid (Non-Zero return) */
489 default_entry = (unsigned)free_space[temp].mbytes_unused; /* AC000 */
490 valid_input = (FLAG)FALSE; /* AC000 */
491
492 while (!valid_input)
493
494 BEGIN
495 /* Display prompt */
496 sprintf(insert,"%4.0d",default_entry);
497 display(menu_39);
498
499 input = get_large_num_input(default_entry,free_space[temp].mbytes_unused,free_space[temp].percent_unused,menu_39,u(0),error_13); /* AC000 */
500
501 /* Update default in case of error, so it gets displayed and used */
502 /* if user presses CR only */
503
504 default_entry = input;
505 clear_screen(u(19),u(0),u(23),u(79)); /* AC000 */
506 END
507
508 if (input != ((unsigned)(ESC_FLAG))) /* AC000 */
509
510 BEGIN
511 /* Change input to cylinders */
512 /* check to see if input was in percent or mbytes */
513
514 if (PercentFlag) /* AN000 */
515 BEGIN /* AN000 */
516 if (input == free_space[temp].percent_unused)
517 input = free_space[temp].space; /* AN000 */
518 else /* AN000 */
519 input = percent_to_cylinders(input,total_disk[cur_disk]);
520 END /* AN000 */
521 else /* AN000 */
522 BEGIN /* AN000 */
523 if (input == free_space[temp].mbytes_unused)
524 input = free_space[temp].space; /* AN000 */
525 else /* AN000 */
526 input = (unsigned)mbytes_to_cylinders(input,
527 cur_disk); /* AN004 */
528 END /* AN000 */
529
530 /* Initialize PecentFlag back to FALSE */
531 PercentFlag = (FLAG)FALSE; /* AN000 */
532
533 /* Go create the partition */
534 make_partition(input,temp,uc(NUL),c(PRIMARY)); /* AC000 */
535
536 /* clear off the old prompt */
537 clear_screen(u(13),u(0),u(19),u(79)); /* AC000 */
538
539 /* Reissue the partition info */
540 table_display();
541
542 /* display the "okay, we did it" msg */
543 if (number_of_drives == uc(1)) /* AN000 */
544 display(status_5);
545 else
546 BEGIN /* AN000 */
547 clear_screen(u(16),u(0),u(23),u(79)); /* AN000 */
548 display(status_12); /* AN000 */
549 END /* AN000 */
550
551 wait_for_ESC();
552
553 reboot_flag = TRUE;
554
555 END
556 END
557 return;
558 END
559
560
561 /* \f */
562 /******************* START OF SPECIFICATIONS *******************/
563 /* */
564 /* SUBROUTINE NAME: EXT_CREATE_PARTITION */
565 /* */
566 /* DESCRIPTIVE NAME: Create EXTENDED DOS partition */
567 /* */
568 /* FUNCTION: Gets user specified size for EXTENDED partition */
569 /* (Maximum is largest contiguous freespace). The */
570 /* default is the largest available freespace. */
571 /* space. Partition is created to default size, */
572 /* unless user enters different size, but is not */
573 /* marked as active. User specified size must be */
574 /* smaller or equal to default size */
575 /* */
576 /* NOTES: Screen can be exited via the ESC command before */
577 /* partition is created and nothing will change */
578 /* */
579 /* The following screen is managed */
580 /* */
581 /* ³0000000000111111111122222222223333333333³ */
582 /* ³0123456789012345678901234567890123456789³ */
583 /* ÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ */
584 /* 00³ ³ */
585 /* 01³ ³ */
586 /* 02³ ³ */
587 /* 03³ ³ */
588 /* 04³Create EXTENDED DOS partition ³ */
589 /* 05³ ³ */
590 /* 06³Current Fixed Disk Drive: # ³ */
591 /* 07³ ³ */
592 /* 08³Partition Status Type Start End Size³ */
593 /* 09³ ³ */
594 /* 10³ ³ */
595 /* 11³ ³ */
596 /* 12³ ³ */
597 /* 13³ ³ */
598 /* 14³Total disk space is #### cylinders. ³ */
599 /* 15³Maximum space available for partition ³ */
600 /* 16³is #### cylinders. ³ */
601 /* 17³ ³ */
602 /* 18³Enter partition size............: [####]³ */
603 /* 19³ ³ */
604 /* 20³ ³ */
605 /* 21³ ³ */
606 /* 22³ ³ */
607 /* 23³Press ESC to return to FDISK Options ³ */
608 /* ÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ */
609 /* */
610 /* ENTRY POINTS: EXTENDED_create_partition */
611 /* LINKAGE: EXTENDED_create_partition(); */
612 /* NEAR CALL */
613 /* */
614 /* INPUT: None */
615 /* */
616 /* EXIT-NORMAL: ERROR=FALSE */
617 /* */
618 /* EXIT-ERROR: ERROR=TRUE */
619 /* GOTO internal_program_error if case statement */
620 /* failure when branching to requested function */
621 /* */
622 /* EFFECTS: No data directly modified by this routine, but */
623 /* child routines will modify data. */
624 /* */
625 /* INTERNAL REFERENCES: */
626 /* ROUTINES: */
627 /* clear_screen */
628 /* table_display */
629 /* get_num_input */
630 /* display */
631 /* find_partition_type */
632 /* wait_for_ESC */
633 /* make_partition */
634 /* */
635 /* EXTERNAL REFERENCES: */
636 /* ROUTINES: */
637 /* */
638 /******************** END OF SPECIFICATIONS ********************/
639
640 /* \f */
641 void ext_create_partition()
642
643
644 BEGIN
645
646 unsigned input;
647 unsigned default_entry;
648 char temp;
649
650
651 input = u(NUL); /* AC000 */
652 /* clear off screen */
653 clear_screen(u(0),u(0),u(24),u(79)); /* AC000 */
654
655 /* Put up heading */
656 display(menu_17);
657
658 /* Setup and print current disk */
659 insert[0] = cur_disk+1+'0';
660 display(menu_5);
661
662 /* print ESC prompt */
663 display(menu_11);
664
665 /* Display partition table-it will return if no partitions there */
666 table_display();
667
668 /* Go see if primary already exists and ext doesn't */
669 if ((cur_disk == c(1)) || (find_partition_type(uc(DOS12))) || (find_partition_type(uc(DOS16))) ||
670 (find_partition_type(uc(DOSNEW)))) /* AC000 */
671 BEGIN
672 if (!find_partition_type(uc(EXTENDED))) /* AC000 */
673 /* We can go create one now */
674 BEGIN
675
676 /* Get the free space */
677 temp = find_part_free_space(c(EXTENDED)); /* AC000 */
678
679 /* Is there any ?*/
680 if (free_space[temp].percent_unused != u(0)) /* AC000 */
681 BEGIN
682
683 /* Display disk space */
684 sprintf(insert,"%4.0d",total_mbytes[cur_disk]);
685 display(menu_15);
686
687 /* Setup and print max partition size */
688
689 sprintf(insert,"%4.0d%3.0d%%",
690 free_space[temp].mbytes_unused,
691 free_space[temp].percent_unused);
692 display(menu_16);
693
694 /* Force repeats on the input until something valid (Non-Zero return) */
695 /* Display MBytes unless MBytes == 0, then display percent */
696 if (free_space[temp].mbytes_unused == u(0)) /* AN000 */
697 BEGIN /* AN000 */
698 default_entry = (unsigned)free_space[temp].percent_unused; /* AC000 */
699 PercentFlag = (FLAG)TRUE; /* AN000 */
700 END /* AN000 */
701 else /* AN000 */
702 BEGIN
703 default_entry = (unsigned)free_space[temp].mbytes_unused; /* AC000 */
704 PercentFlag = (FLAG)FALSE; /* AN000 */
705 END
706
707 valid_input = (FLAG)FALSE; /* AC000 */
708
709 while (!valid_input)
710 BEGIN
711 /* Display prompt */
712 if (!PercentFlag) /* AN000 */
713 sprintf(insert,"%4.0d",default_entry);
714 else /* AN000 */
715 sprintf(insert,"%3.0d%%",default_entry); /* AN000 */
716 display(menu_42); /* AC000 */
717
718 input = get_large_num_input(default_entry,free_space[temp].mbytes_unused,free_space[temp].percent_unused,menu_42,u(0),error_13); /* AC000 */
719
720 /* Update default in case of error, so it gets displayed and used */
721 /* if user presses CR only */
722
723 default_entry = input;
724 clear_screen(u(19),u(0),u(23),u(79)); /* AC000 */
725 END
726
727 if (input != ((unsigned)(ESC_FLAG))) /* AC000 */
728 BEGIN
729
730 /* Change input to cylinders */
731 if (PercentFlag) /* AN000 */
732 BEGIN /* AN000 */
733 if (input == free_space[temp].percent_unused)
734 input = free_space[temp].space; /* AN000 */
735 else /* AN000 */
736 input = percent_to_cylinders(input,total_disk[cur_disk]);
737 END /* AN000 */
738 else /* AN000 */
739 BEGIN /* AN000 */
740 if (input == free_space[temp].mbytes_unused)
741 input = free_space[temp].space; /* AN000 */
742 else /* AN000 */
743 input = (unsigned)mbytes_to_cylinders(input,
744 cur_disk); /* AN004 */
745 END /* AN000 */
746
747
748 /* Initialize PecentFlag back to FALSE */
749 PercentFlag = (FLAG)FALSE; /* AN000 */
750
751 /* Go create the partition */
752 make_partition(input,temp,uc(NUL),c(EXTENDED)); /* AC000 */
753
754 /* clear off the old prompt */
755 clear_screen(u(13),u(0),u(19),u(79)); /* AC000 */
756
757 /* Display the updated partition information */
758 table_display();
759
760 /* Hit esc to continue line */
761 clear_screen(u(24),u(0),u(24),u(79)); /* AN000 */
762 display(menu_46); /* AN000 */
763
764 /* Tell user we created it */
765 display(status_6);
766 wait_for_ESC();
767
768 reboot_flag = (FLAG)TRUE; /* AC000 */
769
770 /* Go allow him to create disk volumes */
771 volume_create();
772 END
773 END
774 else
775 BEGIN
776 /* No room */
777 display(error_10);
778 wait_for_ESC();
779 END
780 END
781 else
782 BEGIN
783 /* Already have ext partition, tell user and bow out */
784 display(error_9);
785 wait_for_ESC();
786 END
787 END
788 else
789 BEGIN
790 /* don't have a primary partition yet, can't create an ext */
791 display(error_19);
792 wait_for_ESC();
793 END
794
795 return;
796 END
797
798
799 /* \f */
800 /******************* START OF SPECIFICATIONS *******************/
801 /* */
802 /* SUBROUTINE NAME: VOLUME_CREATE */
803 /* */
804 /* DESCRIPTIVE NAME: Create DOS disk volumes */
805 /* */
806 /* FUNCTION: Create the boot record/partition table structure */
807 /* needed to support the DOS disk volume arch in */
808 /* the EXTENDED partition. Volume is created to the */
809 /* the default size (largest contiguous freespace or */
810 /* 32mb, whichever smaller) or to the user specified */
811 /* size (must be smaller or equal to default size). */
812 /* The volume boot record is created, and the appro- */
813 /* priate pointers in other volume partition tables */
814 /* are generated. */
815 /* */
816 /* */
817 /* NOTES: Screen can be exited via the ESC command before */
818 /* partition is created and nothing will change */
819 /* */
820 /* The following screen is managed */
821 /* */
822 /* ³0000000000111111111122222222223333333333³ */
823 /* ³0123456789012345678901234567890123456789³ */
824 /* ÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ */
825 /* 00³Create DOS Disk Volume ³ */
826 /* 01³ ³ */
827 /* 02³Vol Start End Size ³ */
828 /* 03³ # #### #### #### ³ */
829 /* 04³ ³ */
830 /* 05³ ³ */
831 /* 06³ ³ */
832 /* 07³ ³ */
833 /* 08³ ³ */
834 /* 09³ ³ */
835 /* 10³ ³ */
836 /* 11³ ³ */
837 /* 12³ ³ */
838 /* 13³ ³ */
839 /* 14³ ³ */
840 /* 15³ ³ */
841 /* 16³Total partition size is #### cylinders. ³ */
842 /* 17³Maximum space available for disk ³ */
843 /* 18³volume is #### cylinders. ³ */
844 /* 19³ ³ */
845 /* 20³Enter disk volume size..........: [####]³ */
846 /* 21³ ³ */
847 /* 22³ ³ */
848 /* 23³Press ESC to return to FDISK Options ³ */
849 /* ÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ */
850 /* */
851 /* ENTRY POINTS: Volume_Create */
852 /* LINKAGE: Volume_Create () */
853 /* NEAR CALL */
854 /* */
855 /* INPUT: None */
856 /* */
857 /* EXIT-NORMAL: ERROR=FALSE */
858 /* */
859 /* EXIT-ERROR: ERROR=TRUE */
860 /* GOTO internal_program_error if case statement */
861 /* failure when branching to requested function */
862 /* */
863 /* EFFECTS: No data directly modified by this routine, but */
864 /* child routines will modify data. */
865 /* */
866 /* INTERNAL REFERENCES: */
867 /* ROUTINES: */
868 /* clear_screen */
869 /* display */
870 /* volume_display */
871 /* get_num_input */
872 /* wait_for_ESC */
873 /* make_partition */
874 /* */
875 /* EXTERNAL REFERENCES: */
876 /* ROUTINES: */
877 /* */
878 /******************** END OF SPECIFICATIONS ********************/
879
880 /* \f */
881 void volume_create()
882
883 BEGIN
884
885 unsigned input;
886 unsigned default_entry;
887 char temp;
888 char drive_letter;
889 char default_value;
890 char location;
891 char previous_location;
892 char ext_location;
893 unsigned char i;
894 char defined_drives;
895 char temp_cur_disk;
896 unsigned ext_part_percent_unused; /* AN000 */
897 unsigned ext_part_num; /* AN000 */
898
899 input = u(NUL); /* AC000 */
900
901 /* clear off screen */
902 clear_screen(u(0),u(0),u(24),u(79)); /* AC000 */
903
904 /* Display header */
905 display (menu_18);
906
907 /* print ESC prompt */
908 display(menu_11);
909
910 /* Display volume info */
911 drive_letter = volume_display();
912
913 /* Loop until done */
914 input = u(NUL); /* AC000 */
915 while (input != ((unsigned)(ESC_FLAG))) /* AC000 */
916
917 BEGIN
918 /* See if we have hit the max number of drives */
919 defined_drives = c(0); /* AC000 */
920 temp_cur_disk = cur_disk;
921
922 /* Search both drives for defined drives */
923 for (i = uc(0); i < number_of_drives; i++) /* AC000 */
924
925 BEGIN
926 cur_disk = ((char)(i));
927
928 /* See if there is a primary drive letter */
929 if ((find_partition_type(uc(DOS12))) || (find_partition_type(uc(DOS16))) || (find_partition_type(uc(DOSNEW)))) /*AC000*/
930 defined_drives++;
931
932 /* See if extended partition on disk */
933 if (find_partition_type(uc(EXTENDED))) /* AC000 */
934 BEGIN
935 /* Get number of logical drives */
936 defined_drives = defined_drives + get_num_logical_dos_drives();
937 END
938 END
939 /* Restore cur_disk to original */
940 cur_disk = temp_cur_disk;
941
942 /* See if 26 or less drives total */
943 if (defined_drives < c(24)) /* AC000 */
944 BEGIN
945 location = find_ext_free_space();
946
947 /* find the number of the extended partiton to figure out percent */
948 ext_part_num = find_partition_location(uc(EXTENDED)); /* AN000 */
949
950 /* Set the percent used */
951 ext_part_percent_unused =
952 cylinders_to_percent(free_space[location].space,
953 ((part_table[cur_disk][ext_part_num].end_cyl-part_table[cur_disk][ext_part_num].start_cyl)+1)); /* AN000 */
954
955 /* Is there any ?*/
956 if (ext_part_percent_unused != u(0)) /* AC000 */
957 BEGIN
958
959 /* Display disk space */
960 sprintf(insert,"%4.0d",get_partition_size(uc(EXTENDED)) );
961 display(menu_21);
962
963 /* Setup and print max partition size */
964
965 sprintf(insert,"%4.0d%3.0d%%",
966 free_space[location].mbytes_unused,
967 ext_part_percent_unused);
968 display(menu_22);
969
970 /* Force repeats on the input until something valid (Non-Zero return) */
971 /* If MBytes unused is equel to zero, display percent unused */
972 if (free_space[location].mbytes_unused == u(0)) /* AN000 */
973 BEGIN /* AN000 */
974 default_entry = (unsigned)ext_part_percent_unused; /* AN000 */
975 PercentFlag = (FLAG)TRUE; /* AN000 */
976 END /* AN000 */
977 else /* AN000 */
978 BEGIN /* AN000 */
979 default_entry = (unsigned)free_space[location].mbytes_unused; /* AC000 */
980 PercentFlag = (FLAG)FALSE; /* AN000 */
981 END /* AN000 */
982
983 valid_input = (FLAG)FALSE; /* AC000 */
984
985 while (!valid_input)
986 BEGIN
987 /* Display prompt */
988 if (!PercentFlag) /* AN000 */
989 sprintf(insert,"%4.0d",default_entry);
990 else /* AN000 */
991 sprintf(insert,"%3.0d%%",default_entry); /* AN000 */
992
993 display(menu_40);
994
995 input = get_large_num_input(default_entry,free_space[location].mbytes_unused,ext_part_percent_unused,menu_40,u(0),error_12); /* AC000*/
996
997 /* Update default in case of error, so it gets displayed and used */
998 /* if user presses CR only */
999
1000 default_entry = input;
1001 clear_screen(u(19),u(0),u(23),u(79)); /* AC000 */
1002 END
1003
1004 if (input != ((unsigned)(ESC_FLAG))) /* AC000 */
1005 BEGIN
1006
1007 /* Change input to cylinders */
1008 if (PercentFlag) /* AN000 */
1009 BEGIN /* AN000 */
1010 if (input == ext_part_percent_unused)
1011 input = free_space[location].space; /* AN000 */
1012 else /* AN000 */
1013 input = percent_to_cylinders(input,((part_table[cur_disk][ext_part_num].end_cyl-part_table[cur_disk][ext_part_num].start_cyl)+1));
1014 END /* AN000 */
1015 else /* AN000 */
1016 BEGIN /* AN000 */
1017 if (input == free_space[location].mbytes_unused)
1018 input = free_space[location].space; /* AN000 */
1019 else /* AN000 */
1020 input = (unsigned)mbytes_to_cylinders(input,
1021 cur_disk); /* AN004 */
1022 END /* AN000 */
1023
1024 /* Initialize PecentFlag back to FALSE */
1025 PercentFlag = (FLAG)FALSE; /* AN000 */
1026
1027 /* go create the entry and find out where it put it */
1028 ext_location = make_volume(input,location);
1029
1030 /* clear off the old prompt */
1031 clear_screen(u(15),u(0),u(19),u(79)); /* AC000 */
1032
1033 reboot_flag = (FLAG)TRUE; /* AC000 */
1034
1035 /* Display the updated partition information */
1036 drive_letter = volume_display();
1037
1038 /* Tell user we created it */
1039 display(status_7);
1040 END
1041 END
1042 else
1043 BEGIN
1044 /* No space left or already max'd on the devices */
1045 /* Get rid of the size prompts */
1046 clear_screen(u(17),u(0),u(21),u(79)); /* AC000 */
1047 display(error_20);
1048 volume_display();
1049 wait_for_ESC(); /* KWC, 11-01-87 */
1050 input = u(ESC_FLAG); /* KWC, 11-01-87 */
1051 END
1052 END
1053 else
1054 BEGIN
1055 /* Reached the maximum */
1056 /* Get rid of the size prompts */
1057 clear_screen(u(17),u(0),u(21),u(79)); /* AC000 */
1058 display(error_27);
1059 /* Force an exit with ESC */
1060 wait_for_ESC(); /* KWC, 11-01-87 */
1061 input = u(ESC_FLAG); /* KWC, 11-01-87 */
1062 END
1063 END
1064 clear_screen(u(0),u(0),u(24),u(79)); /* AC000 */
1065 return;
1066 END
1067