From c02f7796163e944911ced15fa16f9da284b6d57b Mon Sep 17 00:00:00 2001 From: bouyer Date: Mon, 10 Feb 2020 21:39:37 +0000 Subject: [PATCH] Pull up following revision(s) (requested by martin in ticket #693): usr.sbin/sysinst/arch/x68k/msg.md.en: revision 1.2 usr.sbin/sysinst/arch/x68k/md.c: revision 1.10 usr.sbin/sysinst/arch/mvme68k/msg.md.fr: revision 1.2 usr.sbin/sysinst/arch/x68k/msg.md.en: revision 1.3 usr.sbin/sysinst/arch/mvme68k/msg.md.fr: revision 1.3 usr.sbin/sysinst/msg.mi.en: revision 1.28 usr.sbin/sysinst/arch/hp300/md.c: revision 1.10 usr.sbin/sysinst/msg.mi.es: revision 1.22 usr.sbin/sysinst/target.c: revision 1.12 usr.sbin/sysinst/arch/mvme68k/md.c: revision 1.10 usr.sbin/sysinst/arch/i386/md.c: revision 1.30 usr.sbin/sysinst/arch/mvme68k/msg.md.pl: revision 1.2 usr.sbin/sysinst/arch/mvme68k/msg.md.pl: revision 1.3 usr.sbin/sysinst/bsddisklabel.c: revision 1.39 usr.sbin/sysinst/arch/mvme68k/msg.md.de: revision 1.2 usr.sbin/sysinst/arch/mac68k/md.c: revision 1.9 usr.sbin/sysinst/disklabel.c: revision 1.35 usr.sbin/sysinst/arch/mvme68k/msg.md.de: revision 1.3 usr.sbin/sysinst/defs.h: revision 1.55 usr.sbin/sysinst/disks.c: revision 1.63 usr.sbin/sysinst/disks.c: revision 1.64 usr.sbin/sysinst/mbr.c: revision 1.31 usr.sbin/sysinst/disks.c: revision 1.65 usr.sbin/sysinst/txtwalk.c: revision 1.3 usr.sbin/sysinst/txtwalk.c: revision 1.4 usr.sbin/sysinst/arch/mvme68k/msg.md.en: revision 1.2 usr.sbin/sysinst/arch/mvme68k/msg.md.en: revision 1.3 usr.sbin/sysinst/msg.mi.fr: revision 1.26 usr.sbin/sysinst/msg.mi.pl: revision 1.29 usr.sbin/sysinst/arch/mvme68k/msg.md.es: revision 1.2 usr.sbin/sysinst/upgrade.c: revision 1.15 usr.sbin/sysinst/arch/mvme68k/msg.md.es: revision 1.3 usr.sbin/sysinst/upgrade.c: revision 1.16 usr.sbin/sysinst/partman.c: revision 1.50 usr.sbin/sysinst/msg.mi.de: revision 1.21 remove unused "emptypart" message (or moved to ifdef notyet area) PR install/54921: message "ordering" takes a %s argument. PR install/54921: skip non-user partitions when checking for overlaps bootxx_name() - fix oversight in previous change (do not assume first partition is the root partition) PR install/54934: always use -f on the installboot invocation. We come here post-newfs (and maybe should have dd'd zeros to the start of the disk before newfs instead). Remove a bogus assert: when reading disklabel partitions and the outer (MBR) partitioning has changed, but the changes have not yet been written back to disk, we need to ignore the kernels idea of the disklabel and instead continue with an empty one. Deal with partitioning schemes having no inner counterpart. Avoid NULL derefs. Do not assum a partitioning scheme that supports innner partitions always needs to actually have such partitions defined. PR bin/54944: deal with escaped spaces in NAME= syntax in /etc/fstab. PR bin/54944: explicitly reject GPT protective MBRs. PR bin/54944: make the "explicit single wedge" selection also work for upgrades. Reformat a query to add an automatically detected swap partition so it fits on narrow screens. Make re-install sets also work for an explicit selected root wedge Fix copy&pasto in previous - from kre. Only a single partition can ever have the "extend" flag (grow to available size). Do not use -P for tar extractions - the in tree tar has been fixed. Finish conversion to generic partitioning backend --- usr.sbin/sysinst/arch/hp300/md.c | 8 +- usr.sbin/sysinst/arch/i386/md.c | 4 +- usr.sbin/sysinst/arch/mac68k/md.c | 118 ++++++++++-------------- usr.sbin/sysinst/arch/mvme68k/md.c | 8 +- usr.sbin/sysinst/arch/mvme68k/msg.md.de | 13 ++- usr.sbin/sysinst/arch/mvme68k/msg.md.en | 13 +-- usr.sbin/sysinst/arch/mvme68k/msg.md.es | 12 +-- usr.sbin/sysinst/arch/mvme68k/msg.md.fr | 8 +- usr.sbin/sysinst/arch/mvme68k/msg.md.pl | 8 +- usr.sbin/sysinst/arch/x68k/md.c | 8 +- usr.sbin/sysinst/arch/x68k/msg.md.en | 12 +-- usr.sbin/sysinst/bsddisklabel.c | 4 +- usr.sbin/sysinst/defs.h | 4 +- usr.sbin/sysinst/disklabel.c | 10 +- usr.sbin/sysinst/disks.c | 26 +++++- usr.sbin/sysinst/mbr.c | 18 +++- usr.sbin/sysinst/msg.mi.de | 4 +- usr.sbin/sysinst/msg.mi.en | 5 +- usr.sbin/sysinst/msg.mi.es | 5 +- usr.sbin/sysinst/msg.mi.fr | 5 +- usr.sbin/sysinst/msg.mi.pl | 5 +- usr.sbin/sysinst/partman.c | 16 ++-- usr.sbin/sysinst/target.c | 13 ++- usr.sbin/sysinst/txtwalk.c | 11 ++- usr.sbin/sysinst/upgrade.c | 17 ++-- 25 files changed, 196 insertions(+), 159 deletions(-) diff --git a/usr.sbin/sysinst/arch/hp300/md.c b/usr.sbin/sysinst/arch/hp300/md.c index a5e32cd8da6e..79720b62a5a9 100644 --- a/usr.sbin/sysinst/arch/hp300/md.c +++ b/usr.sbin/sysinst/arch/hp300/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8.2.1 2019/12/17 09:44:51 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.8.2.2 2020/02/10 21:39:38 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -136,6 +136,12 @@ md_check_partitions(struct install_partition_desc *install) for (i = 0; i < install->num; i++) { if (i > 0) { + /* skip raw part and similar */ + if (install->infos[i].cur_flags & + (PTI_SEC_CONTAINER|PTI_PSCHEME_INTERNAL| + PTI_RAW_PART)) + continue; + if (install->infos[i].cur_start < last_end) { snprintf(desc, sizeof desc, "%zu (%s)", i, diff --git a/usr.sbin/sysinst/arch/i386/md.c b/usr.sbin/sysinst/arch/i386/md.c index 2b0d22aa5142..793b924509ae 100644 --- a/usr.sbin/sysinst/arch/i386/md.c +++ b/usr.sbin/sysinst/arch/i386/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.20.2.5 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.20.2.6 2020/02/10 21:39:38 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -291,7 +291,7 @@ md_post_newfs_bios(struct install_partition_desc *install) "console=%s,speed=%u", consoles[boottype.bp_consdev], boottype.bp_conspeed); ret = run_program(RUN_DISPLAY, - "/usr/sbin/installboot -o %s %s %s", + "/usr/sbin/installboot -f -o %s %s %s", boot_options, rdev, bootxx_filename); free(bootxx_filename); } else { diff --git a/usr.sbin/sysinst/arch/mac68k/md.c b/usr.sbin/sysinst/arch/mac68k/md.c index 4bbefd7a740d..e619d1a61d58 100644 --- a/usr.sbin/sysinst/arch/mac68k/md.c +++ b/usr.sbin/sysinst/arch/mac68k/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8 2019/07/13 17:13:38 martin Exp $ */ +/* $NetBSD: md.c,v 1.8.2.1 2020/02/10 21:39:38 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -247,12 +247,13 @@ md_get_info(struct install_partition_desc *install) bool md_make_bsd_partitions(struct install_partition_desc *install) { - int rv; -#if 0 // XXX - FILE *f; - int i, j, pl; + int i, j, rv; EBZB *bzb; -#endif + struct disk_part_info info; + uint fs_type; + const char *mountpoint; + part_id pid; + size_t ndx; /* * Scan for any problems and report them before continuing. @@ -272,15 +273,9 @@ md_make_bsd_partitions(struct install_partition_desc *install) break; } -#if 0 // XXX - /* Build standard partitions */ - memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel); + /* Start with empty fake disklabel partitions */ + pm->parts->pscheme->delete_all_partitions(pm->parts); - /* - * The mac68k port has a predefined partition for "c" which - * is the size of the disk, everything else is unused. - */ - pm->bsdlabel[RAW_PART].pi_size = pm->dlsize; /* * Now, scan through the Disk Partition Map and transfer the * information into the incore disklabel. @@ -289,80 +284,63 @@ md_make_bsd_partitions(struct install_partition_desc *install) j = map.mblk[i]; bzb = (EBZB *)&map.blk[j].pmBootArgs[0]; if (bzb->flags.part) { - pl = bzb->flags.part - 'a'; + mountpoint = NULL; + fs_type = FS_UNUSED; switch (whichType(&map.blk[j])) { case HFS_PART: - pm->bsdlabel[pl].pi_fstype = FS_HFS; - strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point); + fs_type = FS_HFS; + mountpoint = (const char*)bzb->mount_point; break; case ROOT_PART: case UFS_PART: - pm->bsdlabel[pl].pi_fstype = FS_BSDFFS; - strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point); - pm->bsdlabel[pl].pi_flags |= PIF_NEWFS | PIF_MOUNT; + fs_type = FS_BSDFFS; + mountpoint = (const char*)bzb->mount_point; break; case SWAP_PART: - pm->bsdlabel[pl].pi_fstype = FS_SWAP; + fs_type = FS_SWAP; break; case SCRATCH_PART: - pm->bsdlabel[pl].pi_fstype = FS_OTHER; - strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point); - default: + fs_type = FS_OTHER; + mountpoint = (const char*)bzb->mount_point; break; + default: + continue; } - if (pm->bsdlabel[pl].pi_fstype != FS_UNUSED) { - pm->bsdlabel[pl].pi_size = map.blk[j].pmPartBlkCnt; - pm->bsdlabel[pl].pi_offset = map.blk[j].pmPyPartStart; - if (pm->bsdlabel[pl].pi_fstype != FS_SWAP) { - pm->bsdlabel[pl].pi_frag = 8; - pm->bsdlabel[pl].pi_fsize = 1024; - } + if (fs_type != FS_UNUSED) { + memset(&info, 0, sizeof info); + info.start = map.blk[j].pmPyPartStart; + info.size = map.blk[j].pmPartBlkCnt; + info.fs_type = fs_type; + info.last_mounted = mountpoint; + info.nat_type = pm->parts->pscheme->get_fs_part_type( + PT_root, fs_type, 0); + pid = pm->parts->pscheme->add_outer_partition(pm->parts, + &info, NULL); + if (pid == NO_PART) + return false; } } } /* Disk name - don't bother asking, just use the physical name*/ - strcpy (pm->bsddiskname, pm->diskdev); + pm->parts->pscheme->set_disk_pack_name(pm->parts, pm->diskdev); -#ifdef DEBUG - f = fopen ("/tmp/disktab", "w"); -#else - f = fopen ("/etc/disktab", "w"); -#endif - if (f == NULL) { - endwin(); - (void) fprintf (stderr, "Could not open /etc/disktab"); - exit (1); - } - (void)fprintf (f, "%s|NetBSD installation generated:\\\n", pm->bsddiskname); - (void)fprintf (f, "\t:dt=%s:ty=winchester:\\\n", pm->disktype); - (void)fprintf (f, "\t:nc#%d:nt#%d:ns#%d:\\\n", pm->dlcyl, pm->dlhead, pm->dlsec); - (void)fprintf (f, "\t:sc#%d:su#%" PRIu32 ":\\\n", pm->dlhead*pm->dlsec, (uint32_t)pm->dlsize); - (void)fprintf (f, "\t:se#%d:%s\\\n", blk_size, pm->doessf); - for (i=0; i<8; i++) { - if (pm->bsdlabel[i].pi_fstype == FS_HFS) - (void)fprintf (f, "\t:p%c#%d:o%c#%d:t%c=macos:", - 'a'+i, pm->bsdlabel[i].pi_size, - 'a'+i, pm->bsdlabel[i].pi_offset, - 'a'+i); - else - (void)fprintf (f, "\t:p%c#%d:o%c#%d:t%c=%s:", - 'a'+i, pm->bsdlabel[i].pi_size, - 'a'+i, pm->bsdlabel[i].pi_offset, - 'a'+i, getfslabelname(pm->bsdlabel[i].pi_fstype)); - if (pm->bsdlabel[i].pi_fstype == FS_BSDFFS) - (void)fprintf (f, "b%c#%d:f%c#%d", - 'a'+i, pm->bsdlabel[i].pi_fsize * pm->bsdlabel[i].pi_frag, - 'a'+i, pm->bsdlabel[i].pi_fsize); - if (i < 7) - (void)fprintf (f, "\\\n"); - else - (void)fprintf (f, "\n"); - } - fclose (f); -#endif + /* Write the converted partitions */ + if (!pm->parts->pscheme->write_to_disk(pm->parts)) + return false; + + /* now convert to install info */ + if (!install_desc_from_parts(install, pm->parts)) + return false; + + /* set newfs flag for all FFS partitions */ + for (ndx = 0; ndx < install->num; ndx++) { + if (install->infos[ndx].fs_type == FS_BSDFFS && + install->infos[ndx].size > 0 && + (install->infos[ndx].instflags & PUIINST_MOUNT)) + install->infos[ndx].instflags |= PUIINST_NEWFS; + } - /* Everything looks OK. */ return true; } diff --git a/usr.sbin/sysinst/arch/mvme68k/md.c b/usr.sbin/sysinst/arch/mvme68k/md.c index e2ad2b75f0cd..535169afbce6 100644 --- a/usr.sbin/sysinst/arch/mvme68k/md.c +++ b/usr.sbin/sysinst/arch/mvme68k/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8.2.1 2019/12/17 09:44:50 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.8.2.2 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -136,6 +136,12 @@ md_check_partitions(struct install_partition_desc *install) for (i = 0; i < install->num; i++) { if (i > 0) { + /* skip raw part and similar */ + if (install->infos[i].cur_flags & + (PTI_SEC_CONTAINER|PTI_PSCHEME_INTERNAL| + PTI_RAW_PART)) + continue; + if (install->infos[i].cur_start < last_end) { snprintf(desc, sizeof desc, "%zu (%s)", i, diff --git a/usr.sbin/sysinst/arch/mvme68k/msg.md.de b/usr.sbin/sysinst/arch/mvme68k/msg.md.de index e94151684e5a..a540d60982f5 100644 --- a/usr.sbin/sysinst/arch/mvme68k/msg.md.de +++ b/usr.sbin/sysinst/arch/mvme68k/msg.md.de @@ -1,4 +1,4 @@ -/* $NetBSD: msg.md.de,v 1.1 2014/07/26 19:30:46 dholland Exp $ */ +/* $NetBSD: msg.md.de,v 1.1.30.1 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -55,12 +55,7 @@ wird ein neues erstellen. } message ordering -{Die Anordnung der Partition %c ist falsch. Erneut editieren?} - - -message emptypart -{Nach der oder den leeren Partition(en) besteht eine gültige Partition %c. -Bitte editieren Sie die Partitionstabelle noch einmal.} +{Die Anordnung der Partition %s ist falsch. Erneut editieren?} message set_kernel_1 @@ -68,6 +63,10 @@ message set_kernel_1 .if notyet /* XXX: not yet implemented */ +message emptypart +{Nach der oder den leeren Partition(en) existiert eine gültige Partition %c. +Bitte editieren Sie die Partitionstabelle noch einmal.} + message existing {Wollen Sie die vorhandene(n) BSD Partition(en) beibehalten?} diff --git a/usr.sbin/sysinst/arch/mvme68k/msg.md.en b/usr.sbin/sysinst/arch/mvme68k/msg.md.en index 47f9132665a1..e6feb52f6a84 100644 --- a/usr.sbin/sysinst/arch/mvme68k/msg.md.en +++ b/usr.sbin/sysinst/arch/mvme68k/msg.md.en @@ -1,4 +1,4 @@ -/* $NetBSD: msg.md.en,v 1.1 2014/07/26 19:30:46 dholland Exp $ */ +/* $NetBSD: msg.md.en,v 1.1.30.1 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -54,17 +54,18 @@ writing a disklabel. } message ordering -{The order of partition %c is wrong. Edit again?} - -message emptypart -{There is a valid partition %c after empty partition(s). -Please re-edit the partition table.} +{The order of partition %s is wrong. Edit again?} message set_kernel_1 {Kernel (GENERIC)} .if notyet /* XXX: not yet implemented */ + +message emptypart +{There is a valid partition %c after empty partition(s). +Please re-edit the partition table.} + message existing {Do you want to preserve existing BSD partition(s)?} diff --git a/usr.sbin/sysinst/arch/mvme68k/msg.md.es b/usr.sbin/sysinst/arch/mvme68k/msg.md.es index 8bdabb90f45c..0e95a4982621 100644 --- a/usr.sbin/sysinst/arch/mvme68k/msg.md.es +++ b/usr.sbin/sysinst/arch/mvme68k/msg.md.es @@ -1,4 +1,4 @@ -/* $NetBSD: msg.md.es,v 1.1 2014/07/26 19:30:46 dholland Exp $ */ +/* $NetBSD: msg.md.es,v 1.1.30.1 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -54,17 +54,17 @@ a escribir un disklabel. } message ordering -{El orden de la partición %c esta mal. ¿Editar de nuevo?} - -message emptypart -{Hay una partición valida %c despues de particion(es) valida(s). -Por favor, reedite la tabla de particiones} +{El orden de la partición %s esta mal. ¿Editar de nuevo?} message set_kernel_1 {Núcleo (GENERIC)} .if notyet /* XXX: not yet implemented */ +message emptypart +{Hay una partición valida %c despues de particion(es) valida(s). +Por favor, reedite la tabla de particiones} + message existing {¿Quiere preservar particion(es) BSD existente(s)?} diff --git a/usr.sbin/sysinst/arch/mvme68k/msg.md.fr b/usr.sbin/sysinst/arch/mvme68k/msg.md.fr index 9e82905c5769..7421933863bb 100644 --- a/usr.sbin/sysinst/arch/mvme68k/msg.md.fr +++ b/usr.sbin/sysinst/arch/mvme68k/msg.md.fr @@ -1,4 +1,4 @@ -/* $NetBSD: msg.md.fr,v 1.1 2014/07/26 19:30:46 dholland Exp $ */ +/* $NetBSD: msg.md.fr,v 1.1.30.1 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -53,11 +53,7 @@ sysinst } message ordering -{L'ordre de la partition %c est erroné. Modifier à nouveau ?} - -message emptypart -{Il y a une partition valide %c après une (ou plusieurs) partition(s) vide(s). -Veuillez modifier la table des partitions.} +{L'ordre de la partition %s est erroné. Modifier à nouveau ?} message set_kernel_1 {Kernel (GENERIC)} diff --git a/usr.sbin/sysinst/arch/mvme68k/msg.md.pl b/usr.sbin/sysinst/arch/mvme68k/msg.md.pl index 998950d7449e..f12a9c3bac63 100644 --- a/usr.sbin/sysinst/arch/mvme68k/msg.md.pl +++ b/usr.sbin/sysinst/arch/mvme68k/msg.md.pl @@ -1,4 +1,4 @@ -/* $NetBSD: msg.md.pl,v 1.1 2014/07/26 19:30:46 dholland Exp $ */ +/* $NetBSD: msg.md.pl,v 1.1.30.1 2020/02/10 21:39:37 bouyer Exp $ */ /* Based on english version: */ /* NetBSD: msg.md.en,v 1.1 2002/03/24 22:04:06 scw Exp */ @@ -56,11 +56,7 @@ taka etykiete. } message ordering -{Uklad partycji %c jest bledny. Edytowac jeszcze raz?} - -message emptypart -{Istnieje poprawna partycja %c po pustych partycjach. -Wyedytuj jeszcze raz tablice partycji.} +{Uklad partycji %s jest bledny. Edytowac jeszcze raz?} message set_kernel_1 {Kernel (GENERIC)} diff --git a/usr.sbin/sysinst/arch/x68k/md.c b/usr.sbin/sysinst/arch/x68k/md.c index 244983712634..e4a20b094cd3 100644 --- a/usr.sbin/sysinst/arch/x68k/md.c +++ b/usr.sbin/sysinst/arch/x68k/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8.2.1 2019/12/17 09:44:50 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.8.2.2 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -164,6 +164,12 @@ md_check_partitions(struct install_partition_desc *install) for (i = 0; i < install->num; i++) { if (i > 0) { + /* skip raw part and similar */ + if (install->infos[i].cur_flags & + (PTI_SEC_CONTAINER|PTI_PSCHEME_INTERNAL| + PTI_RAW_PART)) + continue; + if (install->infos[i].cur_start < last_end) { snprintf(desc, sizeof desc, "%zu (%s)", i, diff --git a/usr.sbin/sysinst/arch/x68k/msg.md.en b/usr.sbin/sysinst/arch/x68k/msg.md.en index 9e81b8525f73..c4e0027ffe41 100644 --- a/usr.sbin/sysinst/arch/x68k/msg.md.en +++ b/usr.sbin/sysinst/arch/x68k/msg.md.en @@ -1,4 +1,4 @@ -/* $NetBSD: msg.md.en,v 1.1 2014/07/26 19:30:47 dholland Exp $ */ +/* $NetBSD: msg.md.en,v 1.1.30.1 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -56,17 +56,17 @@ here and format the disk with Human68k format.x utility. } message ordering -{The order of partition %c is wrong. Edit again?} - -message emptypart -{There is an valid partition %c after empty partition(s). -Please re-edit the partition table.} +{The order of partition %s is wrong. Edit again?} message set_kernel_1 {Kernel (GENERIC)} .if notyet /* XXX: not yet implemented */ +message emptypart +{There is an valid partition %c after empty partition(s). +Please re-edit the partition table.} + message existing {Do you want to preserve existing BSD partition(s)?} diff --git a/usr.sbin/sysinst/bsddisklabel.c b/usr.sbin/sysinst/bsddisklabel.c index 8ccc434c60ed..2b30bef6fb35 100644 --- a/usr.sbin/sysinst/bsddisklabel.c +++ b/usr.sbin/sysinst/bsddisklabel.c @@ -1,4 +1,4 @@ -/* $NetBSD: bsddisklabel.c,v 1.23.2.9 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: bsddisklabel.c,v 1.23.2.10 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -666,6 +666,8 @@ set_ptn_size(menudesc *m, void *arg) if (p->flags & PUIFLAG_EXTEND) p->flags &= ~PUIFLAG_EXTEND; if (extend && (p->limit == 0 || p->limit > p->size)) { + for (size_t k = 0; k < pset->num; k++) + pset->infos[k].flags &= ~PUIFLAG_EXTEND; p->flags |= PUIFLAG_EXTEND; if (size == 0) size = align; diff --git a/usr.sbin/sysinst/defs.h b/usr.sbin/sysinst/defs.h index 1e2b6a0f3787..8e0b07b09867 100644 --- a/usr.sbin/sysinst/defs.h +++ b/usr.sbin/sysinst/defs.h @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.42.2.6 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: defs.h,v 1.42.2.7 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -527,7 +527,7 @@ int clean_xfer_dir; #ifdef USING_PAXASTAR #define TAR_EXTRACT_FLAGS "-xhepf" #else -#define TAR_EXTRACT_FLAGS "-xpPf" +#define TAR_EXTRACT_FLAGS "-xpf" #endif /* Abs. path we extract binary sets from */ diff --git a/usr.sbin/sysinst/disklabel.c b/usr.sbin/sysinst/disklabel.c index bd3e312e971c..2b1450add9a3 100644 --- a/usr.sbin/sysinst/disklabel.c +++ b/usr.sbin/sysinst/disklabel.c @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.c,v 1.10.2.8 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: disklabel.c,v 1.10.2.9 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 2018 The NetBSD Foundation, Inc. @@ -237,8 +237,12 @@ disklabel_parts_read(const char *disk, daddr_t start, daddr_t len, size_t bps, daddr_t dlend = start + parts->l.d_partitions[RAW_PART-1].p_size; - if (dlstart < start && dlend > (start+len)) { - assert(false); + if (dlstart < start || dlend > (start+len)) { + /* + * Kernel assumes different outer partion + * (probably not yet written back to disk) + * so this label is invalid. + */ free(parts); close(fd); return NULL; diff --git a/usr.sbin/sysinst/disks.c b/usr.sbin/sysinst/disks.c index 25469a2feb8f..10ca45d6cc70 100644 --- a/usr.sbin/sysinst/disks.c +++ b/usr.sbin/sysinst/disks.c @@ -1,4 +1,4 @@ -/* $NetBSD: disks.c,v 1.44.2.13 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: disks.c,v 1.44.2.14 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1446,7 +1446,8 @@ find_part_by_name(const char *name, struct disk_partitions **parts, * List has not been filled, only "pm" is valid - check * that first. */ - if (pm->parts->pscheme->find_by_name != NULL) { + if (pm->parts != NULL && + pm->parts->pscheme->find_by_name != NULL) { id = pm->parts->pscheme->find_by_name(pm->parts, name); if (id != NO_PART) { *pno = id; @@ -1520,6 +1521,16 @@ process_found_fs(struct data *list, size_t num, const struct lookfor *item, if (strcmp(item->head, name_prefix) == 0) { /* this fstab entry uses NAME= syntax */ + + /* unescape */ + char *src, *dst; + for (src = list[0].u.s_val, dst =src; src[0] != 0; ) { + if (src[0] == '\\' && src[1] != 0) + src++; + *dst++ = *src++; + } + *dst = 0; + if (!find_part_by_name(list[0].u.s_val, &parts, &pno) || parts == NULL || pno == NO_PART) return 0; @@ -1830,10 +1841,15 @@ mount_disks(struct install_partition_desc *install) assert((size_t)(l - fstabbuf) == num_entries); /* First the root device. */ - if (target_already_root()) + if (target_already_root()) { /* avoid needing to call target_already_root() again */ targetroot_mnt[0] = 0; - else { + } else if (pm->no_part) { + snprintf(devdev, sizeof devdev, _PATH_DEV "%s", pm->diskdev); + error = mount_root(devdev, true, false, install); + if (error != 0 && error != EBUSY) + return -1; + } else { for (i = 0; i < install->num; i++) { if (is_root_part_mount(install->infos[i].mount)) break; @@ -2006,7 +2022,7 @@ bootxx_name(struct install_partition_desc *install) switch (fstype) { #if defined(BOOTXX_FFSV1) || defined(BOOTXX_FFSV2) case FS_BSDFFS: - if (install->infos[0].fs_version == 2) { + if (install->infos[i].fs_version == 2) { #ifdef BOOTXX_FFSV2 bootxxname = BOOTXX_FFSV2; #else diff --git a/usr.sbin/sysinst/mbr.c b/usr.sbin/sysinst/mbr.c index e55e3523cb6b..46767ecfac74 100644 --- a/usr.sbin/sysinst/mbr.c +++ b/usr.sbin/sysinst/mbr.c @@ -1,4 +1,4 @@ -/* $NetBSD: mbr.c,v 1.19.2.5 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: mbr.c,v 1.19.2.6 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -156,6 +156,8 @@ static size_t mbr_get_free_spaces(const struct disk_partitions *arg, struct disk_part_free_space *result, size_t max_num_result, daddr_t min_size, daddr_t align, daddr_t lower_bound, daddr_t ignore); +static size_t mbr_type_from_gen_desc(const struct part_type_desc *desc); + /* * Notes on the extended partition editor. * @@ -999,6 +1001,20 @@ mbr_read_from_disk(const char *disk, daddr_t start, daddr_t len, size_t bps, return NULL; } mbr_calc_free_space(parts); + if (parts->dp.num_part == 1 && + parts->dp.free_space < parts->ptn_alignment) { + struct disk_part_info info; + + /* + * Check if this is a GPT protective MBR + */ + if (parts->dp.pscheme->get_part_info(&parts->dp, 0, &info) + && info.nat_type != NULL + && mbr_type_from_gen_desc(info.nat_type) == 0xEE) { + parts->dp.pscheme->free(&parts->dp); + return NULL; + } + } return &parts->dp; } diff --git a/usr.sbin/sysinst/msg.mi.de b/usr.sbin/sysinst/msg.mi.de index 30babcd89d7f..e5c89b1d028a 100644 --- a/usr.sbin/sysinst/msg.mi.de +++ b/usr.sbin/sysinst/msg.mi.de @@ -1,4 +1,4 @@ -/* $NetBSD: msg.mi.de,v 1.13.2.6 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: msg.mi.de,v 1.13.2.7 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1260,7 +1260,7 @@ message swap_display {Auslagerungspartition} * $1 = swap partition name my_swap */ message Auto_add_swap_part -{Eine Auslagerungspartition (mit Namen $1) +{Eine Auslagerungspartition (mit Namen $1) scheint bereits auf der Festplatte $0 zu existieren. Möchten Sie diese benutzen?} diff --git a/usr.sbin/sysinst/msg.mi.en b/usr.sbin/sysinst/msg.mi.en index 25125a66ba2f..a2d29596f917 100644 --- a/usr.sbin/sysinst/msg.mi.en +++ b/usr.sbin/sysinst/msg.mi.en @@ -1,4 +1,4 @@ -/* $NetBSD: msg.mi.en,v 1.19.2.7 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: msg.mi.en,v 1.19.2.8 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1190,7 +1190,8 @@ message swap_display {swap} * $1 = swap partition name my_swap */ message Auto_add_swap_part -{A swap partition (named $1) seems to exist on $0. +{A swap partition (named $1) +seems to exist on $0. Do you want to use that?} message parttype_disklabel {BSD disklabel} diff --git a/usr.sbin/sysinst/msg.mi.es b/usr.sbin/sysinst/msg.mi.es index bd4af6c89c20..7768f4b14831 100644 --- a/usr.sbin/sysinst/msg.mi.es +++ b/usr.sbin/sysinst/msg.mi.es @@ -1,4 +1,4 @@ -/* $NetBSD: msg.mi.es,v 1.14.2.6 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: msg.mi.es,v 1.14.2.7 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1240,7 +1240,8 @@ message swap_display {swap} * $1 = swap partition name my_swap */ message Auto_add_swap_part -{A swap partition (named $1) seems to exist on $0. +{A swap partition (named $1) +seems to exist on $0. Do you want to use that?} message parttype_disklabel {BSD disklabel} diff --git a/usr.sbin/sysinst/msg.mi.fr b/usr.sbin/sysinst/msg.mi.fr index 8c81538946ca..5c7b5354726e 100644 --- a/usr.sbin/sysinst/msg.mi.fr +++ b/usr.sbin/sysinst/msg.mi.fr @@ -1,4 +1,4 @@ -/* $NetBSD: msg.mi.fr,v 1.17.2.7 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: msg.mi.fr,v 1.17.2.8 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1292,7 +1292,8 @@ message swap_display {swap} * $1 = swap partition name my_swap */ message Auto_add_swap_part -{A swap partition (named $1) seems to exist on $0. +{A swap partition (named $1) +seems to exist on $0. Do you want to use that?} message parttype_disklabel {BSD disklabel} diff --git a/usr.sbin/sysinst/msg.mi.pl b/usr.sbin/sysinst/msg.mi.pl index 496c67041beb..237bbc643cc9 100644 --- a/usr.sbin/sysinst/msg.mi.pl +++ b/usr.sbin/sysinst/msg.mi.pl @@ -1,4 +1,4 @@ -/* $NetBSD: msg.mi.pl,v 1.20.2.7 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: msg.mi.pl,v 1.20.2.8 2020/02/10 21:39:37 bouyer Exp $ */ /* Based on english version: */ /* NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp */ @@ -1191,7 +1191,8 @@ message swap_display {swap} * $1 = swap partition name my_swap */ message Auto_add_swap_part -{Partycja swap ($1) istnieje na $0. +{Partycja swap ($1) +istnieje na $0. Chcesz jej uzyc?} message parttype_disklabel {disklabel BSD} diff --git a/usr.sbin/sysinst/partman.c b/usr.sbin/sysinst/partman.c index 21fe49a77a3b..7ecd8230ef4c 100644 --- a/usr.sbin/sysinst/partman.c +++ b/usr.sbin/sysinst/partman.c @@ -1,4 +1,4 @@ -/* $NetBSD: partman.c,v 1.41.2.4 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: partman.c,v 1.41.2.5 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 2012 Eugene Lozovoy @@ -3249,7 +3249,7 @@ pm_edit_partitions(struct part_entry *pe) { struct pm_devs *my_pm = pm_from_pe(pe); struct partition_usage_set pset = { 0 }; - struct disk_partitions *parts; + struct disk_partitions *parts, *np; if (!my_pm) return; @@ -3264,12 +3264,16 @@ pm_edit_partitions(struct part_entry *pe) if (my_pm->parts->pscheme->secondary_scheme != NULL) { if (!edit_outer_parts(my_pm->parts)) goto done; - parts = get_inner_parts(parts); + np = get_inner_parts(parts); + if (np != NULL) + parts = np; } - usage_set_from_parts(&pset, parts); - edit_and_check_label(my_pm, &pset, false); - free_usage_set(&pset); + if (parts != NULL) { + usage_set_from_parts(&pset, parts); + edit_and_check_label(my_pm, &pset, false); + free_usage_set(&pset); + } done: pm_partusage(my_pm, -1, -1); diff --git a/usr.sbin/sysinst/target.c b/usr.sbin/sysinst/target.c index df938fa02639..40431e043e16 100644 --- a/usr.sbin/sysinst/target.c +++ b/usr.sbin/sysinst/target.c @@ -1,4 +1,4 @@ -/* $NetBSD: target.c,v 1.8.2.3 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: target.c,v 1.8.2.4 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Jonathan Stone @@ -71,7 +71,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: target.c,v 1.8.2.3 2020/01/28 10:17:58 msaitoh Exp $"); +__RCSID("$NetBSD: target.c,v 1.8.2.4 2020/02/10 21:39:37 bouyer Exp $"); #endif /* @@ -157,7 +157,7 @@ target_already_root(void) static struct pm_devs *last_pm; static int last_res; part_id ptn; - struct disk_partitions *parts; + struct disk_partitions *parts, *inner; struct disk_part_info info; if (pm == last_pm) @@ -180,9 +180,12 @@ target_already_root(void) return last_res; } - if (pm->parts->pscheme->secondary_partitions != NULL) - parts = pm->parts->pscheme->secondary_partitions(parts, + if (pm->parts->pscheme->secondary_partitions != NULL) { + inner = pm->parts->pscheme->secondary_partitions(parts, pm->ptstart, false); + if (inner != NULL) + parts = inner; + } for (ptn = 0; ptn < parts->num_part; ptn++) { if (!parts->pscheme->get_part_info(parts, ptn, &info)) diff --git a/usr.sbin/sysinst/txtwalk.c b/usr.sbin/sysinst/txtwalk.c index 3ff64e8026e8..7b2f75400fe0 100644 --- a/usr.sbin/sysinst/txtwalk.c +++ b/usr.sbin/sysinst/txtwalk.c @@ -1,4 +1,4 @@ -/* $NetBSD: txtwalk.c,v 1.1.30.1 2019/08/08 05:51:43 msaitoh Exp $ */ +/* $NetBSD: txtwalk.c,v 1.1.30.2 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -239,9 +239,14 @@ finddata(const struct lookfor *item, char *line, struct data *found, size_t *num break; case 's': /* Matches a 'space' separated string. */ len = 0; - while (line[len] && !isspace((unsigned char)line[len]) - && line[len] != fmt[1]) + while (line[len] + && !isspace((unsigned char)line[len]) + && line[len] != fmt[1]) { + if (line[len] == '\\' + && line[len+1] != 0) + len++; len++; + } found[*numfound].what = STR; found[(*numfound)++].u.s_val = line; line[len] = 0; diff --git a/usr.sbin/sysinst/upgrade.c b/usr.sbin/sysinst/upgrade.c index 20390c893335..84ad8dfd8cb4 100644 --- a/usr.sbin/sysinst/upgrade.c +++ b/usr.sbin/sysinst/upgrade.c @@ -1,4 +1,4 @@ -/* $NetBSD: upgrade.c,v 1.12.2.2 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: upgrade.c,v 1.12.2.3 2020/02/10 21:39:37 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -65,19 +65,19 @@ do_upgrade(void) if (find_disks(msg_string(MSG_upgrade), !root_is_read_only()) < 0) return; - if (pm->parts == NULL && !pm->cur_system) { + if (pm->parts == NULL && !pm->cur_system && !pm->no_part) { hit_enter_to_continue(MSG_noroot, NULL); return; } - if (!pm->cur_system) { + if (!pm->cur_system && pm->parts != NULL) { if (pm->parts->pscheme->pre_update_verify) { if (pm->parts->pscheme->pre_update_verify(pm->parts)) pm->parts->pscheme->write_to_disk(pm->parts); } install_desc_from_parts(&install, pm->parts); - } else { + } else if (pm->cur_system) { install.cur_system = true; } @@ -209,14 +209,9 @@ do_reinstall_sets() if (find_disks(msg_string(MSG_reinstall), !root_is_read_only()) < 0) return; - if (!pm->cur_system) { - if (pm->parts == NULL) { - hit_enter_to_continue(MSG_noroot, NULL); - return; - } - + if (!pm->cur_system && pm->parts != NULL) { install_desc_from_parts(&install, pm->parts); - } else { + } else if (pm->cur_system) { install.cur_system = true; }