Some fixes related to the HAMMER support in the installer.
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / backend / installer / fn_subpart_hammer.c
blob320478be59a9ea94b657878e42ce0fd78fa22693
1 /*
2 * Copyright (c) 2008 The DragonFly Project. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
16 * Neither the name of the DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
35 * fn_subpart_hammer.c
36 * Installer Function : Create HAMMER Subpartitions.
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
43 #ifdef ENABLE_NLS
44 #include <libintl.h>
45 #define _(String) gettext (String)
46 #else
47 #define _(String) (String)
48 #endif
50 #include "libaura/mem.h"
51 #include "libaura/buffer.h"
52 #include "libaura/dict.h"
53 #include "libaura/fspred.h"
55 #include "libdfui/dfui.h"
56 #include "libdfui/dump.h"
57 #include "libdfui/system.h"
59 #include "libinstaller/commands.h"
60 #include "libinstaller/diskutil.h"
61 #include "libinstaller/functions.h"
62 #include "libinstaller/uiutil.h"
64 #include "fn.h"
65 #include "flow.h"
66 #include "pathnames.h"
68 static int create_subpartitions(struct i_fn_args *);
69 static long default_capacity(struct storage *, int);
70 static int check_capacity(struct i_fn_args *);
71 static int check_subpartition_selections(struct dfui_response *, struct i_fn_args *);
72 static void save_subpartition_selections(struct dfui_response *, struct i_fn_args *);
73 static void populate_create_subpartitions_form(struct dfui_form *, struct i_fn_args *);
74 static int warn_subpartition_selections(struct i_fn_args *);
75 static struct dfui_form *make_create_subpartitions_form(struct i_fn_args *);
76 static int show_create_subpartitions_form(struct dfui_form *, struct i_fn_args *);
78 static const char *def_mountpt[7] = {"/", "swap", "/var", "/tmp", "/usr", "/home", NULL};
79 static long def_capacity[7] = {-1, 128, 128, 128, 256, 128, 0};
81 static int expert = 0;
84 * Given a set of subpartitions-to-be in the selected slice,
85 * create them.
87 static int
88 create_subpartitions(struct i_fn_args *a)
90 struct subpartition *sp;
91 struct commands *cmds;
92 int result = 0;
93 int copied_original = 0;
94 int num_partitions;
96 cmds = commands_new();
97 if (!is_file("%sinstall.disklabel.%s",
98 a->tmp,
99 slice_get_device_name(storage_get_selected_slice(a->s)))) {
101 * Get a copy of the 'virgin' disklabel.
102 * XXX It might make more sense for this to
103 * happen right after format_slice() instead.
105 command_add(cmds, "%s%s -r %s >%sinstall.disklabel.%s",
106 a->os_root, cmd_name(a, "DISKLABEL64"),
107 slice_get_device_name(storage_get_selected_slice(a->s)),
108 a->tmp,
109 slice_get_device_name(storage_get_selected_slice(a->s)));
113 * Weave together a new disklabel out the of the 'virgin'
114 * disklabel, and the user's subpartition choices.
118 * Take everything from the 'virgin' disklabel up until the
119 * '16 partitions' line.
121 num_partitions = 16;
122 command_add(cmds, "%s%s '$2==\"partitions:\" || cut { cut = 1 } !cut { print $0 }' <%sinstall.disklabel.%s >%sinstall.disklabel",
123 a->os_root, cmd_name(a, "AWK"),
124 a->tmp,
125 slice_get_device_name(storage_get_selected_slice(a->s)),
126 a->tmp);
129 * 16 partitions:
130 * # size offset fstype
131 * c: 16383969 0 unused # 7999.985MB
134 command_add(cmds, "%s%s '%d partitions:' >>%sinstall.disklabel",
135 a->os_root, cmd_name(a, "ECHO"), num_partitions ,a->tmp);
136 command_add(cmds, "%s%s '%s' >>%sinstall.disklabel",
137 a->os_root, cmd_name(a, "ECHO"),
138 "# size offset fstype",
139 a->tmp);
141 #ifdef DEBUG
142 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
143 sp != NULL; sp = subpartition_next(sp)) {
144 command_add(cmds, "%s%s 'mountpoint: %s device: %s'",
145 a->os_root, cmd_name(a, "ECHO"),
146 subpartition_get_mountpoint(sp),
147 subpartition_get_device_name(sp));
149 #endif
152 * Write a line for each subpartition the user wants.
154 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
155 sp != NULL; sp = subpartition_next(sp)) {
156 if (subpartition_is_mfsbacked(sp)) {
157 continue;
159 if (subpartition_is_swap(sp)) {
160 command_add(cmds, "%s%s ' %c:\t%s\t*\tswap' >>%sinstall.disklabel",
161 a->os_root, cmd_name(a, "ECHO"),
162 subpartition_get_letter(sp),
163 capacity_to_string(subpartition_get_capacity(sp)),
164 a->tmp);
165 } else {
166 command_add(cmds, "%s%s ' %c:\t%s\t%s\tHAMMER' >>%sinstall.disklabel",
167 a->os_root, cmd_name(a, "ECHO"),
168 subpartition_get_letter(sp),
169 capacity_to_string(subpartition_get_capacity(sp)),
170 subpartition_get_letter(sp) == 'a' ? "0" : "*",
171 a->tmp);
174 temp_file_add(a, "install.disklabel");
177 * Label the slice from the disklabel we just wove together.
179 command_add(cmds, "%s%s -R -B -r %s %sinstall.disklabel",
180 a->os_root, cmd_name(a, "DISKLABEL64"),
181 slice_get_device_name(storage_get_selected_slice(a->s)),
182 a->tmp);
185 * Create a snapshot of the disklabel we just created
186 * for debugging inspection in the log.
188 command_add(cmds, "%s%s %s",
189 a->os_root, cmd_name(a, "DISKLABEL64"),
190 slice_get_device_name(storage_get_selected_slice(a->s)));
193 * Create filesystems on the newly-created subpartitions.
195 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
196 sp != NULL; sp = subpartition_next(sp)) {
197 if (subpartition_is_swap(sp) || subpartition_is_mfsbacked(sp))
198 continue;
201 * Ensure that all the needed device nodes exist.
203 command_add_ensure_dev(a, cmds,
204 disk_get_device_name(storage_get_selected_disk(a->s)));
205 command_add_ensure_dev(a, cmds,
206 slice_get_device_name(storage_get_selected_slice(a->s)));
207 command_add_ensure_dev(a, cmds,
208 subpartition_get_device_name(sp));
210 command_add(cmds, "%s%s -f -L ROOT %sdev/%s",
211 a->os_root, cmd_name(a, "NEWFS_HAMMER"),
212 a->os_root,
213 subpartition_get_device_name(sp));
216 result = commands_execute(a, cmds);
217 commands_free(cmds);
218 return(result);
221 static long
222 default_capacity(struct storage *s, int mtpt)
224 unsigned long swap;
225 unsigned long capacity;
226 #if 0
227 if (mtpt == MTPT_HOME)
228 return(-1);
229 #endif
230 capacity = slice_get_capacity(storage_get_selected_slice(s));
231 swap = 2 * storage_get_memsize(s);
232 if (storage_get_memsize(s) > (capacity / 2) || capacity < 4096)
233 swap = storage_get_memsize(s);
234 if (storage_get_memsize(s) > capacity)
235 swap = capacity / 2;
237 if (capacity < DISK_MIN) {
239 * For the purposes of this installer:
240 * can't be done. Sorry.
242 return(-1);
243 } else if (capacity < 1024) {
244 switch (mtpt) {
245 case MTPT_ROOT: return(-1);
246 case MTPT_SWAP: return(swap);
247 case MTPT_VAR: return(256);
248 case MTPT_TMP: return(256);
249 case MTPT_USR: return(3072);
251 } else {
252 switch (mtpt) {
253 case MTPT_ROOT: return(-1);
254 case MTPT_SWAP: return(swap);
255 case MTPT_VAR: return(256);
256 case MTPT_TMP: return(256);
257 case MTPT_USR: return(8192);
260 /* shouldn't ever happen */
261 return(-1);
264 static int
265 check_capacity(struct i_fn_args *a)
267 struct subpartition *sp;
268 unsigned long min_capacity[7] = {128, 128,0, 8, 0, 174, 0};
269 unsigned long total_capacity = 0;
270 int mtpt;
272 if (subpartition_find(storage_get_selected_slice(a->s), "/usr") == NULL)
273 min_capacity[MTPT_ROOT] += min_capacity[MTPT_USR];
275 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
276 sp != NULL; sp = subpartition_next(sp)) {
277 if (subpartition_get_capacity(sp) == -1)
278 total_capacity++;
279 else
280 total_capacity += subpartition_get_capacity(sp);
281 for (mtpt = 0; def_mountpt[mtpt] != NULL; mtpt++) {
282 if (strcmp(subpartition_get_mountpoint(sp), def_mountpt[mtpt]) == 0 &&
283 min_capacity[mtpt] > 0 &&
284 subpartition_get_capacity(sp) < min_capacity[mtpt]) {
285 inform(a->c, _("WARNING: the %s subpartition should "
286 "be at least %dM in size or you will "
287 "risk running out of space during "
288 "the installation."),
289 subpartition_get_mountpoint(sp), min_capacity[mtpt]);
292 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0 &&
293 subpartition_get_capacity(sp) < HAMMER_MIN) {
294 inform(a->c, _("WARNING: HAMMER file systems"
295 "less than 50G are not recommended! You may"
296 "have to run 'hammer prune-everything' and 'hammer reblock'"
297 "quite often, even if using a nohistory mount."));
301 if (total_capacity > slice_get_capacity(storage_get_selected_slice(a->s))) {
302 inform(a->c, _("The space allocated to all of your selected "
303 "subpartitions (%dM) exceeds the total "
304 "capacity of the selected primary partition "
305 "(%dM). Remove some subpartitions or choose "
306 "a smaller size for them and try again."),
307 total_capacity, slice_get_capacity(storage_get_selected_slice(a->s)));
308 return(0);
311 return(1);
314 static int
315 check_subpartition_selections(struct dfui_response *r, struct i_fn_args *a)
317 struct dfui_dataset *ds;
318 struct dfui_dataset *star_ds = NULL;
319 struct aura_dict *d;
320 const char *mountpoint, *capstring;
321 long capacity = 0;
322 long bsize, fsize;
323 int found_root = 0;
324 int valid = 1;
326 d = aura_dict_new(1, AURA_DICT_LIST);
328 if ((ds = dfui_response_dataset_get_first(r)) == NULL) {
329 inform(a->c, _("Please set up at least one subpartition."));
330 valid = 0;
333 for (ds = dfui_response_dataset_get_first(r); valid && ds != NULL;
334 ds = dfui_dataset_get_next(ds)) {
335 #ifdef DEBUG
336 dfui_dataset_dump(ds);
337 #endif
338 mountpoint = dfui_dataset_get_value(ds, "mountpoint");
339 capstring = dfui_dataset_get_value(ds, "capacity");
340 #if 0
341 if (expert) {
342 softupdates =
343 (strcmp(dfui_dataset_get_value(ds, "softupdates"), "Y") == 0);
344 fsize = atol(dfui_dataset_get_value(ds, "fsize"));
345 bsize = atol(dfui_dataset_get_value(ds, "bsize"));
346 mfsbacked = (strcmp(dfui_dataset_get_value(ds, "mfsbacked"), "Y") == 0);
347 } else {
348 softupdates = (strcmp(mountpoint, "/") == 0 ? 0 : 1);
349 mfsbacked = (strcmp(mountpoint, "/tmp") == 0 ? 0 : 1);
350 fsize = -1;
351 bsize = -1;
353 #endif
354 if (aura_dict_exists(d, mountpoint, strlen(mountpoint) + 1)) {
355 inform(a->c, _("The same mount point cannot be specified "
356 "for two different subpartitions."));
357 valid = 0;
360 if (strcmp(mountpoint, "/") == 0)
361 found_root = 1;
363 if (strcmp(capstring, "*") == 0) {
364 if (star_ds != NULL) {
365 inform(a->c, _("You cannot have more than one subpartition "
366 "with a '*' capacity (meaning 'use the remainder "
367 "of the primary partition'.)"));
368 valid = 0;
369 } else {
370 star_ds = ds;
374 if (!(!strcasecmp(mountpoint, "swap") || mountpoint[0] == '/')) {
375 inform(a->c, _("Mount point must be either 'swap', or it must "
376 "start with a '/'."));
377 valid = 0;
380 if (strpbrk(mountpoint, " \\\"'`") != NULL) {
381 inform(a->c, _("Mount point may not contain the following "
382 "characters: blank space, backslash, or "
383 "single, double, or back quotes."));
384 valid = 0;
387 if (strlen(capstring) == 0) {
388 inform(a->c, _("A capacity must be specified."));
389 valid = 0;
392 if (!string_to_capacity(capstring, &capacity)) {
393 inform(a->c, _("Capacity must be either a '*' symbol to indicate "
394 "'use the rest of the primary partition', or it "
395 "must be a series of decimal digits ending with a "
396 "'M' (indicating megabytes) or a 'G' (indicating "
397 "gigabytes.)"));
398 valid = 0;
402 * If we made it through that obstacle course, all is well.
405 if (valid)
406 aura_dict_store(d, mountpoint, strlen(mountpoint) + 1, "", 1);
409 if (!found_root) {
410 inform(a->c, _("You must include a / (root) subpartition."));
411 valid = 0;
414 if (aura_dict_size(d) > 16) {
415 inform(a->c, _("You cannot have more than 16 subpartitions "
416 "on a single primary partition. Remove some "
417 "and try again."));
418 valid = 0;
421 aura_dict_free(d);
423 return(valid);
426 static void
427 save_subpartition_selections(struct dfui_response *r, struct i_fn_args *a)
429 struct dfui_dataset *ds;
430 char mfsbacked;
431 const char *mountpoint, *capstring;
432 long capacity;
433 long bsize, fsize;
434 int valid = 1;
436 subpartitions_free(storage_get_selected_slice(a->s));
438 for (ds = dfui_response_dataset_get_first(r); valid && ds != NULL;
439 ds = dfui_dataset_get_next(ds)) {
440 mountpoint = dfui_dataset_get_value(ds, "mountpoint");
441 capstring = dfui_dataset_get_value(ds, "capacity");
442 #if 0
443 if (expert) {
444 softupdates =
445 (strcmp(dfui_dataset_get_value(ds, "softupdates"), "Y") == 0);
446 fsize = atol(dfui_dataset_get_value(ds, "fsize"));
447 bsize = atol(dfui_dataset_get_value(ds, "bsize"));
448 mfsbacked = (strcmp(dfui_dataset_get_value(ds, "msfbacked"), "Y") == 0);
449 } else {
450 softupdates = (strcmp(mountpoint, "/") == 0 ? 0 : 1);
451 mfsbacked = 0;
452 fsize = -1;
453 bsize = -1;
455 #endif
456 if (string_to_capacity(capstring, &capacity)) {
457 subpartition_new_hammer(storage_get_selected_slice(a->s),
458 mountpoint, capacity);
463 static void
464 populate_create_subpartitions_form(struct dfui_form *f, struct i_fn_args *a)
466 struct subpartition *sp;
467 struct dfui_dataset *ds;
468 char temp[32];
469 int mtpt;
470 long capacity;
472 if (slice_subpartition_first(storage_get_selected_slice(a->s)) != NULL) {
474 * The user has already given us their subpartition
475 * preferences, so use them here.
477 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
478 sp != NULL; sp = subpartition_next(sp)) {
479 ds = dfui_dataset_new();
480 dfui_dataset_celldata_add(ds, "mountpoint",
481 subpartition_get_mountpoint(sp));
482 dfui_dataset_celldata_add(ds, "capacity",
483 capacity_to_string(subpartition_get_capacity(sp)));
484 dfui_form_dataset_add(f, ds);
486 } else {
488 * Otherwise, populate the form with datasets representing
489 * reasonably-calculated defaults. The defaults are chosen
490 * based on the slice's total capacity and the machine's
491 * total physical memory (for swap.)
493 for (mtpt = 0; def_mountpt[mtpt] != NULL; mtpt++) {
494 /* XXX matthias. skip them for now */
495 if (mtpt != MTPT_ROOT && mtpt != MTPT_SWAP)
496 continue;
497 capacity = default_capacity(a->s, mtpt);
498 ds = dfui_dataset_new();
499 dfui_dataset_celldata_add(ds, "mountpoint",
500 def_mountpt[mtpt]);
501 dfui_dataset_celldata_add(ds, "capacity",
502 capacity_to_string(capacity));
503 dfui_form_dataset_add(f, ds);
508 static int
509 warn_subpartition_selections(struct i_fn_args *a)
511 int valid = 0;
512 struct aura_buffer *omit, *consequences;
514 omit = aura_buffer_new(2048);
515 consequences = aura_buffer_new(2048);
517 valid = check_capacity(a);
518 /* XXX matthias
520 * Should we add an information here, that we created /usr, /var, /home
521 * and /tmp as PFS?
523 #if 0
524 if (subpartition_find(storage_get_selected_slice(a->s), "/var") == NULL) {
525 aura_buffer_cat(omit, "/var ");
526 aura_buffer_cat(consequences, _("/var will be a plain dir in /\n"));
528 if (subpartition_find(storage_get_selected_slice(a->s), "/usr") == NULL) {
529 aura_buffer_cat(omit, "/usr ");
530 aura_buffer_cat(consequences, _("/usr will be a plain dir in /\n"));
532 if (subpartition_find(storage_get_selected_slice(a->s), "/tmp") == NULL) {
533 aura_buffer_cat(omit, "/tmp ");
534 aura_buffer_cat(consequences, _("/tmp will be symlinked to /var/tmp\n"));
536 if (subpartition_find(storage_get_selected_slice(a->s), "/home") == NULL) {
537 aura_buffer_cat(omit, "/home ");
538 aura_buffer_cat(consequences, _("/home will be symlinked to /usr/home\n"));
541 if (valid && aura_buffer_len(omit) > 0) {
542 switch (dfui_be_present_dialog(a->c, _("Really omit?"),
543 _("Omit Subpartition(s)|Return to Create Subpartitions"),
544 _("You have elected to not have the following "
545 "subpartition(s):\n\n%s\n\n"
546 "The ramifications of these subpartition(s) being "
547 "missing will be:\n\n%s\n"
548 "Is this really what you want to do?"),
549 aura_buffer_buf(omit), aura_buffer_buf(consequences))) {
550 case 1:
551 valid = 1;
552 break;
553 case 2:
554 valid = 0;
555 break;
556 default:
557 abort_backend();
560 #endif
561 aura_buffer_free(omit);
562 aura_buffer_free(consequences);
564 return(!valid);
567 static struct dfui_form *
568 make_create_subpartitions_form(struct i_fn_args *a)
570 struct dfui_field *fi;
571 struct dfui_form *f;
572 char msg_buf[1][1024];
574 snprintf(msg_buf[0], sizeof(msg_buf[0]),
575 _("Subpartitions further divide a primary partition for "
576 "use with %s. Some reasons you may want "
577 "a set of subpartitions are:\n\n"
578 "- you want to restrict how much data can be written "
579 "to certain parts of the primary partition, to quell "
580 "denial-of-service attacks; and\n"
581 "- you want to speed up access to data on the disk."
582 ""), OPERATING_SYSTEM_NAME);
584 f = dfui_form_create(
585 "create_subpartitions",
586 _("Create Subpartitions"),
587 _("Set up the subpartitions (also known as just `partitions' "
588 "in BSD tradition) you want to have on this primary "
589 "partition.\n\n"
590 "For Capacity, use 'M' to indicate megabytes, 'G' to "
591 "indicate gigabytes, or a single '*' to indicate "
592 "'use the remaining space on the primary partition'."),
594 msg_buf[0],
596 "p", "special", "dfinstaller_create_subpartitions",
597 "p", "minimum_width","64",
599 "f", "mountpoint", _("Mountpoint"), "", "",
600 "f", "capacity", _("Capacity"), "", "",
602 "a", "ok", _("Accept and Create"), "", "",
603 "a", "cancel",
604 (disk_get_formatted(storage_get_selected_disk(a->s)) ?
605 _("Return to Select Disk") :
606 _("Return to Select Primary Partition")), "", "",
607 "p", "accelerator", "ESC",
609 NULL
612 dfui_form_set_multiple(f, 1);
613 dfui_form_set_extensible(f, 1);
615 * Remove ATM until HAMMER installer support is better
616 * dfui_form_set_extensible(f, 1);
618 #if 0
619 if (expert) {
620 fi = dfui_form_field_add(f, "softupdates",
621 dfui_info_new(_("Softupdates"), "", ""));
622 dfui_field_property_set(fi, "control", "checkbox");
624 fi = dfui_form_field_add(f, "mfsbacked",
625 dfui_info_new(_("MFS"), "", ""));
626 dfui_field_property_set(fi, "control", "checkbox");
628 fi = dfui_form_field_add(f, "fsize",
629 dfui_info_new(_("Frag Sz"), "", ""));
631 fi = dfui_form_field_add(f, "bsize",
632 dfui_info_new(_("Block Sz"), "", ""));
634 dfui_form_action_add(f, "switch",
635 dfui_info_new(_("Switch to Normal Mode"), "", ""));
636 } else {
637 dfui_form_action_add(f, "switch",
638 dfui_info_new(_("Switch to Expert Mode"), "", ""));
640 #endif
641 return(f);
645 * Returns:
646 * -1 = the form should be redisplayed
647 * 0 = failure, function is over
648 * 1 = success, function is over
650 static int
651 show_create_subpartitions_form(struct dfui_form *f, struct i_fn_args *a)
653 struct dfui_dataset *ds;
654 struct dfui_response *r;
656 for (;;) {
657 if (dfui_form_dataset_get_first(f) == NULL)
658 populate_create_subpartitions_form(f, a);
660 if (!dfui_be_present(a->c, f, &r))
661 abort_backend();
663 if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
664 dfui_response_free(r);
665 return(0);
666 } else if (strcmp(dfui_response_get_action_id(r), "switch") == 0) {
667 if (check_subpartition_selections(r, a)) {
668 save_subpartition_selections(r, a);
669 expert = expert ? 0 : 1;
670 dfui_response_free(r);
671 return(-1);
673 } else {
674 if (check_subpartition_selections(r, a)) {
675 save_subpartition_selections(r, a);
676 if (!warn_subpartition_selections(a)) {
677 if (!create_subpartitions(a)) {
678 inform(a->c, _("The subpartitions you chose were "
679 "not correctly created, and the "
680 "primary partition may "
681 "now be in an inconsistent state. "
682 "We recommend re-formatting it "
683 "before proceeding."));
684 dfui_response_free(r);
685 return(0);
686 } else {
687 dfui_response_free(r);
688 return(1);
694 dfui_form_datasets_free(f);
695 /* dfui_form_datasets_add_from_response(f, r); */
696 for (ds = dfui_response_dataset_get_first(r); ds != NULL;
697 ds = dfui_dataset_get_next(ds)) {
698 dfui_form_dataset_add(f, dfui_dataset_dup(ds));
704 * fn_create_subpartitions_hammer: let the user specify what subpartitions they
705 * want on the disk, how large each should be, and where it should be mounted.
707 void
708 fn_create_subpartitions_hammer(struct i_fn_args *a)
710 struct dfui_form *f;
711 int done = 0;
713 a->result = 0;
714 while (!done) {
715 f = make_create_subpartitions_form(a);
716 switch (show_create_subpartitions_form(f, a)) {
717 case -1:
718 done = 0;
719 break;
720 case 0:
721 done = 1;
722 a->result = 0;
723 break;
724 case 1:
725 done = 1;
726 a->result = 1;
727 break;
729 dfui_form_free(f);