Date: Sat, 8 Oct 2011 16:45:03 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r226161 - head/usr.sbin/bsdinstall/partedit Message-ID: <201110081645.p98Gj4YK070661@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Sat Oct 8 16:45:03 2011 New Revision: 226161 URL: http://svn.freebsd.org/changeset/base/226161 Log: Avoid magicking into existence sub-partitions due to leftover blocks when creating new ones by destroying any geom that may have come into existence immediately after adding a partition. The EBR partition scheme is particularly enthusiastic about false positives in this case. MFC after: 3 days Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/gpart_ops.c Sat Oct 8 14:59:12 2011 (r226160) +++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c Sat Oct 8 16:45:03 2011 (r226161) @@ -730,7 +730,7 @@ gpart_create(struct gprovider *pp, char struct gconsumer *cp; struct ggeom *geom; const char *errstr, *scheme; - char sizestr[32], startstr[32], output[64]; + char sizestr[32], startstr[32], output[64], *newpartname; char newfs[64], options_fstype[64]; intmax_t maxsize, size, sector, firstfree, stripe; uint64_t bytes; @@ -990,29 +990,43 @@ addpartform: if (items[3].text[0] != '\0') gctl_ro_param(r, "label", -1, items[3].text); gctl_rw_param(r, "output", sizeof(output), output); - errstr = gctl_issue(r); if (errstr != NULL && errstr[0] != '\0') { gpart_show_error("Error", NULL, errstr); gctl_free(r); goto addpartform; } + newpartname = strtok(output, " "); + gctl_free(r); + + /* + * Try to destroy any geom that gpart picked up already here from + * dirty blocks. + */ + r = gctl_get_handle(); + gctl_ro_param(r, "class", -1, "PART"); + gctl_ro_param(r, "arg0", -1, newpartname); + gctl_ro_param(r, "flags", -1, GPART_FLAGS); + junk = 1; + gctl_ro_param(r, "force", sizeof(junk), &junk); + gctl_ro_param(r, "verb", -1, "destroy"); + gctl_issue(r); /* Error usually expected and non-fatal */ + gctl_free(r); if (strcmp(items[0].text, "freebsd-boot") == 0) - get_part_metadata(strtok(output, " "), 1)->bootcode = 1; + get_part_metadata(newpartname, 1)->bootcode = 1; else if (strcmp(items[0].text, "freebsd") == 0) - gpart_partition(strtok(output, " "), "BSD"); + gpart_partition(newpartname, "BSD"); else - set_default_part_metadata(strtok(output, " "), scheme, + set_default_part_metadata(newpartname, scheme, items[0].text, items[2].text, newfs); for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++) if (items[i].text_free) free(items[i].text); - gctl_free(r); if (partname != NULL) - *partname = strdup(strtok(output, " ")); + *partname = strdup(newpartname); } void @@ -1097,7 +1111,6 @@ gpart_revert_all(struct gmesh *mesh) struct gconfig *gc; struct ggeom *gp; struct gctl_req *r; - const char *errstr; const char *modified; LIST_FOREACH(classp, &mesh->lg_class, lg_class) { @@ -1128,9 +1141,7 @@ gpart_revert_all(struct gmesh *mesh) gctl_ro_param(r, "arg0", -1, gp->lg_name); gctl_ro_param(r, "verb", -1, "undo"); - errstr = gctl_issue(r); - if (errstr != NULL && errstr[0] != '\0') - gpart_show_error("Error", NULL, errstr); + gctl_issue(r); gctl_free(r); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110081645.p98Gj4YK070661>