Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/partedit/partedit.c
Show All 38 Lines | |||||
#include "diskeditor.h" | #include "diskeditor.h" | ||||
#include "partedit.h" | #include "partedit.h" | ||||
struct pmetadata_head part_metadata; | struct pmetadata_head part_metadata; | ||||
static int sade_mode = 0; | static int sade_mode = 0; | ||||
static int apply_changes(struct gmesh *mesh); | static int apply_changes(struct gmesh *mesh); | ||||
static void apply_workaround(struct gmesh *mesh); | |||||
static struct partedit_item *read_geom_mesh(struct gmesh *mesh, int *nitems); | static struct partedit_item *read_geom_mesh(struct gmesh *mesh, int *nitems); | ||||
static void add_geom_children(struct ggeom *gp, int recurse, | static void add_geom_children(struct ggeom *gp, int recurse, | ||||
struct partedit_item **items, int *nitems); | struct partedit_item **items, int *nitems); | ||||
static void init_fstab_metadata(void); | static void init_fstab_metadata(void); | ||||
static void get_mount_points(struct partedit_item *items, int nitems); | static void get_mount_points(struct partedit_item *items, int nitems); | ||||
static int validate_setup(void); | static int validate_setup(void); | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | if (op == 5) { /* Finished */ | ||||
"ERASED. Are you sure you want to commit your " | "ERASED. Are you sure you want to commit your " | ||||
"changes?", 0, 0); | "changes?", 0, 0); | ||||
dialog_vars.ok_label = NULL; | dialog_vars.ok_label = NULL; | ||||
dialog_vars.extra_button = FALSE; | dialog_vars.extra_button = FALSE; | ||||
dialog_vars.cancel_label = NULL; | dialog_vars.cancel_label = NULL; | ||||
if (op == 0 && validate_setup()) { /* Save */ | if (op == 0 && validate_setup()) { /* Save */ | ||||
error = apply_changes(&mesh); | error = apply_changes(&mesh); | ||||
if (!error) | |||||
marcel: May want to apply the workaround only when error is 0? | |||||
Not Done Inline Actionsin the case of an error, the disk will be left in an inconsistent state, so it likely makes no difference, but lets do it anyway to avoid generating even more error messages. allanjude: in the case of an error, the disk will be left in an inconsistent state, so it likely makes no… | |||||
apply_workaround(&mesh); | |||||
break; | break; | ||||
} else if (op == 3) { /* Quit */ | } else if (op == 3) { /* Quit */ | ||||
gpart_revert_all(&mesh); | gpart_revert_all(&mesh); | ||||
error = -1; | error = -1; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | if (md->fstab != NULL) | ||||
fprintf(fstab, "%s\t%s\t\t%s\t%s\t%d\t%d\n", | fprintf(fstab, "%s\t%s\t\t%s\t%s\t%d\t%d\n", | ||||
md->fstab->fs_spec, md->fstab->fs_file, | md->fstab->fs_spec, md->fstab->fs_file, | ||||
md->fstab->fs_vfstype, md->fstab->fs_mntops, | md->fstab->fs_vfstype, md->fstab->fs_mntops, | ||||
md->fstab->fs_freq, md->fstab->fs_passno); | md->fstab->fs_freq, md->fstab->fs_passno); | ||||
} | } | ||||
fclose(fstab); | fclose(fstab); | ||||
return (0); | return (0); | ||||
} | |||||
static void | |||||
apply_workaround(struct gmesh *mesh) | |||||
{ | |||||
struct gclass *classp; | |||||
struct ggeom *gp; | |||||
struct gconfig *gc; | |||||
const char *scheme = NULL, *modified = NULL; | |||||
LIST_FOREACH(classp, &mesh->lg_class, lg_class) { | |||||
if (strcmp(classp->lg_name, "PART") == 0) | |||||
break; | |||||
} | |||||
if (strcmp(classp->lg_name, "PART") != 0) { | |||||
dialog_msgbox("Error", "gpart not found!", 0, 0, TRUE); | |||||
return; | |||||
} | |||||
LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { | |||||
LIST_FOREACH(gc, &gp->lg_config, lg_config) { | |||||
if (strcmp(gc->lg_name, "scheme") == 0) { | |||||
scheme = gc->lg_val; | |||||
} else if (strcmp(gc->lg_name, "modified") == 0) { | |||||
modified = gc->lg_val; | |||||
} | |||||
} | |||||
if (scheme && strcmp(scheme, "GPT") == 0 && | |||||
modified && strcmp(modified, "true") == 0) { | |||||
if (getenv("WORKAROUND_LENOVO")) | |||||
gpart_set_root(gp->lg_name, "lenovofix"); | |||||
if (getenv("WORKAROUND_GPTACTIVE")) | |||||
gpart_set_root(gp->lg_name, "active"); | |||||
} | |||||
} | |||||
} | } | ||||
static struct partedit_item * | static struct partedit_item * | ||||
read_geom_mesh(struct gmesh *mesh, int *nitems) | read_geom_mesh(struct gmesh *mesh, int *nitems) | ||||
{ | { | ||||
struct gclass *classp; | struct gclass *classp; | ||||
struct ggeom *gp; | struct ggeom *gp; | ||||
struct partedit_item *items; | struct partedit_item *items; | ||||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |
May want to apply the workaround only when error is 0?