Date: Thu, 13 Jan 2011 17:47:22 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r217366 - user/nwhitehorn/bsdinstall/partedit Message-ID: <201101131747.p0DHlMgN058553@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Thu Jan 13 17:47:22 2011 New Revision: 217366 URL: http://svn.freebsd.org/changeset/base/217366 Log: Rename some global-shadowing variables, move a function in preparation for a guided partitioning wizard, and add an if that was earlier forgotten. Modified: user/nwhitehorn/bsdinstall/partedit/diskeditor.c user/nwhitehorn/bsdinstall/partedit/gpart_ops.c user/nwhitehorn/bsdinstall/partedit/partedit.c user/nwhitehorn/bsdinstall/partedit/partedit.h Modified: user/nwhitehorn/bsdinstall/partedit/diskeditor.c ============================================================================== --- user/nwhitehorn/bsdinstall/partedit/diskeditor.c Thu Jan 13 17:32:32 2011 (r217365) +++ user/nwhitehorn/bsdinstall/partedit/diskeditor.c Thu Jan 13 17:47:22 2011 (r217366) @@ -8,11 +8,11 @@ static void print_partedit_item(WINDOW *partitions, struct partedit_item *items, - int item, int scroll, int selected) + int item, int nscroll, int selected) { chtype attr = A_NORMAL; char sizetext[16]; - int y = item - scroll + 1; + int y = item - nscroll + 1; wattrset(partitions, selected ? item_selected_attr : item_attr); wmove(partitions, y, MARGIN + items[item].indentation*2); @@ -32,7 +32,7 @@ print_partedit_item(WINDOW *partitions, int diskeditor_show(const char *title, const char *cprompt, - struct partedit_item *items, int nitems, int *selected, int *scroll) + struct partedit_item *items, int nitems, int *selected, int *nscroll) { WINDOW *dialog, *partitions; char *prompt; @@ -103,8 +103,8 @@ diskeditor_show(const char *title, const if (selected != NULL) cur_part = *selected; - if (scroll != NULL) - cur_scroll = *scroll; + if (nscroll != NULL) + cur_scroll = *nscroll; if (cur_part - cur_scroll >= partlist_height - 2 || cur_part - cur_scroll < 0) cur_scroll = cur_part; @@ -221,8 +221,8 @@ repaint: done: if (selected != NULL) *selected = cur_part; - if (scroll != NULL) - *scroll = cur_scroll; + if (nscroll != NULL) + *nscroll = cur_scroll; dlg_del_window(partitions); dlg_del_window(dialog); Modified: user/nwhitehorn/bsdinstall/partedit/gpart_ops.c ============================================================================== --- user/nwhitehorn/bsdinstall/partedit/gpart_ops.c Thu Jan 13 17:32:32 2011 (r217365) +++ user/nwhitehorn/bsdinstall/partedit/gpart_ops.c Thu Jan 13 17:47:22 2011 (r217366) @@ -11,9 +11,6 @@ #define GPART_FLAGS "x" /* Do not commit changes by default */ -static void set_part_metadata(const char *name, const char *scheme, - const char *type, const char *mountpoint, int newfs); - static void gpart_show_error(const char *title, const char *explanation, const char *errstr) { @@ -114,7 +111,7 @@ gpart_activate(struct gprovider *pp) struct gctl_req *r; const char *errstr, *scheme; const char *attribute = NULL; - intmax_t index; + intmax_t idx; /* * Some partition schemes need this partition to be marked 'active' @@ -135,7 +132,7 @@ gpart_activate(struct gprovider *pp) LIST_FOREACH(gc, &pp->lg_config, lg_config) { if (strcmp(gc->lg_name, "index") == 0) { - index = atoi(gc->lg_val); + idx = atoi(gc->lg_val); break; } } @@ -145,7 +142,7 @@ gpart_activate(struct gprovider *pp) gctl_ro_param(r, "arg0", -1, pp->lg_geom->lg_name); gctl_ro_param(r, "verb", -1, "set"); gctl_ro_param(r, "attrib", -1, attribute); - gctl_ro_param(r, "index", sizeof(index), &index); + gctl_ro_param(r, "index", sizeof(idx), &idx); errstr = gctl_issue(r); if (errstr != NULL && errstr[0] != '\0') @@ -267,15 +264,16 @@ gpart_destroy(struct ggeom *lg_geom, int gctl_free(r); /* If asked, commit the change */ - r = gctl_get_handle(); - gctl_ro_param(r, "class", -1, "PART"); - gctl_ro_param(r, "arg0", -1, lg_geom->lg_name); - gctl_ro_param(r, "flags", -1, GPART_FLAGS); - gctl_ro_param(r, "verb", -1, "commit"); - errstr = gctl_issue(r); - if (errstr != NULL && errstr[0] != '\0') - gpart_show_error("Error", NULL, errstr); - gctl_free(r); + if (force) { + r = gctl_get_handle(); + gctl_ro_param(r, "class", -1, "PART"); + gctl_ro_param(r, "arg0", -1, lg_geom->lg_name); + gctl_ro_param(r, "verb", -1, "commit"); + errstr = gctl_issue(r); + if (errstr != NULL && errstr[0] != '\0') + gpart_show_error("Error", NULL, errstr); + gctl_free(r); + } /* And any metadata associated with the partition scheme itself */ delete_part_metadata(lg_geom->lg_name); @@ -291,7 +289,7 @@ gpart_edit(struct gprovider *pp) const char *errstr, *oldtype, *scheme; struct partition_metadata *md; char sizestr[32]; - intmax_t index; + intmax_t idx; int hadlabel, choice, junk, nitems; unsigned i; @@ -379,7 +377,7 @@ gpart_edit(struct gprovider *pp) items[3].text = gc->lg_val; } if (strcmp(gc->lg_name, "index") == 0) - index = atoi(gc->lg_val); + idx = atoi(gc->lg_val); } TAILQ_FOREACH(md, &part_metadata, metadata) { @@ -422,7 +420,7 @@ editpart: gctl_ro_param(r, "arg0", -1, geom->lg_name); gctl_ro_param(r, "flags", -1, GPART_FLAGS); gctl_ro_param(r, "verb", -1, "modify"); - gctl_ro_param(r, "index", sizeof(index), &index); + gctl_ro_param(r, "index", sizeof(idx), &idx); if (hadlabel || items[3].text[0] != '\0') gctl_ro_param(r, "label", -1, items[3].text); gctl_ro_param(r, "type", -1, items[0].text); @@ -434,17 +432,17 @@ editpart: } gctl_free(r); - set_part_metadata(pp->lg_name, scheme, items[0].text, items[2].text, - strcmp(oldtype, items[0].text) != 0); + set_default_part_metadata(pp->lg_name, scheme, items[0].text, + items[2].text, strcmp(oldtype, items[0].text) != 0); for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++) if (items[i].text_free) free(items[i].text); } -static void -set_part_metadata(const char *name, const char *scheme, const char *type, - const char *mountpoint, int newfs) +void +set_default_part_metadata(const char *name, const char *scheme, + const char *type, const char *mountpoint, int newfs) { struct partition_metadata *md; @@ -754,8 +752,8 @@ addpartform: else if (strcmp(items[0].text, "freebsd") == 0) gpart_partition(strtok(output, " "), "BSD"); else - set_part_metadata(strtok(output, " "), scheme, items[0].text, - items[2].text, 1); + set_default_part_metadata(strtok(output, " "), scheme, + items[0].text, items[2].text, 1); for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++) if (items[i].text_free) @@ -771,7 +769,7 @@ gpart_delete(struct gprovider *pp) struct gconsumer *cp; struct gctl_req *r; const char *errstr; - intmax_t index; + intmax_t idx; int choice, is_partition; /* Is it a partition? */ @@ -831,8 +829,8 @@ gpart_delete(struct gprovider *pp) LIST_FOREACH(gc, &pp->lg_config, lg_config) { if (strcmp(gc->lg_name, "index") == 0) { - index = atoi(gc->lg_val); - gctl_ro_param(r, "index", sizeof(index), &index); + idx = atoi(gc->lg_val); + gctl_ro_param(r, "index", sizeof(idx), &idx); break; } } Modified: user/nwhitehorn/bsdinstall/partedit/partedit.c ============================================================================== --- user/nwhitehorn/bsdinstall/partedit/partedit.c Thu Jan 13 17:32:32 2011 (r217365) +++ user/nwhitehorn/bsdinstall/partedit/partedit.c Thu Jan 13 17:47:22 2011 (r217366) @@ -26,7 +26,7 @@ main(void) { struct partition_metadata *md; struct partedit_item *items; struct gmesh mesh; - int i, op, nitems, scroll; + int i, op, nitems, nscroll; int error; TAILQ_INIT(&part_metadata); @@ -36,7 +36,7 @@ main(void) { init_dialog(stdin, stdout); dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer"); dialog_vars.item_help = TRUE; - scroll = i = 0; + nscroll = i = 0; while (1) { error = geom_gettree(&mesh); @@ -50,7 +50,7 @@ main(void) { op = diskeditor_show("Partition Editor", "Create partitions for FreeBSD. No changes will be made " "until you select Finished.", - items, nitems, &i, &scroll); + items, nitems, &i, &nscroll); switch (op) { case 0: /* Create */ @@ -87,8 +87,9 @@ main(void) { error = 0; if (op == 4 && validate_setup()) { /* Finished */ dialog_vars.extra_button = TRUE; - dialog_vars.extra_label = "Don't Save"; - dialog_vars.ok_label = "Save"; + dialog_vars.extra_label = + __DECONST(char *, "Don't Save"); + dialog_vars.ok_label = __DECONST(char *, "Save"); op = dialog_yesno("Confirmation", "Your changes will " "now be written to disk. If you have chosen to " "overwrite existing data, it will be PERMANENTLY " Modified: user/nwhitehorn/bsdinstall/partedit/partedit.h ============================================================================== --- user/nwhitehorn/bsdinstall/partedit/partedit.h Thu Jan 13 17:32:32 2011 (r217365) +++ user/nwhitehorn/bsdinstall/partedit/partedit.h Thu Jan 13 17:47:22 2011 (r217366) @@ -28,6 +28,8 @@ void gpart_create(struct gprovider *pp); void gpart_revert(struct gprovider *pp); void gpart_revert_all(struct gmesh *mesh); void gpart_commit(struct gmesh *mesh); +void set_default_part_metadata(const char *name, const char *scheme, + const char *type, const char *mountpoint, int newfs); /* machine-dependent bootability checks */ int is_scheme_bootable(const char *part_type);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101131747.p0DHlMgN058553>