Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/bsdinstall/partedit/gpart_ops.c
Show First 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | newfs_command(const char *fstype, char *command, int use_default) | ||||
} else { | } else { | ||||
if (!use_default) | if (!use_default) | ||||
dialog_msgbox("Error", "No configurable options exist " | dialog_msgbox("Error", "No configurable options exist " | ||||
"for this filesystem.", 0, 0, TRUE); | "for this filesystem.", 0, 0, TRUE); | ||||
command[0] = '\0'; | command[0] = '\0'; | ||||
} | } | ||||
} | } | ||||
int | const char * | ||||
gpart_partition(const char *lg_name, const char *scheme) | choose_part_type(const char *def_scheme) | ||||
{ | { | ||||
int cancel, choice; | int cancel, choice; | ||||
struct gctl_req *r; | const char *scheme = NULL; | ||||
const char *errstr; | |||||
DIALOG_LISTITEM items[] = { | DIALOG_LISTITEM items[] = { | ||||
{"APM", "Apple Partition Map", | {"APM", "Apple Partition Map", | ||||
"Bootable on PowerPC Apple Hardware", 0 }, | "Bootable on PowerPC Apple Hardware", 0 }, | ||||
{"BSD", "BSD Labels", | {"BSD", "BSD Labels", | ||||
"Bootable on most x86 systems", 0 }, | "Bootable on most x86 systems", 0 }, | ||||
{"GPT", "GUID Partition Table", | {"GPT", "GUID Partition Table", | ||||
"Bootable on most x86 systems", 0 }, | "Bootable on most x86 systems", 0 }, | ||||
{"MBR", "DOS Partitions", | {"MBR", "DOS Partitions", | ||||
"Bootable on most x86 systems", 0 }, | "Bootable on most x86 systems", 0 }, | ||||
{"PC98", "NEC PC9801 Partition Table", | {"PC98", "NEC PC9801 Partition Table", | ||||
"Bootable on NEC PC9801 systems", 0 }, | "Bootable on NEC PC9801 systems", 0 }, | ||||
{"VTOC8", "Sun VTOC8 Partition Table", | {"VTOC8", "Sun VTOC8 Partition Table", | ||||
"Bootable on Sun SPARC systems", 0 }, | "Bootable on Sun SPARC systems", 0 }, | ||||
}; | }; | ||||
schememenu: | parttypemenu: | ||||
if (scheme == NULL) { | dialog_vars.default_item = __DECONST(char *, def_scheme); | ||||
dialog_vars.default_item = __DECONST(char *, default_scheme()); | |||||
cancel = dlg_menu("Partition Scheme", | cancel = dlg_menu("Partition Scheme", | ||||
"Select a partition scheme for this volume:", 0, 0, 0, | "Select a partition scheme for this volume:", 0, 0, 0, | ||||
sizeof(items) / sizeof(items[0]), items, &choice, NULL); | sizeof(items) / sizeof(items[0]), items, &choice, NULL); | ||||
dialog_vars.default_item = NULL; | dialog_vars.default_item = NULL; | ||||
if (cancel) | if (cancel) | ||||
return (-1); | return NULL; | ||||
if (!is_scheme_bootable(items[choice].name)) { | if (!is_scheme_bootable(items[choice].name)) { | ||||
char message[512]; | char message[512]; | ||||
sprintf(message, "This partition scheme (%s) is not " | sprintf(message, "This partition scheme (%s) is not " | ||||
"bootable on this platform. Are you sure you want " | "bootable on this platform. Are you sure you want " | ||||
"to proceed?", items[choice].name); | "to proceed?", items[choice].name); | ||||
dialog_vars.defaultno = TRUE; | dialog_vars.defaultno = TRUE; | ||||
cancel = dialog_yesno("Warning", message, 0, 0); | cancel = dialog_yesno("Warning", message, 0, 0); | ||||
dialog_vars.defaultno = FALSE; | dialog_vars.defaultno = FALSE; | ||||
if (cancel) /* cancel */ | if (cancel) /* cancel */ | ||||
goto schememenu; | goto parttypemenu; | ||||
} | } | ||||
scheme = items[choice].name; | scheme = items[choice].name; | ||||
return scheme; | |||||
} | } | ||||
int | |||||
gpart_partition(const char *lg_name, const char *scheme) | |||||
{ | |||||
int cancel; | |||||
struct gctl_req *r; | |||||
const char *errstr; | |||||
schememenu: | |||||
if (scheme == NULL) { | |||||
scheme = choose_part_type(default_scheme()); | |||||
if (scheme == NULL) | |||||
return (-1); | |||||
if (!is_scheme_bootable(scheme)) { | |||||
char message[512]; | |||||
sprintf(message, "This partition scheme (%s) is not " | |||||
"bootable on this platform. Are you sure you want " | |||||
"to proceed?", scheme); | |||||
dialog_vars.defaultno = TRUE; | |||||
cancel = dialog_yesno("Warning", message, 0, 0); | |||||
dialog_vars.defaultno = FALSE; | |||||
if (cancel) { /* cancel */ | |||||
/* Reset scheme so user can choose another */ | |||||
scheme = NULL; | |||||
goto schememenu; | |||||
} | |||||
} | |||||
} | |||||
r = gctl_get_handle(); | r = gctl_get_handle(); | ||||
gctl_ro_param(r, "class", -1, "PART"); | gctl_ro_param(r, "class", -1, "PART"); | ||||
gctl_ro_param(r, "arg0", -1, lg_name); | gctl_ro_param(r, "arg0", -1, lg_name); | ||||
gctl_ro_param(r, "flags", -1, GPART_FLAGS); | gctl_ro_param(r, "flags", -1, GPART_FLAGS); | ||||
gctl_ro_param(r, "scheme", -1, scheme); | gctl_ro_param(r, "scheme", -1, scheme); | ||||
gctl_ro_param(r, "verb", -1, "create"); | gctl_ro_param(r, "verb", -1, "create"); | ||||
errstr = gctl_issue(r); | errstr = gctl_issue(r); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | gpart_activate(struct gprovider *pp) | ||||
gctl_ro_param(r, "arg0", -1, pp->lg_geom->lg_name); | gctl_ro_param(r, "arg0", -1, pp->lg_geom->lg_name); | ||||
gctl_ro_param(r, "verb", -1, "set"); | gctl_ro_param(r, "verb", -1, "set"); | ||||
gctl_ro_param(r, "attrib", -1, attribute); | gctl_ro_param(r, "attrib", -1, attribute); | ||||
gctl_ro_param(r, "index", sizeof(idx), &idx); | gctl_ro_param(r, "index", sizeof(idx), &idx); | ||||
errstr = gctl_issue(r); | errstr = gctl_issue(r); | ||||
if (errstr != NULL && errstr[0] != '\0') | if (errstr != NULL && errstr[0] != '\0') | ||||
gpart_show_error("Error", "Error marking partition active:", | gpart_show_error("Error", "Error marking partition active:", | ||||
errstr); | |||||
gctl_free(r); | |||||
} | |||||
void | |||||
gpart_set_root(const char *lg_name, const char *attribute) | |||||
{ | |||||
struct gctl_req *r; | |||||
const char *errstr; | |||||
r = gctl_get_handle(); | |||||
gctl_ro_param(r, "class", -1, "PART"); | |||||
gctl_ro_param(r, "arg0", -1, lg_name); | |||||
gctl_ro_param(r, "flags", -1, "C"); | |||||
gctl_ro_param(r, "verb", -1, "set"); | |||||
gctl_ro_param(r, "attrib", -1, attribute); | |||||
errstr = gctl_issue(r); | |||||
if (errstr != NULL && errstr[0] != '\0') | |||||
gpart_show_error("Error", "Error setting parameter on disk:", | |||||
errstr); | errstr); | ||||
gctl_free(r); | gctl_free(r); | ||||
} | } | ||||
static void | static void | ||||
gpart_bootcode(struct ggeom *gp) | gpart_bootcode(struct ggeom *gp) | ||||
{ | { | ||||
const char *bootcode; | const char *bootcode; | ||||
▲ Show 20 Lines • Show All 1,008 Lines • Show Last 20 Lines |