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