diff options
| author | bouyer <bouyer@NetBSD.org> | 2020-10-15 19:36:50 +0000 |
|---|---|---|
| committer | bouyer <bouyer@NetBSD.org> | 2020-10-15 19:36:50 +0000 |
| commit | c0cfa96cd341ed6823087c59bc93352cab3a2077 (patch) | |
| tree | 5d2d4df2ff302115d80fcb52d0657a569ec4b152 /usr.sbin | |
| parent | 1fd8877c4aeb83f0ce4f12961b6c1c12473592d2 (diff) | |
Pull up following revision(s) (requested by martin in ticket #1113):
usr.sbin/sysinst/bsddisklabel.c: revision 1.46
usr.sbin/sysinst/bsddisklabel.c: revision 1.47
usr.sbin/sysinst/disklabel.c: revision 1.40
usr.sbin/sysinst/arch/cobalt/md.c: revision 1.13
usr.sbin/sysinst/bsddisklabel.c: revision 1.48
usr.sbin/sysinst/disklabel.c: revision 1.41
usr.sbin/sysinst/arch/cobalt/md.c: revision 1.14
usr.sbin/sysinst/bsddisklabel.c: revision 1.49
usr.sbin/sysinst/disklabel.c: revision 1.42
usr.sbin/sysinst/Makefile.inc: revision 1.34
usr.sbin/sysinst/disks.c: revision 1.70
usr.sbin/sysinst/arch/hp300/md.c: revision 1.11
usr.sbin/sysinst/disks.c: revision 1.71
usr.sbin/sysinst/arch/i386/md.h: revision 1.8
usr.sbin/sysinst/arch/arc/md.c: revision 1.13
usr.sbin/sysinst/mbr.h: revision 1.5
usr.sbin/sysinst/mbr.h: revision 1.6
usr.sbin/sysinst/arch/mac68k/md.c: revision 1.10
usr.sbin/sysinst/bsddisklabel.c: revision 1.50
usr.sbin/sysinst/arch/acorn32/md.c: revision 1.7
usr.sbin/sysinst/bsddisklabel.c: revision 1.51
usr.sbin/sysinst/bsddisklabel.c: revision 1.52
usr.sbin/sysinst/bsddisklabel.c: revision 1.53
usr.sbin/sysinst/bsddisklabel.c: revision 1.54
usr.sbin/sysinst/bsddisklabel.c: revision 1.55
usr.sbin/sysinst/bsddisklabel.c: revision 1.56
usr.sbin/sysinst/arch/dummy/md.c: revision 1.6
usr.sbin/sysinst/arch/amd64/md.h: revision 1.9
usr.sbin/sysinst/arch/evbsh3/md.c: revision 1.6
usr.sbin/sysinst/arch/sparc/md.c: revision 1.6
usr.sbin/sysinst/arch/zaurus/md.c: revision 1.10
usr.sbin/sysinst/arch/x68k/md.c: revision 1.11
usr.sbin/sysinst/arch/sandpoint/md.c: revision 1.9
usr.sbin/sysinst/arch/vax/md.c: revision 1.7
usr.sbin/sysinst/arch/luna68k/md.c: revision 1.9
usr.sbin/sysinst/gpt.c: revision 1.19
usr.sbin/sysinst/arch/i386/md.c: revision 1.31
usr.sbin/sysinst/arch/i386/md.c: revision 1.32
usr.sbin/sysinst/arch/evbarm/md.c: revision 1.17
usr.sbin/sysinst/arch/evbarm/md.c: revision 1.18
usr.sbin/sysinst/arch/evbarm/md.c: revision 1.19
usr.sbin/sysinst/arch/shark/md.c: revision 1.6
usr.sbin/sysinst/arch/landisk/md.c: revision 1.14
usr.sbin/sysinst/util.c: revision 1.43
usr.sbin/sysinst/gpt.c: revision 1.20
usr.sbin/sysinst/util.c: revision 1.44
usr.sbin/sysinst/gpt.c: revision 1.21
usr.sbin/sysinst/gpt.c: revision 1.22
usr.sbin/sysinst/arch/evbarm/msg.md.en: revision 1.2
usr.sbin/sysinst/arch/ofppc/md.c: revision 1.11
usr.sbin/sysinst/util.c: revision 1.46
usr.sbin/sysinst/arch/ofppc/md.c: revision 1.12
usr.sbin/sysinst/util.c: revision 1.47
usr.sbin/sysinst/arch/evbarm/md.h: revision 1.6
usr.sbin/sysinst/util.c: revision 1.48
usr.sbin/sysinst/arch/evbarm/md.h: revision 1.7
usr.sbin/sysinst/arch/evbmips/md.c: revision 1.9
usr.sbin/sysinst/msg.mi.fr: revision 1.28
usr.sbin/sysinst/msg.mi.fr: revision 1.29
usr.sbin/sysinst/arch/sgimips/md.c: revision 1.9
usr.sbin/sysinst/arch/evbarm/Makefile: revision 1.3
usr.sbin/sysinst/msg.mi.de: revision 1.23
usr.sbin/sysinst/arch/hpcsh/md.c: revision 1.10
usr.sbin/sysinst/msg.mi.de: revision 1.24
usr.sbin/sysinst/install.c: revision 1.15
usr.sbin/sysinst/install.c: revision 1.16
usr.sbin/sysinst/arch/sparc64/md.c: revision 1.6
usr.sbin/sysinst/install.c: revision 1.17
usr.sbin/sysinst/install.c: revision 1.18
usr.sbin/sysinst/partitions.h: revision 1.16
usr.sbin/sysinst/install.c: revision 1.19
usr.sbin/sysinst/partitions.h: revision 1.17
usr.sbin/sysinst/arch/evbppc/md.c: revision 1.9
usr.sbin/sysinst/arch/playstation2/md.c: revision 1.9
usr.sbin/sysinst/partitions.h: revision 1.18
usr.sbin/sysinst/arch/hpcarm/md.c: revision 1.9
usr.sbin/sysinst/partitions.h: revision 1.19
usr.sbin/sysinst/msg.mi.es: revision 1.24
usr.sbin/sysinst/msg.mi.es: revision 1.25
usr.sbin/sysinst/msg.mi.es: revision 1.26
usr.sbin/sysinst/arch/zaurus/md.c: revision 1.9
usr.sbin/sysinst/target.c: revision 1.13
usr.sbin/sysinst/target.c: revision 1.14
usr.sbin/sysinst/part_edit.c: revision 1.17
usr.sbin/sysinst/part_edit.c: revision 1.18
usr.sbin/sysinst/msg.mi.fr: revision 1.30
usr.sbin/sysinst/arch/mvme68k/md.c: revision 1.11
usr.sbin/sysinst/part_edit.c: revision 1.19
usr.sbin/sysinst/msg.mi.fr: revision 1.31
usr.sbin/sysinst/arch/alpha/md.c: revision 1.9
usr.sbin/sysinst/msg.mi.en: revision 1.30
usr.sbin/sysinst/defs.h: revision 1.56
usr.sbin/sysinst/msg.mi.en: revision 1.31
usr.sbin/sysinst/defs.h: revision 1.57
usr.sbin/sysinst/msg.mi.en: revision 1.32
usr.sbin/sysinst/arch/amiga/md.c: revision 1.6
usr.sbin/sysinst/arch/hpcmips/md.c: revision 1.9
usr.sbin/sysinst/defs.h: revision 1.58
usr.sbin/sysinst/arch/cats/md.c: revision 1.5
usr.sbin/sysinst/defs.h: revision 1.59
usr.sbin/sysinst/arch/newsmips/md.c: revision 1.6
usr.sbin/sysinst/arch/pmax/md.c: revision 1.8
usr.sbin/sysinst/arch/mipsco/md.c: revision 1.8
usr.sbin/sysinst/part_edit.c: revision 1.20
usr.sbin/sysinst/part_edit.c: revision 1.21
usr.sbin/sysinst/arch/macppc/md.c: revision 1.6
usr.sbin/sysinst/part_edit.c: revision 1.22
usr.sbin/sysinst/part_edit.c: revision 1.23
usr.sbin/sysinst/part_edit.c: revision 1.24
usr.sbin/sysinst/defs.h: revision 1.60
usr.sbin/sysinst/arch/mac68k/Makefile: revision 1.3
usr.sbin/sysinst/defs.h: revision 1.61
usr.sbin/sysinst/defs.h: revision 1.63
usr.sbin/sysinst/defs.h: revision 1.64
usr.sbin/sysinst/defs.h: revision 1.65
usr.sbin/sysinst/label.c: revision 1.21
usr.sbin/sysinst/defs.h: revision 1.66
usr.sbin/sysinst/label.c: revision 1.22
usr.sbin/sysinst/defs.h: revision 1.67
usr.sbin/sysinst/label.c: revision 1.23
usr.sbin/sysinst/label.c: revision 1.24
usr.sbin/sysinst/label.c: revision 1.25
usr.sbin/sysinst/label.c: revision 1.26
usr.sbin/sysinst/label.c: revision 1.27
usr.sbin/sysinst/msg.mi.pl: revision 1.31
usr.sbin/sysinst/label.c: revision 1.28
usr.sbin/sysinst/msg.mi.pl: revision 1.32
usr.sbin/sysinst/label.c: revision 1.29
usr.sbin/sysinst/arch/atari/md.c: revision 1.7
usr.sbin/sysinst/disklabel.c: revision 1.36
usr.sbin/sysinst/disklabel.c: revision 1.37
usr.sbin/sysinst/disklabel.c: revision 1.38
usr.sbin/sysinst/disklabel.c: revision 1.39
usr.sbin/sysinst/arch/bebox/md.c: revision 1.9
usr.sbin/sysinst/mbr.c: revision 1.32
usr.sbin/sysinst/disks.c: revision 1.66
usr.sbin/sysinst/mbr.c: revision 1.33
usr.sbin/sysinst/disks.c: revision 1.67
usr.sbin/sysinst/mbr.c: revision 1.34
usr.sbin/sysinst/arch/emips/md.c: revision 1.9
usr.sbin/sysinst/disks.c: revision 1.68
usr.sbin/sysinst/partitions.c: revision 1.11
usr.sbin/sysinst/mbr.c: revision 1.35
usr.sbin/sysinst/disks.c: revision 1.69
usr.sbin/sysinst/mbr.c: revision 1.36
usr.sbin/sysinst/arch/hppa/md.c: revision 1.8
usr.sbin/sysinst/arch/prep/md.c: revision 1.13
usr.sbin/sysinst/label.c: revision 1.30
usr.sbin/sysinst/arch/ews4800mips/md.c: revision 1.7
usr.sbin/sysinst/main.c: revision 1.21
usr.sbin/sysinst/main.c: revision 1.22
usr.sbin/sysinst/main.c: revision 1.23
usr.sbin/sysinst/bsddisklabel.c: revision 1.40
usr.sbin/sysinst/main.c: revision 1.24
usr.sbin/sysinst/arch/cobalt/md.h: revision 1.6
usr.sbin/sysinst/bsddisklabel.c: revision 1.41
usr.sbin/sysinst/main.c: revision 1.25
usr.sbin/sysinst/arch/news68k/md.c: revision 1.7
usr.sbin/sysinst/bsddisklabel.c: revision 1.42
usr.sbin/sysinst/bsddisklabel.c: revision 1.43
usr.sbin/sysinst/bsddisklabel.c: revision 1.44
usr.sbin/sysinst/bsddisklabel.c: revision 1.45
Use strlcpy in a few places to guarnatee 0-terminated strings
Rever previous: the d_packname in struct disklabel is not NUL terminated.
Disable the warning instead.
Do not force -Os optimization (unless SMALLPROG)
Remove unused "rel" global variable and make the -r option a no-op.
PR 55045: strlcpy(NULL, ..., 0) considered harmfull in some implementations.
PR misc/54886: bump threshold for automatic/default creation of a tmpfs /tmp
up slightly (to 384 MB ram). This will make sure the default install has
a > 64 MB /tmp available (number pulled out of thin air, 64 MB is the minimum
required by the ZFS tests).
Don't depend on common symbol definitions.
boardype should not be common.
Redo the root-size-limit check again after we grew the root partition
for kernel dumps. Auto-enable the /usr partition if it overflows.
For all non-root partitions, default to FFSv2.
When extending a partition (to fill the total disk size) do respect
size limits.
Do not suggest a size limited partition for extension by default.
Minor tweak to previous: when forcing a /usr partition just to have an
arbitrary extendable partition, still use its default size initially.
At the end of a new installation save entropy.
Ooops, backout previous - twice the entropy saving is not needed.
Instead slightly improve the (slightly) hidden other code that already
did it.
PR 55202: disable swapping if we started it due to low ram
it's "its"
Remove "If you booted from a floppy" message
Set HAVE_INSTALL_IMAGE for evbarm
Change mountpoint of boot ext2fs from /stand to /ext2 to avoid conflict.
Should be pulled up to netbsd-9, with fixes of PR/55060.
MBR type for Ext2 should be MBR_PTYPE_LNXEXT2, not MBR_PTYPE_FAT12.
Silence -Wstringop-truncation for ``name'' in disp_selected_part().
This variable is used only for display, and truncation seems harmless.
PR 55572: avoid crash when answering the mount point prompt for a previously
empty mount point with an emptry sting.
When adding a new partition in the concrete partition editor, make sure
to set a pointer to the partition table interface in the new entry.
Otherwise we may end up not writing back the partitions at all, leading
to further fallout later.
Receipe to reproduce the issue from Frederic Fauberteau, thanks!
In the concrete partitions editor, after deleting the last partition move
the menu selection to the "add a partition" entry (instead of the sentinel
line which is not an active menu entry).
Typo in comment
Keep a list of all partition tables from which we have deleted partitions
and make sure we update those partition tables when writing partitions,
even if no install related partition remains on them.
Fix display of timezone selection menu
If there is no current partitioning manager assume we are editing the
current system and make target_already_root() return true.
Fixes various fallout when using sysinst post installation.
PR 55377: mark boot partitions in the partition size display, as suggested
by Izumi Tsutsui (minor modifications + all bugs by me)
PR 55378: do not assume RAW_PART to be either 2 or 3
PR 55379: avoid creating bogus /etc/fstab lines for /dev/cd* if no
cdrom is available.
PR 55381: try to deal with moved (but not yet saved) partitions when
calculating free space
Apply patch provided by Izumi Tsutsui in PR 55382: make ext2 partitions
show up in the outer (MBR) partition table, needed for example on Cobalt
where firmware boots from that partition.
PR 55384: detangle pm->ptstart from the "install" flag (selecting a
target partition). Instead introduce a new PTI_INSTALL_TARGET per partition
flag and deal with it in the partitioning backends.
Honour pm->ptstart when allocating new partitions - it is supposed to be
the first sector usable by NetBSD.
If we have no explicitly marke target root partition, make sure to set
the proper flag on the implicit one.
When merging existing partitions with desired target system layout
information, only force the "mount" flag if the existing partitions
has a valid mount point.
Add a heuristic to detect and properly mark EFI system partitions
when re-using pre-existing partitions.
When MD code requests a reserved area (at the start of the disk)
make sure to properly account for the "lost" space during all calculations
and especially when expanding the main partition to fill the disk.
Avoid using the global "pm" or a passed device descriptons when we are
passing disk limits explicitly anyway.
Simplify/fix a few rounding calculations.
When creating new partitions for "full disk" use, pass a install target
hint to the partitioning backend (for the outer NetBSD partition).
Use an install target hint to mark a new partition active.
When compiled with BOOTSEL support, also name the new partition "NetBSD".
Remove more pm->ptstart abuse - calculate values localy where needed
instead.
Fix editing start and size of not yet existing outer partitions.
Previously we abused pm->ptstart / pm->ptsize to pass the bounds of the
NetBSD outer partition to the inner partition editor - but now this is
not a valid assumption any more, so explicitly fix the bounds if an
outer partition exists.
Remove very strange code that special-cased MSDOS file systems and refused
to newfs the partition (despite explicit request to do so) if it was
mountable.
Accidently carried over from a dim and distant past, before we had
fsck_newfs.
PR 55536: when we find existing partition tables and have alternative
formats available, offer to delete partitions and create new ones from
scratch (in some other or the same on-disk format).
Minor fix to previous: fix condition when we offer the partition type
switch - it makes sense even if the disk is partitioned but has no valid
partitions.
Before forcing MBR partitions into our disklabel, make sure they are not
there yet - could happen in various paths when reusing existing partitions
(or parts of that) - previously we would blindly duplicate identical
partitions.
Ooops, part of previous was not meant to be included yet
When renumbering partitions (after deletions) be slightly more lax
in matching, to cope with differences between MBR EFI partitions and
disklabel MSDOS partitions.
PR 55142: on popular demand bring back expert options to adjust the
number of free inodes, block size and fragment size for FFS and LFS.
Fix copy & pasto noticed by Jason Mitchell: change the type of a GPT
partition via "gpt type" - not "gpt label".
Fix copy & pasto (missing "again" label)
Remove dead code
Move MBR writing (if any) post disklabel writing, otherwise strange
interactions happen.
Properly convert partition default sizes in MB to number of sectors
Diffstat (limited to 'usr.sbin')
69 files changed, 1514 insertions, 552 deletions
diff --git a/usr.sbin/sysinst/Makefile.inc b/usr.sbin/sysinst/Makefile.inc index 2c10826b3c7..eeaae1af36a 100644 --- a/usr.sbin/sysinst/Makefile.inc +++ b/usr.sbin/sysinst/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.22.2.2 2019/12/17 09:48:30 msaitoh Exp $ +# $NetBSD: Makefile.inc,v 1.22.2.3 2020/10/15 19:36:50 bouyer Exp $ # # Makefile for sysinst @@ -119,11 +119,11 @@ O0TRACKING= -fvar-tracking-assignments -fvar-tracking .endif CPPFLAGS+=-DDEBUG DBG +=-g -O0 ${O0TRACKING} -.endif - -.if empty(DBG:M-g) +.else +.if defined(SMALLPROG) COPTS += -Os .endif +.endif .if (!defined(SMALLPROG) || defined(SMALLPROG_INET6)) && (${USE_INET6} != "no") CPPFLAGS+=-DINET6 diff --git a/usr.sbin/sysinst/arch/acorn32/md.c b/usr.sbin/sysinst/arch/acorn32/md.c index 9529d5eb0b5..79a87bd2c2d 100644 --- a/usr.sbin/sysinst/arch/acorn32/md.c +++ b/usr.sbin/sysinst/arch/acorn32/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:36 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -202,7 +202,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/alpha/md.c b/usr.sbin/sysinst/arch/alpha/md.c index 23cad870b59..f780375292e 100644 --- a/usr.sbin/sysinst/arch/alpha/md.c +++ b/usr.sbin/sysinst/arch/alpha/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.6.2.2 2020/03/09 18:50:19 snj Exp $ */ +/* $NetBSD: md.c,v 1.6.2.3 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -104,7 +104,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/amd64/md.h b/usr.sbin/sysinst/arch/amd64/md.h index 15941e08dcf..dd37a13b3dc 100644 --- a/usr.sbin/sysinst/arch/amd64/md.h +++ b/usr.sbin/sysinst/arch/amd64/md.h @@ -1,4 +1,4 @@ -/* $NetBSD: md.h,v 1.6.2.2 2019/11/17 13:45:26 msaitoh Exp $ */ +/* $NetBSD: md.h,v 1.6.2.3 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -128,3 +128,6 @@ bool x86_md_need_bootblock(struct install_partition_desc *install); /* post-process boot.cfg for KASLR if that kernel has been selected */ void amd64_md_boot_cfg_finalize(const char*); #define MD_BOOT_CFG_FINALIZE(P) amd64_md_boot_cfg_finalize(P) + +#define HAVE_EFI_BOOT 1 /* we support EFI boot partitions */ + diff --git a/usr.sbin/sysinst/arch/amiga/md.c b/usr.sbin/sysinst/arch/amiga/md.c index 0d2a80e9f37..0b9f79361cc 100644 --- a/usr.sbin/sysinst/arch/amiga/md.c +++ b/usr.sbin/sysinst/arch/amiga/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:36 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -65,7 +65,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return 1; diff --git a/usr.sbin/sysinst/arch/arc/md.c b/usr.sbin/sysinst/arch/arc/md.c index fe831be9c53..d90e9731ceb 100644 --- a/usr.sbin/sysinst/arch/arc/md.c +++ b/usr.sbin/sysinst/arch/arc/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8.2.3 2020/01/28 10:17:57 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.8.2.4 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -65,10 +65,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -88,13 +90,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { diff --git a/usr.sbin/sysinst/arch/atari/md.c b/usr.sbin/sysinst/arch/atari/md.c index 57123b1b6ed..4272d341eb0 100644 --- a/usr.sbin/sysinst/arch/atari/md.c +++ b/usr.sbin/sysinst/arch/atari/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.6 2019/07/13 17:13:36 martin Exp $ */ +/* $NetBSD: md.c,v 1.6.2.1 2020/10/15 19:36:55 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -65,7 +65,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { msg_fmt_display(MSG_infoahdilabel, "%s", pm->diskdev); diff --git a/usr.sbin/sysinst/arch/bebox/md.c b/usr.sbin/sysinst/arch/bebox/md.c index 50cbefd2d98..4fb04397870 100644 --- a/usr.sbin/sysinst/arch/bebox/md.c +++ b/usr.sbin/sysinst/arch/bebox/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5.2.2 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.5.2.3 2020/10/15 19:36:55 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -58,10 +58,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -81,13 +83,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/cats/md.c b/usr.sbin/sysinst/arch/cats/md.c index daf08f8cbb2..7736d0a8205 100644 --- a/usr.sbin/sysinst/arch/cats/md.c +++ b/usr.sbin/sysinst/arch/cats/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.4 2019/07/13 17:13:36 martin Exp $ */ +/* $NetBSD: md.c,v 1.4.2.1 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -123,7 +123,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/cobalt/md.c b/usr.sbin/sysinst/arch/cobalt/md.c index 95c8c9f790b..4fecbd966fa 100644 --- a/usr.sbin/sysinst/arch/cobalt/md.c +++ b/usr.sbin/sysinst/arch/cobalt/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8.2.3 2020/01/28 10:17:57 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.8.2.4 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -65,10 +65,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -88,13 +90,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); @@ -281,7 +291,7 @@ md_parts_use_wholedisk(struct disk_partitions *parts) struct disk_part_info boot_part = { .size = PART_BOOT / 512, .fs_type = PART_BOOT_TYPE, - .fs_sub_type = MBR_PTYPE_FAT12, + .fs_sub_type = MBR_PTYPE_LNXEXT2, .last_mounted = PART_BOOT_MOUNT, }; diff --git a/usr.sbin/sysinst/arch/cobalt/md.h b/usr.sbin/sysinst/arch/cobalt/md.h index 6cf757fc4aa..980c3a25b00 100644 --- a/usr.sbin/sysinst/arch/cobalt/md.h +++ b/usr.sbin/sysinst/arch/cobalt/md.h @@ -1,4 +1,4 @@ -/* $NetBSD: md.h,v 1.3.2.2 2019/12/17 09:44:51 msaitoh Exp $ */ +/* $NetBSD: md.h,v 1.3.2.3 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -49,7 +49,7 @@ #define PART_BOOT_MIN (1 * 1024 * 1024) /* 1MB minimum */ #define PART_BOOT_TYPE FS_EX2FS #define PART_BOOT_SUBT 1 /* use "old" ext2 */ -#define PART_BOOT_MOUNT "/stand" +#define PART_BOOT_MOUNT "/ext2" /* default partition size */ #define DEFSWAPRAM 32 /* Assume at least this RAM for swap calc */ diff --git a/usr.sbin/sysinst/arch/dummy/md.c b/usr.sbin/sysinst/arch/dummy/md.c index 33fd4ca620c..3c98bf83704 100644 --- a/usr.sbin/sysinst/arch/dummy/md.c +++ b/usr.sbin/sysinst/arch/dummy/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:37 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -55,7 +55,7 @@ md_get_info(struct install_partition_desc *desc) return true; } -bool +int md_make_bsd_partitions(struct install_partition_desc *desc) { return make_bsd_partitions(desc); diff --git a/usr.sbin/sysinst/arch/emips/md.c b/usr.sbin/sysinst/arch/emips/md.c index 9a9e0813ea8..98edb93d464 100644 --- a/usr.sbin/sysinst/arch/emips/md.c +++ b/usr.sbin/sysinst/arch/emips/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.7.2.1 2019/12/17 09:44:51 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.7.2.2 2020/10/15 19:36:55 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -109,7 +109,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/evbarm/Makefile b/usr.sbin/sysinst/arch/evbarm/Makefile index 00d8eb09048..1e0bda4f2d3 100644 --- a/usr.sbin/sysinst/arch/evbarm/Makefile +++ b/usr.sbin/sysinst/arch/evbarm/Makefile @@ -1,11 +1,11 @@ -# $NetBSD: Makefile,v 1.2 2019/06/12 06:20:19 martin Exp $ +# $NetBSD: Makefile,v 1.2.2.1 2020/10/15 19:36:52 bouyer Exp $ # # Makefile for evbarm # MENUS_MD= menus.md.${SYSINSTLANG} MSG_MD= msg.md.${SYSINSTLANG} msg.mbr.${SYSINSTLANG} -MD_OPTIONS= AOUT2ELF +MD_OPTIONS= AOUT2ELF HAVE_INSTALL_IMAGE NO_MBR=no .include "../../Makefile.inc" diff --git a/usr.sbin/sysinst/arch/evbarm/md.c b/usr.sbin/sysinst/arch/evbarm/md.c index 29ff7077834..6ce8ba61688 100644 --- a/usr.sbin/sysinst/arch/evbarm/md.c +++ b/usr.sbin/sysinst/arch/evbarm/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8.2.4 2020/01/29 23:31:30 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.8.2.5 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -93,10 +93,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -116,13 +118,29 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return edit_outer_parts(pm->parts); + /* + * If the selected scheme does not need two-stage partitioning + * (like GPT), do not bother to edit the outer partitions. + */ + if (pm->parts->pscheme->secondary_partitions == NULL || + pm->parts->pscheme->secondary_scheme == NULL) + return true; + + res = edit_outer_parts(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); @@ -154,6 +172,21 @@ md_pre_disklabel(struct install_partition_desc *install, struct disk_partitions *parts) { + /* + * RAW_PART is 2 on evbarm and bad things happen if we + * write the MBR first and then the disklabel - so postpone + * the MBR to md_post_disklabel(), unlike other architecturs. + */ + return true; +} + +/* + * hook called after writing disklabel to new target disk. + */ +bool +md_post_disklabel(struct install_partition_desc *install, + struct disk_partitions *parts) +{ if (parts->parent == NULL) return true; /* no outer partitions */ @@ -173,16 +206,6 @@ md_pre_disklabel(struct install_partition_desc *install, } /* - * hook called after writing disklabel to new target disk. - */ -bool -md_post_disklabel(struct install_partition_desc *install, - struct disk_partitions *parts) -{ - return true; -} - -/* * hook called after upgrade() or install() has finished setting * up the target disk but immediately before the user is given the * ``disks are now set up'' message. @@ -314,7 +337,8 @@ md_parts_use_wholedisk(struct disk_partitions *parts) { struct disk_part_info boot_part = { .size = boardtype == BOARD_TYPE_NORMAL ? - PART_BOOT_LARGE/512 : PART_BOOT/512, + PART_BOOT_LARGE/parts->bytes_per_sector : + PART_BOOT/parts->bytes_per_sector, .fs_type = PART_BOOT_TYPE, .fs_sub_type = MBR_PTYPE_FAT16L, }; @@ -354,7 +378,8 @@ evbarm_part_defaults(struct pm_devs *my_pm, struct part_usage_info *infos, if (infos[i].fs_type == PART_BOOT_TYPE && infos[i].mount[0] != 0 && strcmp(infos[i].mount, PART_BOOT_MOUNT) == 0) { - infos[i].size = PART_BOOT_LARGE; + infos[i].size = PART_BOOT_LARGE / + my_pm->parts->bytes_per_sector; return; } } diff --git a/usr.sbin/sysinst/arch/evbarm/md.h b/usr.sbin/sysinst/arch/evbarm/md.h index 55220ed7146..b23a8d8f440 100644 --- a/usr.sbin/sysinst/arch/evbarm/md.h +++ b/usr.sbin/sysinst/arch/evbarm/md.h @@ -1,4 +1,4 @@ -/* $NetBSD: md.h,v 1.2.2.2 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: md.h,v 1.2.2.3 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -96,7 +96,7 @@ #define BOARD_TYPE_NORMAL 0 /* assume u-boot */ #define BOARD_TYPE_RPI 1 /* RPi firmware booted us */ #define BOARD_TYPE_ACPI 2 /* generic SBSA machine */ -int boardtype; +extern int boardtype; /* * Size limit for the initial GPT part, in bytes. This allows us to @@ -118,3 +118,5 @@ void evbarm_part_defaults(struct pm_devs*, struct part_usage_info*, #define MD_PART_DEFAULTS(A,B,C) evbarm_part_defaults(A,B,C) +#define HAVE_EFI_BOOT 1 /* we support EFI boot partitions */ + diff --git a/usr.sbin/sysinst/arch/evbarm/msg.md.en b/usr.sbin/sysinst/arch/evbarm/msg.md.en index ee2815790ef..932dd3edc9f 100644 --- a/usr.sbin/sysinst/arch/evbarm/msg.md.en +++ b/usr.sbin/sysinst/arch/evbarm/msg.md.en @@ -1,4 +1,4 @@ -/* $NetBSD: msg.md.en,v 1.1 2014/07/26 19:30:45 dholland Exp $ */ +/* $NetBSD: msg.md.en,v 1.1.30.1 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -41,7 +41,7 @@ message md_hello } message md_may_remove_boot_medium -{If you booted from a floppy, you may now remove the disk. +{ } message badreadbb diff --git a/usr.sbin/sysinst/arch/evbmips/md.c b/usr.sbin/sysinst/arch/evbmips/md.c index 159cb913379..6b0a9134f4d 100644 --- a/usr.sbin/sysinst/arch/evbmips/md.c +++ b/usr.sbin/sysinst/arch/evbmips/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5.2.2 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.5.2.3 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997,2002 Piermont Information Systems Inc. @@ -58,10 +58,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -81,13 +83,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/evbppc/md.c b/usr.sbin/sysinst/arch/evbppc/md.c index 01bee1e9d2b..6c374ca8c77 100644 --- a/usr.sbin/sysinst/arch/evbppc/md.c +++ b/usr.sbin/sysinst/arch/evbppc/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5.2.2 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.5.2.3 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997,2002 Piermont Information Systems Inc. @@ -58,10 +58,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -81,13 +83,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/evbsh3/md.c b/usr.sbin/sysinst/arch/evbsh3/md.c index 17efd1c5c31..6657721419a 100644 --- a/usr.sbin/sysinst/arch/evbsh3/md.c +++ b/usr.sbin/sysinst/arch/evbsh3/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:37 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -124,7 +124,7 @@ md_post_newfs(struct install_partition_desc *install) return 0; } -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { diff --git a/usr.sbin/sysinst/arch/ews4800mips/md.c b/usr.sbin/sysinst/arch/ews4800mips/md.c index e2beae501de..20078a4b6bf 100644 --- a/usr.sbin/sysinst/arch/ews4800mips/md.c +++ b/usr.sbin/sysinst/arch/ews4800mips/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.4.2.1 2019/12/17 09:44:51 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.4.2.2 2020/10/15 19:36:55 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -106,7 +106,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { diff --git a/usr.sbin/sysinst/arch/hp300/md.c b/usr.sbin/sysinst/arch/hp300/md.c index 79720b62a5a..5369438e554 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.2 2020/02/10 21:39:38 bouyer Exp $ */ +/* $NetBSD: md.c,v 1.8.2.3 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -116,7 +116,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { diff --git a/usr.sbin/sysinst/arch/hpcarm/md.c b/usr.sbin/sysinst/arch/hpcarm/md.c index 5afcaa4b8b4..f3ad84a3f54 100644 --- a/usr.sbin/sysinst/arch/hpcarm/md.c +++ b/usr.sbin/sysinst/arch/hpcarm/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5.2.2 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.5.2.3 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -87,10 +87,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -110,13 +112,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/hpcmips/md.c b/usr.sbin/sysinst/arch/hpcmips/md.c index f05c785b55f..f91085b7d18 100644 --- a/usr.sbin/sysinst/arch/hpcmips/md.c +++ b/usr.sbin/sysinst/arch/hpcmips/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5.2.2 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.5.2.3 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -61,10 +61,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -84,13 +86,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/hpcsh/md.c b/usr.sbin/sysinst/arch/hpcsh/md.c index ffd8e74fa22..e5519058e28 100644 --- a/usr.sbin/sysinst/arch/hpcsh/md.c +++ b/usr.sbin/sysinst/arch/hpcsh/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.6.2.2 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.6.2.3 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -62,10 +62,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -85,13 +87,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { diff --git a/usr.sbin/sysinst/arch/hppa/md.c b/usr.sbin/sysinst/arch/hppa/md.c index cf98186802a..069868810bf 100644 --- a/usr.sbin/sysinst/arch/hppa/md.c +++ b/usr.sbin/sysinst/arch/hppa/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.7 2019/07/13 17:13:38 martin Exp $ */ +/* $NetBSD: md.c,v 1.7.2.1 2020/10/15 19:36:55 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -117,7 +117,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/i386/md.c b/usr.sbin/sysinst/arch/i386/md.c index 793b924509a..fc92ce40025 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.6 2020/02/10 21:39:38 bouyer Exp $ */ +/* $NetBSD: md.c,v 1.20.2.7 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -65,7 +65,7 @@ static bool uefi_boot; /* prototypes */ static bool get_bios_info(const char*, struct disk_partitions*, int*, int*, int*); -static int mbr_root_above_chs(void); +static int mbr_root_above_chs(daddr_t); static int md_read_bootcode(const char *, struct mbr_sector *); static unsigned int get_bootmodel(void); @@ -107,11 +107,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { - int bcyl = 0, bhead = 0, bsec = 0; + int bcyl = 0, bhead = 0, bsec = 0, res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -149,13 +150,21 @@ md_get_info(struct install_partition_desc *install) if (pm->no_mbr || pm->no_part) return true; - return edit_outer_parts(pm->parts); + res = edit_outer_parts(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); @@ -462,6 +471,7 @@ md_check_mbr(struct disk_partitions *parts, mbr_info_t *mbri, bool quiet) mbr_info_t *ext; struct mbr_partition *p; const char *bootcode; + daddr_t inst_start, inst_size; int i, names, fl, ofl; #define ACTIVE_FOUND 0x0100 #define NETBSD_ACTIVE 0x0200 @@ -469,8 +479,15 @@ md_check_mbr(struct disk_partitions *parts, mbr_info_t *mbri, bool quiet) #define ACTIVE_NAMED 0x0800 root_limit = 0; + if (parts->pscheme->guess_install_target == NULL || + !parts->pscheme->guess_install_target(parts, &inst_start, + &inst_size)) { + inst_start = parts->disk_start; + inst_size = parts->disk_size; + } + if (biosdisk != NULL && (biosdisk->bi_flags & BIFLAG_EXTINT13) == 0) { - if (mbr_root_above_chs()) { + if (mbr_root_above_chs(inst_start)) { if (quiet) return 0; msg_display(MSG_partabovechs); @@ -487,7 +504,7 @@ md_check_mbr(struct disk_partitions *parts, mbr_info_t *mbri, bool quiet) } /* - * Ensure the install partition (at sector pm->ptstart) and the active + * Ensure the install partition (at sector inst_start) and the active * partition are bootable. * Determine whether the bootselect code is needed. * Note that MBR_BS_NEWMBR is always set, so we ignore it! @@ -499,14 +516,14 @@ md_check_mbr(struct disk_partitions *parts, mbr_info_t *mbri, bool quiet) for (i = 0; i < MBR_PART_COUNT; p++, i++) { if (p->mbrp_flag == MBR_PFLAG_ACTIVE) { fl |= ACTIVE_FOUND; - if (ext->sector + p->mbrp_start == pm->ptstart) + if (ext->sector + p->mbrp_start == inst_start) fl |= NETBSD_ACTIVE; } if (ext->mbrb.mbrbs_nametab[i][0] == 0) { /* No bootmenu label... */ if (ext->sector == 0) continue; - if (ext->sector + p->mbrp_start == pm->ptstart) + if (ext->sector + p->mbrp_start == inst_start) /* * Have installed into an extended ptn * force name & bootsel... @@ -517,7 +534,7 @@ md_check_mbr(struct disk_partitions *parts, mbr_info_t *mbri, bool quiet) /* Partition has a bootmenu label... */ if (ext->sector != 0) fl |= MBR_BS_EXTLBA; - if (ext->sector + p->mbrp_start == pm->ptstart) + if (ext->sector + p->mbrp_start == inst_start) fl |= NETBSD_NAMED; else if (p->mbrp_flag == MBR_PFLAG_ACTIVE) fl |= ACTIVE_NAMED; @@ -571,7 +588,7 @@ md_check_mbr(struct disk_partitions *parts, mbr_info_t *mbri, bool quiet) /* Check there is some bootcode at all... */ if (mbri->mbr.mbr_magic != htole16(MBR_MAGIC) || mbri->mbr.mbr_jmpboot[0] == 0 || - mbr_root_above_chs()) + mbr_root_above_chs(inst_start)) /* Existing won't do, force update */ fl |= MBR_BS_NEWMBR; } @@ -709,9 +726,9 @@ nogeom: } static int -mbr_root_above_chs(void) +mbr_root_above_chs(daddr_t ptstart) { - return pm->ptstart + (daddr_t)DEFROOTSIZE * (daddr_t)(MEG / 512) + return ptstart + (daddr_t)DEFROOTSIZE * (daddr_t)(MEG / 512) >= pm->max_chs; } diff --git a/usr.sbin/sysinst/arch/i386/md.h b/usr.sbin/sysinst/arch/i386/md.h index 20972c6c96c..f36efd93f3f 100644 --- a/usr.sbin/sysinst/arch/i386/md.h +++ b/usr.sbin/sysinst/arch/i386/md.h @@ -1,4 +1,4 @@ -/* $NetBSD: md.h,v 1.6.2.1 2019/11/17 07:04:34 martin Exp $ */ +/* $NetBSD: md.h,v 1.6.2.2 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -123,3 +123,5 @@ void x86_md_part_defaults(struct pm_devs*, struct part_usage_info**, /* no need to install bootblock if installing for UEFI */ bool x86_md_need_bootblock(struct install_partition_desc *install); #define MD_NEED_BOOTBLOCK(A) x86_md_need_bootblock(A) + +#define HAVE_EFI_BOOT 1 /* we support EFI boot partitions */ diff --git a/usr.sbin/sysinst/arch/landisk/md.c b/usr.sbin/sysinst/arch/landisk/md.c index 5d789320789..3b639c627be 100644 --- a/usr.sbin/sysinst/arch/landisk/md.c +++ b/usr.sbin/sysinst/arch/landisk/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.10.2.2 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.10.2.3 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997,2002 Piermont Information Systems Inc. @@ -58,10 +58,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -81,13 +83,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/luna68k/md.c b/usr.sbin/sysinst/arch/luna68k/md.c index 5fde49d5bad..fa65f93381b 100644 --- a/usr.sbin/sysinst/arch/luna68k/md.c +++ b/usr.sbin/sysinst/arch/luna68k/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.7.2.1 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.7.2.2 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -110,7 +110,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { diff --git a/usr.sbin/sysinst/arch/mac68k/Makefile b/usr.sbin/sysinst/arch/mac68k/Makefile index 508553781e1..e297f600bec 100644 --- a/usr.sbin/sysinst/arch/mac68k/Makefile +++ b/usr.sbin/sysinst/arch/mac68k/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2019/06/12 06:20:21 martin Exp $ +# $NetBSD: Makefile,v 1.2.2.1 2020/10/15 19:36:51 bouyer Exp $ # # Makefile for mac68k # @@ -13,4 +13,7 @@ NO_GPT= yes NO_MBR= yes .endif +# XXX +COPTS.md.c= -Wno-stringop-truncation + .include "../../Makefile.inc" diff --git a/usr.sbin/sysinst/arch/mac68k/md.c b/usr.sbin/sysinst/arch/mac68k/md.c index e619d1a61d5..20cda52e46a 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.2.1 2020/02/10 21:39:38 bouyer Exp $ */ +/* $NetBSD: md.c,v 1.8.2.2 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -244,7 +244,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { int i, j, rv; @@ -265,7 +265,7 @@ md_make_bsd_partitions(struct install_partition_desc *install) if (check_for_errors()) { process_menu (MENU_sanity, &rv); if (rv < 0) - return false; + return 0; else if (rv) break; edit_diskmap(); @@ -317,7 +317,7 @@ md_make_bsd_partitions(struct install_partition_desc *install) pid = pm->parts->pscheme->add_outer_partition(pm->parts, &info, NULL); if (pid == NO_PART) - return false; + return 0; } } } @@ -327,11 +327,11 @@ md_make_bsd_partitions(struct install_partition_desc *install) /* Write the converted partitions */ if (!pm->parts->pscheme->write_to_disk(pm->parts)) - return false; + return 0; /* now convert to install info */ if (!install_desc_from_parts(install, pm->parts)) - return false; + return 0; /* set newfs flag for all FFS partitions */ for (ndx = 0; ndx < install->num; ndx++) { @@ -341,7 +341,7 @@ md_make_bsd_partitions(struct install_partition_desc *install) install->infos[ndx].instflags |= PUIINST_NEWFS; } - return true; + return 1; } /* diff --git a/usr.sbin/sysinst/arch/macppc/md.c b/usr.sbin/sysinst/arch/macppc/md.c index 68202becb9c..4b00376886e 100644 --- a/usr.sbin/sysinst/arch/macppc/md.c +++ b/usr.sbin/sysinst/arch/macppc/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:38 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:55 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -104,7 +104,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/mipsco/md.c b/usr.sbin/sysinst/arch/mipsco/md.c index 71e4b1fd2e8..c9549f2cf49 100644 --- a/usr.sbin/sysinst/arch/mipsco/md.c +++ b/usr.sbin/sysinst/arch/mipsco/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.6.2.1 2019/12/17 09:44:51 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.6.2.2 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -110,7 +110,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/mvme68k/md.c b/usr.sbin/sysinst/arch/mvme68k/md.c index 535169afbce..923e9e669d9 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.2 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: md.c,v 1.8.2.3 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -116,7 +116,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { diff --git a/usr.sbin/sysinst/arch/news68k/md.c b/usr.sbin/sysinst/arch/news68k/md.c index d06efb0baed..624dc070074 100644 --- a/usr.sbin/sysinst/arch/news68k/md.c +++ b/usr.sbin/sysinst/arch/news68k/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.6 2019/07/13 17:13:39 martin Exp $ */ +/* $NetBSD: md.c,v 1.6.2.1 2020/10/15 19:36:55 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -105,7 +105,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { diff --git a/usr.sbin/sysinst/arch/newsmips/md.c b/usr.sbin/sysinst/arch/newsmips/md.c index f500c748fc8..5e7612bcb4b 100644 --- a/usr.sbin/sysinst/arch/newsmips/md.c +++ b/usr.sbin/sysinst/arch/newsmips/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:39 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -104,7 +104,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/ofppc/md.c b/usr.sbin/sysinst/arch/ofppc/md.c index 6da77c4a84a..7b8e4efe91c 100644 --- a/usr.sbin/sysinst/arch/ofppc/md.c +++ b/usr.sbin/sysinst/arch/ofppc/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.7.2.2 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.7.2.3 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -75,6 +75,7 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (check_rdb()) return true; @@ -83,6 +84,7 @@ md_get_info(struct install_partition_desc *install) if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -102,13 +104,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { #if 0 diff --git a/usr.sbin/sysinst/arch/playstation2/md.c b/usr.sbin/sysinst/arch/playstation2/md.c index 99b46220b19..ee4589504b6 100644 --- a/usr.sbin/sysinst/arch/playstation2/md.c +++ b/usr.sbin/sysinst/arch/playstation2/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5.2.2 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.5.2.3 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -62,11 +62,12 @@ md_init_set_status(int minimal) bool md_get_info(struct install_partition_desc *install) { - int cyl, head, sec; + int cyl, head, sec, res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -107,13 +108,21 @@ md_get_info(struct install_partition_desc *install) if (pm->no_mbr || pm->no_part) return true; - return edit_outer_parts(pm->parts); + res = edit_outer_parts(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/pmax/md.c b/usr.sbin/sysinst/arch/pmax/md.c index 753ccc8d96b..7a6ec8096e2 100644 --- a/usr.sbin/sysinst/arch/pmax/md.c +++ b/usr.sbin/sysinst/arch/pmax/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.6.2.1 2019/12/17 09:44:51 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.6.2.2 2020/10/15 19:36:54 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -109,7 +109,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/prep/md.c b/usr.sbin/sysinst/arch/prep/md.c index dad962d7bd5..f0c4edafeda 100644 --- a/usr.sbin/sysinst/arch/prep/md.c +++ b/usr.sbin/sysinst/arch/prep/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8.2.3 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.8.2.4 2020/10/15 19:36:55 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -63,10 +63,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -86,13 +88,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/sandpoint/md.c b/usr.sbin/sysinst/arch/sandpoint/md.c index f1f5d8def3c..e3b06256b29 100644 --- a/usr.sbin/sysinst/arch/sandpoint/md.c +++ b/usr.sbin/sysinst/arch/sandpoint/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5.2.2 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.5.2.3 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -92,10 +92,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -115,13 +117,21 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/sgimips/md.c b/usr.sbin/sysinst/arch/sgimips/md.c index 0b1d48d82df..836a3f7746c 100644 --- a/usr.sbin/sysinst/arch/sgimips/md.c +++ b/usr.sbin/sysinst/arch/sgimips/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8 2019/07/13 17:13:40 martin Exp $ */ +/* $NetBSD: md.c,v 1.8.2.1 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -126,7 +126,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/shark/md.c b/usr.sbin/sysinst/arch/shark/md.c index 050bd9c142d..18e9b79ab4d 100644 --- a/usr.sbin/sysinst/arch/shark/md.c +++ b/usr.sbin/sysinst/arch/shark/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:40 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -107,7 +107,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/sparc/md.c b/usr.sbin/sysinst/arch/sparc/md.c index 13836cdb782..d74fe740b6f 100644 --- a/usr.sbin/sysinst/arch/sparc/md.c +++ b/usr.sbin/sysinst/arch/sparc/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:40 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -73,7 +73,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return(make_bsd_partitions(install)); diff --git a/usr.sbin/sysinst/arch/sparc64/md.c b/usr.sbin/sysinst/arch/sparc64/md.c index 22808d9efaa..f2e9c771351 100644 --- a/usr.sbin/sysinst/arch/sparc64/md.c +++ b/usr.sbin/sysinst/arch/sparc64/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5 2019/07/13 17:13:40 martin Exp $ */ +/* $NetBSD: md.c,v 1.5.2.1 2020/10/15 19:36:53 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -74,7 +74,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/vax/md.c b/usr.sbin/sysinst/arch/vax/md.c index 930baeae36f..e652face18d 100644 --- a/usr.sbin/sysinst/arch/vax/md.c +++ b/usr.sbin/sysinst/arch/vax/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.6 2019/07/13 17:13:40 martin Exp $ */ +/* $NetBSD: md.c,v 1.6.2.1 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -112,7 +112,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/x68k/md.c b/usr.sbin/sysinst/arch/x68k/md.c index e4a20b094cd..bfd5b2ac1f0 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.2 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: md.c,v 1.8.2.3 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -145,7 +145,7 @@ md_get_info(struct install_partition_desc *install) /* * md back-end code for menu-driven BSD disklabel editor. */ -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/arch/zaurus/md.c b/usr.sbin/sysinst/arch/zaurus/md.c index f1a4c462c0a..6839ae88cef 100644 --- a/usr.sbin/sysinst/arch/zaurus/md.c +++ b/usr.sbin/sysinst/arch/zaurus/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.5.2.2 2020/01/28 10:17:59 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.5.2.3 2020/10/15 19:36:52 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -72,10 +72,12 @@ md_init_set_status(int flags) bool md_get_info(struct install_partition_desc *install) { + int res; if (pm->no_mbr || pm->no_part) return true; +again: if (pm->parts == NULL) { const struct disk_partitioning_scheme *ps = @@ -95,10 +97,18 @@ md_get_info(struct install_partition_desc *install) pm->dlsize = ps->size_limit; } - return set_bios_geom_with_mbr_guess(pm->parts); + res = set_bios_geom_with_mbr_guess(pm->parts); + if (res == 0) + return false; + else if (res == 1) + return true; + + pm->parts->pscheme->destroy_part_scheme(pm->parts); + pm->parts = NULL; + goto again; } -bool +int md_make_bsd_partitions(struct install_partition_desc *install) { return make_bsd_partitions(install); diff --git a/usr.sbin/sysinst/bsddisklabel.c b/usr.sbin/sysinst/bsddisklabel.c index 2b30bef6fb3..9b666a6293e 100644 --- a/usr.sbin/sysinst/bsddisklabel.c +++ b/usr.sbin/sysinst/bsddisklabel.c @@ -1,4 +1,4 @@ -/* $NetBSD: bsddisklabel.c,v 1.23.2.10 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: bsddisklabel.c,v 1.23.2.11 2020/10/15 19:36:50 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -76,7 +76,7 @@ default_parts_init[] = #endif #ifdef PART_BOOT_TYPE .fs_type = PART_BOOT_TYPE, -#if PART_BOOT_TYPE == FS_MSDOS +#if (PART_BOOT_TYPE == FS_MSDOS) || (PART_BOOT_TYPE == FS_EX2FS) .flags = PUIFLAG_ADD_OUTER, #endif #endif @@ -100,7 +100,7 @@ default_parts_init[] = #endif #ifdef PART_BOOT1_TYPE .fs_type = PART_BOOT1_TYPE, -#if PART_BOOT1_TYPE == FS_MSDOS +#if (PART_BOOT1_TYPE == FS_MSDOS) || (PART_BOOT1_TYPE == FS_EX2FS) .flags = PUIFLAG_ADD_OUTER, #endif #endif @@ -119,7 +119,7 @@ default_parts_init[] = #endif #ifdef PART_BOOT2_TYPE .fs_type = PART_BOOT2_TYPE, -#if PART_BOOT2_TYPE == FS_MSDOS +#if (PART_BOOT2_TYPE == FS_MSDOS) || (PART_BOOT2_TYPE == FS_EX2FS) .flags = PUIFLAG_ADD_OUTER, #endif #endif @@ -143,8 +143,10 @@ default_parts_init[] = { .type = PT_root, .mount = "/tmp", .fs_type = FS_MFS, .flags = PUIFLG_JUST_MOUNTPOINT }, #endif - { .def_size = DEFUSRSIZE*(MEG/512), .mount = "/usr", .type = PT_root }, - { .def_size = DEFVARSIZE*(MEG/512), .mount = "/var", .type = PT_root }, + { .def_size = DEFUSRSIZE*(MEG/512), .mount = "/usr", .type = PT_root, + .fs_type = FS_BSDFFS, .fs_version = 2 }, + { .def_size = DEFVARSIZE*(MEG/512), .mount = "/var", .type = PT_root, + .fs_type = FS_BSDFFS, .fs_version = 2 }, }; static const char size_separator[] = @@ -258,7 +260,13 @@ draw_size_menu_line(menudesc *m, int opt, void *arg) pset->infos[opt].fs_version)); mount = swap; } else if (pset->infos[opt].mount[0]) { - mount = pset->infos[opt].mount; + if (pset->infos[opt].instflags & PUIINST_BOOT) { + snprintf(swap, sizeof swap, "%s <%s>", + pset->infos[opt].mount, msg_string(MSG_ptn_boot)); + mount = swap; + } else { + mount = pset->infos[opt].mount; + } #ifndef NO_CLONES } else if (pset->infos[opt].flags & PUIFLG_CLONE_PARTS) { snprintf(swap, sizeof swap, "%zu %s", @@ -276,6 +284,11 @@ draw_size_menu_line(menudesc *m, int opt, void *arg) if (mount == NULL) mount = getfslabelname(pset->infos[opt].fs_type, pset->infos[opt].fs_version); + if (pset->infos[opt].instflags & PUIINST_BOOT) { + snprintf(swap, sizeof swap, "%s <%s>", + mount, msg_string(MSG_ptn_boot)); + mount = swap; + } mount = str_arg_subst(msg_string(MSG_size_ptn_not_mounted), 1, &mount); free_mount = true; @@ -488,7 +501,7 @@ fill_ptn_menu(struct partition_usage_set *pset) m++; /* calculate free space */ - free_space = pset->parts->free_space; + free_space = pset->parts->free_space - pset->reserved_space; for (i = 0; i < pset->parts->num_part; i++) { if (!pset->parts->pscheme->get_part_info(pset->parts, i, &info)) @@ -742,6 +755,13 @@ set_keep_existing(menudesc *m, void *arg) } static int +set_switch_scheme(menudesc *m, void *arg) +{ + ((arg_rep_int*)arg)->rv = LY_OTHERSCHEME; + return 0; +} + +static int set_edit_part_sizes(menudesc *m, void *arg) { ((arg_rep_int*)arg)->rv = LY_SETSIZES; @@ -789,14 +809,14 @@ ask_layout(struct disk_partitions *parts, bool have_existing) const char *args[2]; int menu; size_t num_opts; - menu_ent options[3], *opt; + menu_ent options[4], *opt; args[0] = msg_string(parts->pscheme->name); args[1] = msg_string(parts->pscheme->short_name); ai.args.argv = args; ai.args.argc = 2; - ai.rv = LY_SETSIZES; - + ai.rv = LY_ERROR; + memset(options, 0, sizeof(options)); num_opts = 0; opt = &options[0]; @@ -820,8 +840,17 @@ ask_layout(struct disk_partitions *parts, bool have_existing) opt++; num_opts++; + if (num_available_part_schemes > 1 && + parts->parent == NULL) { + opt->opt_name = MSG_Use_Different_Part_Scheme; + opt->opt_flags = OPT_EXIT; + opt->opt_action = set_switch_scheme; + opt++; + num_opts++; + } + menu = new_menu(MSG_Select_your_choice, options, num_opts, - -1, -10, 0, 0, MC_NOEXITOPT, NULL, NULL, NULL, NULL, NULL); + -1, -10, 0, 0, 0, NULL, NULL, NULL, NULL, MSG_cancel); if (menu != -1) { get_menudesc(menu)->expand_act = expand_all_option_texts; process_menu(menu, &ai); @@ -856,7 +885,9 @@ merge_part_with_wanted(struct disk_partitions *parts, part_id pno, wanted->infos[i].cur_start = info->start; wanted->infos[i].flags &= ~PUIFLAG_EXTEND; if (wanted->infos[i].fs_type != FS_UNUSED && - wanted->infos[i].type != PT_swap) + wanted->infos[i].type != PT_swap && + info->last_mounted != NULL && + info->last_mounted[0] != 0) wanted->infos[i].instflags |= PUIINST_MOUNT; if (is_outer) wanted->infos[i].flags |= PUIFLG_IS_OUTER; @@ -921,6 +952,12 @@ fill_defaults(struct partition_usage_set *wanted, struct disk_partitions *parts, memset(wanted, 0, sizeof(*wanted)); wanted->parts = parts; + if (ptstart > parts->disk_start) + wanted->reserved_space = ptstart - parts->disk_start; + if ((ptstart + ptsize) < (parts->disk_start+parts->disk_size)) + wanted->reserved_space += + (parts->disk_start+parts->disk_size) - + (ptstart + ptsize); wanted->num = __arraycount(default_parts_init); wanted->infos = calloc(wanted->num, sizeof(*wanted->infos)); if (wanted->infos == NULL) { @@ -961,7 +998,8 @@ fill_defaults(struct partition_usage_set *wanted, struct disk_partitions *parts, wanted->infos[i].type = pt->generic_ptype; } if (wanted->parts->parent != NULL && - wanted->infos[i].fs_type == FS_MSDOS) + (wanted->infos[i].fs_type == FS_MSDOS || + wanted->infos[i].fs_type == FS_EX2FS)) wanted->infos[i].flags |= PUIFLG_ADD_INNER|PUIFLAG_ADD_OUTER; @@ -1008,8 +1046,8 @@ fill_defaults(struct partition_usage_set *wanted, struct disk_partitions *parts, * empty disk. Merge the partitions in target range that are already * there (match with wanted) or are there additionaly. * The only thing outside of target range that we care for - * are FAT partitions and a potential swap partition - we assume one - * is enough. + * are FAT partitions, EXT2FS partitions, and a potential + * swap partition - we assume one is enough. */ size_t num = wanted->num; if (parts->parent) { @@ -1020,7 +1058,8 @@ fill_defaults(struct partition_usage_set *wanted, struct disk_partitions *parts, parts->parent, pno, &info)) continue; if (info.nat_type->generic_ptype != PT_swap && - info.fs_type != FS_MSDOS) + info.fs_type != FS_MSDOS && + info.fs_type != FS_EX2FS) continue; merge_part_with_wanted(parts->parent, pno, &info, wanted, num, true); @@ -1093,14 +1132,14 @@ fill_defaults(struct partition_usage_set *wanted, struct disk_partitions *parts, * adjustments, so we don't present the user inherently * impossible defaults. */ - free_space = parts->free_space; + free_space = parts->free_space - wanted->reserved_space; required = 0; if (root < wanted->num) required += wanted->infos[root].size; if (usr < wanted->num) required += wanted->infos[usr].size; else if (def_usr < wanted->num) - required += wanted->infos[def_usr].def_size; + required += wanted->infos[def_usr].def_size; free_space -= required; for (i = 0; i < wanted->num; i++) { if (i == root || i == usr) @@ -1129,8 +1168,42 @@ fill_defaults(struct partition_usage_set *wanted, struct disk_partitions *parts, dump_space = roundup(dump_space, align); if (free_space > dump_space*2) dump_space *= 2; - if (free_space > dump_space) + if (free_space > dump_space) { wanted->infos[root].size += dump_space; + free_space -= dump_space; + } + } + if (wanted->infos[root].limit > 0 && + (wanted->infos[root].cur_start + wanted->infos[root].size > + wanted->infos[root].limit || + (wanted->infos[root].flags & PUIFLAG_EXTEND && + (wanted->infos[root].cur_start + wanted->infos[root].size + + free_space > wanted->infos[root].limit)))) { + if (usr >= wanted->num && def_usr < wanted->num) { + usr = def_usr; + wanted->infos[usr].size = wanted->infos[root].size + - wanted->infos[root].limit; + if (wanted->infos[usr].size <= 0) + wanted->infos[usr].size = max(1, + wanted->infos[usr].def_size); + wanted->infos[root].size = + wanted->infos[root].limit; + if (wanted->infos[root].flags & PUIFLAG_EXTEND) { + wanted->infos[root].flags &= ~PUIFLAG_EXTEND; + wanted->infos[usr].flags |= PUIFLAG_EXTEND; + } + } else if (usr < wanted->num) { + /* move space from root to usr */ + daddr_t spill = wanted->infos[root].size - + wanted->infos[root].limit; + spill = roundup(spill, align); + wanted->infos[root].size = + wanted->infos[root].limit; + wanted->infos[usr].size = spill; + } else { + wanted->infos[root].size = + wanted->infos[root].limit; + } } } @@ -1149,7 +1222,7 @@ sort_and_sync_parts(struct partition_usage_set *pset) size_t i, j, no; part_id pno; - pset->cur_free_space = pset->parts->free_space; + pset->cur_free_space = pset->parts->free_space - pset->reserved_space; /* count non-empty entries that are not in pset->parts */ no = pset->parts->num_part; @@ -1285,8 +1358,8 @@ normalize_clones(struct part_usage_info **infos, size_t *num) #endif static void -apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, - struct partition_usage_set *wanted, daddr_t start, daddr_t size) +apply_settings_to_partitions(struct disk_partitions *parts, + struct partition_usage_set *wanted, daddr_t start, daddr_t xsize) { size_t i, exp_ndx = ~0U; daddr_t planned_space = 0, nsp, from, align; @@ -1310,7 +1383,6 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, } align = wanted->parts->pscheme->get_part_alignment(wanted->parts); - /* * Pass one: calculate space available for expanding * the marked partition. @@ -1337,10 +1409,26 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, /* * Expand the pool partition (or shrink, if we overran), + * but check size limits. */ - if (exp_ndx < wanted->num) - wanted->infos[exp_ndx].size += - parts->free_space - planned_space; + if (exp_ndx < wanted->num) { + daddr_t free_space = + parts->free_space - roundup(wanted->reserved_space, align); + free_space -= planned_space; + daddr_t new_size = wanted->infos[exp_ndx].size; + if (free_space > 0) + new_size += free_space; + + if (wanted->infos[exp_ndx].limit > 0 && + (new_size + wanted->infos[exp_ndx].cur_start) + > wanted->infos[exp_ndx].limit) { + wanted->infos[exp_ndx].size = + wanted->infos[exp_ndx].limit + - wanted->infos[exp_ndx].cur_start; + } else { + wanted->infos[exp_ndx].size = new_size; + } + } /* * Now it gets tricky: we want the wanted partitions in order @@ -1372,7 +1460,7 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, } } - from = -1; + from = start > 0 ? start : -1; /* * First add all outer partitions - we need to align those exactly * with the inner counterpart later. @@ -1406,6 +1494,9 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, infos[i].last_mounted = want->mount; infos[i].fs_type = want->fs_type; infos[i].fs_sub_type = want->fs_version; + infos[i].fs_opt1 = want->fs_opt1; + infos[i].fs_opt2 = want->fs_opt2; + infos[i].fs_opt3 = want->fs_opt3; new_part_id = ps->pscheme->add_partition(ps, &infos[i], NULL); if (new_part_id == NO_PART) @@ -1416,16 +1507,20 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, want->cur_part_id = new_part_id; want->flags |= PUIFLG_ADD_INNER|PUIFLG_IS_OUTER; - from = rounddown(infos[i].start + - infos[i].size+outer_align, outer_align); + from = roundup(infos[i].start + + infos[i].size, outer_align); } } /* * Now add new inner partitions (and cloned partitions) */ - for (i = 0; i < wanted->num && from < - (wanted->parts->disk_size + wanted->parts->disk_start); i++) { + for (i = 0; i < wanted->num; i++) { + + daddr_t limit = wanted->parts->disk_size + wanted->parts->disk_start; + if (from >= limit) + break; + struct part_usage_info *want = &wanted->infos[i]; if (want->cur_part_id != NO_PART) @@ -1486,6 +1581,9 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, infos[i].last_mounted = want->mount; infos[i].fs_type = want->fs_type; infos[i].fs_sub_type = want->fs_version; + infos[i].fs_opt1 = want->fs_opt1; + infos[i].fs_opt2 = want->fs_opt2; + infos[i].fs_opt3 = want->fs_opt3; if (want->fs_type != FS_UNUSED && want->type != PT_swap) { want->instflags |= PUIINST_NEWFS; @@ -1501,7 +1599,7 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, wanted->parts->pscheme->get_part_info( wanted->parts, new_part_id, &infos[i]); - from = rounddown(infos[i].start+infos[i].size+align, align); + from = roundup(infos[i].start+infos[i].size, align); } @@ -1523,26 +1621,45 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, (PUIFLG_ADD_INNER|PUIFLG_IS_OUTER)) continue; - infos[i].start = want->cur_start; - infos[i].size = want->size; - infos[i].nat_type = wanted->parts->pscheme->get_fs_part_type( - want->type, want->fs_type, want->fs_version); - infos[i].last_mounted = want->mount; - infos[i].fs_type = want->fs_type; - infos[i].fs_sub_type = want->fs_version; - - if (wanted->parts->pscheme->add_outer_partition - != NULL) - new_part_id = wanted->parts->pscheme-> - add_outer_partition( - wanted->parts, &infos[i], NULL); - else - new_part_id = wanted->parts->pscheme-> - add_partition( - wanted->parts, &infos[i], NULL); + new_part_id = NO_PART; + for (part_id j = 0; new_part_id == NO_PART && + j < wanted->parts->num_part; j++) { + struct disk_part_info test; + + if (!wanted->parts->pscheme->get_part_info( + wanted->parts, j, &test)) + continue; + if (test.start == want->cur_start && + test.size == want->size) + new_part_id = j; + } + + if (new_part_id == NO_PART) { + infos[i].start = want->cur_start; + infos[i].size = want->size; + infos[i].nat_type = wanted->parts->pscheme-> + get_fs_part_type(want->type, want->fs_type, + want->fs_version); + infos[i].last_mounted = want->mount; + infos[i].fs_type = want->fs_type; + infos[i].fs_sub_type = want->fs_version; + infos[i].fs_opt1 = want->fs_opt1; + infos[i].fs_opt2 = want->fs_opt2; + infos[i].fs_opt3 = want->fs_opt3; + + if (wanted->parts->pscheme->add_outer_partition + != NULL) + new_part_id = wanted->parts->pscheme-> + add_outer_partition( + wanted->parts, &infos[i], NULL); + else + new_part_id = wanted->parts->pscheme-> + add_partition( + wanted->parts, &infos[i], NULL); - if (new_part_id == NO_PART) - continue; /* failed to add, skip */ + if (new_part_id == NO_PART) + continue; /* failed to add, skip */ + } wanted->parts->pscheme->get_part_info( wanted->parts, new_part_id, &infos[i]); @@ -1586,7 +1703,7 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts, } static void -replace_by_default(struct pm_devs *p, struct disk_partitions *parts, +replace_by_default(struct disk_partitions *parts, daddr_t start, daddr_t size, struct partition_usage_set *wanted) { @@ -1598,11 +1715,11 @@ replace_by_default(struct pm_devs *p, struct disk_partitions *parts, assert(parts->num_part == 0); fill_defaults(wanted, parts, start, size); - apply_settings_to_partitions(p, parts, wanted, start, size); + apply_settings_to_partitions(parts, wanted, start, size); } static bool -edit_with_defaults(struct pm_devs *p, struct disk_partitions *parts, +edit_with_defaults(struct disk_partitions *parts, daddr_t start, daddr_t size, struct partition_usage_set *wanted) { bool ok; @@ -1610,35 +1727,35 @@ edit_with_defaults(struct pm_devs *p, struct disk_partitions *parts, fill_defaults(wanted, parts, start, size); ok = get_ptn_sizes(wanted); if (ok) - apply_settings_to_partitions(p, parts, wanted, start, size); + apply_settings_to_partitions(parts, wanted, start, size); return ok; } /* * md back-end code for menu-driven BSD disklabel editor. - * returns 0 on failure, 1 on success. + * returns 0 on failure, 1 on success, -1 for restart. * fills the install target with a list for newfs/fstab. */ -bool +int make_bsd_partitions(struct install_partition_desc *install) { struct disk_partitions *parts = pm->parts; const struct disk_partitioning_scheme *pscheme; struct partition_usage_set wanted; + daddr_t p_start, p_size; enum layout_type layoutkind = LY_SETSIZES; bool have_existing; if (pm && pm->no_part && parts == NULL) - return true; - + return 1; if (parts == NULL) { pscheme = select_part_scheme(pm, NULL, !pm->no_mbr, NULL); if (pscheme == NULL) - return false; + return 0; parts = pscheme->create_new_for_disk(pm->diskdev, 0, pm->dlsize, true, NULL); if (parts == NULL) - return false; + return 0; pm->parts = parts; } else { pscheme = parts->pscheme; @@ -1657,19 +1774,13 @@ make_bsd_partitions(struct install_partition_desc *install) have_existing = check_existing_netbsd(parts); /* - * Initialize global variables that track space used on this disk. + * Make sure the cylinder size multiplier/divisor and disk sieze are + * valid */ - if (pm->ptsize == 0) - pm->ptsize = pm->dlsize - pm->ptstart; - if (pm->dlsize == 0) - pm->dlsize = pm->ptstart + pm->ptsize; - - if (logfp) fprintf(logfp, "dlsize=%" PRId64 " ptsize=%" PRId64 - " ptstart=%" PRId64 "\n", - pm->dlsize, pm->ptsize, pm->ptstart); - if (pm->current_cylsize == 0) pm->current_cylsize = pm->dlcylsize; + if (pm->ptsize == 0) + pm->ptsize = pm->dlsize; /* Ask for layout type -- standard or special */ if (partman_go == 0) { @@ -1699,22 +1810,116 @@ make_bsd_partitions(struct install_partition_desc *install) bsd_size, min_size, x_size); msg_display_add("\n\n"); layoutkind = ask_layout(parts, have_existing); + if (layoutkind == LY_ERROR) + return 0; } - if (layoutkind == LY_USEDEFAULT) { - replace_by_default(pm, parts, pm->ptstart, pm->ptsize, + if (layoutkind == LY_USEDEFAULT || layoutkind == LY_SETSIZES) { + /* calc available disk area for the NetBSD partitions */ + p_start = pm->ptstart; + p_size = pm->ptsize; + if (parts->parent != NULL && + parts->parent->pscheme->guess_install_target != NULL) + parts->parent->pscheme->guess_install_target( + parts->parent, &p_start, &p_size); + } + if (layoutkind == LY_OTHERSCHEME) { + parts->pscheme->destroy_part_scheme(parts); + return -1; + } else if (layoutkind == LY_USEDEFAULT) { + replace_by_default(parts, p_start, p_size, &wanted); } else if (layoutkind == LY_SETSIZES) { - if (!edit_with_defaults(pm, parts, pm->ptstart, pm->ptsize, + if (!edit_with_defaults(parts, p_start, p_size, &wanted)) { free_usage_set(&wanted); - return false; + return 0; } } else { usage_set_from_parts(&wanted, parts); } /* + * Make sure the target root partition is properly marked, + * check for existing EFI boot partition. + */ + bool have_inst_target = false; +#ifdef HAVE_EFI_BOOT + daddr_t target_start = -1; +#endif + for (size_t i = 0; i < wanted.num; i++) { + if (wanted.infos[i].cur_flags & PTI_INSTALL_TARGET) { + have_inst_target = true; +#ifdef HAVE_EFI_BOOT + target_start = wanted.infos[i].cur_start; +#endif + break; + } + } + if (!have_inst_target) { + for (size_t i = 0; i < wanted.num; i++) { + struct disk_part_info info; + + if (wanted.infos[i].type != PT_root || + strcmp(wanted.infos[i].mount, "/") != 0) + continue; + wanted.infos[i].cur_flags |= PTI_INSTALL_TARGET; + + if (!wanted.parts->pscheme->get_part_info(wanted.parts, + wanted.infos[i].cur_part_id, &info)) + break; + info.flags |= PTI_INSTALL_TARGET; + wanted.parts->pscheme->set_part_info(wanted.parts, + wanted.infos[i].cur_part_id, &info, NULL); +#ifdef HAVE_EFI_BOOT + target_start = wanted.infos[i].cur_start; +#endif + break; + } + } +#ifdef HAVE_EFI_BOOT + size_t boot_part = ~0U; + for (part_id i = 0; i < wanted.num; i++) { + if ((wanted.infos[i].cur_flags & PTI_BOOT) != 0 || + wanted.infos[i].type == PT_EFI_SYSTEM) { + boot_part = i; + break; + } + } + if (boot_part == ~0U) { + for (part_id i = 0; i < wanted.num; i++) { + /* + * heuristic to recognize existing MBR FAT + * partitions as EFI without looking for + * details + */ + if ((wanted.infos[i].type != PT_FAT && + wanted.infos[i].type != PT_EFI_SYSTEM) || + wanted.infos[i].fs_type != FS_MSDOS) + continue; + daddr_t ps = wanted.infos[i].cur_start; + daddr_t pe = ps + wanted.infos[i].size; + if (target_start >= 0 && + (ps >= target_start || pe >= target_start)) + continue; + boot_part = i; + break; + } + } + if (boot_part != ~0U) { + struct disk_part_info info; + + if (wanted.parts->pscheme->get_part_info(wanted.parts, + wanted.infos[boot_part].cur_part_id, &info)) { + info.flags |= PTI_BOOT; + wanted.parts->pscheme->set_part_info(wanted.parts, + wanted.infos[boot_part].cur_part_id, &info, NULL); + } + wanted.infos[boot_part].instflags |= PUIINST_BOOT; + } +#endif + + /* * OK, we have a partition table. Give the user the chance to * edit it and verify it's OK, or abort altogether. */ @@ -1723,11 +1928,13 @@ make_bsd_partitions(struct install_partition_desc *install) if (rv == 0) { msg_display(MSG_abort_part); free_usage_set(&wanted); - return false; + return 0; } /* update install infos */ install->num = wanted.num; install->infos = wanted.infos; + install->write_back = wanted.write_back; + install->num_write_back = wanted.num_write_back; /* and check them */ if (check_partitions(install)) break; @@ -1735,10 +1942,11 @@ make_bsd_partitions(struct install_partition_desc *install) /* we moved infos from wanted to install target */ wanted.infos = NULL; + wanted.write_back = NULL; free_usage_set(&wanted); /* Everything looks OK. */ - return true; + return 1; } #ifndef MD_NEED_BOOTBLOCK diff --git a/usr.sbin/sysinst/defs.h b/usr.sbin/sysinst/defs.h index 8e0b07b0986..5e368589512 100644 --- a/usr.sbin/sysinst/defs.h +++ b/usr.sbin/sysinst/defs.h @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.42.2.7 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: defs.h,v 1.42.2.8 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -72,7 +72,7 @@ const char *getfslabelname(uint, uint); * if a system has less ram (in MB) than this, we will not create a * tmpfs /tmp by default (to workaround PR misc/54886) */ -#define SMALL_RAM_SIZE 256 +#define SMALL_RAM_SIZE 384 /* helper macros to create unique internal error messages */ #define STR_NO(STR) #STR @@ -103,7 +103,15 @@ const char *getfslabelname(uint, uint); #define RUN_XFER_DIR 0x0200 /* cd to xfer_dir in child */ /* for bsddisklabel.c */ -enum layout_type { LY_KEEPEXISTING, LY_SETSIZES, LY_USEDEFAULT, LY_USEFULL }; +enum layout_type { + LY_KEEPEXISTING, /* keep exisiting partitions */ + LY_OTHERSCHEME, /* delete all, select new partitioning scheme */ + LY_SETSIZES, /* edit sizes */ + LY_USEDEFAULT, /* use default sizes */ + LY_USEFULL, /* use full disk for NetBSD */ + LY_ERROR /* used for "abort" in menu */ +}; + enum setup_type { SY_NEWRAID, SY_NEWCGD, SY_NEWLVM }; /* Installation sets */ @@ -298,6 +306,7 @@ struct part_usage_info { unsigned int instflags; /* installer handling flags */ uint fs_type, fs_version; /* e.g. FS_LFS, or FS_BSDFS, * version = 2 for FFSv2 */ + uint fs_opt1, fs_opt2, fs_opt3; /* FS specific, FFS: block/frag */ #ifndef NO_CLONES /* * Only != NULL when PUIFLG_CLONE_PARTS is set, describes the @@ -317,10 +326,17 @@ struct part_usage_info { * A list of partition suggestions, bundled for editing */ struct partition_usage_set { - struct disk_partitions *parts; - size_t num; + struct disk_partitions *parts; /* main partition table */ + size_t num; /* number of infos */ struct part_usage_info *infos; /* 0 .. num-1 */ + struct disk_partitions **write_back; + /* partition tables from which we + * did delete some partitions and + * that need updating, even if + * no active partition remains. */ + size_t num_write_back; /* number of write_back */ daddr_t cur_free_space; /* estimate of free sectors */ + daddr_t reserved_space; /* space we are not allowed to use */ menu_ent *menu_opts; /* 0 .. num+N */ int menu; /* the menu to edit this */ bool ok; /* ok to continue (all fit) */ @@ -332,7 +348,7 @@ struct partition_usage_set { */ struct single_part_fs_edit { struct partition_usage_set *pset; - size_t index, first_custom_attr; + size_t index, first_custom_attr, offset, mode; part_id id; struct disk_part_info info; /* current partition data */ struct part_usage_info *wanted; /* points at our edit data */ @@ -355,37 +371,42 @@ struct single_part_fs_edit { struct install_partition_desc { size_t num; /* how many entries in infos */ struct part_usage_info *infos; /* individual partitions */ + struct disk_partitions **write_back; /* partition tables from + * which we did delete some + * partitions and that need + * updating, even if no + * active partition remains. */ + size_t num_write_back; /* number of write_back */ bool cur_system; /* target is the life system */ }; /* variables */ -int debug; /* set by -D option */ +extern int debug; /* set by -D option */ -char rel[SSTRSIZE]; -char machine[SSTRSIZE]; +extern char machine[SSTRSIZE]; -int ignorerror; -int ttysig_ignore; -pid_t ttysig_forward; -uint sizemult; +extern int ignorerror; +extern int ttysig_ignore; +extern pid_t ttysig_forward; +extern uint sizemult; extern const char *multname; extern const char *err_outofmem; -int partman_go; /* run extended partition manager */ +extern int partman_go; /* run extended partition manager */ /* logging variables */ -FILE *logfp; -FILE *script; +extern FILE *logfp; +extern FILE *script; #define MAX_DISKS 15 -daddr_t root_limit; /* BIOS (etc) read limit */ +extern daddr_t root_limit; /* BIOS (etc) read limit */ enum SHRED_T { SHRED_NONE=0, SHRED_ZEROS, SHRED_RANDOM }; /* All information that is unique for each drive */ -SLIST_HEAD(pm_head_t, pm_devs) pm_head; +extern SLIST_HEAD(pm_head_t, pm_devs) pm_head; struct pm_devs { /* @@ -454,8 +475,8 @@ struct pm_devs { SLIST_ENTRY(pm_devs) l; }; -struct pm_devs *pm; /* Pointer to current device with which we work */ -struct pm_devs *pm_new; /* Pointer for next allocating device in find_disks() */ +extern struct pm_devs *pm; /* Pointer to current device with which we work */ +extern struct pm_devs *pm_new; /* Pointer for next allocating device in find_disks() */ /* Generic structure for partman */ struct part_entry { @@ -470,8 +491,8 @@ struct part_entry { }; /* Relative file name for storing a distribution. */ -char xfer_dir[STRSIZE]; -int clean_xfer_dir; +extern char xfer_dir[STRSIZE]; +extern int clean_xfer_dir; #if !defined(SYSINST_FTP_HOST) #define SYSINST_FTP_HOST "ftp.NetBSD.org" @@ -531,28 +552,28 @@ int clean_xfer_dir; #endif /* Abs. path we extract binary sets from */ -char ext_dir_bin[STRSIZE]; +extern char ext_dir_bin[STRSIZE]; /* Abs. path we extract source sets from */ -char ext_dir_src[STRSIZE]; +extern char ext_dir_src[STRSIZE]; /* Abs. path we extract pkgsrc from */ -char ext_dir_pkgsrc[STRSIZE]; +extern char ext_dir_pkgsrc[STRSIZE]; /* Place we look for binary sets in all fs types */ -char set_dir_bin[STRSIZE]; +extern char set_dir_bin[STRSIZE]; /* Place we look for source sets in all fs types */ -char set_dir_src[STRSIZE]; +extern char set_dir_src[STRSIZE]; /* Place we look for pkgs in all fs types */ -char pkg_dir[STRSIZE]; +extern char pkg_dir[STRSIZE]; /* Place we look for pkgsrc in all fs types */ -char pkgsrc_dir[STRSIZE]; +extern char pkgsrc_dir[STRSIZE]; /* User shell */ -const char *ushell; +extern const char *ushell; #define XFER_FTP 0 #define XFER_HTTP 1 @@ -568,26 +589,26 @@ struct ftpinfo { }; /* use the same struct for sets ftp and to build pkgpath */ -struct ftpinfo ftp, pkg, pkgsrc; +extern struct ftpinfo ftp, pkg, pkgsrc; -int (*fetch_fn)(const char *); -char nfs_host[STRSIZE]; -char nfs_dir[STRSIZE]; +extern int (*fetch_fn)(const char *); +extern char nfs_host[STRSIZE]; +extern char nfs_dir[STRSIZE]; -char cdrom_dev[SSTRSIZE]; /* Typically "cd0a" */ -char fd_dev[SSTRSIZE]; /* Typically "/dev/fd0a" */ -const char *fd_type; /* "msdos", "ffs" or maybe "ados" */ +extern char cdrom_dev[SSTRSIZE]; /* Typically "cd0a" */ +extern char fd_dev[SSTRSIZE]; /* Typically "/dev/fd0a" */ +extern const char *fd_type; /* "msdos", "ffs" or maybe "ados" */ -char localfs_dev[SSTRSIZE]; -char localfs_fs[SSTRSIZE]; -char localfs_dir[STRSIZE]; +extern char localfs_dev[SSTRSIZE]; +extern char localfs_fs[SSTRSIZE]; +extern char localfs_dir[STRSIZE]; -char targetroot_mnt[SSTRSIZE]; +extern char targetroot_mnt[SSTRSIZE]; -int mnt2_mounted; +extern int mnt2_mounted; -char dist_postfix[SSTRSIZE]; -char dist_tgz_postfix[SSTRSIZE]; +extern char dist_postfix[SSTRSIZE]; +extern char dist_tgz_postfix[SSTRSIZE]; /* needed prototypes */ void set_menu_numopts(int, int); @@ -602,7 +623,8 @@ void md_init_set_status(int); /* SFLAG_foo */ /* MD functions if user selects install - in order called */ bool md_get_info(struct install_partition_desc*); -bool md_make_bsd_partitions(struct install_partition_desc*); +/* returns -1 to restart partitioning, 0 for error, 1 for success */ +int md_make_bsd_partitions(struct install_partition_desc*); bool md_check_partitions(struct install_partition_desc*); #ifdef HAVE_GPT /* @@ -674,8 +696,14 @@ void disp_cur_fspart(int, int); int make_filesystems(struct install_partition_desc *); int make_fstab(struct install_partition_desc *); int mount_disks(struct install_partition_desc *); +/* + * set_swap_if_low_ram and set_swap return -1 on error, + * 0 if no swap was added on purpose and + * 1 if swap has been added (and needs to be cleared later). + */ int set_swap_if_low_ram(struct install_partition_desc *); int set_swap(struct install_partition_desc *); +void clear_swap(void); int check_swap(const char *, int); char *bootxx_name(struct install_partition_desc *); int get_dkwedges(struct dkwedge_info **, const char *); @@ -715,8 +743,8 @@ void canonicalize_last_mounted(char*); int edit_and_check_label(struct pm_devs *p, struct partition_usage_set *pset, bool install); int edit_ptn(menudesc *, void *); int checkoverlap(struct disk_partitions *parts); -daddr_t getpartsize(struct disk_partitions *parts, daddr_t partstart, - daddr_t defpartsize); +daddr_t getpartsize(struct disk_partitions *parts, daddr_t orig_start, + daddr_t partstart, daddr_t defpartsize); daddr_t getpartoff(struct disk_partitions *parts, daddr_t defpartstart); /* from install.c */ @@ -763,7 +791,13 @@ int err_msg_win(const char*); const struct disk_partitioning_scheme *select_part_scheme(struct pm_devs *dev, const struct disk_partitioning_scheme *skip, bool bootable, const char *title); -bool edit_outer_parts(struct disk_partitions*); +/* + * return value: + * 0 -> abort + * 1 -> ok, continue + * -1 -> partitions have been deleted, start from scratch +*/ +int edit_outer_parts(struct disk_partitions*); bool parts_use_wholedisk(struct disk_partitions*, size_t add_ext_parts, const struct disk_part_info *ext_parts); @@ -929,7 +963,8 @@ extern int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk; void check_available_binaries(void); /* from bsddisklabel.c */ -bool make_bsd_partitions(struct install_partition_desc*); +/* returns -1 to restart partitioning, 0 for error, 1 for success */ +int make_bsd_partitions(struct install_partition_desc*); void set_ptn_titles(menudesc *, int, void *); int set_ptn_size(menudesc *, void *); bool get_ptn_sizes(struct partition_usage_set*); @@ -952,7 +987,7 @@ void do_configmenu(struct install_partition_desc*); /* from checkrc.c */ int check_rcvar(const char *); int check_rcdefault(const char *); - WINDOW *mainwin; +extern WINDOW *mainwin; /* in menus.mi */ void expand_all_option_texts(menudesc *menu, void *arg); diff --git a/usr.sbin/sysinst/disklabel.c b/usr.sbin/sysinst/disklabel.c index 2b1450add9a..36dfd62526e 100644 --- a/usr.sbin/sysinst/disklabel.c +++ b/usr.sbin/sysinst/disklabel.c @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.c,v 1.10.2.9 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: disklabel.c,v 1.10.2.10 2020/10/15 19:36:50 bouyer Exp $ */ /* * Copyright 2018 The NetBSD Foundation, Inc. @@ -42,9 +42,9 @@ const struct disk_partitioning_scheme disklabel_parts; struct disklabel_disk_partitions { struct disk_partitions dp; struct disklabel l; - daddr_t ptn_alignment; + daddr_t ptn_alignment, install_target; char last_mounted[MAXPARTITIONS][MOUNTLEN]; - uint fs_sub_type[MAXPARTITIONS]; + uint fs_sub_type[MAXPARTITIONS], fs_opt3[MAXPARTITIONS]; }; /* @@ -150,6 +150,7 @@ disklabel_parts_new(const char *dev, daddr_t start, daddr_t len, if (parts == NULL) return NULL; + parts->install_target = -1; total_size = geo.dg_secperunit; if (len*(geo.dg_secsize/512) > disklabel_parts.size_limit) len = disklabel_parts.size_limit/(geo.dg_secsize/512); @@ -172,7 +173,7 @@ disklabel_parts_new(const char *dev, daddr_t start, daddr_t len, strncpy(parts->l.d_packname, "fictious", sizeof parts->l.d_packname); -#if RAW_PART > 2 +#if RAW_PART == 3 if (parts->dp.parent != NULL) { parts->l.d_partitions[RAW_PART-1].p_fstype = FS_UNUSED; parts->l.d_partitions[RAW_PART-1].p_offset = start; @@ -213,6 +214,7 @@ disklabel_parts_read(const char *disk, daddr_t start, daddr_t len, size_t bps, struct disklabel_disk_partitions *parts = calloc(1, sizeof(*parts)); if (parts == NULL) return NULL; + parts->install_target = -1; fd = opendisk(disk, O_RDONLY, diskpath, sizeof(diskpath), 0); if (fd == -1) { @@ -231,7 +233,7 @@ disklabel_parts_read(const char *disk, daddr_t start, daddr_t len, size_t bps, close(fd); return NULL; } -#if RAW_PART > 2 +#if RAW_PART == 3 if (parts->l.d_partitions[RAW_PART-1].p_fstype == FS_UNUSED) { daddr_t dlstart = parts->l.d_partitions[RAW_PART-1].p_offset; daddr_t dlend = start + @@ -272,8 +274,12 @@ disklabel_parts_read(const char *disk, daddr_t start, daddr_t len, size_t bps, flags = 0; if (parts->l.d_partitions[part].p_fstype == FS_MSDOS) flags = GLM_MAYBE_FAT32; - else if (parts->l.d_partitions[part].p_fstype == FS_BSDFFS) + else if (parts->l.d_partitions[part].p_fstype == FS_BSDFFS) { flags = GLM_LIKELY_FFS; + if (parts->install_target < 0) + parts->install_target = + parts->l.d_partitions[part].p_offset; + } if (flags != 0) { uint fs_type, fs_sub_type; const char *lm = get_last_mounted(fd, @@ -467,7 +473,7 @@ disklabel_delete_all(struct disk_partitions *arg) memset(&parts->l.d_partitions, 0, sizeof(parts->l.d_partitions)); parts->dp.num_part = 0; -#if RAW_PART > 2 +#if RAW_PART == 3 if (parts->dp.parent != NULL) { parts->l.d_partitions[RAW_PART-1].p_fstype = FS_UNUSED; parts->l.d_partitions[RAW_PART-1].p_offset = @@ -501,7 +507,7 @@ disklabel_delete(struct disk_partitions *arg, part_id id, if (ndx == id) { if (part == RAW_PART -#if RAW_PART > 2 +#if RAW_PART == 3 || (part == RAW_PART-1 && parts->dp.parent != NULL) #endif @@ -511,6 +517,9 @@ disklabel_delete(struct disk_partitions *arg, part_id id, MSG_part_not_deletable); return false; } + if (parts->install_target == + parts->l.d_partitions[part].p_offset) + parts->install_target = -1; parts->l.d_partitions[part].p_size = 0; parts->l.d_partitions[part].p_offset = 0; parts->l.d_partitions[part].p_fstype = FS_UNUSED; @@ -543,7 +552,7 @@ disklabel_delete_range(struct disk_partitions *arg, daddr_t r_start, daddr_t start = parts->l.d_partitions[part].p_offset; daddr_t end = start + parts->l.d_partitions[part].p_size; -#if RAW_PART > 2 +#if RAW_PART == 3 if (parts->dp.parent != NULL && part == RAW_PART - 1 && start == r_start && r_start + r_size == end) @@ -552,6 +561,8 @@ disklabel_delete_range(struct disk_partitions *arg, daddr_t r_start, if ((start >= r_start && start <= r_start+r_size) || (end >= r_start && end <= r_start+r_size)) { + if (start == parts->install_target) + parts->install_target = -1; if (parts->dp.num_part > 1) parts->dp.num_part--; parts->dp.free_space += @@ -582,6 +593,9 @@ dl_init_types(void) pt = PT_root; break; case FS_SWAP: pt = PT_swap; break; case FS_MSDOS: pt = PT_FAT; break; + case FS_EX2FS: pt = PT_EXT2; break; + case FS_SYSVBFS: + pt = PT_SYSVBFS; break; default: pt = PT_unknown; break; } dl_types[i].generic_ptype = pt; @@ -707,6 +721,9 @@ disklabel_get_generic_type(enum part_type pt) case PT_FAT: case PT_EFI_SYSTEM: nt = FS_MSDOS; break; + case PT_EXT2: nt = FS_EX2FS; break; + case PT_SYSVBFS: + nt = FS_SYSVBFS; break; default: nt = FS_UNUSED; break; } @@ -755,11 +772,17 @@ disklabel_get_part_info(const struct disk_partitions *arg, part_id id, info->last_mounted = parts->last_mounted[part]; info->fs_type = parts->l.d_partitions[part].p_fstype; info->fs_sub_type = parts->fs_sub_type[part]; + info->fs_opt2 = parts->l.d_partitions[part].p_fsize; + info->fs_opt1 = info->fs_opt2 * + parts->l.d_partitions[part].p_frag; + info->fs_opt3 = parts->fs_opt3[part]; if (part == RAW_PART && parts->l.d_partitions[part].p_fstype == FS_UNUSED) info->flags |= PTI_PSCHEME_INTERNAL|PTI_RAW_PART; -#if RAW_PART > 2 + if (info->start == parts->install_target) + info->flags |= PTI_INSTALL_TARGET; +#if RAW_PART == 3 if (part == (RAW_PART-1) && parts->dp.parent != NULL && parts->l.d_partitions[part].p_fstype == FS_UNUSED) info->flags |= @@ -783,6 +806,7 @@ disklabel_set_part_info(struct disk_partitions *arg, part_id id, struct disklabel_disk_partitions *parts = (struct disklabel_disk_partitions*)arg; part_id ndx; + bool was_inst_target; if (dl_types[0].description == NULL) dl_init_types(); @@ -794,15 +818,28 @@ disklabel_set_part_info(struct disk_partitions *arg, part_id id, continue; if (ndx == id) { + was_inst_target = parts->l.d_partitions[part].p_offset + == parts->install_target; parts->l.d_partitions[part].p_offset = info->start; parts->l.d_partitions[part].p_size = info->size; parts->l.d_partitions[part].p_fstype = dl_part_type_from_generic(info->nat_type); + parts->l.d_partitions[part].p_fsize = info->fs_opt2; + if (info->fs_opt2 != 0) + parts->l.d_partitions[part].p_frag = + info->fs_opt1 / info->fs_opt2; + else + parts->l.d_partitions[part].p_frag = 0; + parts->fs_opt3[part] = info->fs_opt3; if (info->last_mounted != NULL && info->last_mounted != parts->last_mounted[part]) strlcpy(parts->last_mounted[part], info->last_mounted, sizeof(parts->last_mounted[part])); + if (info->flags & PTI_INSTALL_TARGET) + parts->install_target = info->start; + else if (was_inst_target) + parts->install_target = -1; assert(info->fs_type == 0 || info->fs_type == parts->l.d_partitions[part].p_fstype); if (info->fs_sub_type != 0) @@ -906,7 +943,7 @@ disklabel_can_add_partition(const struct disk_partitions *arg) for (i = 0; i < parts->l.d_npartitions; i++) { if (i == RAW_PART) continue; -#if RAW_PART > 2 +#if RAW_PART == 3 if (i == RAW_PART-1 && parts->dp.parent != NULL) continue; #endif @@ -1061,7 +1098,7 @@ disklabel_add_partition(struct disk_partitions *arg, continue; if (i == RAW_PART) continue; -#if RAW_PART > 2 +#if RAW_PART == 3 if (i == RAW_PART-1 && parts->dp.parent != NULL) continue; #endif @@ -1085,6 +1122,12 @@ disklabel_add_partition(struct disk_partitions *arg, parts->l.d_partitions[part].p_size = data.size; parts->l.d_partitions[part].p_fstype = dl_part_type_from_generic(data.nat_type); + parts->l.d_partitions[part].p_fsize = info->fs_opt2; + if (info->fs_opt2 != 0) + parts->l.d_partitions[part].p_frag = + info->fs_opt1 / info->fs_opt2; + else + parts->l.d_partitions[part].p_frag = 0; if (data.last_mounted && data.last_mounted[0]) strlcpy(parts->last_mounted[part], data.last_mounted, sizeof(parts->last_mounted[part])); @@ -1124,7 +1167,7 @@ disklabel_add_outer_partition(struct disk_partitions *arg, continue; if (i == RAW_PART) continue; -#if RAW_PART > 2 +#if RAW_PART == 3 if (i == RAW_PART-1 && parts->dp.parent != NULL) continue; #endif @@ -1148,6 +1191,12 @@ disklabel_add_outer_partition(struct disk_partitions *arg, parts->l.d_partitions[part].p_size = info->size; parts->l.d_partitions[part].p_fstype = dl_part_type_from_generic(info->nat_type); + parts->l.d_partitions[part].p_fsize = info->fs_opt2; + if (info->fs_opt2 != 0) + parts->l.d_partitions[part].p_frag = + info->fs_opt1 / info->fs_opt2; + else + parts->l.d_partitions[part].p_frag = 0; if (info->last_mounted && info->last_mounted[0]) strlcpy(parts->last_mounted[part], info->last_mounted, sizeof(parts->last_mounted[part])); @@ -1233,6 +1282,14 @@ disklabel_free(struct disk_partitions *arg) free(arg); } +static void +disklabel_destroy_part_scheme(struct disk_partitions *arg) +{ + + run_program(RUN_SILENT, "disklabel -D %s", arg->disk); + free(arg); +} + const struct disk_partitioning_scheme disklabel_parts = { .name = MSG_parttype_disklabel, @@ -1271,4 +1328,5 @@ disklabel_parts = { .get_free_spaces = disklabel_get_free_spaces, .get_part_device = disklabel_get_part_device, .free = disklabel_free, + .destroy_part_scheme = disklabel_destroy_part_scheme, }; diff --git a/usr.sbin/sysinst/disks.c b/usr.sbin/sysinst/disks.c index 10ca45d6cc7..30e0b62aa78 100644 --- a/usr.sbin/sysinst/disks.c +++ b/usr.sbin/sysinst/disks.c @@ -1,4 +1,4 @@ -/* $NetBSD: disks.c,v 1.44.2.14 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: disks.c,v 1.44.2.15 2020/10/15 19:36:50 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1078,7 +1078,8 @@ int make_filesystems(struct install_partition_desc *install) { int error = 0, partno = -1; - char *newfs = NULL, devdev[PATH_MAX], rdev[PATH_MAX]; + char *newfs = NULL, devdev[PATH_MAX], rdev[PATH_MAX], + opts[200], opt[30]; size_t i; struct part_usage_info *ptn; struct disk_partitions *parts; @@ -1120,7 +1121,7 @@ make_filesystems(struct install_partition_desc *install) for (i = 0; i < install->num; i++) { /* - * Newfs all file systems mareked as needing this. + * Newfs all file systems marked as needing this. * Mount the ones that have a mountpoint in the target. */ ptn = &install->infos[i]; @@ -1142,16 +1143,33 @@ make_filesystems(struct install_partition_desc *install) parts->pscheme->get_part_device(parts, ptn->cur_part_id, rdev, sizeof rdev, &partno, raw_dev_name, true, true); + opts[0] = 0; switch (ptn->fs_type) { case FS_APPLEUFS: - asprintf(&newfs, "/sbin/newfs"); + if (ptn->fs_opt3 != 0) + snprintf(opts, sizeof opts, "-i %u", + ptn->fs_opt3); + asprintf(&newfs, "/sbin/newfs %s", opts); mnt_opts = "-tffs -o async"; fsname = "ffs"; break; case FS_BSDFFS: + if (ptn->fs_opt3 != 0) + snprintf(opts, sizeof opts, "-i %u ", + ptn->fs_opt3); + if (ptn->fs_opt1 != 0) { + snprintf(opt, sizeof opt, "-b %u ", + ptn->fs_opt1); + strcat(opts, opt); + } + if (ptn->fs_opt2 != 0) { + snprintf(opt, sizeof opt, "-f %u ", + ptn->fs_opt2); + strcat(opts, opt); + } asprintf(&newfs, - "/sbin/newfs -V2 -O %d", - ptn->fs_version == 2 ? 2 : 1); + "/sbin/newfs -V2 -O %d %s", + ptn->fs_version == 2 ? 2 : 1, opts); if (ptn->mountflags & PUIMNT_LOG) mnt_opts = "-tffs -o log"; else @@ -1159,7 +1177,10 @@ make_filesystems(struct install_partition_desc *install) fsname = "ffs"; break; case FS_BSDLFS: - asprintf(&newfs, "/sbin/newfs_lfs"); + if (ptn->fs_opt1 != 0 && ptn->fs_opt2 != 0) + snprintf(opts, sizeof opts, "-b %u", + ptn->fs_opt1 * ptn->fs_opt2); + asprintf(&newfs, "/sbin/newfs_lfs %s", opts); mnt_opts = "-tlfs"; fsname = "lfs"; break; @@ -1188,23 +1209,8 @@ make_filesystems(struct install_partition_desc *install) break; } if ((ptn->instflags & PUIINST_NEWFS) && newfs != NULL) { - if (ptn->fs_type == FS_MSDOS) { - /* newfs only if mount fails */ - if (run_program(RUN_SILENT | RUN_ERROR_OK, - "mount -rt msdos %s /mnt2", devdev) != 0) - error = run_program( - RUN_DISPLAY | RUN_PROGRESS, - "%s %s", - newfs, rdev); - else { - run_program(RUN_SILENT | RUN_ERROR_OK, - "umount /mnt2"); - error = 0; - } - } else { - error = run_program(RUN_DISPLAY | RUN_PROGRESS, + error = run_program(RUN_DISPLAY | RUN_PROGRESS, "%s %s", newfs, rdev); - } } else if ((ptn->instflags & (PUIINST_MOUNT|PUIINST_BOOT)) && fsname != NULL) { /* We'd better check it isn't dirty */ @@ -1347,7 +1353,7 @@ make_fstab(struct install_partition_desc *install) break; case FS_SWAP: if (swap_dev[0] == 0) { - strncpy(swap_dev, dev, sizeof swap_dev); + strlcpy(swap_dev, dev, sizeof swap_dev); dump_dev = ",dp"; } else { dump_dev = ""; @@ -1414,14 +1420,16 @@ done_with_disks: scripting_fprintf(f, "kernfs\t\t/kern\tkernfs\trw\n"); scripting_fprintf(f, "ptyfs\t\t/dev/pts\tptyfs\trw\n"); scripting_fprintf(f, "procfs\t\t/proc\tprocfs\trw\n"); - scripting_fprintf(f, "/dev/%s\t\t/cdrom\tcd9660\tro,noauto\n", - cdrom_dev); + if (cdrom_dev[0] != 0) + scripting_fprintf(f, "/dev/%s\t\t/cdrom\tcd9660\tro,noauto\n", + cdrom_dev); scripting_fprintf(f, "%stmpfs\t\t/var/shm\ttmpfs\trw,-m1777,-sram%%25\n", tmpfs_on_var_shm() ? "" : "#"); make_target_dir("/kern"); make_target_dir("/proc"); make_target_dir("/dev/pts"); - make_target_dir("/cdrom"); + if (cdrom_dev[0] != 0) + make_target_dir("/cdrom"); make_target_dir("/var/shm"); scripting_fprintf(NULL, "EOF\n"); @@ -1905,9 +1913,12 @@ mount_disks(struct install_partition_desc *install) return error; } +static char swap_dev[PATH_MAX]; + int set_swap_if_low_ram(struct install_partition_desc *install) { + swap_dev[0] = 0; if (get_ramsize() <= TINY_RAM_SIZE) return set_swap(install); return 0; @@ -1917,9 +1928,9 @@ int set_swap(struct install_partition_desc *install) { size_t i; - char dev_buf[PATH_MAX]; int rval; + swap_dev[0] = 0; for (i = 0; i < install->num; i++) { if (install->infos[i].type == PT_swap) break; @@ -1928,15 +1939,27 @@ set_swap(struct install_partition_desc *install) return 0; if (!install->infos[i].parts->pscheme->get_part_device( - install->infos[i].parts, install->infos[i].cur_part_id, dev_buf, - sizeof dev_buf, NULL, plain_name, true, true)) + install->infos[i].parts, install->infos[i].cur_part_id, swap_dev, + sizeof swap_dev, NULL, plain_name, true, true)) return -1; - rval = swapctl(SWAP_ON, dev_buf, 0); - if (rval != 0) + rval = swapctl(SWAP_ON, swap_dev, 0); + if (rval != 0) { + swap_dev[0] = 0; return -1; + } - return 0; + return 1; +} + +void +clear_swap(void) +{ + + if (swap_dev[0] == 0) + return; + swapctl(SWAP_OFF, swap_dev, 0); + swap_dev[0] = 0; } int diff --git a/usr.sbin/sysinst/gpt.c b/usr.sbin/sysinst/gpt.c index 532b6118895..8b645468296 100644 --- a/usr.sbin/sysinst/gpt.c +++ b/usr.sbin/sysinst/gpt.c @@ -1,4 +1,4 @@ -/* $NetBSD: gpt.c,v 1.6.2.8 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: gpt.c,v 1.6.2.9 2020/10/15 19:36:50 bouyer Exp $ */ /* * Copyright 2018 The NetBSD Foundation, Inc. @@ -130,12 +130,14 @@ struct gpt_part_entry { char gp_label[GPT_LABEL_LEN]; /* user defined label */ char gp_dev_name[GPT_DEV_LEN]; /* name of wedge */ const char *last_mounted; /* last mounted if known */ - uint fs_type, fs_sub_type; /* FS_* and maybe sub type */ + uint fs_type, fs_sub_type, /* FS_* and maybe sub type */ + fs_opt1, fs_opt2, fs_opt3; /* transient file system options */ uint gp_flags; #define GPEF_ON_DISK 1 /* This entry exists on-disk */ #define GPEF_MODIFIED 2 /* this entry has been changed */ #define GPEF_WEDGE 4 /* wedge for this exists */ #define GPEF_RESIZED 8 /* size has changed */ +#define GPEF_TARGET 16 /* marked install target */ struct gpt_part_entry *gp_next; }; @@ -280,6 +282,9 @@ gpt_read_from_disk(const char *dev, daddr_t start, daddr_t len, size_t bps, static const char regpart_prefix[] = "GPT part - "; struct gpt_disk_partitions *parts; struct gpt_part_entry *last = NULL, *add_to = NULL; + const struct gpt_ptype_desc *native_root + = gpt_find_native_type(gpt_native_root); + bool have_target = false; if (collect(T_OUTPUT, &textbuf, "gpt -r show -a %s 2>/dev/null", dev) < 1) @@ -351,6 +356,11 @@ gpt_read_from_disk(const char *dev, daddr_t start, daddr_t len, size_t bps, np->gp_start = p_start; np->gp_size = p_size; np->gp_flags |= GPEF_ON_DISK; + if (!have_target && native_root != NULL && + strcmp(np->gp_id, native_root->tid) == 0) { + have_target = true; + np->gp_flags |= GPEF_TARGET; + } if (last == NULL) parts->partitions = np; @@ -508,6 +518,11 @@ gpt_get_part_info(const struct disk_partitions *arg, part_id id, info->last_mounted = p->last_mounted; info->fs_type = p->fs_type; info->fs_sub_type = p->fs_sub_type; + info->fs_opt1 = p->fs_opt1; + info->fs_opt2 = p->fs_opt2; + info->fs_opt3 = p->fs_opt3; + if (p->gp_flags & GPEF_TARGET) + info->flags |= PTI_INSTALL_TARGET; return true; } @@ -603,6 +618,7 @@ gpt_set_part_info(struct disk_partitions *arg, part_id id, struct gpt_part_entry *p = parts->partitions, *n; part_id no; daddr_t lendiff; + bool was_target; for (no = 0; p != NULL && no < id; no++) p = p->gp_next; @@ -610,6 +626,17 @@ gpt_set_part_info(struct disk_partitions *arg, part_id id, if (no != id || p == NULL) return false; + /* update target mark - we can only have one */ + was_target = (p->gp_flags & GPEF_TARGET) != 0; + if (info->flags & PTI_INSTALL_TARGET) + p->gp_flags |= GPEF_TARGET; + else + p->gp_flags &= ~GPEF_TARGET; + if (was_target) + for (n = parts->partitions; n != NULL; n = n->gp_next) + if (n != p) + n->gp_flags &= ~GPEF_TARGET; + if ((p->gp_flags & GPEF_ON_DISK)) { if (info->start != p->gp_start) { /* partition moved, we need to delete and re-add */ @@ -1031,6 +1058,9 @@ gpt_info_to_part(struct gpt_part_entry *p, const struct disk_part_info *info, } p->fs_type = info->fs_type; p->fs_sub_type = info->fs_sub_type; + p->fs_opt1 = info->fs_opt1; + p->fs_opt2 = info->fs_opt2; + p->fs_opt3 = info->fs_opt3; return true; } @@ -1235,7 +1265,7 @@ gpt_modify_part(const char *disk, struct gpt_part_entry *p) /* Check type */ if (p->gp_type != old.gp_type) { if (run_program(RUN_SILENT, - "gpt label -b %" PRIu64 " -T %s %s", + "gpt type -b %" PRIu64 " -T %s %s", p->gp_start, p->gp_type->tid, disk) != 0) return false; } @@ -1443,7 +1473,7 @@ gpt_write_to_disk(struct disk_partitions *arg) p->gp_flags &= ~GPEF_WEDGE; if (root_id == NO_PART && p->gp_type != NULL) { if (p->gp_type->gent.generic_ptype == PT_root && - p->gp_start == pm->ptstart) { + (p->gp_flags & GPEF_TARGET)) { root_id = pno; root_is_new = !(p->gp_flags & GPEF_ON_DISK); } else if (efi_id == NO_PART && @@ -1585,6 +1615,14 @@ gpt_free(struct disk_partitions *arg) free(parts); } +static void +gpt_destroy_part_scheme(struct disk_partitions *arg) +{ + + run_program(RUN_SILENT, "gpt destroy %s", arg->disk); + gpt_free(arg); +} + static bool gpt_custom_attribute_writable(const struct disk_partitions *arg, part_id ptn, size_t attr_no) @@ -1811,5 +1849,6 @@ gpt_parts = { .delete_partition = gpt_delete_partition, .write_to_disk = gpt_write_to_disk, .free = gpt_free, + .destroy_part_scheme = gpt_destroy_part_scheme, .cleanup = gpt_cleanup, }; diff --git a/usr.sbin/sysinst/install.c b/usr.sbin/sysinst/install.c index 4202c455eb5..ea84e1da231 100644 --- a/usr.sbin/sysinst/install.c +++ b/usr.sbin/sysinst/install.c @@ -1,4 +1,4 @@ -/* $NetBSD: install.c,v 1.9.2.3 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: install.c,v 1.9.2.4 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -57,12 +57,28 @@ write_all_parts(struct install_partition_desc *install) bool found, res; /* pessimistic assumption: all partitions on different devices */ - allparts = calloc(install->num, sizeof(*allparts)); + allparts = calloc(install->num + install->num_write_back, + sizeof(*allparts)); if (allparts == NULL) return false; /* collect all different partition sets */ num_parts = 0; + for (i = 0; i < install->num_write_back; i++) { + parts = install->write_back[i]; + if (parts == NULL) + continue; + found = false; + for (j = 0; j < num_parts; j++) { + if (allparts[j] == parts) { + found = true; + break; + } + } + if (found) + continue; + allparts[num_parts++] = parts; + } for (i = 0; i < install->num; i++) { parts = install->infos[i].parts; if (parts == NULL) @@ -137,9 +153,8 @@ void do_install(void) { int find_disks_ret; - int retcode = 0; + int retcode = 0, res; struct install_partition_desc install = {}; - struct disk_partitions *parts; #ifndef NO_PARTMAN partman_go = -1; @@ -179,8 +194,16 @@ do_install(void) } } - if (!md_get_info(&install) || - !md_make_bsd_partitions(&install)) { + for (;;) { + if (md_get_info(&install)) { + res = md_make_bsd_partitions(&install); + if (res == -1) { + pm->parts = NULL; + continue; + } else if (res == 1) { + break; + } + } hit_enter_to_continue(MSG_abort_inst, NULL); goto error; } @@ -192,21 +215,6 @@ do_install(void) if (!ask_noyes(NULL)) goto error; - /* - * Check if we have a secondary partitioning and - * use that if available. The MD code will typically - * have written the outer partitioning in md_pre_disklabel. - */ - parts = pm->parts; - if (!pm->no_part && parts != NULL) { - if (parts->pscheme->secondary_scheme != NULL && - parts->pscheme->secondary_partitions != NULL) { - parts = parts->pscheme->secondary_partitions( - parts, pm->ptstart, false); - if (parts == NULL) - parts = pm->parts; - } - } if ((!pm->no_part && !write_all_parts(&install)) || make_filesystems(&install) || make_fstab(&install) != 0 || diff --git a/usr.sbin/sysinst/label.c b/usr.sbin/sysinst/label.c index 0f864f0edcd..79d06444882 100644 --- a/usr.sbin/sysinst/label.c +++ b/usr.sbin/sysinst/label.c @@ -1,4 +1,4 @@ -/* $NetBSD: label.c,v 1.10.2.5 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: label.c,v 1.10.2.6 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Jonathan Stone @@ -36,7 +36,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: label.c,v 1.10.2.5 2020/01/28 10:17:58 msaitoh Exp $"); +__RCSID("$NetBSD: label.c,v 1.10.2.6 2020/10/15 19:36:51 bouyer Exp $"); #endif #include <sys/types.h> @@ -50,6 +50,7 @@ __RCSID("$NetBSD: label.c,v 1.10.2.5 2020/01/28 10:17:58 msaitoh Exp $"); #include <sys/dkio.h> #include <sys/param.h> #include <sys/bootblock.h> +#include <sys/bitops.h> #include <ufs/ffs/fs.h> #include "defs.h" @@ -187,11 +188,10 @@ verify_parts(struct partition_usage_set *pset, bool install) struct part_usage_info *wanted; struct disk_partitions *parts; size_t i, num_root; - daddr_t first_bsdstart, first_bsdsize, inst_start, inst_size; + daddr_t first_bsdstart, inst_start; int rv; - first_bsdstart = first_bsdsize = 0; - inst_start = inst_size = 0; + first_bsdstart = inst_start = -1; num_root = 0; parts = pset->parts; for (i = 0; i < pset->num; i++) { @@ -207,18 +207,17 @@ verify_parts(struct partition_usage_set *pset, bool install) continue; num_root++; - if (first_bsdstart == 0) { + if (first_bsdstart <= 0) { first_bsdstart = wanted->cur_start; - first_bsdsize = wanted->size; } - if (inst_start == 0 && wanted->cur_start == pm->ptstart) { + if (inst_start < 0 && + (wanted->cur_flags & PTI_INSTALL_TARGET)) { inst_start = wanted->cur_start; - inst_size = wanted->size; } } if ((num_root == 0 && install) || - (num_root > 1 && inst_start == 0)) { + (num_root > 1 && inst_start < 0)) { if (num_root == 0 && install) msg_display_subst(MSG_must_be_one_root, 2, msg_string(parts->pscheme->name), @@ -232,21 +231,6 @@ verify_parts(struct partition_usage_set *pset, bool install) return rv; } - if (pm->ptstart == 0) { - if (inst_start > 0) { - pm->ptstart = inst_start; - pm->ptsize = inst_size; - } else if (first_bsdstart > 0) { - pm->ptstart = first_bsdstart; - pm->ptsize = first_bsdsize; - } else if (parts->pscheme->guess_install_target && - parts->pscheme->guess_install_target( - parts, &inst_start, &inst_size)) { - pm->ptstart = inst_start; - pm->ptsize = inst_size; - } - } - /* Check for overlaps */ if (checkoverlap(parts) != 0) { rv = ask_reedit(parts); @@ -291,10 +275,15 @@ static int edit_fs_size(menudesc *m, void *arg) { struct single_part_fs_edit *edit = arg; + struct disk_part_info pinfo; daddr_t size; - size = getpartsize(edit->pset->parts, edit->info.start, - edit->info.size); + /* get original partition data, in case start moved already */ + edit->pset->parts->pscheme->get_part_info(edit->pset->parts, + edit->id, &pinfo); + /* ask for new size with old start and current values */ + size = getpartsize(edit->pset->parts, pinfo.start, + edit->info.start, edit->info.size); if (size < 0) return 0; if (size > edit->pset->parts->disk_size) @@ -304,6 +293,97 @@ edit_fs_size(menudesc *m, void *arg) } static int +set_ffs_opt_pow2(menudesc *m, void *arg) +{ + struct single_part_fs_edit *edit = arg; + size_t val = 1 << (edit->offset+m->cursel); + + if (edit->mode == 1) { + edit->info.fs_opt1 = val; + edit->wanted->fs_opt1 = val; + } else if (edit->mode == 2) { + edit->info.fs_opt2 = val; + edit->wanted->fs_opt2 = val; + } + return 0; +} + +static int +edit_fs_ffs_opt(menudesc *m, void *arg, msg head, + size_t min_val, size_t max_val) +{ + struct single_part_fs_edit *edit = arg; + menu_ent opts[min(MAXPHYS/4096, 8)]; + char names[min(MAXPHYS/4096, 8)][20]; + size_t i, val; + int menu; + + edit->offset = ilog2(min_val); + memset(opts, 0, sizeof opts); + for (i = 0, val = min_val; val <= max_val; i++, val <<= 1) { + snprintf(names[i], sizeof names[i], "%zu", val); + opts[i].opt_name = names[i]; + opts[i].opt_action = set_ffs_opt_pow2; + opts[i].opt_flags = OPT_EXIT; + } + menu = new_menu(head, opts, i, 40, 6, 0, 0, MC_NOEXITOPT, + NULL, NULL, NULL, NULL, NULL); + if (menu < 0) + return 1; + process_menu(menu, arg); + free_menu(menu); + return 0; +} + +static int +edit_fs_ffs_block(menudesc *m, void *arg) +{ + struct single_part_fs_edit *edit = arg; + + edit->mode = 1; /* edit fs_opt1 */ + return edit_fs_ffs_opt(m, arg, MSG_Select_file_system_block_size, + 4096, MAXPHYS); +} + +static int +edit_fs_ffs_frag(menudesc *m, void *arg) +{ + struct single_part_fs_edit *edit = arg; + size_t bsize, sec_size; + + edit->mode = 2; /* edit fs_opt2 */ + bsize = edit->info.fs_opt1; + if (bsize == 0) { + sec_size = edit->wanted->parts->bytes_per_sector; + if (edit->wanted->size >= (daddr_t)(128L*(GIG/sec_size))) + bsize = 32*1024; + else if (edit->wanted->size >= (daddr_t)(1000L*(MEG/sec_size))) + bsize = 16*1024; + else if (edit->wanted->size >= (daddr_t)(20L*(MEG/sec_size))) + bsize = 8*1024; + else + bsize = 4+1024; + } + return edit_fs_ffs_opt(m, arg, MSG_Select_file_system_fragment_size, + bsize / 8, bsize); +} + +static int +edit_fs_ffs_avg_size(menudesc *m, void *arg) +{ + struct single_part_fs_edit *edit = arg; + char answer[12]; + + snprintf(answer, sizeof answer, "%u", edit->info.fs_opt3); + msg_prompt_win(MSG_ptn_isize_prompt, -1, 18, 0, 0, + answer, answer, sizeof answer); + edit->info.fs_opt3 = atol(answer); + edit->wanted->fs_opt3 = edit->info.fs_opt3; + + return 0; +} + +static int edit_fs_preserve(menudesc *m, void *arg) { struct single_part_fs_edit *edit = arg; @@ -317,10 +397,7 @@ edit_install(menudesc *m, void *arg) { struct single_part_fs_edit *edit = arg; - if (edit->info.start == pm->ptstart) - pm->ptstart = 0; - else - pm->ptstart = edit->info.start; + edit->info.flags ^= PTI_INSTALL_TARGET; return 0; } @@ -356,7 +433,7 @@ edit_fs_mountpt(menudesc *m, void *arg) if (last != NULL) last[1] = 0; - if (*first == 0 || strcmp(first, "none") == 0) { + if (first == NULL || *first == 0 || strcmp(first, "none") == 0) { edit->wanted->mount[0] = 0; edit->wanted->instflags &= ~PUIINST_MOUNT; return 0; @@ -428,12 +505,15 @@ renumber_partitions(struct partition_usage_set *pset) continue; if (pset->infos[i].cur_flags != info.flags) continue; - if (pset->infos[i].type != info.nat_type->generic_ptype) - continue; - memcpy(&ninfos[pno], &pset->infos[i], - sizeof(ninfos[pno])); - ninfos[pno].cur_part_id = pno; - break; + if ((info.fs_type != FS_UNUSED && + info.fs_type == pset->infos[i].fs_type) || + (pset->infos[i].type == + info.nat_type->generic_ptype)) { + memcpy(&ninfos[pno], &pset->infos[i], + sizeof(ninfos[pno])); + ninfos[pno].cur_part_id = pno; + break; + } } } @@ -710,6 +790,29 @@ static void update_edit_ptn_menu(menudesc *m, void *arg); static void draw_edit_ptn_line(menudesc *m, int opt, void *arg); static int edit_ptn_custom_type(menudesc *m, void *arg); +static void +remember_deleted(struct partition_usage_set *pset, + struct disk_partitions *parts) +{ + size_t i, num; + struct disk_partitions **tab; + + /* do we have parts on record already? */ + for (i = 0; i < pset->num_write_back; i++) + if (pset->write_back[i] == parts) + return; + /* + * Need to record this partition table for write back + */ + num = pset->num_write_back + 1; + tab = realloc(pset->write_back, num*sizeof(*pset->write_back)); + if (!tab) + return; + tab[pset->num_write_back] = parts; + pset->write_back = tab; + pset->num_write_back = num; +} + int edit_ptn(menudesc *menu, void *arg) { @@ -737,6 +840,13 @@ edit_ptn(menudesc *menu, void *arg) { .opt_menu=MENU_mountoptions, .opt_flags=OPT_SUB }, { .opt_action=edit_fs_mountpt }, }; + + static const menu_ent edit_ptn_fields_ffs[] = { + { .opt_action=edit_fs_ffs_avg_size }, + { .opt_action=edit_fs_ffs_block }, + { .opt_action=edit_fs_ffs_frag }, + }; + static const menu_ent edit_ptn_fields_tail[] = { { .opt_name=MSG_askunits, .opt_menu=MENU_sizechoice, .opt_flags=OPT_SUB }, @@ -760,6 +870,9 @@ edit_ptn(menudesc *menu, void *arg) num_opts = __arraycount(edit_ptn_fields_head) + __arraycount(edit_ptn_fields_head2) + __arraycount(edit_ptn_fields_tail); + if (edit.wanted->fs_type == FS_BSDFFS || + edit.wanted->fs_type == FS_BSDLFS) + num_opts += __arraycount(edit_ptn_fields_ffs); if (with_inst_opt) num_opts += __arraycount(edit_ptn_fields_head_add); if (is_new_part) @@ -781,6 +894,11 @@ edit_ptn(menudesc *menu, void *arg) } memcpy(popt, edit_ptn_fields_head2, sizeof(edit_ptn_fields_head2)); popt += __arraycount(edit_ptn_fields_head2); + if (edit.wanted->fs_type == FS_BSDFFS || + edit.wanted->fs_type == FS_BSDLFS) { + memcpy(popt, edit_ptn_fields_ffs, sizeof(edit_ptn_fields_ffs)); + popt += __arraycount(edit_ptn_fields_ffs); + } edit.first_custom_attr = popt - mopts; if (!is_new_part) { for (size_t i = 0; @@ -835,6 +953,7 @@ edit_ptn(menudesc *menu, void *arg) if (edit.rv == 0) { /* OK, set new data */ edit.info.last_mounted = edit.wanted->mount; if (is_new_part) { + edit.wanted->parts = pset->parts; edit.wanted->cur_part_id = pset->parts->pscheme-> add_partition(pset->parts, &edit.info, &err); if (edit.wanted->cur_part_id == NO_PART) @@ -883,6 +1002,9 @@ edit_ptn(menudesc *menu, void *arg) err_msg_win(err); return 0; } + remember_deleted(pset, + pset->infos[edit.index].parts); + pset->cur_free_space += pset->infos[edit.index].size; memmove(pset->infos+edit.index, pset->infos+edit.index+1, sizeof(*pset->infos)*(pset->num-edit.index)); @@ -891,6 +1013,8 @@ edit_ptn(menudesc *menu, void *arg) sizeof(*menu->opts)*(menu->numopts-edit.index)); menu->numopts--; menu->cursel = 0; + if (pset->parts->num_part == 0) + menu->cursel = 1; /* skip sentinel line */ /* things have changed, re-sort */ pset->num--; @@ -958,7 +1082,7 @@ draw_edit_ptn_line(menudesc *m, int opt, void *arg) static int col_width; static const char *ptn_type, *ptn_start, *ptn_size, *ptn_end, *ptn_newfs, *ptn_mount, *ptn_mount_options, *ptn_mountpt, - *ptn_install; + *ptn_install, *ptn_bsize, *ptn_fsize, *ptn_isize; const char *c; char val[MENUSTRSIZE]; const char *attrname; @@ -979,6 +1103,9 @@ draw_edit_ptn_line(menudesc *m, int opt, void *arg) LOAD(ptn_mount); LOAD(ptn_mount_options); LOAD(ptn_mountpt); + LOAD(ptn_bsize); + LOAD(ptn_fsize); + LOAD(ptn_isize); #undef LOAD for (size_t i = 0; @@ -1031,7 +1158,7 @@ draw_edit_ptn_line(menudesc *m, int opt, void *arg) } if (m->opts[opt].opt_action == edit_install) { wprintw(m->mw, "%*s : %s", col_width, ptn_install, - msg_string(edit->info.start == pm->ptstart + msg_string((edit->info.flags & PTI_INSTALL_TARGET) ? MSG_Yes : MSG_No)); return; } @@ -1047,6 +1174,33 @@ draw_edit_ptn_line(menudesc *m, int opt, void *arg) ? MSG_Yes : MSG_No)); return; } + if (m->opts[opt].opt_action == edit_fs_ffs_block) { + wprintw(m->mw, "%*s : %u", col_width, ptn_bsize, + edit->wanted->fs_opt1); + return; + } + if (m->opts[opt].opt_action == edit_fs_ffs_frag) { + wprintw(m->mw, "%*s : %u", col_width, ptn_fsize, + edit->wanted->fs_opt2); + return; + } + if (m->opts[opt].opt_action == edit_fs_ffs_avg_size) { + if (edit->wanted->fs_opt3 == 0) + wprintw(m->mw, "%*s : %s", col_width, ptn_isize, + msg_string(MSG_ptn_isize_dflt)); + else { + char buf[24], *line; + const char *t = buf; + + snprintf(buf, sizeof buf, "%u", edit->wanted->fs_opt3); + line = str_arg_subst(msg_string(MSG_ptn_isize_bytes), + 1, &t); + wprintw(m->mw, "%*s : %s", col_width, ptn_isize, + line); + free(line); + } + return; + } if (m->opts[opt].opt_menu == MENU_mountoptions) { wprintw(m->mw, "%*s : ", col_width, ptn_mount_options); if (edit->wanted->mountflags & PUIMNT_ASYNC) @@ -1285,7 +1439,7 @@ fmt_fspart_row(menudesc *m, int ptn, void *arg) fp = flag_str; inst_flags = pset->infos[ptn].instflags; - if (with_inst_flag && info.start == pm->ptstart && + if (with_inst_flag && (info.flags & PTI_INSTALL_TARGET) && info.nat_type->generic_ptype == PT_root) { static char inst_flag; @@ -1418,7 +1572,7 @@ part_ext_clone(menudesc *m, void *arg) clones[clone_cnt].new_id = cid; clones[clone_cnt].ndx = s; clone_cnt++; - offset = rounddown(cinfo.start+cinfo.size+align, align); + offset = roundup(cinfo.start+cinfo.size, align); } /* insert new clone records at offset data.res */ @@ -2012,7 +2166,8 @@ getpartoff(struct disk_partitions *parts, daddr_t defpartstart) /* Ask for a partition size, check bounds and do the needed roundups */ daddr_t -getpartsize(struct disk_partitions *parts, daddr_t partstart, daddr_t dflt) +getpartsize(struct disk_partitions *parts, daddr_t orig_start, + daddr_t partstart, daddr_t dflt) { char dsize[24], isize[24], max_size[24], maxpartc, valid_parts[4], *label_msg, *prompt, *head, *hint, *tail; @@ -2022,7 +2177,10 @@ getpartsize(struct disk_partitions *parts, daddr_t partstart, daddr_t dflt) part_id partn; diskend = parts->disk_start + parts->disk_size; - max = parts->pscheme->max_free_space_at(parts, partstart); + max = parts->pscheme->max_free_space_at(parts, orig_start); + max += orig_start - partstart; + if (sizemult == 1) + max--; /* with hugher scale proper rounding later will be ok */ /* We need to keep both the unrounded and rounded (_r) max and dflt */ dflt_r = (partstart + dflt) / sizemult - partstart / sizemult; diff --git a/usr.sbin/sysinst/main.c b/usr.sbin/sysinst/main.c index 0e24f951614..e55c9d4d7e3 100644 --- a/usr.sbin/sysinst/main.c +++ b/usr.sbin/sysinst/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.17.2.3 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: main.c,v 1.17.2.4 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -52,6 +52,45 @@ #include "menu_defs.h" #include "txtwalk.h" +int debug; +char machine[SSTRSIZE]; +int ignorerror; +int ttysig_ignore; +pid_t ttysig_forward; +uint sizemult; +int partman_go; +FILE *logfp; +FILE *script; +daddr_t root_limit; +struct pm_head_t pm_head; +struct pm_devs *pm; +struct pm_devs *pm_new; +char xfer_dir[STRSIZE]; +int clean_xfer_dir; +char ext_dir_bin[STRSIZE]; +char ext_dir_src[STRSIZE]; +char ext_dir_pkgsrc[STRSIZE]; +char set_dir_bin[STRSIZE]; +char set_dir_src[STRSIZE]; +char pkg_dir[STRSIZE]; +char pkgsrc_dir[STRSIZE]; +const char *ushell; +struct ftpinfo ftp, pkg, pkgsrc; +int (*fetch_fn)(const char *); +char nfs_host[STRSIZE]; +char nfs_dir[STRSIZE]; +char cdrom_dev[SSTRSIZE]; +char fd_dev[SSTRSIZE]; +const char *fd_type; +char localfs_dev[SSTRSIZE]; +char localfs_fs[SSTRSIZE]; +char localfs_dir[STRSIZE]; +char targetroot_mnt[SSTRSIZE]; +int mnt2_mounted; +char dist_postfix[SSTRSIZE]; +char dist_tgz_postfix[SSTRSIZE]; +WINDOW *mainwin; + static void select_language(void); __dead static void usage(void); __dead static void miscsighandler(int); @@ -87,7 +126,7 @@ struct f_arg { }; static const struct f_arg fflagopts[] = { - {"release", REL, rel, sizeof rel}, + {"release", REL, NULL, 0}, {"machine", MACH, machine, sizeof machine}, {"xfer dir", "/usr/INSTALL", xfer_dir, sizeof xfer_dir}, {"ext dir", "", ext_dir_bin, sizeof ext_dir_bin}, @@ -144,6 +183,8 @@ init(void) memset(pm_new, 0, sizeof *pm_new); for (arg = fflagopts; arg->name != NULL; arg++) { + if (arg->var == NULL) + continue; if (arg->var == cdrom_dev) get_default_cdrom(arg->var, arg->size); else @@ -192,8 +233,7 @@ main(int argc, char **argv) debug = 1; break; case 'r': - /* Release name other than compiled in release. */ - strncpy(rel, optarg, sizeof rel); + /* Release name - ignore for compatibility with older versions */ break; case 'f': /* Definition file to read. */ @@ -410,6 +450,7 @@ toplevel(void) if (chdir(home) != 0) (void)chdir("/"); unwind_mounts(); + clear_swap(); /* Display banner message in (english, francais, deutsch..) */ msg_display(MSG_hello); @@ -500,6 +541,7 @@ cleanup(void) chdir(getenv("HOME")); unwind_mounts(); umount_mnt2(); + clear_swap(); endwin(); @@ -551,6 +593,8 @@ process_f_flag(char *f_name) len = strlen(arg->name); if (memcmp(cp, arg->name, len) != 0) continue; + if (arg->var == NULL || arg->size == 0) + continue; cp1 = cp + len; cp1 += strspn(cp1, " \t"); if (*cp1++ != '=') diff --git a/usr.sbin/sysinst/mbr.c b/usr.sbin/sysinst/mbr.c index 46767ecfac7..df47f48775d 100644 --- a/usr.sbin/sysinst/mbr.c +++ b/usr.sbin/sysinst/mbr.c @@ -1,4 +1,4 @@ -/* $NetBSD: mbr.c,v 1.19.2.6 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: mbr.c,v 1.19.2.7 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -133,7 +133,7 @@ struct mbr_disk_partitions { struct disk_partitions dp, *dlabel; mbr_info_t mbr; uint ptn_alignment, ptn_0_offset, ext_ptn_alignment, - geo_sec, geo_head, geo_cyl; + geo_sec, geo_head, geo_cyl, target; }; const struct disk_partitioning_scheme mbr_parts; @@ -144,7 +144,7 @@ static const size_t first_part_type = MBR_PTYPE_NETBSD; /* all partition types (we are lucky, only a fixed number is possible) */ struct mbr_part_type_info mbr_gen_type_desc[256]; -const struct disk_partitioning_scheme disklabel_parts; +extern const struct disk_partitioning_scheme disklabel_parts; static void convert_mbr_chs(int, int, int, uint8_t *, uint8_t *, uint8_t *, uint32_t); @@ -318,7 +318,7 @@ free_mbr_info(mbr_info_t *m) /* * To be used only on ports which cannot provide any bios geometry */ -bool +int set_bios_geom_with_mbr_guess(struct disk_partitions *parts) { int cyl, head, sec; @@ -529,7 +529,8 @@ valid_mbr(struct mbr_sector *mbrs) } static int -read_mbr(const char *disk, size_t secsize, mbr_info_t *mbri) +read_mbr(const char *disk, size_t secsize, mbr_info_t *mbri, + struct mbr_disk_partitions *parts) { struct mbr_partition *mbrp; struct mbr_sector *mbrs = &mbri->mbr; @@ -552,7 +553,8 @@ read_mbr(const char *disk, size_t secsize, mbr_info_t *mbri) for (;;) { if (blockread(fd, secsize, mbrs, sizeof *mbrs, - (ext_base + next_ext) * (off_t)MBR_SECSIZE) - sizeof *mbrs != 0) + (ext_base + next_ext) * (off_t)MBR_SECSIZE) + - sizeof *mbrs != 0) break; if (!valid_mbr(mbrs)) @@ -605,9 +607,13 @@ read_mbr(const char *disk, size_t secsize, mbr_info_t *mbri) next_ext = mbrp->mbrp_start; } else { uint flags = 0; - if (mbrp->mbrp_type == MBR_PTYPE_NETBSD) + if (mbrp->mbrp_type == MBR_PTYPE_NETBSD) { flags |= GLM_LIKELY_FFS; - else if (mbrp->mbrp_type == MBR_PTYPE_FAT12 || + if (parts->target == ~0U) + parts->target = + mbri->sector + + mbrp->mbrp_start; + } else if (mbrp->mbrp_type == MBR_PTYPE_FAT12 || mbrp->mbrp_type == MBR_PTYPE_FAT16S || mbrp->mbrp_type == MBR_PTYPE_FAT16B || mbrp->mbrp_type == MBR_PTYPE_FAT32 || @@ -923,6 +929,7 @@ mbr_create_new(const char *disk, daddr_t start, daddr_t len, parts->geo_sec = MAXSECTOR; parts->geo_head = MAXHEAD; parts->geo_cyl = len/MAXHEAD/MAXSECTOR+1; + parts->target = ~0U; if (get_disk_geom(disk, &geo)) { parts->geo_sec = geo.dg_nsectors; @@ -995,8 +1002,10 @@ mbr_read_from_disk(const char *disk, daddr_t start, daddr_t len, size_t bps, parts->geo_head = MAXHEAD; parts->geo_cyl = len/MAXHEAD/MAXSECTOR+1; parts->dp.bytes_per_sector = bps; + parts->target = ~0U; mbr_init_default_alignments(parts, 0); - if (read_mbr(disk, parts->dp.bytes_per_sector, &parts->mbr) == -1) { + if (read_mbr(disk, parts->dp.bytes_per_sector, &parts->mbr, parts) + == -1) { free(parts); return NULL; } @@ -1117,6 +1126,8 @@ mbr_map_part_type(unsigned int t) return PT_FAT; case MBR_PTYPE_EFI: return PT_EFI_SYSTEM; + case MBR_PTYPE_LNXEXT2: + return PT_EXT2; case MBR_PTYPE_NETBSD: return PT_root; } @@ -1279,6 +1290,8 @@ mbr_get_generic_part_type(enum part_type pt) return mbr_get_gen_type_desc(MBR_PTYPE_NETBSD); case PT_FAT: return mbr_get_gen_type_desc(MBR_PTYPE_FAT32L); + case PT_EXT2: + return mbr_get_gen_type_desc(MBR_PTYPE_LNXEXT2); case PT_EFI_SYSTEM: return mbr_get_gen_type_desc(MBR_PTYPE_EFI); default: @@ -1356,8 +1369,12 @@ mbr_do_get_part_info(const struct disk_partitions *arg, part_id id, const struct mbr_partition *mp, void *cookie) { struct disk_part_info *info = cookie; + const struct mbr_disk_partitions *parts = + (const struct mbr_disk_partitions*)arg; mbr_partition_to_info(mp, mb->sector, info); + if (mp->mbrp_start + mb->sector == parts->target) + info->flags |= PTI_INSTALL_TARGET; if (mb->last_mounted[i] != NULL && mb->last_mounted[i][0] != 0) info->last_mounted = mb->last_mounted[i]; if (mb->fs_type[i] != FS_UNUSED) { @@ -1386,6 +1403,9 @@ mbr_do_get_part_info(const struct disk_partitions *arg, part_id id, case MBR_PTYPE_EFI: info->fs_type = FS_MSDOS; break; + case MBR_PTYPE_LNXEXT2: + info->fs_type = FS_EX2FS; + break; case MBR_PTYPE_XENIX_ROOT: case MBR_PTYPE_XENIX_USR: info->fs_type = FS_SYSV; @@ -1559,7 +1579,8 @@ mbr_part_attr_str(const struct disk_partitions *arg, part_id id, static bool mbr_info_to_partitition(const struct disk_part_info *info, - struct mbr_partition *mp, uint sector, const char **err_msg) + struct mbr_partition *mp, uint sector, + struct mbr_info_t *mb, size_t index, const char **err_msg) { size_t pt = mbr_type_from_gen_desc(info->nat_type); if (info->start + info->size > UINT_MAX @@ -1571,6 +1592,12 @@ mbr_info_to_partitition(const struct disk_part_info *info, mp->mbrp_start = info->start - sector; mp->mbrp_size = info->size; mp->mbrp_type = pt; + if (info->flags & PTI_INSTALL_TARGET) { + mp->mbrp_flag |= MBR_PFLAG_ACTIVE; +#ifdef BOOTSEL + strcpy(mb->mbrb.mbrbs_nametab[index], "NetBSD"); +#endif + } return true; } @@ -1751,8 +1778,12 @@ found: data.size = size; uint old_start = m->mbr.mbr_parts[i].mbrp_start; if (!mbr_info_to_partitition(&data, - &m->mbr.mbr_parts[i], m->sector, err_msg)) + &m->mbr.mbr_parts[i], m->sector, m, i, err_msg)) return false; + if (data.flags & PTI_INSTALL_TARGET) + parts->target = start; + else if (old_start == parts->target) + parts->target = -1; if (data.last_mounted && m->last_mounted[i] && data.last_mounted != m->last_mounted[i]) { free(__UNCONST(m->last_mounted[i])); @@ -2070,6 +2101,9 @@ mbr_delete_part(struct disk_partitions *arg, part_id pno, const char **err_msg) return false; } + if (parts->target == data.start) + parts->target = ~0U; + if (parts->dlabel) { /* * If we change the mbr partitioning, the we must @@ -2235,7 +2269,7 @@ mbr_add_part(struct disk_partitions *arg, /* empty slot, we can just use it */ newp = &m->mbr.mbr_parts[0]; mbr_info_to_partitition(&data, &m->mbr.mbr_parts[0], - m->sector, errmsg); + m->sector, m, 0, errmsg); if (data.last_mounted && m->last_mounted[0] && data.last_mounted != m->last_mounted[0]) { free(__UNCONST(m->last_mounted[0])); @@ -2289,7 +2323,7 @@ mbr_add_part(struct disk_partitions *arg, newp = &new_mbr->mbr.mbr_parts[0]; mbr_info_to_partitition(&data, &new_mbr->mbr.mbr_parts[0], - new_mbr->sector, errmsg); + new_mbr->sector, new_mbr, 0, errmsg); if (data.last_mounted && m->last_mounted[0] && data.last_mounted != m->last_mounted[0]) { free(__UNCONST(m->last_mounted[0])); @@ -2308,7 +2342,7 @@ mbr_add_part(struct disk_partitions *arg, newp = &new_mbr->mbr.mbr_parts[0]; mbr_info_to_partitition(&data, &new_mbr->mbr.mbr_parts[0], - new_mbr->sector, errmsg); + new_mbr->sector, new_mbr, 0, errmsg); if (data.last_mounted && m->last_mounted[0] && data.last_mounted != m->last_mounted[0]) { free(__UNCONST(m->last_mounted[0])); @@ -2372,7 +2406,7 @@ mbr_add_part(struct disk_partitions *arg, if (data.start + data.size > start + size) data.size = start + size - data.start; mbr_info_to_partitition(&data, &m->mbr.mbr_parts[free_primary], - m->sector, errmsg); + m->sector, m, free_primary, errmsg); if (data.last_mounted && m->last_mounted[free_primary] && data.last_mounted != m->last_mounted[free_primary]) { free(__UNCONST(m->last_mounted[free_primary])); @@ -2652,6 +2686,29 @@ mbr_free(struct disk_partitions *arg) free(parts); } +static void +mbr_destroy_part_scheme(struct disk_partitions *arg) +{ + struct mbr_disk_partitions *parts = (struct mbr_disk_partitions*)arg; + char diskpath[MAXPATHLEN]; + int fd; + + if (parts->dlabel != NULL) + parts->dlabel->pscheme->destroy_part_scheme(parts->dlabel); + fd = opendisk(arg->disk, O_RDWR, diskpath, sizeof(diskpath), 0); + if (fd != -1) { + char *buf; + + buf = calloc(arg->bytes_per_sector, 1); + if (buf != NULL) { + write(fd, buf, arg->bytes_per_sector); + free(buf); + } + close(fd); + } + mbr_free(arg); +} + static bool mbr_verify_for_update(struct disk_partitions *arg) { @@ -3143,6 +3200,7 @@ mbr_parts = { .post_edit_verify = mbr_verify, .pre_update_verify = mbr_verify_for_update, .free = mbr_free, + .destroy_part_scheme = mbr_destroy_part_scheme, }; #endif diff --git a/usr.sbin/sysinst/mbr.h b/usr.sbin/sysinst/mbr.h index 4efb25a8488..f3bf34a1cdd 100644 --- a/usr.sbin/sysinst/mbr.h +++ b/usr.sbin/sysinst/mbr.h @@ -1,4 +1,4 @@ -/* $NetBSD: mbr.h,v 1.3.2.1 2019/11/17 13:45:26 msaitoh Exp $ */ +/* $NetBSD: mbr.h,v 1.3.2.2 2020/10/15 19:36:50 bouyer Exp $ */ /* * Copyright 1997, 1988 Piermont Information Systems Inc. @@ -76,7 +76,7 @@ struct mbr_info_t { }; #ifdef BOOTSEL -struct mbr_bootsel *mbs; +extern struct mbr_bootsel *mbs; /* sync with src/sbin/fdisk/fdisk.c */ #define DEFAULT_BOOTDIR "/usr/mdec" @@ -102,7 +102,8 @@ int partsoverlap(struct mbr_partition *, int, int); /* from mbr.c */ int guess_biosgeom_from_parts(struct disk_partitions*, int *, int *, int *); -bool set_bios_geom_with_mbr_guess(struct disk_partitions*); +/* same return values as edit_outer_parts() */ +int set_bios_geom_with_mbr_guess(struct disk_partitions*); void set_bios_geom(struct disk_partitions *, int *cyl, int *head, int *sec); int otherpart(int); int ourpart(int); diff --git a/usr.sbin/sysinst/msg.mi.de b/usr.sbin/sysinst/msg.mi.de index e5c89b1d028..f9b9def74a9 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.7 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: msg.mi.de,v 1.13.2.8 2020/10/15 19:36:50 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -147,9 +147,6 @@ message heads message sectors {Sektoren} -message fs_isize -{Durchschnittliche Dateigröße (in Bytes)} - message mountpoint {Mountpoint (oder 'kein(e)'))} @@ -410,12 +407,6 @@ message label_offset_tail {Start ($2)} message invalid_sector_number {Ungültiger Wert} -message Select_file_system_block_size -{Wählen Sie die Blockgröße des Dateisystems aus} - -message Select_file_system_fragment_size -{Wählen Sie die Fragmentgröße des Dateisystems aus} - message packname {Bitte geben Sie Ihrer NetBSD-Festplatte einen Namen} @@ -1065,10 +1056,18 @@ message Set_Sizes {Größen der NetBSD-Partitionen festlegen} */ message Use_Default_Parts {Standard-Partitionsgößen verwenden} -message Gigabytes {Gigabytes} -message Megabytes {Megabytes} -message Cylinders {Zylinder} -message Sectors {Sektoren} +/* Called with: Example + * $0 = current partitioning name Master Boot Record (MBR) + * $1 = short version of $0 MBR + */ +message Use_Different_Part_Scheme +{Alles löschen, anderes Partitionierungsverfahren statt $1 verwenden} + +message Gigabytes {Gigabyte} +message Megabytes {Megabyte} +message Bytes {Byte} +message Cylinders {Zylinder} +message Sectors {Sektoren} message Select_medium {Medium auswählen} message ftp {FTP} message http {HTTP} @@ -1329,6 +1328,25 @@ message ptn_start {Start} message ptn_size {Größe} message ptn_end {Ende} +message ptn_bsize {Blockgröße} +message ptn_fsize {Fragmentgröße} +message ptn_isize {Durchschnittliche Dateigröße} + +/* Called with: Example + * $0 = avg file size in byte 1200 + */ +message ptn_isize_bytes {$0 Bytes (zur Inode-Bestimmung)} +message ptn_isize_dflt {4 Fragmente} + +message Select_file_system_block_size +{Wählen Sie die Blockgröße des Dateisystems aus} + +message Select_file_system_fragment_size +{Wählen Sie die Fragmentgröße des Dateisystems aus} + +message ptn_isize_prompt +{Durchschnittliche Dateigröße (in Bytes)} + message Invalid_numeric {Ungültige Zahl!} message Too_large {Zu groß!} message No_free_space {Kein freier Speicherplatz.} diff --git a/usr.sbin/sysinst/msg.mi.en b/usr.sbin/sysinst/msg.mi.en index a2d29596f91..ece04dd25d5 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.8 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: msg.mi.en,v 1.19.2.9 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -140,9 +140,6 @@ message heads message sectors {sectors} -message fs_isize -{average file size (bytes)} - message mountpoint {mount point (or 'none')} @@ -399,12 +396,6 @@ message label_offset_tail {Start ($2)} message invalid_sector_number {Badly formed number} -message Select_file_system_block_size -{Select file system block size} - -message Select_file_system_fragment_size -{Select file system fragment size} - message packname {Please enter a name for your NetBSD disk} @@ -1003,8 +994,16 @@ message Set_Sizes {Set sizes of NetBSD partitions} */ message Use_Default_Parts {Use default partition sizes} +/* Called with: Example + * $0 = current partitioning name Master Boot Record (MBR) + * $1 = short version of $0 MBR + */ +message Use_Different_Part_Scheme +{Delete everything, use different partitions (not $1)} + message Gigabytes {Gigabytes} message Megabytes {Megabytes} +message Bytes {Bytes} message Cylinders {Cylinders} message Sectors {Sectors} message Select_medium {Install from} @@ -1248,7 +1247,7 @@ message mp_already_exists {$0 already defined!} message ptnsize_replace_existing {This is an already existing partition. -To change it's size, the partition will need to be deleted and later +To change its size, the partition will need to be deleted and later recreated. All data in this partition will be lost. Would you like to delete this partition and continue?} @@ -1260,6 +1259,25 @@ message ptn_start {start} message ptn_size {size} message ptn_end {end} +message ptn_bsize {block size} +message ptn_fsize {fragment size} +message ptn_isize {avg file size} + +/* Called with: Example + * $0 = avg file size in byte 1200 + */ +message ptn_isize_bytes {$0 bytes (for number of inodes)} +message ptn_isize_dflt {4 fragments} + +message Select_file_system_block_size +{Select file system block size} + +message Select_file_system_fragment_size +{Select file system fragment size} + +message ptn_isize_prompt +{average file size (bytes)} + message No_free_space {No free space} message Invalid_numeric {Invalid numeric!} message Too_large {Too large!} diff --git a/usr.sbin/sysinst/msg.mi.es b/usr.sbin/sysinst/msg.mi.es index 7768f4b1483..575d6b7bdbc 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.7 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: msg.mi.es,v 1.14.2.8 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -147,9 +147,6 @@ message heads message sectors {sectores} -message fs_isize -{tamaño promedio del fichero (bytes)} - message mountpoint {punto de montaje (o 'ninguno')} @@ -405,12 +402,6 @@ message label_offset_tail {inicio ($2)} message invalid_sector_number {Número mal formado} -message Select_file_system_block_size -{Seleccione el tamaño de bloque del sistema de archivos} - -message Select_file_system_fragment_size -{Seleccione el tamaño de fragmento del sistema de archivos} - message packname {Por favor entroduzca un nombre para el disco NetBSD} @@ -1030,8 +1021,16 @@ message Set_Sizes {Establecer los tamaños de las particiones NetBSD} */ message Use_Default_Parts {Use default partition sizes} +/* Called with: Example + * $0 = current partitioning name Master Boot Record (MBR) + * $1 = short version of $0 MBR + */ +message Use_Different_Part_Scheme +{Delete everything, use different partitions (not $1)} + message Gigabytes {Gigabytes} message Megabytes {Megabytes} +message Bytes {Bytes} message Cylinders {Cilindros} message Sectors {Sectores} message Select_medium {Seleccione el medio} @@ -1298,7 +1297,7 @@ message mp_already_exists {$0 already defined!} message ptnsize_replace_existing {This is an already existing partition. -To change it's size, the partition will need to be deleted and later +To change its size, the partition will need to be deleted and later recreated. All data in this partition will be lost. Would you like to delete this partition and continue?} @@ -1310,6 +1309,25 @@ message ptn_start {inicio} message ptn_size {tamaño} message ptn_end {fin} +message ptn_bsize {tamaño bloque} +message ptn_fsize {tamaño frag} +message ptn_isize {tam prom archi} + +/* Called with: Example + * $0 = avg file size in byte 1200 + */ +message ptn_isize_bytes {$0 bytes (para número de inodos)} +message ptn_isize_dflt {4 fragmentos} + +message Select_file_system_block_size +{Seleccione el tamaño de bloque del sistema de archivos} + +message Select_file_system_fragment_size +{Seleccione el tamaño de fragmento del sistema de archivos} + +message ptn_isize_prompt +{tamaño promedio del fichero (bytes)} + message No_free_space {Sin espacio libre} message Invalid_numeric {Número no válido!} message Too_large {Demasiado grande!} diff --git a/usr.sbin/sysinst/msg.mi.fr b/usr.sbin/sysinst/msg.mi.fr index 5c7b5354726..35e0311a866 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.8 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: msg.mi.fr,v 1.17.2.9 2020/10/15 19:36:50 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -149,9 +149,6 @@ message heads message sectors {secteurs} -message fs_isize -{taille moyenne de fichier (octets)} - message mountpoint {point de montage (ou 'aucun')} @@ -408,12 +405,6 @@ message label_offset_tail {Début ($2)} message invalid_sector_number {nombre invalide} -message Select_file_system_block_size -{Sélectionnez la taille de bloc du système de fichiers} - -message Select_file_system_fragment_size -{Sélectionnez la taille de fragment du système de fichiers} - message packname {Veuillez donner un nom à votre disque.} @@ -996,7 +987,7 @@ Appuyez sur la touche Entrée pour confirmer votre choix. Appuyez sur "x" puis sur Entrée pour valider la sélection en cours. Par défaut : %s - Sélection actuelle : %s + Sélection actuelle : %s Heure locale : %s %s } @@ -1093,8 +1084,16 @@ message Set_Sizes {Spécifier les tailles des partitions NetBSD} */ message Use_Default_Parts {Use default partition sizes} +/* Called with: Example + * $0 = current partitioning name Master Boot Record (MBR) + * $1 = short version of $0 MBR + */ +message Use_Different_Part_Scheme +{Delete everything, use different partitions (not $1)} + message Gigabytes {Gigaoctets} message Megabytes {Mégaoctets} +message Bytes {Octets} message Cylinders {Cylindres} message Sectors {Secteurs} message Select_medium {Sélection du média d'installation} @@ -1350,7 +1349,7 @@ message mp_already_exists {$0 already defined!} message ptnsize_replace_existing {This is an already existing partition. -To change it's size, the partition will need to be deleted and later +To change its size, the partition will need to be deleted and later recreated. All data in this partition will be lost. Would you like to delete this partition and continue?} @@ -1362,6 +1361,25 @@ message ptn_start {Début} message ptn_size {taille} message ptn_end {fin} +message ptn_bsize {taille de bloc} +message ptn_fsize {taille de fragment} +message ptn_isize {taille moyenne de fichier} + +/* Called with: Example + * $0 = avg file size in byte 1200 + */ +message ptn_isize_bytes {$0 bytes} +message ptn_isize_dflt {4 fragments} + +message Select_file_system_block_size +{Sélectionnez la taille de bloc du système de fichiers} + +message Select_file_system_fragment_size +{Sélectionnez la taille de fragment du système de fichiers} + +message ptn_isize_prompt +{taille moyenne de fichier (octets)} + message No_free_space {Pas d'espace libre} message Invalid_numeric {Nombre invalide!} message Too_large {Trop grand!} diff --git a/usr.sbin/sysinst/msg.mi.pl b/usr.sbin/sysinst/msg.mi.pl index 237bbc643cc..6a38abfed9f 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.8 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: msg.mi.pl,v 1.20.2.9 2020/10/15 19:36:51 bouyer Exp $ */ /* Based on english version: */ /* NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp */ @@ -144,9 +144,6 @@ message heads message sectors {sektory} -message fs_isize -{sredni rozmiar pliku (bajty)} - message mountpoint {punkt montowania (lub 'zaden')} @@ -391,12 +388,6 @@ message label_offset_tail {Poczatek ($2)} message invalid_sector_number {Nieprawidlowa liczba} -message Select_file_system_block_size -{Wybierz rozmiar bloku dla systemu plikow} - -message Select_file_system_fragment_size -{Wybierz rozmiar fragmentu dla systemu plikow} - message packname {Podaj nazwe dla swojego dysku NetBSD} @@ -998,8 +989,16 @@ message Set_Sizes {Ustaw rozmiary partycji NetBSD} */ message Use_Default_Parts {Uzyj domyslnych rozmiarow partycji} +/* Called with: Example + * $0 = current partitioning name Master Boot Record (MBR) + * $1 = short version of $0 MBR + */ +message Use_Different_Part_Scheme +{Delete everything, use different partitions (not $1)} + message Gigabytes {Gigabajty} message Megabytes {Megabajty} +message Bytes {Bajty} message Cylinders {Cylindry} message Sectors {Sektory} message Select_medium {Wybierz nosnik} @@ -1259,6 +1258,25 @@ message ptn_start {poczatek} message ptn_size {rozmiar} message ptn_end {koniec} +message ptn_bsize {rozmiar bloku} +message ptn_fsize {rozmiar fragmentu} +message ptn_isize {Sredni rozm. pliku} + +/* Called with: Example + * $0 = avg file size in byte 1200 + */ +message ptn_isize_bytes {$0 bajtow} +message ptn_isize_dflt {4 fragmenty} + +message Select_file_system_block_size +{Wybierz rozmiar bloku dla systemu plikow} + +message Select_file_system_fragment_size +{Wybierz rozmiar fragmentu dla systemu plikow} + +message ptn_isize_prompt +{sredni rozmiar pliku (bajty)} + message No_free_space {Brak wolnego miejsca} message Invalid_numeric {Nieprawidlowa wartosc!} message Too_large {Zbyt duza wartosc!} diff --git a/usr.sbin/sysinst/part_edit.c b/usr.sbin/sysinst/part_edit.c index df27d60ef2d..cec01463b89 100644 --- a/usr.sbin/sysinst/part_edit.c +++ b/usr.sbin/sysinst/part_edit.c @@ -1,4 +1,4 @@ -/* $NetBSD: part_edit.c,v 1.7.2.4 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: part_edit.c,v 1.7.2.5 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -211,11 +211,17 @@ static int edit_part_start(menudesc *m, void *arg) { struct part_edit_info *marg = arg; + struct disk_part_info pinfo; daddr_t max_size; + if (marg->cur_id == NO_PART || + !marg->parts->pscheme->get_part_info(marg->parts, marg->cur_id, + &pinfo)) + pinfo = marg->cur; marg->cur.start = getpartoff(marg->parts, marg->cur.start); max_size = marg->parts->pscheme->max_free_space_at(marg->parts, - marg->cur.start); + pinfo.start); + max_size += pinfo.start - marg->cur.start; if (marg->cur.size > max_size) marg->cur.size = max_size; @@ -226,9 +232,14 @@ static int edit_part_size(menudesc *m, void *arg) { struct part_edit_info *marg = arg; + struct disk_part_info pinfo; - marg->cur.size = getpartsize(marg->parts, marg->cur.start, - marg->cur.size); + if (marg->cur_id == NO_PART || + !marg->parts->pscheme->get_part_info(marg->parts, marg->cur_id, + &pinfo)) + pinfo = marg->cur; + marg->cur.size = getpartsize(marg->parts, pinfo.start, + marg->cur.start, marg->cur.size); return 0; } @@ -238,13 +249,7 @@ edit_part_install(menudesc *m, void *arg) { struct part_edit_info *marg = arg; - if (pm->ptstart == marg->cur.start) { - pm->ptstart = 0; - pm->ptsize = 0; - } else { - pm->ptstart = marg->cur.start; - pm->ptsize = marg->cur.size; - } + marg->cur.flags ^= PTI_INSTALL_TARGET; return 0; } @@ -543,7 +548,7 @@ add_part_clone(menudesc *menu, void *arg) if (cid == NO_PART) continue; parts->pscheme->get_part_info(parts, cid, &cinfo); - offset = rounddown(cinfo.start+cinfo.size+align, align); + offset = roundup(cinfo.start+cinfo.size, align); } /* reload menu and start again */ @@ -566,7 +571,7 @@ add_part_entry(menudesc *m, void *arg) struct part_edit_info data = { .parts = pdata->av.arg, .first_custom_opt = PTN_OPTS_COMMON }; int ptn_menu; - daddr_t ptn_alignment; + daddr_t ptn_alignment, start; menu_ent *opts; size_t num_opts; struct disk_part_free_space space; @@ -578,12 +583,13 @@ add_part_entry(menudesc *m, void *arg) return 1; ptn_alignment = data.parts->pscheme->get_part_alignment(data.parts); + start = pm->ptstart > 0 ? pm->ptstart : -1; data.cur_id = NO_PART; memset(&data.cur, 0, sizeof(data.cur)); data.cur.nat_type = data.parts->pscheme-> get_generic_part_type(PT_root); if (data.parts->pscheme->get_free_spaces(data.parts, &space, 1, - max(sizemult, ptn_alignment), ptn_alignment, -1, -1) > 0) { + max(sizemult, ptn_alignment), ptn_alignment, start, -1) > 0) { data.cur.start = space.start; data.cur.size = space.size; } else { @@ -686,7 +692,7 @@ draw_outer_ptn_line(menudesc *m, int line, void *arg) case PTN_OPT_INSTALL: wprintw(m->mw, "%*s : %s", col_width, ptn_install, (marg->cur.nat_type->generic_ptype == PT_root && - marg->cur.start == pm->ptstart) ? yes : no); + (marg->cur.flags & PTI_INSTALL_TARGET)) ? yes : no); break; } @@ -763,7 +769,7 @@ draw_outer_part_line(menudesc *m, int opt, void *arg) return; } - if (info.start == pm->ptstart && + if ((info.flags & PTI_INSTALL_TARGET) && info.nat_type->generic_ptype == PT_root) { if (install_flag == 0) install_flag = msg_string(MSG_install_flag)[0]; @@ -960,17 +966,18 @@ parts_use_wholedisk(struct disk_partitions *parts, part_id nbsd; struct disk_part_info info; struct disk_part_free_space space; - daddr_t align; + daddr_t align, start; size_t i; parts->pscheme->delete_all_partitions(parts); align = parts->pscheme->get_part_alignment(parts); + start = pm->ptstart > 0 ? pm->ptstart : -1; if (ext_parts != NULL) { for (i = 0; i < add_ext_parts; i++) { info = ext_parts[i]; if (parts->pscheme->get_free_spaces(parts, &space, - 1, info.size, align, -1, -1) != 1) + 1, info.size, align, start, -1) != 1) return false; info.start = space.start; if (info.nat_type == NULL) @@ -984,12 +991,15 @@ parts_use_wholedisk(struct disk_partitions *parts, } if (parts->pscheme->get_free_spaces(parts, &space, 1, 3*align, - align, -1, -1) != 1) + align, start, -1) != 1) return false; memset(&info, 0, sizeof(info)); info.start = space.start; info.size = space.size; + info.flags = PTI_INSTALL_TARGET; + if (parts->pscheme->secondary_scheme != NULL) + info.flags |= PTI_SEC_CONTAINER; info.nat_type = parts->pscheme->get_generic_part_type(PT_root); nbsd = parts->pscheme->add_partition(parts, &info, NULL); @@ -1004,8 +1014,6 @@ parts_use_wholedisk(struct disk_partitions *parts, parts->pscheme->secondary_partitions(parts, info.start, true); } - pm->ptstart = info.start; - pm->ptsize = info.size; return true; } @@ -1030,6 +1038,13 @@ set_use_entire_disk(menudesc *m, void *arg) return 0; } +static int +set_switch_scheme(menudesc *m, void *arg) +{ + ((arg_rep_int*)arg)->rv = LY_OTHERSCHEME; + return 0; +} + static enum layout_type ask_fullpart(struct disk_partitions *parts) { @@ -1037,14 +1052,14 @@ ask_fullpart(struct disk_partitions *parts) const char *args[2]; int menu; size_t num_opts; - menu_ent options[3], *opt; + menu_ent options[4], *opt; daddr_t start, size; args[0] = msg_string(pm->parts->pscheme->name); args[1] = msg_string(pm->parts->pscheme->short_name); ai.args.argv = args; ai.args.argc = 2; - ai.rv = LY_SETSIZES; + ai.rv = LY_ERROR; memset(options, 0, sizeof(options)); num_opts = 0; @@ -1069,8 +1084,16 @@ ask_fullpart(struct disk_partitions *parts) opt++; num_opts++; + if (num_available_part_schemes > 1) { + opt->opt_name = MSG_Use_Different_Part_Scheme; + opt->opt_flags = OPT_EXIT; + opt->opt_action = set_switch_scheme; + opt++; + num_opts++; + } + menu = new_menu(MSG_Select_your_choice, options, num_opts, - -1, -10, 0, 0, MC_NOEXITOPT, NULL, NULL, NULL, NULL, NULL); + -1, -10, 0, 0, 0, NULL, NULL, NULL, NULL, MSG_cancel); if (menu != -1) { get_menudesc(menu)->expand_act = expand_all_option_texts; process_menu(menu, &ai); @@ -1091,10 +1114,10 @@ verify_outer_parts(struct disk_partitions *parts, bool quiet) { part_id i; int num_bsdparts; - daddr_t first_bsdstart, first_bsdsize, inst_start, inst_size; + daddr_t first_bsdstart, inst_start, inst_size; - first_bsdstart = first_bsdsize = 0; - inst_start = inst_size = 0; + first_bsdstart = inst_start = -1; + inst_size = 0; num_bsdparts = 0; for (i = 0; i < parts->num_part; i++) { struct disk_part_info info; @@ -1106,26 +1129,22 @@ verify_outer_parts(struct disk_partitions *parts, bool quiet) continue; num_bsdparts++; - if (first_bsdstart == 0) { + if (first_bsdstart < 0) { first_bsdstart = info.start; - first_bsdsize = info.size; } - if (inst_start == 0 && info.start == pm->ptstart) { + if (inst_start< 0 && (info.flags & PTI_INSTALL_TARGET)) { inst_start = info.start; inst_size = info.size; } } if (num_bsdparts == 0 || - (num_bsdparts > 1 && inst_start == 0)) { + (num_bsdparts > 1 && inst_start < 0)) { if (quiet && num_bsdparts == 0) return 0; - if (quiet && parts->pscheme->guess_install_target && - parts->pscheme->guess_install_target(parts, + if (!quiet || parts->pscheme->guess_install_target == NULL || + !parts->pscheme->guess_install_target(parts, &inst_start, &inst_size)) { - pm->ptstart = inst_start; - pm->ptsize = inst_size; - } else { if (num_bsdparts == 0) msg_display_subst(MSG_nobsdpart, 2, msg_string(parts->pscheme->name), @@ -1139,21 +1158,6 @@ verify_outer_parts(struct disk_partitions *parts, bool quiet) } } - if (pm->ptstart == 0) { - if (inst_start > 0) { - pm->ptstart = inst_start; - pm->ptsize = inst_size; - } else if (first_bsdstart > 0) { - pm->ptstart = first_bsdstart; - pm->ptsize = first_bsdsize; - } else if (parts->pscheme->guess_install_target && - parts->pscheme->guess_install_target( - parts, &inst_start, &inst_size)) { - pm->ptstart = inst_start; - pm->ptsize = inst_size; - } - } - /* * post_edit_verify returns: * 0 -> abort @@ -1192,8 +1196,6 @@ ask_outer_partsizes(struct disk_partitions *parts) set_default_sizemult(parts->disk, MEG, parts->bytes_per_sector); if (pm->current_cylsize == 0) pm->current_cylsize = 16065; /* noone cares nowadays */ - pm->ptstart = 0; - pm->ptsize = 0; memset(&data, 0, sizeof data); data.av.arg = parts; @@ -1240,7 +1242,7 @@ ask_outer_partsizes(struct disk_partitions *parts) return data.av.rv == 0; } -bool +int edit_outer_parts(struct disk_partitions *parts) { part_id i; @@ -1249,13 +1251,13 @@ edit_outer_parts(struct disk_partitions *parts) /* If targeting a wedge, do not ask for further partitioning */ if (pm && (pm->no_part || pm->no_mbr)) - return true; + return 1; /* Make sure parts has been properly initialized */ assert(parts && parts->pscheme); if (parts->pscheme->secondary_scheme == NULL) - return true; /* no outer parts */ + return 1; /* no outer parts */ if (partman_go) { layout = LY_SETSIZES; @@ -1288,6 +1290,10 @@ edit_outer_parts(struct disk_partitions *parts) msg_display_add("\n\n"); layout = ask_fullpart(parts); + if (layout == LY_ERROR) + return 0; + else if (layout == LY_OTHERSCHEME) + return -1; } if (layout == LY_USEFULL) { @@ -1316,18 +1322,18 @@ edit_outer_parts(struct disk_partitions *parts) (void)fprintf(logfp, "User answered no to destroy " "other data, aborting.\n"); - return false; + return 0; } } if (!md_parts_use_wholedisk(parts)) { hit_enter_to_continue(MSG_No_free_space, NULL); - return false; + return 0; } if (parts->pscheme->post_edit_verify) { return parts->pscheme->post_edit_verify(parts, true) == 2; } - return true; + return 1; } else if (layout == LY_SETSIZES) { return ask_outer_partsizes(parts); } else { diff --git a/usr.sbin/sysinst/partitions.c b/usr.sbin/sysinst/partitions.c index 67dcddb5a5a..9d65b4fa025 100644 --- a/usr.sbin/sysinst/partitions.c +++ b/usr.sbin/sysinst/partitions.c @@ -1,4 +1,4 @@ -/* $NetBSD: partitions.c,v 1.1.2.5 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: partitions.c,v 1.1.2.6 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 2018 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ extern const struct disk_partitioning_scheme gpt_parts; extern const struct disk_partitioning_scheme mbr_parts; #endif -#if RAW_PART != 2 +#if RAW_PART == 3 static struct disk_partitioning_scheme only_disklabel_parts; /* @@ -163,7 +163,7 @@ partitions_init(void) * only offer very few entries. */ static const struct part_scheme_desc all_descs[] = { -#if RAW_PART == 2 /* only available as primary on some architectures */ +#if RAW_PART != 3 /* only available as primary on some architectures */ { NULL, &disklabel_parts }, #endif #ifdef HAVE_GPT @@ -172,7 +172,7 @@ static const struct part_scheme_desc all_descs[] = { #ifdef HAVE_MBR { NULL, &mbr_parts }, #endif -#if RAW_PART != 2 /* "whole disk NetBSD" disklabel variant */ +#if RAW_PART == 3 /* "whole disk NetBSD" disklabel variant */ { NULL, &only_disklabel_parts }, #endif }; @@ -184,7 +184,7 @@ static const struct part_scheme_desc all_descs[] = { check_available_binaries(); -#if RAW_PART != 2 +#if RAW_PART == 3 /* generate a variant of disklabel w/o parent scheme */ only_disklabel_parts = disklabel_parts; only_disklabel_parts.name = MSG_parttype_only_disklabel; diff --git a/usr.sbin/sysinst/partitions.h b/usr.sbin/sysinst/partitions.h index d265e14e247..161d5d3b6bf 100644 --- a/usr.sbin/sysinst/partitions.h +++ b/usr.sbin/sysinst/partitions.h @@ -1,4 +1,4 @@ -/* $NetBSD: partitions.h,v 1.4.2.6 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: partitions.h,v 1.4.2.7 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 2018 The NetBSD Foundation, Inc. @@ -91,6 +91,8 @@ enum part_type { PT_root, /* the NetBSD / partition (bootable) */ PT_swap, /* the NetBSD swap partition */ PT_FAT, /* boot partition (e.g. for u-boot) */ + PT_EXT2, /* boot partition (for Linux appliances) */ + PT_SYSVBFS, /* boot partition (for some SYSV machines) */ PT_EFI_SYSTEM, /* (U)EFI boot partition */ }; @@ -115,6 +117,12 @@ struct part_type_desc { #define PTI_PSCHEME_INTERNAL 8 /* no user partition, e.g. MBRs extend partition */ #define PTI_RAW_PART 16 /* total disk */ +#define PTI_INSTALL_TARGET 32 /* marks the target partition + * assumed to become / after + * reboot; may not be + * persistent; may only be + * set for a single partition! + */ /* A single partition */ struct disk_part_info { @@ -131,10 +139,14 @@ struct disk_part_info { * returned. Backends can not rely on them to be valid. */ const char *last_mounted; /* last mount point or NULL */ - unsigned int fs_type, fs_sub_type; /* FS_* type of filesystem + unsigned int fs_type, fs_sub_type, /* FS_* type of filesystem * and for some FS a sub * type (e.g. FFSv1 vs. FFSv2) */ + fs_opt1, fs_opt2, fs_opt3; /* FS specific option, used + * for FFS block/fragsize + * and inodes + */ }; /* An unused area that may be used for new partitions */ @@ -534,6 +546,9 @@ struct disk_partitioning_scheme { /* Free all the data */ void (*free)(struct disk_partitions*); + /* Wipe all on-disk state, leave blank disk - and free data */ + void (*destroy_part_scheme)(struct disk_partitions*); + /* Scheme global cleanup */ void (*cleanup)(void); }; diff --git a/usr.sbin/sysinst/target.c b/usr.sbin/sysinst/target.c index 40431e043e1..b7512512211 100644 --- a/usr.sbin/sysinst/target.c +++ b/usr.sbin/sysinst/target.c @@ -1,4 +1,4 @@ -/* $NetBSD: target.c,v 1.8.2.4 2020/02/10 21:39:37 bouyer Exp $ */ +/* $NetBSD: target.c,v 1.8.2.5 2020/10/15 19:36:51 bouyer Exp $ */ /* * Copyright 1997 Jonathan Stone @@ -71,7 +71,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: target.c,v 1.8.2.4 2020/02/10 21:39:37 bouyer Exp $"); +__RCSID("$NetBSD: target.c,v 1.8.2.5 2020/10/15 19:36:51 bouyer Exp $"); #endif /* @@ -160,6 +160,9 @@ target_already_root(void) struct disk_partitions *parts, *inner; struct disk_part_info info; + if (pm == NULL) + return 1; + if (pm == last_pm) return last_res; @@ -436,8 +439,8 @@ cp_within_target(const char *frompath, const char *topath, int optional) char realfrom[STRSIZE]; char realto[STRSIZE]; - strncpy(realfrom, target_expand(frompath), STRSIZE); - strncpy(realto, target_expand(topath), STRSIZE); + strlcpy(realfrom, target_expand(frompath), sizeof realfrom); + strlcpy(realto, target_expand(topath), sizeof realto); if (access(realfrom, R_OK) == -1 && optional) return 0; diff --git a/usr.sbin/sysinst/util.c b/usr.sbin/sysinst/util.c index 1c081423a2d..6fd68bff484 100644 --- a/usr.sbin/sysinst/util.c +++ b/usr.sbin/sysinst/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.29.2.6 2020/01/28 10:17:58 msaitoh Exp $ */ +/* $NetBSD: util.c,v 1.29.2.7 2020/10/15 19:36:50 bouyer Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1083,6 +1083,7 @@ get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_ distinfo *dist; int status; int set, olderror, oldfound; + bool entropy_loaded = false; /* Ensure mountpoint for distribution files exists in current root. */ (void)mkdir("/mnt2", S_IRWXU| S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH); @@ -1200,7 +1201,8 @@ get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_ /* Don't discard the system's old entropy if any */ run_program(RUN_CHROOT | RUN_SILENT, - "/etc/rc.d/random_seed start"); + "/etc/rc.d/random_seed start"); + entropy_loaded = true; } /* Configure the system */ @@ -1242,7 +1244,8 @@ get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_ umount_mnt2(); /* Save entropy -- on some systems it's ~all we'll ever get */ - run_program(RUN_DISPLAY | RUN_CHROOT | RUN_FATAL | RUN_PROGRESS, + if (!update || entropy_loaded) + run_program(RUN_SILENT | RUN_CHROOT | RUN_ERROR_OK, "/etc/rc.d/random_seed stop"); /* Install/Upgrade complete ... reboot or exit to script */ hit_enter_to_continue(success_msg, NULL); @@ -1334,6 +1337,26 @@ static char *tz_selected; /* timezonename (relative to share/zoneinfo */ const char *tz_default; /* UTC, or whatever /etc/localtime points to */ static char tz_env[STRSIZE]; static int save_cursel, save_topline; +static int time_menu = -1; + +static void +update_time_display(void) +{ + time_t t; + struct tm *tm; + char cur_time[STRSIZE], *p; + + t = time(NULL); + tm = localtime(&t); + strlcpy(cur_time, safectime(&t), sizeof cur_time); + p = strchr(cur_time, '\n'); + if (p != NULL) + *p = 0; + + msg_clear(); + msg_fmt_table_add(MSG_choose_timezone, "%s%s%s%s", + tz_default, tz_selected, cur_time, tm ? tm->tm_zone : "?"); +} /* * Callback from timezone menu @@ -1341,9 +1364,7 @@ static int save_cursel, save_topline; static int set_tz_select(menudesc *m, void *arg) { - time_t t; char *new; - struct tm *tm; if (m && strcmp(tz_selected, m->opts[m->cursel].opt_name) != 0) { /* Change the displayed timezone */ @@ -1360,12 +1381,14 @@ set_tz_select(menudesc *m, void *arg) /* Warp curser to 'Exit' line on menu */ m->cursel = -1; - /* Update displayed time */ - t = time(NULL); - tm = localtime(&t); - msg_fmt_display(MSG_choose_timezone, "%s%s%s%s", - tz_default, tz_selected, safectime(&t), tm ? tm->tm_zone : - "?"); + update_time_display(); + if (time_menu >= 1) { + WINDOW *w = get_menudesc(time_menu)->mw; + if (w != NULL) { + touchwin(w); + wrefresh(w); + } + } return 0; } @@ -1520,8 +1543,6 @@ set_timezone(void) { char localtime_link[STRSIZE]; char localtime_target[STRSIZE]; - time_t t; - struct tm *tm; int menu_no; strlcpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo/"), @@ -1533,10 +1554,7 @@ set_timezone(void) tz_selected = strdup(tz_default); snprintf(tz_env, sizeof(tz_env), "%s%s", zoneinfo_dir, tz_selected); setenv("TZ", tz_env, 1); - t = time(NULL); - tm = localtime(&t); - msg_fmt_display(MSG_choose_timezone, "%s%s%s%s", - tz_default, tz_selected, safectime(&t), tm ? tm->tm_zone : "?"); + update_time_display(); signal(SIGALRM, timezone_sig); alarm(60); @@ -1549,7 +1567,9 @@ set_timezone(void) if (menu_no < 0) goto done; /* error - skip timezone setting */ + time_menu = menu_no; process_menu(menu_no, NULL); + time_menu = -1; free_menu(menu_no); @@ -2107,6 +2127,9 @@ usage_info_list_from_parts(struct part_usage_info **list, size_t *count, (*list)[no].fs_type = info.fs_type; (*list)[no].fs_version = info.fs_sub_type; } + (*list)[no].fs_opt1 = info.fs_opt1; + (*list)[no].fs_opt2 = info.fs_opt2; + (*list)[no].fs_opt3 = info.fs_opt3; no++; } return true; @@ -2172,6 +2195,7 @@ void free_usage_set(struct partition_usage_set *wanted) { /* XXX - free parts? free clone src? */ + free(wanted->write_back); free(wanted->menu_opts); free(wanted->infos); } @@ -2193,6 +2217,7 @@ free_install_desc(struct install_partition_desc *install) install->infos[j].clone_src = NULL; } #endif + free(install->write_back); free(install->infos); } |
