Pull up following revision(s) (requested by martin in ticket #436):
usr.sbin/sysinst/disks.c: revision 1.55 usr.sbin/sysinst/msg.mi.en: revision 1.24 usr.sbin/sysinst/mbr.c: revision 1.22 usr.sbin/sysinst/disks.c: revision 1.56 usr.sbin/sysinst/msg.mi.en: revision 1.25 usr.sbin/sysinst/disks.c: revision 1.57 usr.sbin/sysinst/arch/playstation2/msg.md.pl: revision 1.3 usr.sbin/sysinst/Makefile.inc: revision 1.30 usr.sbin/sysinst/configmenu.c: revision 1.11 usr.sbin/sysinst/util.c: revision 1.35 usr.sbin/sysinst/gpt.c: revision 1.12 usr.sbin/sysinst/util.c: revision 1.36 usr.sbin/sysinst/arch/playstation2/msg.md.de: revision 1.3 usr.sbin/sysinst/arch/i386/menus.md: revision 1.3 usr.sbin/sysinst/util.c: revision 1.37 usr.sbin/sysinst/part_edit.c: revision 1.11 usr.sbin/sysinst/arch/i386/msg.md.en: revision 1.2 usr.sbin/sysinst/util.c: revision 1.38 usr.sbin/sysinst/part_edit.c: revision 1.12 usr.sbin/sysinst/arch/i386/msg.md.en: revision 1.3 usr.sbin/sysinst/util.c: revision 1.39 usr.sbin/sysinst/part_edit.c: revision 1.13 usr.sbin/sysinst/arch/i386/msg.md.en: revision 1.4 usr.sbin/sysinst/disklabel.c: revision 1.15 usr.sbin/sysinst/bsddisklabel.c: revision 1.30 usr.sbin/sysinst/arch/i386/msg.md.es: revision 1.2 usr.sbin/sysinst/bsddisklabel.c: revision 1.31 usr.sbin/sysinst/arch/i386/msg.md.es: revision 1.3 usr.sbin/sysinst/arch/i386/msg.md.es: revision 1.4 usr.sbin/sysinst/mbr.h: revision 1.4 usr.sbin/sysinst/main.c: revision 1.18 usr.sbin/sysinst/partman.c: revision 1.44 usr.sbin/sysinst/msg.mi.de: revision 1.17 usr.sbin/sysinst/arch/i386/msg.md.fr: revision 1.2 usr.sbin/sysinst/msg.mi.de: revision 1.18 usr.sbin/sysinst/arch/i386/msg.md.fr: revision 1.3 usr.sbin/sysinst/arch/playstation2/msg.md.en: revision 1.3 usr.sbin/sysinst/arch/i386/msg.md.fr: revision 1.4 usr.sbin/sysinst/arch/amd64/md.c: revision 1.2 usr.sbin/sysinst/arch/ews4800mips/Makefile: revision 1.3 usr.sbin/sysinst/arch/playstation2/msg.md.es: revision 1.3 usr.sbin/sysinst/label.c: revision 1.13 usr.sbin/sysinst/Makefile.inc: revision 1.29 usr.sbin/sysinst/label.c: revision 1.14 usr.sbin/sysinst/util.c: revision 1.40 usr.sbin/sysinst/partitions.c: revision 1.5 usr.sbin/sysinst/arch/amd64/md.h: revision 1.8 usr.sbin/sysinst/msg.mi.es: revision 1.18 usr.sbin/sysinst/net.c: revision 1.34 usr.sbin/sysinst/msg.mi.es: revision 1.19 usr.sbin/sysinst/arch/i386/msg.md.pl: revision 1.2 usr.sbin/sysinst/arch/i386/md.c: revision 1.22 usr.sbin/sysinst/msg.mi.fr: revision 1.22 usr.sbin/sysinst/arch/playstation2/msg.md.fr: revision 1.3 usr.sbin/sysinst/arch/i386/msg.md.pl: revision 1.3 usr.sbin/sysinst/arch/i386/md.c: revision 1.23 usr.sbin/sysinst/msg.mi.pl: revision 1.25 usr.sbin/sysinst/msg.mi.fr: revision 1.23 usr.sbin/sysinst/arch/i386/msg.md.pl: revision 1.4 usr.sbin/sysinst/arch/i386/md.c: revision 1.24 usr.sbin/sysinst/partitions.h: revision 1.8 usr.sbin/sysinst/msg.mi.pl: revision 1.26 usr.sbin/sysinst/arch/i386/msg.md.de: revision 1.2 usr.sbin/sysinst/arch/i386/msg.md.de: revision 1.3 usr.sbin/sysinst/arch/i386/msg.md.de: revision 1.4 usr.sbin/sysinst/run.c: revision 1.13 usr.sbin/sysinst/defs.h: revision 1.46 usr.sbin/sysinst/install.c: revision 1.12 usr.sbin/sysinst/defs.h: revision 1.47 usr.sbin/sysinst/install.c: revision 1.13 usr.sbin/sysinst/defs.h: revision 1.48 Add options to the various partitioning stages that allow cloning of alien partitions (optionally including data). PR 54467: we trust our own sets, extract them with -P to allow symlink redirection (especially for updates and chroot services - back out once a better solution for those is implemented) Make cloning support optional, so we can save some space on very small install media. Drop MBR and cloning support on crunched install media. Make tar extraction flags depend on our usage of pax-as-tar or bsdtar. Fix missing newlines in bios match display, pointed out by maxv. Drop unused variable. Fix table of bios geomatries knf style adjustments Make the bootblock selection menu more sane, pointed out by maxv Make sure all menus have a translatable exit option (or none at all). On amd64 support installation with a KASLR kernel, via "custom install" and selecting the GENERIC_KASLR kernel set. Setup /prekern and boot.cfg accordingly.
This commit is contained in:
parent
9b40af6022
commit
73b240f7fc
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: Makefile.inc,v 1.22 2019/06/20 15:59:40 christos Exp $
|
# $NetBSD: Makefile.inc,v 1.22.2.1 2019/11/17 13:45:26 msaitoh Exp $
|
||||||
#
|
#
|
||||||
# Makefile for sysinst
|
# Makefile for sysinst
|
||||||
|
|
||||||
|
@ -43,6 +43,9 @@ CPPFLAGS.gpt.c+= -I${GPT_DIR}
|
||||||
CPPFLAGS+= -DHAVE_MBR
|
CPPFLAGS+= -DHAVE_MBR
|
||||||
SRCS+= mbr.c
|
SRCS+= mbr.c
|
||||||
.endif
|
.endif
|
||||||
|
.if ${NO_CLONES:Uno} == "yes"
|
||||||
|
CPPFLAGS+= -DNO_CLONES
|
||||||
|
.endif
|
||||||
|
|
||||||
MSG_MD?= msg.md.${SYSINSTLANG}
|
MSG_MD?= msg.md.${SYSINSTLANG}
|
||||||
MENUS_MD?= menus.md.${SYSINSTLANG}
|
MENUS_MD?= menus.md.${SYSINSTLANG}
|
||||||
|
@ -65,6 +68,10 @@ MSG_CMP_SH= ${.CURDIR}/../../msg_cmp.sh
|
||||||
|
|
||||||
SETS_TAR_SUFF=${"${USE_XZ_SETS:Uno}"!="no":?"tar.xz":"tgz"}
|
SETS_TAR_SUFF=${"${USE_XZ_SETS:Uno}"!="no":?"tar.xz":"tgz"}
|
||||||
|
|
||||||
|
.if ${MKBSDTAR:Uno} == "no"
|
||||||
|
CPPFLAGS+= -DUSING_PAXASTAR
|
||||||
|
.endif
|
||||||
|
|
||||||
CATALOGDIR= /usr/share/sysinst/catalog
|
CATALOGDIR= /usr/share/sysinst/catalog
|
||||||
CPPFLAGS+= -I. -I${.CURDIR}/../.. -I${.CURDIR} \
|
CPPFLAGS+= -I. -I${.CURDIR}/../.. -I${.CURDIR} \
|
||||||
-I${.CURDIR}/../../../../sbin/fsck \
|
-I${.CURDIR}/../../../../sbin/fsck \
|
||||||
|
|
|
@ -1,5 +1,22 @@
|
||||||
/* $NetBSD: md.c,v 1.1 2014/07/26 19:30:44 dholland Exp $ */
|
/* $NetBSD: md.c,v 1.1.30.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/* md.c -- Machine specific code for amd64 */
|
/* md.c -- Machine specific code for amd64 */
|
||||||
|
|
||||||
#include "../i386/md.c"
|
#include "../i386/md.c"
|
||||||
|
|
||||||
|
void amd64_md_boot_cfg_finalize(const char *path);
|
||||||
|
|
||||||
|
void
|
||||||
|
amd64_md_boot_cfg_finalize(const char *path)
|
||||||
|
{
|
||||||
|
char buf[MAXPATHLEN];
|
||||||
|
|
||||||
|
if (get_kernel_set() != SET_KERNEL_2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
run_program(RUN_CHROOT|RUN_FATAL,
|
||||||
|
"sh -c 'sed -e \"s:;boot:;pkboot:\" "
|
||||||
|
"< %s > %s.1", path, path);
|
||||||
|
snprintf(buf, sizeof buf, "%s.1", path);
|
||||||
|
mv_within_target_or_die(buf, path);
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: md.h,v 1.6.2.1 2019/11/17 07:04:37 martin Exp $ */
|
/* $NetBSD: md.h,v 1.6.2.2 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -85,6 +85,7 @@
|
||||||
* from floppy.
|
* from floppy.
|
||||||
*/
|
*/
|
||||||
#define SET_KERNEL_1_NAME "kern-GENERIC"
|
#define SET_KERNEL_1_NAME "kern-GENERIC"
|
||||||
|
#define SET_KERNEL_2_NAME "kern-GENERIC_KASLR"
|
||||||
|
|
||||||
#define SET_KERNEL_GENERIC SET_KERNEL_1
|
#define SET_KERNEL_GENERIC SET_KERNEL_1
|
||||||
|
|
||||||
|
@ -117,9 +118,13 @@ extern struct mbr_bootsel *mbs;
|
||||||
*/
|
*/
|
||||||
void x86_md_part_defaults(struct pm_devs*, struct part_usage_info**,
|
void x86_md_part_defaults(struct pm_devs*, struct part_usage_info**,
|
||||||
size_t *num_usage_infos);
|
size_t *num_usage_infos);
|
||||||
|
|
||||||
#define MD_PART_DEFAULTS(A,B,C) x86_md_part_defaults(A,&(B),&(C))
|
#define MD_PART_DEFAULTS(A,B,C) x86_md_part_defaults(A,&(B),&(C))
|
||||||
|
|
||||||
/* no need to install bootblock if installing for UEFI */
|
/* no need to install bootblock if installing for UEFI */
|
||||||
bool x86_md_need_bootblock(struct install_partition_desc *install);
|
bool x86_md_need_bootblock(struct install_partition_desc *install);
|
||||||
#define MD_NEED_BOOTBLOCK(A) x86_md_need_bootblock(A)
|
#define MD_NEED_BOOTBLOCK(A) x86_md_need_bootblock(A)
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: Makefile,v 1.2 2019/06/13 06:34:31 martin Exp $
|
# $NetBSD: Makefile,v 1.2.2.1 2019/11/17 13:45:26 msaitoh Exp $
|
||||||
#
|
#
|
||||||
# Makefile for ews4800mips
|
# Makefile for ews4800mips
|
||||||
#
|
#
|
||||||
|
@ -8,6 +8,8 @@ LANGUAGES= # no translations
|
||||||
.ifdef SMALLPROG
|
.ifdef SMALLPROG
|
||||||
NOPARTMAN= yes
|
NOPARTMAN= yes
|
||||||
NO_GPT= yes
|
NO_GPT= yes
|
||||||
|
NO_MBR= yes
|
||||||
|
NO_CLONES= yes
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.include "../../Makefile.inc"
|
.include "../../Makefile.inc"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: md.c,v 1.20.2.1 2019/08/18 13:19:52 msaitoh Exp $ */
|
/* $NetBSD: md.c,v 1.20.2.2 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -256,11 +256,12 @@ md_post_newfs_bios(struct install_partition_desc *install)
|
||||||
* Too hard to double check, so just 'know' the device numbers.
|
* Too hard to double check, so just 'know' the device numbers.
|
||||||
*/
|
*/
|
||||||
len = sizeof condev;
|
len = sizeof condev;
|
||||||
if (sysctl(conmib, __arraycount(conmib), &condev, &len, NULL, 0) != -1
|
if (sysctl(conmib, __arraycount(conmib), &condev, &len, NULL,
|
||||||
&& (condev & ~3) == 0x800) {
|
0) != -1 && (condev & ~3) == 0x800) {
|
||||||
/* Motherboard serial port */
|
/* Motherboard serial port */
|
||||||
boottype.bp_consdev = (condev & 3) + 1;
|
boottype.bp_consdev = (condev & 3) + 1;
|
||||||
/* Defaulting the baud rate to that of stdin should suffice */
|
/* Defaulting the baud rate to that of stdin should
|
||||||
|
suffice */
|
||||||
if (tcgetattr(0, &t) != -1)
|
if (tcgetattr(0, &t) != -1)
|
||||||
boottype.bp_conspeed = t.c_ispeed;
|
boottype.bp_conspeed = t.c_ispeed;
|
||||||
}
|
}
|
||||||
|
@ -375,6 +376,13 @@ md_post_newfs_uefi(struct install_partition_desc *install)
|
||||||
int
|
int
|
||||||
md_post_newfs(struct install_partition_desc *install)
|
md_post_newfs(struct install_partition_desc *install)
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = cp_to_target("/usr/mdec/prekern", "/prekern");
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
|
||||||
return uefi_boot ? md_post_newfs_uefi(install)
|
return uefi_boot ? md_post_newfs_uefi(install)
|
||||||
: md_post_newfs_bios(install);
|
: md_post_newfs_bios(install);
|
||||||
|
@ -895,7 +903,7 @@ x86_md_part_defaults(struct pm_devs *cur_pm, struct part_usage_info **partsp,
|
||||||
if (info.nat_type->generic_ptype != boot->type)
|
if (info.nat_type->generic_ptype != boot->type)
|
||||||
continue;
|
continue;
|
||||||
boot->flags &= ~PUIFLAG_ADD_OUTER;
|
boot->flags &= ~PUIFLAG_ADD_OUTER;
|
||||||
boot->flags |= PUIFLG_IS_OUTER|PUIFLAG_ADD_INNER;
|
boot->flags |= PUIFLG_IS_OUTER|PUIFLG_ADD_INNER;
|
||||||
boot->size = info.size;
|
boot->size = info.size;
|
||||||
boot->cur_start = info.start;
|
boot->cur_start = info.start;
|
||||||
boot->cur_flags = info.flags;
|
boot->cur_flags = info.flags;
|
||||||
|
@ -910,5 +918,3 @@ x86_md_need_bootblock(struct install_partition_desc *install)
|
||||||
|
|
||||||
return !uefi_boot;
|
return !uefi_boot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: menus.md,v 1.2 2019/06/20 00:43:56 christos Exp $ */
|
/* $NetBSD: menus.md,v 1.2.2.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -34,7 +34,8 @@
|
||||||
|
|
||||||
/* Menu definitions for sysinst. i386 version, machine dependent. */
|
/* Menu definitions for sysinst. i386 version, machine dependent. */
|
||||||
|
|
||||||
menu getboottype, title MSG_Bootblocks_selection, y=10, exit, no clear;
|
menu getboottype, title MSG_Bootblocks_selection, y=10, exit, no clear,
|
||||||
|
exitstring MSG_Continue;
|
||||||
display action { msg_display(MSG_getboottype);
|
display action { msg_display(MSG_getboottype);
|
||||||
switch (((struct x86_boot_params *)arg)->bp_consdev) {
|
switch (((struct x86_boot_params *)arg)->bp_consdev) {
|
||||||
default:
|
default:
|
||||||
|
@ -52,7 +53,7 @@ menu getboottype, title MSG_Bootblocks_selection, y=10, exit, no clear;
|
||||||
msg_display_add(MSG_console_unchanged);
|
msg_display_add(MSG_console_unchanged);
|
||||||
break;
|
break;
|
||||||
}};
|
}};
|
||||||
option MSG_Use_normal_bootblocks, action
|
option MSG_Use_normal_bootblocks, exit, action
|
||||||
{((struct x86_boot_params *)arg)->bp_consdev = 0; m->cursel = 7;};
|
{((struct x86_boot_params *)arg)->bp_consdev = 0; m->cursel = 7;};
|
||||||
option MSG_Use_serial_com0, action
|
option MSG_Use_serial_com0, action
|
||||||
{((struct x86_boot_params *)arg)->bp_consdev = 1; m->cursel = 5;};
|
{((struct x86_boot_params *)arg)->bp_consdev = 1; m->cursel = 5;};
|
||||||
|
@ -63,7 +64,7 @@ menu getboottype, title MSG_Bootblocks_selection, y=10, exit, no clear;
|
||||||
option MSG_Use_serial_com3, action
|
option MSG_Use_serial_com3, action
|
||||||
{((struct x86_boot_params *)arg)->bp_consdev = 4; m->cursel = 5;};
|
{((struct x86_boot_params *)arg)->bp_consdev = 4; m->cursel = 5;};
|
||||||
option MSG_serial_baud_rate, sub menu consolebaud;
|
option MSG_serial_baud_rate, sub menu consolebaud;
|
||||||
option MSG_Use_existing_bootblocks, action
|
option MSG_Use_existing_bootblocks, exit, action
|
||||||
{((struct x86_boot_params *)arg)->bp_consdev = ~0; m->cursel = 7;};
|
{((struct x86_boot_params *)arg)->bp_consdev = ~0; m->cursel = 7;};
|
||||||
|
|
||||||
menu consolebaud, title MSG_serial_baud_rate, x=40, y=13;
|
menu consolebaud, title MSG_serial_baud_rate, x=40, y=13;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.de,v 1.1 2014/07/26 19:30:45 dholland Exp $ */
|
/* $NetBSD: msg.md.de,v 1.1.24.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -82,8 +82,8 @@ message onebiosmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # Zylinder Köpfe Sektoren Anzahl Sektoren GB
|
{BIOS # Zylinder Köpfe Sektoren Anzahl Sektoren GB
|
||||||
------ -------- ----- -------- --------------- ---
|
------ -------- ----- -------- --------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
|
@ -97,13 +97,13 @@ message Use_one_of_these_disks
|
||||||
{Benutzen Sie eine dieser Festplatten}
|
{Benutzen Sie eine dieser Festplatten}
|
||||||
|
|
||||||
message biosmultmatch
|
message biosmultmatch
|
||||||
{Diese Festplatte entspricht der folgenden BIOS Disk:
|
{Diese Festplatte entspricht den folgenden BIOS Disks:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # Zylinder Köpfe Sektoren Anzahl Sektoren GB
|
{ BIOS # Zylinder Köpfe Sektoren Anzahl Sektoren GB
|
||||||
------ -------- ----- -------- --------------- ---
|
------ -------- ----- -------- ---------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
@ -165,3 +165,4 @@ message updatembr
|
||||||
NetBSD Bootcodes updaten?}
|
NetBSD Bootcodes updaten?}
|
||||||
|
|
||||||
message set_kernel_1 {Kernel (GENERIC)}
|
message set_kernel_1 {Kernel (GENERIC)}
|
||||||
|
message set_kernel_2 {Kernel (GENERIC_KASLR)}
|
||||||
|
|
|
@ -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.24.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -82,8 +82,8 @@ message onebiosmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # cylinders heads sectors total sectors GB
|
{BIOS # cylinders heads sectors total sectors GB
|
||||||
------ --------- ----- ------- ------------- ---
|
------ --------- ----- ------- ------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
|
@ -102,8 +102,8 @@ message biosmultmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # cylinders heads sectors total sectors GB
|
{ BIOS # cylinders heads sectors total sectors GB
|
||||||
------ --------- ----- ------- ------------- ----
|
------ --------- ----- ------- ------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
@ -161,3 +161,4 @@ message updatembr
|
||||||
the latest version of the NetBSD bootcode?}
|
the latest version of the NetBSD bootcode?}
|
||||||
|
|
||||||
message set_kernel_1 {Kernel (GENERIC)}
|
message set_kernel_1 {Kernel (GENERIC)}
|
||||||
|
message set_kernel_2 {Kernel (GENERIC_KASLR)}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.es,v 1.1 2014/07/26 19:30:45 dholland Exp $ */
|
/* $NetBSD: msg.md.es,v 1.1.24.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -82,8 +82,8 @@ message onebiosmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # cilindros cabez sectors sect. totales GB
|
{BIOS # cilindros cabez sectors sect. totales GB
|
||||||
------ --------- ----- ------- ------------- ---
|
------ --------- ----- ------- ------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
|
@ -102,8 +102,8 @@ message biosmultmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # cilindros cabez sectors sect totales GB
|
{ BIOS # cilindros cabez sectors sect totales GB
|
||||||
------ --------- ----- ------- ------------- ----
|
------ --------- ----- ------- ------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
@ -162,3 +162,4 @@ message updatembr
|
||||||
Record a la ultima versión del código de arranque de NetBSD?}
|
Record a la ultima versión del código de arranque de NetBSD?}
|
||||||
|
|
||||||
message set_kernel_1 {Núcleo (GENERIC)}
|
message set_kernel_1 {Núcleo (GENERIC)}
|
||||||
|
message set_kernel_2 {Kernel (GENERIC_KASLR)}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.fr,v 1.1 2014/07/26 19:30:45 dholland Exp $ */
|
/* $NetBSD: msg.md.fr,v 1.1.24.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -82,8 +82,8 @@ message onebiosmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # cylindres têtes secteurs nb total de secteurs GB
|
{BIOS # cylindres têtes secteurs nb total de secteurs GB
|
||||||
------ --------- ----- -------- -------------------- ---
|
------ --------- ----- -------- -------------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row /* XXX adjust for length of titles above */
|
message onebiosmatch_row /* XXX adjust for length of titles above */
|
||||||
|
@ -102,8 +102,8 @@ message biosmultmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # cylindres têtes secteurs nb total de secteurs GB
|
{ BIOS # cylindres têtes secteurs nb total de secteurs GB
|
||||||
------ --------- ----- -------- -------------------- ---
|
------ --------- ----- -------- -------------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row /* XXX adjust for length of titles above */
|
message biosmultmatch_row /* XXX adjust for length of titles above */
|
||||||
|
@ -157,3 +157,4 @@ message updatembr
|
||||||
avec la dernière version du code d'amorçage de NetBSD ?}
|
avec la dernière version du code d'amorçage de NetBSD ?}
|
||||||
|
|
||||||
message set_kernel_1 {Kernel (GENERIC)}
|
message set_kernel_1 {Kernel (GENERIC)}
|
||||||
|
message set_kernel_2 {Kernel (GENERIC_KASLR)}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.pl,v 1.1 2014/07/26 19:30:45 dholland Exp $ */
|
/* $NetBSD: msg.md.pl,v 1.1.24.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
/* Based on english version: */
|
/* Based on english version: */
|
||||||
/* NetBSD: msg.md.en,v 1.24 2001/01/27 07:34:39 jmc Exp */
|
/* NetBSD: msg.md.en,v 1.24 2001/01/27 07:34:39 jmc Exp */
|
||||||
|
|
||||||
|
@ -80,12 +80,12 @@ message onebiosmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # cylindry glowice sektory razem sektory GB
|
{BIOS # cylindry glowice sektory razem sektory GB
|
||||||
------ -------- ------- ------- ------------- ---
|
------ -------- ------- ------- ------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
{%#6x %8d %6d %7d %13u %3u\n}
|
{%#6x %8d %7d %7d %13u %3u\n}
|
||||||
|
|
||||||
message This_is_the_correct_geometry
|
message This_is_the_correct_geometry
|
||||||
{To jest prawidlowa geometria}
|
{To jest prawidlowa geometria}
|
||||||
|
@ -100,8 +100,8 @@ message biosmultmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # cylindry glowice sektory razem sektory GB
|
{ BIOS # cylindry glowice sektory razem sektory GB
|
||||||
------ -------- ------- ------- ------------- ---
|
------ -------- ------- ------- ------------- ----
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
@ -156,3 +156,4 @@ message updatembr
|
||||||
kodu rozruchowego NetBSD?}
|
kodu rozruchowego NetBSD?}
|
||||||
|
|
||||||
message set_kernel_1 {Kernel (GENERIC)}
|
message set_kernel_1 {Kernel (GENERIC)}
|
||||||
|
message set_kernel_2 {Kernel (GENERIC_KASLR)}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.de,v 1.2 2014/08/03 16:09:40 martin Exp $ */
|
/* $NetBSD: msg.md.de,v 1.2.30.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -62,7 +62,7 @@ message onebiosmatch
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # Zylinder Köpfe Sektoren
|
{BIOS # Zylinder Köpfe Sektoren
|
||||||
------ ---------- ------- --------
|
------ ---------- ------- --------
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
|
@ -75,7 +75,7 @@ message biosmultmatch
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # Zylinder Köpfe Sektoren
|
{ BIOS # Zylinder Köpfe Sektoren
|
||||||
------ ---------- ------- --------
|
------ ---------- ------- --------
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.en,v 1.2 2014/08/03 16:09:40 martin Exp $ */
|
/* $NetBSD: msg.md.en,v 1.2.30.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -60,8 +60,8 @@ message onebiosmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # cylinders heads sectors
|
{BIOS # cylinders heads sectors
|
||||||
------ ---------- ------- -------
|
------ ---------- ------- -------
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
|
@ -73,8 +73,8 @@ message biosmultmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # cylinders heads sectors
|
{ BIOS # cylinders heads sectors
|
||||||
------ ---------- ------- -------
|
------ ---------- ------- -------
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.es,v 1.2 2014/08/03 16:09:40 martin Exp $ */
|
/* $NetBSD: msg.md.es,v 1.2.30.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -61,7 +61,7 @@ message onebiosmatch
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # cilindros cabezal sectore
|
{BIOS # cilindros cabezal sectore
|
||||||
------ ---------- ------- -------
|
------ ---------- ------- -------
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
|
@ -73,8 +73,8 @@ message biosmultmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # cilindros cabez sectore
|
{ BIOS # cilindros cabez sectore
|
||||||
------ ---------- ------- -------
|
------ ---------- ------- -------
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.fr,v 1.2 2014/08/03 16:09:40 martin Exp $ */
|
/* $NetBSD: msg.md.fr,v 1.2.30.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -60,8 +60,8 @@ message onebiosmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # cylinders heads sectors
|
{BIOS # cylinders heads sectors
|
||||||
------ ---------- ------- -------
|
------ ---------- ------- -------
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
|
@ -73,8 +73,8 @@ message biosmultmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # cylinders heads sectors
|
{ BIOS # cylinders heads sectors
|
||||||
------ ---------- ------- -------
|
------ ---------- ------- -------
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.md.pl,v 1.2 2014/08/03 16:09:40 martin Exp $ */
|
/* $NetBSD: msg.md.pl,v 1.2.30.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
/* Based on english version: */
|
/* Based on english version: */
|
||||||
/* NetBSD: msg.md.en,v 1.1 2001/10/15 16:22:52 uch Exp */
|
/* NetBSD: msg.md.en,v 1.1 2001/10/15 16:22:52 uch Exp */
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ message onebiosmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_header
|
message onebiosmatch_header
|
||||||
{BIOS # cylindry glowice sektory
|
{BIOS # cylindry glowice sektory
|
||||||
------ ---------- ------- -------
|
------ ---------- ------- -------
|
||||||
}
|
}
|
||||||
|
|
||||||
message onebiosmatch_row
|
message onebiosmatch_row
|
||||||
|
@ -75,8 +75,8 @@ message biosmultmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_header
|
message biosmultmatch_header
|
||||||
{ BIOS # cylindry glowice sektory
|
{ BIOS # cylindry glowice sektory
|
||||||
------ ---------- ------- -------
|
------ ---------- ------- -------
|
||||||
}
|
}
|
||||||
|
|
||||||
message biosmultmatch_row
|
message biosmultmatch_row
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: bsddisklabel.c,v 1.23.2.5 2019/10/28 02:53:17 msaitoh Exp $ */
|
/* $NetBSD: bsddisklabel.c,v 1.23.2.6 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -251,6 +251,13 @@ draw_size_menu_line(menudesc *m, int opt, void *arg)
|
||||||
mount = swap;
|
mount = swap;
|
||||||
} else if (pset->infos[opt].mount[0]) {
|
} else if (pset->infos[opt].mount[0]) {
|
||||||
mount = pset->infos[opt].mount;
|
mount = pset->infos[opt].mount;
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
} else if (pset->infos[opt].flags & PUIFLG_CLONE_PARTS) {
|
||||||
|
snprintf(swap, sizeof swap, "%zu %s",
|
||||||
|
pset->infos[opt].clone_src->num_sel,
|
||||||
|
msg_string(MSG_clone_target_disp));
|
||||||
|
mount = swap;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
mount = NULL;
|
mount = NULL;
|
||||||
if (pset->infos[opt].parts->pscheme->other_partition_identifier
|
if (pset->infos[opt].parts->pscheme->other_partition_identifier
|
||||||
|
@ -319,7 +326,7 @@ add_other_ptn_size(menudesc *menu, void *arg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m = realloc(pset->menu_opts, (pset->num+4)*sizeof(*pset->menu_opts));
|
m = realloc(pset->menu_opts, (pset->num+5)*sizeof(*pset->menu_opts));
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
p = realloc(pset->infos, (pset->num+1)*sizeof(*pset->infos));
|
p = realloc(pset->infos, (pset->num+1)*sizeof(*pset->infos));
|
||||||
|
@ -348,6 +355,86 @@ add_other_ptn_size(menudesc *menu, void *arg)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
static int
|
||||||
|
inst_ext_clone(menudesc *menu, void *arg)
|
||||||
|
{
|
||||||
|
struct selected_partitions selected;
|
||||||
|
struct clone_target_menu_data data;
|
||||||
|
struct partition_usage_set *pset = arg;
|
||||||
|
struct part_usage_info *p;
|
||||||
|
menu_ent *men;
|
||||||
|
int num_men, i;
|
||||||
|
|
||||||
|
if (!select_partitions(&selected, pm->parts))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
num_men = pset->num+1;
|
||||||
|
men = calloc(num_men, sizeof *men);
|
||||||
|
if (men == NULL)
|
||||||
|
return 0;
|
||||||
|
for (i = 0; i < num_men; i++)
|
||||||
|
men[i].opt_action = clone_target_select;
|
||||||
|
men[num_men-1].opt_name = MSG_clone_target_end;
|
||||||
|
|
||||||
|
memset(&data, 0, sizeof data);
|
||||||
|
data.usage = *pset;
|
||||||
|
data.res = -1;
|
||||||
|
|
||||||
|
data.usage.menu = new_menu(MSG_clone_target_hdr,
|
||||||
|
men, num_men, 3, 2, 0, 65, MC_SCROLL,
|
||||||
|
NULL, draw_size_menu_line, NULL, NULL, MSG_cancel);
|
||||||
|
process_menu(data.usage.menu, &data);
|
||||||
|
free_menu(data.usage.menu);
|
||||||
|
free(men);
|
||||||
|
|
||||||
|
if (data.res < 0)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
/* insert clone record */
|
||||||
|
men = realloc(pset->menu_opts, (pset->num+5)*sizeof(*pset->menu_opts));
|
||||||
|
if (men == NULL)
|
||||||
|
goto err;
|
||||||
|
pset->menu_opts = men;
|
||||||
|
menu->opts = men;
|
||||||
|
menu->numopts = pset->num+4;
|
||||||
|
|
||||||
|
p = realloc(pset->infos, (pset->num+1)*sizeof(*pset->infos));
|
||||||
|
if (p == NULL)
|
||||||
|
goto err;
|
||||||
|
pset->infos = p;
|
||||||
|
|
||||||
|
men += data.res;
|
||||||
|
p += data.res;
|
||||||
|
memmove(men+1, men, sizeof(*men)*((pset->num+4)-data.res));
|
||||||
|
memmove(p+1, p, sizeof(*p)*((pset->num)-data.res));
|
||||||
|
memset(men, 0, sizeof(*men));
|
||||||
|
memset(p, 0, sizeof(*p));
|
||||||
|
p->flags = PUIFLG_CLONE_PARTS;
|
||||||
|
p->cur_part_id = NO_PART;
|
||||||
|
p->clone_src = malloc(sizeof(selected));
|
||||||
|
if (p->clone_src != NULL) {
|
||||||
|
*p->clone_src = selected;
|
||||||
|
p->clone_ndx = ~0U;
|
||||||
|
p->size = selected_parts_size(&selected);
|
||||||
|
p->parts = pset->parts;
|
||||||
|
} else {
|
||||||
|
p->clone_ndx = 0;
|
||||||
|
free_selected_partitions(&selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->cursel = data.res == 0 ? 1 : 0;
|
||||||
|
pset->num++;
|
||||||
|
fill_ptn_menu(pset);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
err:
|
||||||
|
free_selected_partitions(&selected);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
fill_ptn_menu(struct partition_usage_set *pset)
|
fill_ptn_menu(struct partition_usage_set *pset)
|
||||||
{
|
{
|
||||||
|
@ -357,9 +444,19 @@ fill_ptn_menu(struct partition_usage_set *pset)
|
||||||
size_t i;
|
size_t i;
|
||||||
daddr_t free_space;
|
daddr_t free_space;
|
||||||
|
|
||||||
memset(pset->menu_opts, 0, (pset->num+3)*sizeof(*pset->menu_opts));
|
#ifdef NO_CLONES
|
||||||
|
#define ADD_ITEMS 3
|
||||||
|
#else
|
||||||
|
#define ADD_ITEMS 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
memset(pset->menu_opts, 0, (pset->num+ADD_ITEMS)
|
||||||
|
*sizeof(*pset->menu_opts));
|
||||||
for (m = pset->menu_opts, p = pset->infos, i = 0; i < pset->num;
|
for (m = pset->menu_opts, p = pset->infos, i = 0; i < pset->num;
|
||||||
m++, p++, i++) {
|
m++, p++, i++) {
|
||||||
|
if (p->flags & PUIFLG_CLONE_PARTS)
|
||||||
|
m->opt_flags = OPT_IGNORE|OPT_NOSHORT;
|
||||||
|
else
|
||||||
m->opt_action = set_ptn_size;
|
m->opt_action = set_ptn_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,6 +468,12 @@ fill_ptn_menu(struct partition_usage_set *pset)
|
||||||
m->opt_action = add_other_ptn_size;
|
m->opt_action = add_other_ptn_size;
|
||||||
m++;
|
m++;
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
m->opt_name = MSG_clone_from_elsewhere;
|
||||||
|
m->opt_action = inst_ext_clone;
|
||||||
|
m++;
|
||||||
|
#endif
|
||||||
|
|
||||||
m->opt_name = MSG_askunits;
|
m->opt_name = MSG_askunits;
|
||||||
m->opt_menu = MENU_sizechoice;
|
m->opt_menu = MENU_sizechoice;
|
||||||
m->opt_flags = OPT_SUB;
|
m->opt_flags = OPT_SUB;
|
||||||
|
@ -552,7 +655,7 @@ get_ptn_sizes(struct partition_usage_set *pset)
|
||||||
wrefresh(stdscr);
|
wrefresh(stdscr);
|
||||||
|
|
||||||
if (pset->menu_opts == NULL)
|
if (pset->menu_opts == NULL)
|
||||||
pset->menu_opts = calloc(pset->num+3, sizeof(*pset->menu_opts));
|
pset->menu_opts = calloc(pset->num+4, sizeof(*pset->menu_opts));
|
||||||
|
|
||||||
pset->menu = -1;
|
pset->menu = -1;
|
||||||
num = fill_ptn_menu(pset);
|
num = fill_ptn_menu(pset);
|
||||||
|
@ -1000,7 +1103,7 @@ sort_and_sync_parts(struct partition_usage_set *pset)
|
||||||
continue;
|
continue;
|
||||||
if (pset->infos[i].flags & PUIFLG_JUST_MOUNTPOINT)
|
if (pset->infos[i].flags & PUIFLG_JUST_MOUNTPOINT)
|
||||||
continue;
|
continue;
|
||||||
if ((pset->infos[i].flags & (PUIFLG_IS_OUTER|PUIFLAG_ADD_INNER))
|
if ((pset->infos[i].flags & (PUIFLG_IS_OUTER|PUIFLG_ADD_INNER))
|
||||||
== PUIFLG_IS_OUTER)
|
== PUIFLG_IS_OUTER)
|
||||||
continue;
|
continue;
|
||||||
if (pno >= pset->parts->num_part)
|
if (pno >= pset->parts->num_part)
|
||||||
|
@ -1046,6 +1149,61 @@ sort_and_sync_parts(struct partition_usage_set *pset)
|
||||||
pset->infos = infos;
|
pset->infos = infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
/*
|
||||||
|
* Convert clone entries with more than one source into
|
||||||
|
* several entries with a single source each.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
normalize_clones(struct part_usage_info **infos, size_t *num)
|
||||||
|
{
|
||||||
|
size_t i, j, add_clones;
|
||||||
|
struct part_usage_info *ui, *src, *target;
|
||||||
|
struct disk_part_info info;
|
||||||
|
struct selected_partition *clone;
|
||||||
|
|
||||||
|
for (add_clones = 0, i = 0; i < *num; i++) {
|
||||||
|
if ((*infos)[i].clone_src != NULL &&
|
||||||
|
(*infos)[i].flags & PUIFLG_CLONE_PARTS &&
|
||||||
|
(*infos)[i].cur_part_id == NO_PART)
|
||||||
|
add_clones += (*infos)[i].clone_src->num_sel-1;
|
||||||
|
}
|
||||||
|
if (add_clones == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ui = calloc(*num+add_clones, sizeof(**infos));
|
||||||
|
if (ui == NULL)
|
||||||
|
return; /* can not handle this well here, drop some clones */
|
||||||
|
|
||||||
|
/* walk the list and dedup clones */
|
||||||
|
for (src = *infos, target = ui, i = 0; i < *num; i++) {
|
||||||
|
if (src != target)
|
||||||
|
*target = *src;
|
||||||
|
if (target->clone_src != NULL &&
|
||||||
|
(target->flags & PUIFLG_CLONE_PARTS) &&
|
||||||
|
target->cur_part_id == NO_PART) {
|
||||||
|
for (j = 0; j < src->clone_src->num_sel; j++) {
|
||||||
|
if (j > 0) {
|
||||||
|
target++;
|
||||||
|
*target = *src;
|
||||||
|
}
|
||||||
|
target->clone_ndx = j;
|
||||||
|
clone = &target->clone_src->selection[j];
|
||||||
|
clone->parts->pscheme->get_part_info(
|
||||||
|
clone->parts, clone->id, &info);
|
||||||
|
target->size = info.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
target++;
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
*num += add_clones;
|
||||||
|
assert((target-ui) >= 0 && (size_t)(target-ui) == *num);
|
||||||
|
free(*infos);
|
||||||
|
*infos = ui;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts,
|
apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts,
|
||||||
struct partition_usage_set *wanted, daddr_t start, daddr_t size)
|
struct partition_usage_set *wanted, daddr_t start, daddr_t size)
|
||||||
|
@ -1053,10 +1211,18 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts,
|
||||||
size_t i, exp_ndx = ~0U;
|
size_t i, exp_ndx = ~0U;
|
||||||
daddr_t planned_space = 0, nsp, from, align;
|
daddr_t planned_space = 0, nsp, from, align;
|
||||||
struct disk_part_info *infos;
|
struct disk_part_info *infos;
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
struct disk_part_info cinfo, srcinfo;
|
||||||
|
struct selected_partition *sp;
|
||||||
|
#endif
|
||||||
struct disk_part_free_space space;
|
struct disk_part_free_space space;
|
||||||
struct disk_partitions *ps = NULL;
|
struct disk_partitions *ps = NULL;
|
||||||
part_id pno, new_part_id;
|
part_id pno, new_part_id;
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
normalize_clones(&wanted->infos, &wanted->num);
|
||||||
|
#endif
|
||||||
|
|
||||||
infos = calloc(wanted->num, sizeof(*infos));
|
infos = calloc(wanted->num, sizeof(*infos));
|
||||||
if (infos == NULL) {
|
if (infos == NULL) {
|
||||||
err_msg_win(err_outofmem);
|
err_msg_win(err_outofmem);
|
||||||
|
@ -1167,14 +1333,14 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts,
|
||||||
new_part_id, &infos[i]);
|
new_part_id, &infos[i]);
|
||||||
want->cur_part_id = new_part_id;
|
want->cur_part_id = new_part_id;
|
||||||
|
|
||||||
want->flags |= PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER;
|
want->flags |= PUIFLG_ADD_INNER|PUIFLG_IS_OUTER;
|
||||||
from = rounddown(infos[i].start +
|
from = rounddown(infos[i].start +
|
||||||
infos[i].size+outer_align, outer_align);
|
infos[i].size+outer_align, outer_align);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now add new inner partitions
|
* Now add new inner partitions (and cloned partitions)
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < wanted->num && from < wanted->parts->disk_size; i++) {
|
for (i = 0; i < wanted->num && from < wanted->parts->disk_size; i++) {
|
||||||
struct part_usage_info *want = &wanted->infos[i];
|
struct part_usage_info *want = &wanted->infos[i];
|
||||||
|
@ -1183,35 +1349,70 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts,
|
||||||
continue;
|
continue;
|
||||||
if (want->flags & (PUIFLG_JUST_MOUNTPOINT|PUIFLG_IS_OUTER))
|
if (want->flags & (PUIFLG_JUST_MOUNTPOINT|PUIFLG_IS_OUTER))
|
||||||
continue;
|
continue;
|
||||||
if (want->size <= 0)
|
#ifndef NO_CLONES
|
||||||
continue;
|
if ((want->flags & PUIFLG_CLONE_PARTS) &&
|
||||||
|
want->clone_src != NULL &&
|
||||||
|
want->clone_ndx < want->clone_src->num_sel) {
|
||||||
|
sp = &want->clone_src->selection[want->clone_ndx];
|
||||||
|
if (!sp->parts->pscheme->get_part_info(
|
||||||
|
sp->parts, sp->id, &srcinfo))
|
||||||
|
continue;
|
||||||
|
if (!wanted->parts->pscheme->
|
||||||
|
adapt_foreign_part_info(wanted->parts,
|
||||||
|
&cinfo, sp->parts->pscheme, &srcinfo))
|
||||||
|
continue;
|
||||||
|
|
||||||
size_t cnt = wanted->parts->pscheme->get_free_spaces(
|
/* find space for cinfo and add a partition */
|
||||||
wanted->parts, &space, 1, want->size-align, align, from,
|
size_t cnt = wanted->parts->pscheme->get_free_spaces(
|
||||||
-1);
|
wanted->parts, &space, 1, want->size-align, align,
|
||||||
if (cnt == 0)
|
from, -1);
|
||||||
cnt = wanted->parts->pscheme->get_free_spaces(
|
if (cnt == 0)
|
||||||
wanted->parts, &space, 1,
|
cnt = wanted->parts->pscheme->get_free_spaces(
|
||||||
want->size-5*align, align, from, -1);
|
wanted->parts, &space, 1,
|
||||||
|
want->size-5*align, align, from, -1);
|
||||||
|
|
||||||
if (cnt == 0)
|
if (cnt == 0)
|
||||||
continue; /* no free space for this partition */
|
continue; /* no free space for this clone */
|
||||||
|
|
||||||
infos[i].start = space.start;
|
infos[i] = cinfo;
|
||||||
infos[i].size = min(want->size, space.size);
|
infos[i].start = space.start;
|
||||||
infos[i].nat_type =
|
new_part_id = wanted->parts->pscheme->add_partition(
|
||||||
wanted->parts->pscheme->get_fs_part_type(want->fs_type,
|
wanted->parts, &infos[i], NULL);
|
||||||
want->fs_version);
|
} else {
|
||||||
infos[i].last_mounted = want->mount;
|
#else
|
||||||
infos[i].fs_type = want->fs_type;
|
{
|
||||||
infos[i].fs_sub_type = want->fs_version;
|
#endif
|
||||||
if (want->fs_type != FS_UNUSED && want->type != PT_swap) {
|
if (want->size <= 0)
|
||||||
want->instflags |= PUIINST_NEWFS;
|
continue;
|
||||||
if (want->mount[0] != 0)
|
size_t cnt = wanted->parts->pscheme->get_free_spaces(
|
||||||
want->instflags |= PUIINST_MOUNT;
|
wanted->parts, &space, 1, want->size-align, align,
|
||||||
|
from, -1);
|
||||||
|
if (cnt == 0)
|
||||||
|
cnt = wanted->parts->pscheme->get_free_spaces(
|
||||||
|
wanted->parts, &space, 1,
|
||||||
|
want->size-5*align, align, from, -1);
|
||||||
|
|
||||||
|
if (cnt == 0)
|
||||||
|
continue; /* no free space for this partition */
|
||||||
|
|
||||||
|
infos[i].start = space.start;
|
||||||
|
infos[i].size = min(want->size, space.size);
|
||||||
|
infos[i].nat_type =
|
||||||
|
wanted->parts->pscheme->get_fs_part_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 (want->fs_type != FS_UNUSED &&
|
||||||
|
want->type != PT_swap) {
|
||||||
|
want->instflags |= PUIINST_NEWFS;
|
||||||
|
if (want->mount[0] != 0)
|
||||||
|
want->instflags |= PUIINST_MOUNT;
|
||||||
|
}
|
||||||
|
new_part_id = wanted->parts->pscheme->add_partition(
|
||||||
|
wanted->parts, &infos[i], NULL);
|
||||||
}
|
}
|
||||||
new_part_id = wanted->parts->pscheme->add_partition(
|
|
||||||
wanted->parts, &infos[i], NULL);
|
|
||||||
if (new_part_id == NO_PART)
|
if (new_part_id == NO_PART)
|
||||||
continue; /* failed to add, skip */
|
continue; /* failed to add, skip */
|
||||||
|
|
||||||
|
@ -1235,8 +1436,8 @@ apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts,
|
||||||
if (want->size <= 0)
|
if (want->size <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((want->flags & (PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER)) !=
|
if ((want->flags & (PUIFLG_ADD_INNER|PUIFLG_IS_OUTER)) !=
|
||||||
(PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER))
|
(PUIFLG_ADD_INNER|PUIFLG_IS_OUTER))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
infos[i].start = want->cur_start;
|
infos[i].start = want->cur_start;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: configmenu.c,v 1.10 2019/07/23 18:13:40 martin Exp $ */
|
/* $NetBSD: configmenu.c,v 1.10.2.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||||
|
@ -464,7 +464,7 @@ do_configmenu(struct install_partition_desc *install)
|
||||||
|
|
||||||
menu_no = new_menu(NULL, me, opts, 0, -4, 0, 70,
|
menu_no = new_menu(NULL, me, opts, 0, -4, 0, 70,
|
||||||
MC_SCROLL | MC_NOBOX | MC_DFLTEXIT,
|
MC_SCROLL | MC_NOBOX | MC_DFLTEXIT,
|
||||||
configmenu_hdr, set_config, NULL, "XXX Help String",
|
configmenu_hdr, set_config, NULL, NULL,
|
||||||
MSG_doneconfig);
|
MSG_doneconfig);
|
||||||
|
|
||||||
process_menu(menu_no, ce);
|
process_menu(menu_no, ce);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: defs.h,v 1.42.2.3 2019/11/17 07:04:34 martin Exp $ */
|
/* $NetBSD: defs.h,v 1.42.2.4 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -252,8 +252,9 @@ struct part_usage_info {
|
||||||
#define PUIFLAG_ADD_OUTER 2 /* Add this partition to the outer
|
#define PUIFLAG_ADD_OUTER 2 /* Add this partition to the outer
|
||||||
* partitions (if available) */
|
* partitions (if available) */
|
||||||
#define PUIFLG_IS_OUTER 4 /* this is an existing outer one */
|
#define PUIFLG_IS_OUTER 4 /* this is an existing outer one */
|
||||||
#define PUIFLAG_ADD_INNER 8 /* add outer also to inner */
|
#define PUIFLG_ADD_INNER 8 /* add outer also to inner */
|
||||||
#define PUIFLG_JUST_MOUNTPOINT 16 /* tmpfs of mfs mountpoints */
|
#define PUIFLG_JUST_MOUNTPOINT 16 /* tmpfs of mfs mountpoints */
|
||||||
|
#define PUIFLG_CLONE_PARTS 32 /* clone external partitions */
|
||||||
uint flags;
|
uint flags;
|
||||||
struct disk_partitions *parts; /* Where does this partition live?
|
struct disk_partitions *parts; /* Where does this partition live?
|
||||||
* We currently only support
|
* We currently only support
|
||||||
|
@ -282,6 +283,19 @@ struct part_usage_info {
|
||||||
unsigned int instflags; /* installer handling flags */
|
unsigned int instflags; /* installer handling flags */
|
||||||
uint fs_type, fs_version; /* e.g. FS_LFS, or FS_BSDFS,
|
uint fs_type, fs_version; /* e.g. FS_LFS, or FS_BSDFS,
|
||||||
* version = 2 for FFSv2 */
|
* version = 2 for FFSv2 */
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
/*
|
||||||
|
* Only != NULL when PUIFLG_CLONE_PARTS is set, describes the
|
||||||
|
* source partitions to clone here.
|
||||||
|
*/
|
||||||
|
struct selected_partitions *clone_src;
|
||||||
|
/*
|
||||||
|
* If clone_src != NULL, this record corresponds to a single
|
||||||
|
* selected source partition, if clone_ndx is a valid index in clone_src
|
||||||
|
* (>= 0 && <= clone_src->num_sel, or all of them if clone_ndx = ~0U.
|
||||||
|
*/
|
||||||
|
size_t clone_ndx;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -494,6 +508,12 @@ int clean_xfer_dir;
|
||||||
#define SETS_TAR_SUFF "tgz"
|
#define SETS_TAR_SUFF "tgz"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USING_PAXASTAR
|
||||||
|
#define TAR_EXTRACT_FLAGS "-xhepf"
|
||||||
|
#else
|
||||||
|
#define TAR_EXTRACT_FLAGS "-xpPf"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Abs. path we extract binary sets from */
|
/* Abs. path we extract binary sets from */
|
||||||
char ext_dir_bin[STRSIZE];
|
char ext_dir_bin[STRSIZE];
|
||||||
|
|
||||||
|
@ -608,6 +628,33 @@ bool is_bootable_device(const char *dev);
|
||||||
bool is_partitionable_device(const char *dev);
|
bool is_partitionable_device(const char *dev);
|
||||||
bool convert_scheme(struct pm_devs *p, bool is_boot_drive, const char **err_msg);
|
bool convert_scheme(struct pm_devs *p, bool is_boot_drive, const char **err_msg);
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
/* a single partition selected for cloning (etc) */
|
||||||
|
struct selected_partition {
|
||||||
|
struct disk_partitions *parts;
|
||||||
|
part_id id;
|
||||||
|
};
|
||||||
|
struct selected_partitions {
|
||||||
|
struct selected_partition *selection;
|
||||||
|
size_t num_sel;
|
||||||
|
bool with_data; /* partitions and their data selected */
|
||||||
|
bool free_parts; /* caller should free parts */
|
||||||
|
};
|
||||||
|
bool select_partitions(struct selected_partitions *res,
|
||||||
|
const struct disk_partitions *ignore);
|
||||||
|
daddr_t selected_parts_size(struct selected_partitions *);
|
||||||
|
void free_selected_partitions(struct selected_partitions *);
|
||||||
|
|
||||||
|
struct clone_target_menu_data {
|
||||||
|
struct partition_usage_set usage;
|
||||||
|
int res;
|
||||||
|
};
|
||||||
|
|
||||||
|
int clone_target_select(menudesc *m, void *arg);
|
||||||
|
bool clone_partition_data(struct disk_partitions *dest_parts, part_id did,
|
||||||
|
struct disk_partitions *src_parts, part_id sid);
|
||||||
|
#endif
|
||||||
|
|
||||||
struct menudesc;
|
struct menudesc;
|
||||||
void disp_cur_fspart(int, int);
|
void disp_cur_fspart(int, int);
|
||||||
int make_filesystems(struct install_partition_desc *);
|
int make_filesystems(struct install_partition_desc *);
|
||||||
|
@ -716,6 +763,7 @@ bool md_parts_use_wholedisk(struct disk_partitions*);
|
||||||
/* from util.c */
|
/* from util.c */
|
||||||
bool root_is_read_only(void);
|
bool root_is_read_only(void);
|
||||||
void get_ptn_alignment(const struct disk_partitions *parts, daddr_t *align, daddr_t *p0off);
|
void get_ptn_alignment(const struct disk_partitions *parts, daddr_t *align, daddr_t *p0off);
|
||||||
|
struct disk_partitions *get_inner_parts(struct disk_partitions *parts);
|
||||||
char* str_arg_subst(const char *, size_t, const char **);
|
char* str_arg_subst(const char *, size_t, const char **);
|
||||||
void msg_display_subst(const char *, size_t, ...);
|
void msg_display_subst(const char *, size_t, ...);
|
||||||
void msg_display_add_subst(const char *, size_t, ...);
|
void msg_display_add_subst(const char *, size_t, ...);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: disklabel.c,v 1.10.2.4 2019/10/23 06:03:24 msaitoh Exp $ */
|
/* $NetBSD: disklabel.c,v 1.10.2.5 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2018 The NetBSD Foundation, Inc.
|
* Copyright 2018 The NetBSD Foundation, Inc.
|
||||||
|
@ -140,7 +140,7 @@ disklabel_parts_new(const char *dev, daddr_t start, daddr_t len,
|
||||||
parts->l.d_secpercyl = geo.dg_nsectors * geo.dg_ntracks;
|
parts->l.d_secpercyl = geo.dg_nsectors * geo.dg_ntracks;
|
||||||
|
|
||||||
parts->dp.pscheme = &disklabel_parts;
|
parts->dp.pscheme = &disklabel_parts;
|
||||||
parts->dp.disk = dev;
|
parts->dp.disk = strdup(dev);
|
||||||
parts->dp.disk_start = start;
|
parts->dp.disk_start = start;
|
||||||
parts->dp.disk_size = parts->dp.free_space = len;
|
parts->dp.disk_size = parts->dp.free_space = len;
|
||||||
disklabel_init_default_alignment(parts, parts->l.d_secpercyl);
|
disklabel_init_default_alignment(parts, parts->l.d_secpercyl);
|
||||||
|
@ -216,7 +216,7 @@ disklabel_parts_read(const char *disk, daddr_t start, daddr_t len,
|
||||||
if (len > disklabel_parts.size_limit)
|
if (len > disklabel_parts.size_limit)
|
||||||
len = disklabel_parts.size_limit;
|
len = disklabel_parts.size_limit;
|
||||||
parts->dp.pscheme = scheme;
|
parts->dp.pscheme = scheme;
|
||||||
parts->dp.disk = disk;
|
parts->dp.disk = strdup(disk);
|
||||||
parts->dp.disk_start = start;
|
parts->dp.disk_start = start;
|
||||||
parts->dp.disk_size = parts->dp.free_space = len;
|
parts->dp.disk_size = parts->dp.free_space = len;
|
||||||
disklabel_init_default_alignment(parts, 0);
|
disklabel_init_default_alignment(parts, 0);
|
||||||
|
@ -581,6 +581,12 @@ disklabel_get_fs_part_type(unsigned fstype, unsigned subtype)
|
||||||
return disklabel_find_type(fstype, false);
|
return disklabel_find_type(fstype, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct part_type_desc *
|
||||||
|
disklabel_create_unknown_part_type(void)
|
||||||
|
{
|
||||||
|
return disklabel_find_type(FS_OTHER, false);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct part_type_desc *
|
static const struct part_type_desc *
|
||||||
disklabel_get_generic_type(enum part_type pt)
|
disklabel_get_generic_type(enum part_type pt)
|
||||||
{
|
{
|
||||||
|
@ -1076,6 +1082,7 @@ disklabel_free(struct disk_partitions *arg)
|
||||||
{
|
{
|
||||||
|
|
||||||
assert(arg != NULL);
|
assert(arg != NULL);
|
||||||
|
free(__UNCONST(arg->disk));
|
||||||
free(arg);
|
free(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1100,7 +1107,9 @@ disklabel_parts = {
|
||||||
.get_generic_part_type = disklabel_get_generic_type,
|
.get_generic_part_type = disklabel_get_generic_type,
|
||||||
.get_fs_part_type = disklabel_get_fs_part_type,
|
.get_fs_part_type = disklabel_get_fs_part_type,
|
||||||
.create_custom_part_type = disklabel_create_custom_part_type,
|
.create_custom_part_type = disklabel_create_custom_part_type,
|
||||||
|
.create_unknown_part_type = disklabel_create_unknown_part_type,
|
||||||
.get_part_alignment = disklabel_get_alignment,
|
.get_part_alignment = disklabel_get_alignment,
|
||||||
|
.adapt_foreign_part_info = generic_adapt_foreign_part_info,
|
||||||
.get_part_info = disklabel_get_part_info,
|
.get_part_info = disklabel_get_part_info,
|
||||||
.can_add_partition = disklabel_can_add_partition,
|
.can_add_partition = disklabel_can_add_partition,
|
||||||
.set_part_info = disklabel_set_part_info,
|
.set_part_info = disklabel_set_part_info,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: disks.c,v 1.44.2.10 2019/10/28 02:53:17 msaitoh Exp $ */
|
/* $NetBSD: disks.c,v 1.44.2.11 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -734,7 +734,7 @@ convert_copy(struct disk_partitions *old_parts,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!new_parts->pscheme->adapt_foreign_part_info(new_parts,
|
if (!new_parts->pscheme->adapt_foreign_part_info(new_parts,
|
||||||
&oinfo, &ninfo))
|
&ninfo, old_parts->pscheme, &oinfo))
|
||||||
continue;
|
continue;
|
||||||
new_parts->pscheme->add_partition(new_parts, &ninfo, NULL);
|
new_parts->pscheme->add_partition(new_parts, &ninfo, NULL);
|
||||||
}
|
}
|
||||||
|
@ -852,7 +852,7 @@ find_disks(const char *doingwhat, bool allow_cur_system)
|
||||||
menu_no = new_menu(MSG_Available_disks,
|
menu_no = new_menu(MSG_Available_disks,
|
||||||
dsk_menu, i, -1,
|
dsk_menu, i, -1,
|
||||||
4, 0, 0, MC_SCROLL,
|
4, 0, 0, MC_SCROLL,
|
||||||
NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, MSG_exit_menu_generic);
|
||||||
if (menu_no == -1)
|
if (menu_no == -1)
|
||||||
return -1;
|
return -1;
|
||||||
msg_fmt_display(MSG_ask_disk, "%s", doingwhat);
|
msg_fmt_display(MSG_ask_disk, "%s", doingwhat);
|
||||||
|
@ -2045,3 +2045,474 @@ get_dkwedges(struct dkwedge_info **dkw, const char *diskdev)
|
||||||
|
|
||||||
return dkwl.dkwl_nwedges;
|
return dkwl.dkwl_nwedges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
/*
|
||||||
|
* Helper structures used in the partition select menu
|
||||||
|
*/
|
||||||
|
struct single_partition {
|
||||||
|
struct disk_partitions *parts;
|
||||||
|
part_id id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sel_menu_data {
|
||||||
|
struct single_partition *partitions;
|
||||||
|
struct selected_partition result;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
select_single_part(menudesc *m, void *arg)
|
||||||
|
{
|
||||||
|
struct sel_menu_data *data = arg;
|
||||||
|
|
||||||
|
data->result.parts = data->partitions[m->cursel].parts;
|
||||||
|
data->result.id = data->partitions[m->cursel].id;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
display_single_part(menudesc *m, int opt, void *arg)
|
||||||
|
{
|
||||||
|
const struct sel_menu_data *data = arg;
|
||||||
|
struct disk_part_info info;
|
||||||
|
struct disk_partitions *parts = data->partitions[opt].parts;
|
||||||
|
part_id id = data->partitions[opt].id;
|
||||||
|
int l;
|
||||||
|
const char *desc = NULL;
|
||||||
|
char line[MENUSTRSIZE*2];
|
||||||
|
|
||||||
|
if (!parts->pscheme->get_part_info(parts, id, &info))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (parts->pscheme->other_partition_identifier != NULL)
|
||||||
|
desc = parts->pscheme->other_partition_identifier(
|
||||||
|
parts, id);
|
||||||
|
|
||||||
|
daddr_t start = info.start / sizemult;
|
||||||
|
daddr_t size = info.size / sizemult;
|
||||||
|
snprintf(line, sizeof line, "%s [%" PRIu64 " @ %" PRIu64 "]",
|
||||||
|
parts->disk, size, start);
|
||||||
|
|
||||||
|
if (info.nat_type != NULL) {
|
||||||
|
strlcat(line, " ", sizeof line);
|
||||||
|
strlcat(line, info.nat_type->description, sizeof line);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (desc != NULL) {
|
||||||
|
strlcat(line, ": ", sizeof line);
|
||||||
|
strlcat(line, desc, sizeof line);
|
||||||
|
}
|
||||||
|
|
||||||
|
l = strlen(line);
|
||||||
|
if (l >= (m->w))
|
||||||
|
strcpy(line + (m->w-3), "...");
|
||||||
|
wprintw(m->mw, "%s", line);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* is the given "test" partitions set used in the selected set?
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
|
selection_has_parts(struct selected_partitions *sel,
|
||||||
|
const struct disk_partitions *test)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < sel->num_sel; i++) {
|
||||||
|
if (sel->selection[i].parts == test)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* is the given "test" partition in the selected set?
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
|
selection_has_partition(struct selected_partitions *sel,
|
||||||
|
const struct disk_partitions *test, part_id test_id)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < sel->num_sel; i++) {
|
||||||
|
if (sel->selection[i].parts == test &&
|
||||||
|
sel->selection[i].id == test_id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* let the user select a partition, optionally skipping all partitions
|
||||||
|
* on the "ignore" device
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
|
add_select_partition(struct selected_partitions *res,
|
||||||
|
struct disk_partitions **all_parts, size_t all_cnt)
|
||||||
|
{
|
||||||
|
struct disk_partitions *ps;
|
||||||
|
struct disk_part_info info;
|
||||||
|
part_id id;
|
||||||
|
struct single_partition *partitions, *pp;
|
||||||
|
struct menu_ent *part_menu_opts, *menup;
|
||||||
|
size_t n, part_cnt;
|
||||||
|
int sel_menu;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* count how many items our menu will have
|
||||||
|
*/
|
||||||
|
part_cnt = 0;
|
||||||
|
for (n = 0; n < all_cnt; n++) {
|
||||||
|
ps = all_parts[n];
|
||||||
|
for (id = 0; id < ps->num_part; id++) {
|
||||||
|
if (selection_has_partition(res, ps, id))
|
||||||
|
continue;
|
||||||
|
if (!ps->pscheme->get_part_info(ps, id, &info))
|
||||||
|
continue;
|
||||||
|
if (info.flags & (PTI_SEC_CONTAINER|PTI_WHOLE_DISK|
|
||||||
|
PTI_PSCHEME_INTERNAL|PTI_RAW_PART))
|
||||||
|
continue;
|
||||||
|
part_cnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* create a menu from this and let the user
|
||||||
|
* select one partition
|
||||||
|
*/
|
||||||
|
part_menu_opts = NULL;
|
||||||
|
partitions = calloc(part_cnt, sizeof *partitions);
|
||||||
|
if (partitions == NULL)
|
||||||
|
goto done;
|
||||||
|
part_menu_opts = calloc(part_cnt, sizeof *part_menu_opts);
|
||||||
|
if (part_menu_opts == NULL)
|
||||||
|
goto done;
|
||||||
|
pp = partitions;
|
||||||
|
menup = part_menu_opts;
|
||||||
|
for (n = 0; n < all_cnt; n++) {
|
||||||
|
ps = all_parts[n];
|
||||||
|
for (id = 0; id < ps->num_part; id++) {
|
||||||
|
if (selection_has_partition(res, ps, id))
|
||||||
|
continue;
|
||||||
|
if (!ps->pscheme->get_part_info(ps, id, &info))
|
||||||
|
continue;
|
||||||
|
if (info.flags & (PTI_SEC_CONTAINER|PTI_WHOLE_DISK|
|
||||||
|
PTI_PSCHEME_INTERNAL|PTI_RAW_PART))
|
||||||
|
continue;
|
||||||
|
pp->parts = ps;
|
||||||
|
pp->id = id;
|
||||||
|
pp++;
|
||||||
|
menup->opt_action = select_single_part;
|
||||||
|
menup++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sel_menu = new_menu(MSG_select_foreign_part, part_menu_opts, part_cnt,
|
||||||
|
3, 3, 0, 60,
|
||||||
|
MC_SUBMENU | MC_SCROLL | MC_NOCLEAR,
|
||||||
|
NULL, display_single_part, NULL,
|
||||||
|
NULL, MSG_exit_menu_generic);
|
||||||
|
if (sel_menu != -1) {
|
||||||
|
struct selected_partition *newsels;
|
||||||
|
struct sel_menu_data data;
|
||||||
|
|
||||||
|
memset(&data, 0, sizeof data);
|
||||||
|
data.partitions = partitions;
|
||||||
|
process_menu(sel_menu, &data);
|
||||||
|
free_menu(sel_menu);
|
||||||
|
|
||||||
|
if (data.result.parts != NULL) {
|
||||||
|
newsels = realloc(res->selection,
|
||||||
|
sizeof(*res->selection)*(res->num_sel+1));
|
||||||
|
if (newsels != NULL) {
|
||||||
|
res->selection = newsels;
|
||||||
|
newsels += res->num_sel++;
|
||||||
|
newsels->parts = data.result.parts;
|
||||||
|
newsels->id = data.result.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Final cleanup
|
||||||
|
*/
|
||||||
|
done:
|
||||||
|
free(part_menu_opts);
|
||||||
|
free(partitions);
|
||||||
|
|
||||||
|
return res->num_sel > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct part_selection_and_all_parts {
|
||||||
|
struct selected_partitions *selection;
|
||||||
|
struct disk_partitions **all_parts;
|
||||||
|
size_t all_cnt;
|
||||||
|
char *title;
|
||||||
|
bool cancelled;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
toggle_clone_data(struct menudesc *m, void *arg)
|
||||||
|
{
|
||||||
|
struct part_selection_and_all_parts *sel = arg;
|
||||||
|
|
||||||
|
sel->selection->with_data = !sel->selection->with_data;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
add_another(struct menudesc *m, void *arg)
|
||||||
|
{
|
||||||
|
struct part_selection_and_all_parts *sel = arg;
|
||||||
|
|
||||||
|
add_select_partition(sel->selection, sel->all_parts, sel->all_cnt);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cancel_clone(struct menudesc *m, void *arg)
|
||||||
|
{
|
||||||
|
struct part_selection_and_all_parts *sel = arg;
|
||||||
|
|
||||||
|
sel->cancelled = true;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_sel_part_title(struct part_selection_and_all_parts *sel)
|
||||||
|
{
|
||||||
|
struct disk_part_info info;
|
||||||
|
char *buf, line[MENUSTRSIZE];
|
||||||
|
size_t buf_len, i;
|
||||||
|
|
||||||
|
buf_len = MENUSTRSIZE * (1+sel->selection->num_sel);
|
||||||
|
buf = malloc(buf_len);
|
||||||
|
if (buf == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
strcpy(buf, msg_string(MSG_select_source_hdr));
|
||||||
|
for (i = 0; i < sel->selection->num_sel; i++) {
|
||||||
|
struct selected_partition *s =
|
||||||
|
&sel->selection->selection[i];
|
||||||
|
if (!s->parts->pscheme->get_part_info(s->parts, s->id, &info))
|
||||||
|
continue;
|
||||||
|
daddr_t start = info.start / sizemult;
|
||||||
|
daddr_t size = info.size / sizemult;
|
||||||
|
sprintf(line, "\n %s [%" PRIu64 " @ %" PRIu64 "] ",
|
||||||
|
s->parts->disk, size, start);
|
||||||
|
if (info.nat_type != NULL)
|
||||||
|
strlcat(line, info.nat_type->description, sizeof(line));
|
||||||
|
strlcat(buf, line, buf_len);
|
||||||
|
}
|
||||||
|
free(sel->title);
|
||||||
|
sel->title = buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
post_sel_part(struct menudesc *m, void *arg)
|
||||||
|
{
|
||||||
|
struct part_selection_and_all_parts *sel = arg;
|
||||||
|
|
||||||
|
if (m->mw == NULL)
|
||||||
|
return;
|
||||||
|
update_sel_part_title(sel);
|
||||||
|
m->title = sel->title;
|
||||||
|
m->h = 0;
|
||||||
|
resize_menu_height(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fmt_sel_part_line(struct menudesc *m, int i, void *arg)
|
||||||
|
{
|
||||||
|
struct part_selection_and_all_parts *sel = arg;
|
||||||
|
|
||||||
|
wprintw(m->mw, "%s: %s", msg_string(MSG_clone_with_data),
|
||||||
|
sel->selection->with_data ?
|
||||||
|
msg_string(MSG_Yes) :
|
||||||
|
msg_string(MSG_No));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
select_partitions(struct selected_partitions *res,
|
||||||
|
const struct disk_partitions *ignore)
|
||||||
|
{
|
||||||
|
struct disk_desc disks[MAX_DISKS];
|
||||||
|
struct disk_partitions *ps;
|
||||||
|
struct part_selection_and_all_parts data;
|
||||||
|
struct pm_devs *i;
|
||||||
|
size_t j;
|
||||||
|
int cnt, n, m;
|
||||||
|
static menu_ent men[] = {
|
||||||
|
{ .opt_name = MSG_select_source_add,
|
||||||
|
.opt_action = add_another },
|
||||||
|
{ .opt_action = toggle_clone_data },
|
||||||
|
{ .opt_name = MSG_cancel, .opt_action = cancel_clone },
|
||||||
|
};
|
||||||
|
|
||||||
|
memset(res, 0, sizeof *res);
|
||||||
|
memset(&data, 0, sizeof data);
|
||||||
|
data.selection = res;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* collect all available partition sets
|
||||||
|
*/
|
||||||
|
data.all_cnt = 0;
|
||||||
|
if (SLIST_EMPTY(&pm_head)) {
|
||||||
|
cnt = get_disks(disks, false);
|
||||||
|
if (cnt <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* allocate two slots for each disk (primary/secondary)
|
||||||
|
*/
|
||||||
|
data.all_parts = calloc(2*cnt, sizeof *data.all_parts);
|
||||||
|
if (data.all_parts == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (n = 0; n < cnt; n++) {
|
||||||
|
if (ignore != NULL &&
|
||||||
|
strcmp(disks[n].dd_name, ignore->disk) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ps = partitions_read_disk(disks[n].dd_name,
|
||||||
|
disks[n].dd_totsec, disks[n].dd_no_mbr);
|
||||||
|
if (ps == NULL)
|
||||||
|
continue;
|
||||||
|
data.all_parts[data.all_cnt++] = ps;
|
||||||
|
ps = get_inner_parts(ps);
|
||||||
|
if (ps == NULL)
|
||||||
|
continue;
|
||||||
|
data.all_parts[data.all_cnt++] = ps;
|
||||||
|
}
|
||||||
|
if (data.all_cnt > 0)
|
||||||
|
res->free_parts = true;
|
||||||
|
} else {
|
||||||
|
cnt = 0;
|
||||||
|
SLIST_FOREACH(i, &pm_head, l)
|
||||||
|
cnt++;
|
||||||
|
|
||||||
|
data.all_parts = calloc(cnt, sizeof *data.all_parts);
|
||||||
|
if (data.all_parts == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SLIST_FOREACH(i, &pm_head, l) {
|
||||||
|
if (i->parts == NULL)
|
||||||
|
continue;
|
||||||
|
if (i->parts == ignore)
|
||||||
|
continue;
|
||||||
|
data.all_parts[data.all_cnt++] = i->parts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!add_select_partition(res, data.all_parts, data.all_cnt))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* loop with menu */
|
||||||
|
update_sel_part_title(&data);
|
||||||
|
m = new_menu(data.title, men, __arraycount(men), 3, 2, 0, 65, MC_SCROLL,
|
||||||
|
post_sel_part, fmt_sel_part_line, NULL, NULL, MSG_clone_src_done);
|
||||||
|
process_menu(m, &data);
|
||||||
|
free(data.title);
|
||||||
|
if (res->num_sel == 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* cleanup */
|
||||||
|
if (res->free_parts) {
|
||||||
|
for (j = 0; j < data.all_cnt; j++) {
|
||||||
|
if (selection_has_parts(res, data.all_parts[j]))
|
||||||
|
continue;
|
||||||
|
if (data.all_parts[j]->parent != NULL)
|
||||||
|
continue;
|
||||||
|
data.all_parts[j]->pscheme->free(data.all_parts[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(data.all_parts);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (res->free_parts) {
|
||||||
|
for (j = 0; j < data.all_cnt; j++) {
|
||||||
|
if (data.all_parts[j]->parent != NULL)
|
||||||
|
continue;
|
||||||
|
data.all_parts[j]->pscheme->free(data.all_parts[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(data.all_parts);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
free_selected_partitions(struct selected_partitions *selected)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
struct disk_partitions *parts;
|
||||||
|
|
||||||
|
if (!selected->free_parts)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < selected->num_sel; i++) {
|
||||||
|
parts = selected->selection[i].parts;
|
||||||
|
|
||||||
|
/* remove from list before testing for other instances */
|
||||||
|
selected->selection[i].parts = NULL;
|
||||||
|
|
||||||
|
/* if this is the secondary partion set, the parent owns it */
|
||||||
|
if (parts->parent != NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* only free once (we use the last one) */
|
||||||
|
if (selection_has_parts(selected, parts))
|
||||||
|
continue;
|
||||||
|
parts->pscheme->free(parts);
|
||||||
|
}
|
||||||
|
free(selected->selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
daddr_t
|
||||||
|
selected_parts_size(struct selected_partitions *selected)
|
||||||
|
{
|
||||||
|
struct disk_part_info info;
|
||||||
|
size_t i;
|
||||||
|
daddr_t s = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < selected->num_sel; i++) {
|
||||||
|
if (!selected->selection[i].parts->pscheme->get_part_info(
|
||||||
|
selected->selection[i].parts,
|
||||||
|
selected->selection[i].id, &info))
|
||||||
|
continue;
|
||||||
|
s += info.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
clone_target_select(menudesc *m, void *arg)
|
||||||
|
{
|
||||||
|
struct clone_target_menu_data *data = arg;
|
||||||
|
|
||||||
|
data->res = m->cursel;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
clone_partition_data(struct disk_partitions *dest_parts, part_id did,
|
||||||
|
struct disk_partitions *src_parts, part_id sid)
|
||||||
|
{
|
||||||
|
char src_dev[MAXPATHLEN], target_dev[MAXPATHLEN];
|
||||||
|
|
||||||
|
if (!src_parts->pscheme->get_part_device(
|
||||||
|
src_parts, sid, src_dev, sizeof src_dev, NULL,
|
||||||
|
raw_dev_name, true))
|
||||||
|
return false;
|
||||||
|
if (!dest_parts->pscheme->get_part_device(
|
||||||
|
dest_parts, did, target_dev, sizeof target_dev, NULL,
|
||||||
|
raw_dev_name, true))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return run_program(RUN_DISPLAY | RUN_PROGRESS,
|
||||||
|
"progress -f %s -b 1m dd bs=1m of=%s",
|
||||||
|
src_dev, target_dev) == 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: gpt.c,v 1.6.2.5 2019/08/27 04:21:01 msaitoh Exp $ */
|
/* $NetBSD: gpt.c,v 1.6.2.6 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2018 The NetBSD Foundation, Inc.
|
* Copyright 2018 The NetBSD Foundation, Inc.
|
||||||
|
@ -32,10 +32,12 @@
|
||||||
#include "md.h"
|
#include "md.h"
|
||||||
#include "gpt_uuid.h"
|
#include "gpt_uuid.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
#include <uuid.h>
|
||||||
|
|
||||||
bool gpt_parts_check(void); /* check for needed binaries */
|
bool gpt_parts_check(void); /* check for needed binaries */
|
||||||
|
|
||||||
|
@ -44,7 +46,8 @@ bool gpt_parts_check(void); /* check for needed binaries */
|
||||||
/* a GPT based disk_partitions interface */
|
/* a GPT based disk_partitions interface */
|
||||||
|
|
||||||
#define GUID_STR_LEN 40
|
#define GUID_STR_LEN 40
|
||||||
#define GPT_PTYPE_MAX 32 /* should be > gpt type -l | wc -l */
|
#define GPT_PTYPE_ALLOC 32 /* initial type array allocation, should be >
|
||||||
|
* gpt type -l | wc -l */
|
||||||
#define GPT_DEV_LEN 16 /* dkNN */
|
#define GPT_DEV_LEN 16 /* dkNN */
|
||||||
|
|
||||||
#define GPT_PARTS_PER_SEC 4 /* a 512 byte sector hols 4 entries */
|
#define GPT_PARTS_PER_SEC 4 /* a 512 byte sector hols 4 entries */
|
||||||
|
@ -112,8 +115,11 @@ struct {
|
||||||
{ .name = "vmresered", .fstype = FS_VMWRESV, .ptype = PT_unknown }
|
{ .name = "vmresered", .fstype = FS_VMWRESV, .ptype = PT_unknown }
|
||||||
};
|
};
|
||||||
|
|
||||||
static size_t gpt_ptype_cnt;
|
static size_t gpt_ptype_cnt = 0, gpt_ptype_alloc = 0;
|
||||||
static struct gpt_ptype_desc gpt_ptype_descs[GPT_PTYPE_MAX];
|
static struct gpt_ptype_desc *gpt_ptype_descs = NULL;
|
||||||
|
|
||||||
|
/* "well" known types with special handling */
|
||||||
|
static const struct part_type_desc *gpt_native_root;
|
||||||
|
|
||||||
/* similar to struct gpt_ent, but matching our needs */
|
/* similar to struct gpt_ent, but matching our needs */
|
||||||
struct gpt_part_entry {
|
struct gpt_part_entry {
|
||||||
|
@ -364,7 +370,7 @@ gpt_read_from_disk(const char *dev, daddr_t start, daddr_t len,
|
||||||
}
|
}
|
||||||
|
|
||||||
parts->dp.pscheme = scheme;
|
parts->dp.pscheme = scheme;
|
||||||
parts->dp.disk = dev;
|
parts->dp.disk = strdup(dev);
|
||||||
parts->dp.disk_start = start;
|
parts->dp.disk_start = start;
|
||||||
parts->dp.disk_size = disk_size;
|
parts->dp.disk_size = disk_size;
|
||||||
parts->dp.free_space = avail_size;
|
parts->dp.free_space = avail_size;
|
||||||
|
@ -449,7 +455,7 @@ gpt_create_new(const char *disk, daddr_t start, daddr_t len, daddr_t total,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
parts->dp.pscheme = &gpt_parts;
|
parts->dp.pscheme = &gpt_parts;
|
||||||
parts->dp.disk = disk;
|
parts->dp.disk = strdup(disk);
|
||||||
|
|
||||||
gpt_md_init(is_boot_drive, &parts->max_num_parts, &parts->prologue,
|
gpt_md_init(is_boot_drive, &parts->max_num_parts, &parts->prologue,
|
||||||
&parts->epilogue);
|
&parts->epilogue);
|
||||||
|
@ -709,26 +715,6 @@ gpt_get_free_spaces(const struct disk_partitions *arg,
|
||||||
max_num_result, min_space_size, align, start, ignore);
|
max_num_result, min_space_size, align, start, ignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
|
||||||
gpt_adapt(const struct disk_partitions *arg,
|
|
||||||
const struct disk_part_info *src, struct disk_part_info *dest)
|
|
||||||
{
|
|
||||||
/* slightly simplistic, enhance when needed */
|
|
||||||
memcpy(dest, src, sizeof(*dest));
|
|
||||||
|
|
||||||
if (src->nat_type == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
dest->nat_type = arg->pscheme->get_generic_part_type(
|
|
||||||
src->nat_type->generic_ptype);
|
|
||||||
if (dest->nat_type == NULL)
|
|
||||||
dest->nat_type = arg->pscheme->get_generic_part_type(
|
|
||||||
PT_unknown);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gpt_match_ptype(const char *name, struct gpt_ptype_desc *t)
|
gpt_match_ptype(const char *name, struct gpt_ptype_desc *t)
|
||||||
{
|
{
|
||||||
|
@ -739,6 +725,11 @@ gpt_match_ptype(const char *name, struct gpt_ptype_desc *t)
|
||||||
t->gent.generic_ptype = gpt_fs_types[i].ptype;
|
t->gent.generic_ptype = gpt_fs_types[i].ptype;
|
||||||
t->fsflags = gpt_fs_types[i].fsflags;
|
t->fsflags = gpt_fs_types[i].fsflags;
|
||||||
t->default_fs_type = gpt_fs_types[i].fstype;
|
t->default_fs_type = gpt_fs_types[i].fstype;
|
||||||
|
|
||||||
|
/* recongnize special entries */
|
||||||
|
if (gpt_native_root == NULL && i == 0)
|
||||||
|
gpt_native_root = &t->gent;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -751,10 +742,20 @@ gpt_match_ptype(const char *name, struct gpt_ptype_desc *t)
|
||||||
static void
|
static void
|
||||||
gpt_internal_add_ptype(const char *uid, const char *name, const char *desc)
|
gpt_internal_add_ptype(const char *uid, const char *name, const char *desc)
|
||||||
{
|
{
|
||||||
|
if (gpt_ptype_cnt >= gpt_ptype_alloc) {
|
||||||
|
gpt_ptype_alloc = gpt_ptype_alloc ? 2*gpt_ptype_alloc
|
||||||
|
: GPT_PTYPE_ALLOC;
|
||||||
|
struct gpt_ptype_desc *nptypes = realloc(gpt_ptype_descs,
|
||||||
|
gpt_ptype_alloc*sizeof(*gpt_ptype_descs));
|
||||||
|
if (nptypes == 0)
|
||||||
|
errx(EXIT_FAILURE, "out of memory");
|
||||||
|
gpt_ptype_descs = nptypes;
|
||||||
|
}
|
||||||
|
|
||||||
strlcpy(gpt_ptype_descs[gpt_ptype_cnt].tid, uid,
|
strlcpy(gpt_ptype_descs[gpt_ptype_cnt].tid, uid,
|
||||||
sizeof(gpt_ptype_descs[gpt_ptype_cnt].tid));
|
sizeof(gpt_ptype_descs[gpt_ptype_cnt].tid));
|
||||||
gpt_ptype_descs[gpt_ptype_cnt].gent.short_desc = name;
|
gpt_ptype_descs[gpt_ptype_cnt].gent.short_desc = strdup(name);
|
||||||
gpt_ptype_descs[gpt_ptype_cnt].gent.description = desc;
|
gpt_ptype_descs[gpt_ptype_cnt].gent.description = strdup(desc);
|
||||||
gpt_match_ptype(name, &gpt_ptype_descs[gpt_ptype_cnt]);
|
gpt_match_ptype(name, &gpt_ptype_descs[gpt_ptype_cnt]);
|
||||||
gpt_ptype_cnt++;
|
gpt_ptype_cnt++;
|
||||||
}
|
}
|
||||||
|
@ -766,6 +767,19 @@ gpt_init_ptypes(void)
|
||||||
gpt_uuid_query(gpt_internal_add_ptype);
|
gpt_uuid_query(gpt_internal_add_ptype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gpt_cleanup(void)
|
||||||
|
{
|
||||||
|
/* free all of gpt_ptype_descs */
|
||||||
|
for (size_t i = 0; i < gpt_ptype_cnt; i++) {
|
||||||
|
free(__UNCONST(gpt_ptype_descs[i].gent.short_desc));
|
||||||
|
free(__UNCONST(gpt_ptype_descs[i].gent.description));
|
||||||
|
}
|
||||||
|
free(gpt_ptype_descs);
|
||||||
|
gpt_ptype_descs = NULL;
|
||||||
|
gpt_ptype_cnt = gpt_ptype_alloc = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
gpt_type_count(void)
|
gpt_type_count(void)
|
||||||
{
|
{
|
||||||
|
@ -793,6 +807,11 @@ gpt_get_generic_type(enum part_type gent)
|
||||||
if (gpt_ptype_cnt == 0)
|
if (gpt_ptype_cnt == 0)
|
||||||
gpt_init_ptypes();
|
gpt_init_ptypes();
|
||||||
|
|
||||||
|
if (gent == PT_root)
|
||||||
|
return gpt_native_root;
|
||||||
|
if (gent == PT_unknown)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (size_t i = 0; i < gpt_ptype_cnt; i++)
|
for (size_t i = 0; i < gpt_ptype_cnt; i++)
|
||||||
if (gpt_ptype_descs[i].gent.generic_ptype == gent)
|
if (gpt_ptype_descs[i].gent.generic_ptype == gent)
|
||||||
return &gpt_ptype_descs[i].gent;
|
return &gpt_ptype_descs[i].gent;
|
||||||
|
@ -863,7 +882,61 @@ gpt_get_fs_part_type(unsigned fstype, unsigned fs_sub_type)
|
||||||
if (fstype == gpt_fs_types[i].fstype)
|
if (fstype == gpt_fs_types[i].fstype)
|
||||||
return gpt_find_type(gpt_fs_types[i].name);
|
return gpt_find_type(gpt_fs_types[i].name);
|
||||||
|
|
||||||
return gpt_get_generic_type(PT_root);
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct part_type_desc *
|
||||||
|
gpt_get_uuid_part_type(const uuid_t *id)
|
||||||
|
{
|
||||||
|
char str[GUID_STR_LEN], desc[GUID_STR_LEN + MENUSTRSIZE];
|
||||||
|
const struct gpt_ptype_desc *t;
|
||||||
|
char *guid = NULL;
|
||||||
|
uint32_t err;
|
||||||
|
|
||||||
|
uuid_to_string(id, &guid, &err);
|
||||||
|
strlcpy(str, err == uuid_s_ok ? guid : "-", sizeof str);
|
||||||
|
free(guid);
|
||||||
|
|
||||||
|
t = gpt_find_guid_type(str);
|
||||||
|
if (t == NULL) {
|
||||||
|
snprintf(desc, sizeof desc, "%s (%s)",
|
||||||
|
msg_string(MSG_custom_type), str);
|
||||||
|
gpt_internal_add_ptype(str, str, desc);
|
||||||
|
t = gpt_find_guid_type(str);
|
||||||
|
assert(t != NULL);
|
||||||
|
}
|
||||||
|
return &t->gent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct part_type_desc *
|
||||||
|
gpt_create_custom_part_type(const char *custom, const char **err_msg)
|
||||||
|
{
|
||||||
|
uuid_t id;
|
||||||
|
uint32_t err;
|
||||||
|
|
||||||
|
uuid_from_string(custom, &id, &err);
|
||||||
|
if (err_msg != NULL &&
|
||||||
|
(err == uuid_s_invalid_string_uuid || err == uuid_s_bad_version)) {
|
||||||
|
*err_msg = MSG_invalid_guid;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (err != uuid_s_ok)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return gpt_get_uuid_part_type(&id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct part_type_desc *
|
||||||
|
gpt_create_unknown_part_type(void)
|
||||||
|
{
|
||||||
|
uuid_t id;
|
||||||
|
uint32_t err;
|
||||||
|
|
||||||
|
uuid_create(&id, &err);
|
||||||
|
if (err != uuid_s_ok)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return gpt_get_uuid_part_type(&id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static daddr_t
|
static daddr_t
|
||||||
|
@ -1312,9 +1385,11 @@ gpt_write_to_disk(struct disk_partitions *arg)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Collect first root and efi partition (if available)
|
* Collect first root and efi partition (if available), clear
|
||||||
|
* "have wedge" flags.
|
||||||
*/
|
*/
|
||||||
for (pno = 0, p = parts->partitions; p != NULL; p = p->gp_next, pno++) {
|
for (pno = 0, p = parts->partitions; p != NULL; p = p->gp_next, pno++) {
|
||||||
|
p->gp_flags &= ~GPEF_WEDGE;
|
||||||
if (root_id == NO_PART && p->gp_type != NULL) {
|
if (root_id == NO_PART && p->gp_type != NULL) {
|
||||||
if (p->gp_type->gent.generic_ptype == PT_root &&
|
if (p->gp_type->gent.generic_ptype == PT_root &&
|
||||||
p->gp_start == pm->ptstart) {
|
p->gp_start == pm->ptstart) {
|
||||||
|
@ -1455,6 +1530,7 @@ gpt_free(struct disk_partitions *arg)
|
||||||
n = p->gp_next;
|
n = p->gp_next;
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
free(__UNCONST(parts->dp.disk));
|
||||||
free(parts);
|
free(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1657,6 +1733,8 @@ gpt_parts = {
|
||||||
.get_part_type = gpt_get_ptype,
|
.get_part_type = gpt_get_ptype,
|
||||||
.get_generic_part_type = gpt_get_generic_type,
|
.get_generic_part_type = gpt_get_generic_type,
|
||||||
.get_fs_part_type = gpt_get_fs_part_type,
|
.get_fs_part_type = gpt_get_fs_part_type,
|
||||||
|
.create_custom_part_type = gpt_create_custom_part_type,
|
||||||
|
.create_unknown_part_type = gpt_create_unknown_part_type,
|
||||||
.get_part_alignment = gpt_get_part_alignment,
|
.get_part_alignment = gpt_get_part_alignment,
|
||||||
.read_from_disk = gpt_read_from_disk,
|
.read_from_disk = gpt_read_from_disk,
|
||||||
.create_new_for_disk = gpt_create_new,
|
.create_new_for_disk = gpt_create_new,
|
||||||
|
@ -1671,7 +1749,7 @@ gpt_parts = {
|
||||||
.get_part_device = gpt_get_part_device,
|
.get_part_device = gpt_get_part_device,
|
||||||
.max_free_space_at = gpt_max_free_space_at,
|
.max_free_space_at = gpt_max_free_space_at,
|
||||||
.get_free_spaces = gpt_get_free_spaces,
|
.get_free_spaces = gpt_get_free_spaces,
|
||||||
.adapt_foreign_part_info = gpt_adapt,
|
.adapt_foreign_part_info = generic_adapt_foreign_part_info,
|
||||||
.get_part_info = gpt_get_part_info,
|
.get_part_info = gpt_get_part_info,
|
||||||
.get_part_attr_str = gpt_get_part_attr_str,
|
.get_part_attr_str = gpt_get_part_attr_str,
|
||||||
.set_part_info = gpt_set_part_info,
|
.set_part_info = gpt_set_part_info,
|
||||||
|
@ -1680,4 +1758,5 @@ gpt_parts = {
|
||||||
.delete_partition = gpt_delete_partition,
|
.delete_partition = gpt_delete_partition,
|
||||||
.write_to_disk = gpt_write_to_disk,
|
.write_to_disk = gpt_write_to_disk,
|
||||||
.free = gpt_free,
|
.free = gpt_free,
|
||||||
|
.cleanup = gpt_cleanup,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: install.c,v 1.9.2.1 2019/08/18 13:29:15 msaitoh Exp $ */
|
/* $NetBSD: install.c,v 1.9.2.2 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
/* install.c -- system installation. */
|
/* install.c -- system installation. */
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
@ -49,6 +50,9 @@ static bool
|
||||||
write_all_parts(struct install_partition_desc *install)
|
write_all_parts(struct install_partition_desc *install)
|
||||||
{
|
{
|
||||||
struct disk_partitions **allparts, *parts;
|
struct disk_partitions **allparts, *parts;
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
struct selected_partition *src;
|
||||||
|
#endif
|
||||||
size_t num_parts, i, j;
|
size_t num_parts, i, j;
|
||||||
bool found, res;
|
bool found, res;
|
||||||
|
|
||||||
|
@ -75,7 +79,7 @@ write_all_parts(struct install_partition_desc *install)
|
||||||
allparts[num_parts++] = parts;
|
allparts[num_parts++] = parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do four phases, abort anytime and go out, returning res */
|
/* do multiple phases, abort anytime and go out, returning res */
|
||||||
|
|
||||||
res = true;
|
res = true;
|
||||||
|
|
||||||
|
@ -98,7 +102,22 @@ write_all_parts(struct install_partition_desc *install)
|
||||||
/* phase 3: now we may have a first chance to enable swap space */
|
/* phase 3: now we may have a first chance to enable swap space */
|
||||||
set_swap_if_low_ram(install);
|
set_swap_if_low_ram(install);
|
||||||
|
|
||||||
/* phase 4: post disklabel (used for updating boot loaders) */
|
#ifndef NO_CLONES
|
||||||
|
/* phase 4: copy any cloned partitions data (if requested) */
|
||||||
|
for (i = 0; i < install->num; i++) {
|
||||||
|
if ((install->infos[i].flags & PUIFLG_CLONE_PARTS) == 0
|
||||||
|
|| install->infos[i].clone_src == NULL
|
||||||
|
|| !install->infos[i].clone_src->with_data)
|
||||||
|
continue;
|
||||||
|
src = &install->infos[i].clone_src
|
||||||
|
->selection[install->infos[i].clone_ndx];
|
||||||
|
clone_partition_data(install->infos[i].parts,
|
||||||
|
install->infos[i].cur_part_id,
|
||||||
|
src->parts, src->id);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* phase 5: post disklabel (used for updating boot loaders) */
|
||||||
for (i = 0; i < num_parts; i++) {
|
for (i = 0; i < num_parts; i++) {
|
||||||
if (!md_post_disklabel(install, allparts[i])) {
|
if (!md_post_disklabel(install, allparts[i])) {
|
||||||
res = false;
|
res = false;
|
||||||
|
@ -217,5 +236,5 @@ do_install(void)
|
||||||
hit_enter_to_continue(MSG_instcomplete, NULL);
|
hit_enter_to_continue(MSG_instcomplete, NULL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
free(install.infos);
|
free_install_desc(&install);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: label.c,v 1.10.2.2 2019/08/05 04:38:47 msaitoh Exp $ */
|
/* $NetBSD: label.c,v 1.10.2.3 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Jonathan Stone
|
* Copyright 1997 Jonathan Stone
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
__RCSID("$NetBSD: label.c,v 1.10.2.2 2019/08/05 04:38:47 msaitoh Exp $");
|
__RCSID("$NetBSD: label.c,v 1.10.2.3 2019/11/17 13:45:26 msaitoh Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -1113,11 +1113,16 @@ fmt_fspart_header(menudesc *menu, void *arg)
|
||||||
{
|
{
|
||||||
struct partition_usage_set *pset = arg;
|
struct partition_usage_set *pset = arg;
|
||||||
char total[6], free_space[6], scol[13], ecol[13], szcol[13],
|
char total[6], free_space[6], scol[13], ecol[13], szcol[13],
|
||||||
sepline[MENUSTRSIZE], *p;
|
sepline[MENUSTRSIZE], *p, desc[MENUSTRSIZE];
|
||||||
const char *fstype, *flags;
|
const char *fstype, *flags;
|
||||||
int i;
|
int i;
|
||||||
bool with_inst_flag = pset->parts->parent == NULL;
|
size_t ptn;
|
||||||
|
bool with_clone, with_inst_flag = pset->parts->parent == NULL;
|
||||||
|
|
||||||
|
with_clone = false;
|
||||||
|
for (ptn = 0; ptn < pset->num && !with_clone; ptn++)
|
||||||
|
if (pset->infos[ptn].flags & PUIFLG_CLONE_PARTS)
|
||||||
|
with_clone = true;
|
||||||
humanize_number(total, sizeof total,
|
humanize_number(total, sizeof total,
|
||||||
pset->parts->disk_size * 512,
|
pset->parts->disk_size * 512,
|
||||||
"", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
|
"", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
|
||||||
|
@ -1125,14 +1130,19 @@ fmt_fspart_header(menudesc *menu, void *arg)
|
||||||
pset->cur_free_space * 512,
|
pset->cur_free_space * 512,
|
||||||
"", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
|
"", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
|
||||||
|
|
||||||
|
if (with_clone)
|
||||||
|
strlcpy(desc, msg_string(MSG_clone_flag_desc), sizeof desc);
|
||||||
|
else
|
||||||
|
desc[0] = 0;
|
||||||
|
if (pset->parts->pscheme->part_flag_desc)
|
||||||
|
strlcat(desc, msg_string(pset->parts->pscheme->part_flag_desc),
|
||||||
|
sizeof desc);
|
||||||
|
|
||||||
msg_display_subst(MSG_fspart, 7, pset->parts->disk,
|
msg_display_subst(MSG_fspart, 7, pset->parts->disk,
|
||||||
msg_string(pset->parts->pscheme->name),
|
msg_string(pset->parts->pscheme->name),
|
||||||
msg_string(pset->parts->pscheme->short_name),
|
msg_string(pset->parts->pscheme->short_name),
|
||||||
with_inst_flag ? msg_string(MSG_ptn_instflag_desc) : "",
|
with_inst_flag ? msg_string(MSG_ptn_instflag_desc) : "",
|
||||||
pset->parts->pscheme->part_flag_desc ?
|
desc, total, free_space);
|
||||||
msg_string(pset->parts->pscheme->part_flag_desc)
|
|
||||||
: "",
|
|
||||||
total, free_space);
|
|
||||||
|
|
||||||
snprintf(scol, sizeof scol, "%s (%s)",
|
snprintf(scol, sizeof scol, "%s (%s)",
|
||||||
msg_string(MSG_ptnheaders_start), multname);
|
msg_string(MSG_ptnheaders_start), multname);
|
||||||
|
@ -1177,11 +1187,44 @@ fmt_fspart_row(menudesc *m, int ptn, void *arg)
|
||||||
static const char *Yes;
|
static const char *Yes;
|
||||||
char flag_str[MENUSTRSIZE], *fp;
|
char flag_str[MENUSTRSIZE], *fp;
|
||||||
unsigned inst_flags;
|
unsigned inst_flags;
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
size_t clone_cnt;
|
||||||
|
#endif
|
||||||
bool with_inst_flag = pset->parts->parent == NULL;
|
bool with_inst_flag = pset->parts->parent == NULL;
|
||||||
|
|
||||||
if (Yes == NULL)
|
if (Yes == NULL)
|
||||||
Yes = msg_string(MSG_Yes);
|
Yes = msg_string(MSG_Yes);
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
if ((pset->infos[ptn].flags & PUIFLG_CLONE_PARTS) &&
|
||||||
|
pset->infos[ptn].cur_part_id == NO_PART) {
|
||||||
|
psize = pset->infos[ptn].size / sizemult;
|
||||||
|
if (pset->infos[ptn].clone_ndx <
|
||||||
|
pset->infos[ptn].clone_src->num_sel)
|
||||||
|
clone_cnt = 1;
|
||||||
|
else
|
||||||
|
clone_cnt = pset->infos[ptn].clone_src->num_sel;
|
||||||
|
if (pset->infos[ptn].cur_part_id == NO_PART)
|
||||||
|
wprintw(m->mw, " %12" PRIu64
|
||||||
|
" [%zu %s]", psize, clone_cnt,
|
||||||
|
msg_string(MSG_clone_target_disp));
|
||||||
|
else {
|
||||||
|
poffset = pset->infos[ptn].cur_start / sizemult;
|
||||||
|
pend = (pset->infos[ptn].cur_start +
|
||||||
|
pset->infos[ptn].size) / sizemult - 1;
|
||||||
|
wprintw(m->mw, "%12" PRIu64 " %12" PRIu64 " %12" PRIu64
|
||||||
|
" [%zu %s]",
|
||||||
|
poffset, pend, psize, clone_cnt,
|
||||||
|
msg_string(MSG_clone_target_disp));
|
||||||
|
}
|
||||||
|
if (m->title == fspart_title)
|
||||||
|
m->opts[ptn].opt_flags |= OPT_IGNORE;
|
||||||
|
else
|
||||||
|
m->opts[ptn].opt_flags &= ~OPT_IGNORE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!real_partition(pset, ptn))
|
if (!real_partition(pset, ptn))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1189,11 +1232,22 @@ fmt_fspart_row(menudesc *m, int ptn, void *arg)
|
||||||
pset->infos[ptn].cur_part_id, &info))
|
pset->infos[ptn].cur_part_id, &info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* enable / disable this line if it is something like RAW_PART */
|
/*
|
||||||
if (info.flags & (PTI_WHOLE_DISK|PTI_PSCHEME_INTERNAL|PTI_RAW_PART))
|
* We use this function in multiple menus, but only want it
|
||||||
m->opts[ptn].opt_flags |= OPT_IGNORE;
|
* to play with enable/disable in a single one:
|
||||||
else
|
*/
|
||||||
m->opts[ptn].opt_flags &= ~OPT_IGNORE;
|
if (m->title == fspart_title) {
|
||||||
|
/*
|
||||||
|
* Enable / disable this line if it is something
|
||||||
|
* like RAW_PART
|
||||||
|
*/
|
||||||
|
if ((info.flags &
|
||||||
|
(PTI_WHOLE_DISK|PTI_PSCHEME_INTERNAL|PTI_RAW_PART))
|
||||||
|
|| (pset->infos[ptn].flags & PUIFLG_CLONE_PARTS))
|
||||||
|
m->opts[ptn].opt_flags |= OPT_IGNORE;
|
||||||
|
else
|
||||||
|
m->opts[ptn].opt_flags &= ~OPT_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
poffset = info.start / sizemult;
|
poffset = info.start / sizemult;
|
||||||
psize = info.size / sizemult;
|
psize = info.size / sizemult;
|
||||||
|
@ -1223,6 +1277,8 @@ fmt_fspart_row(menudesc *m, int ptn, void *arg)
|
||||||
}
|
}
|
||||||
if (inst_flags & PUIINST_NEWFS)
|
if (inst_flags & PUIINST_NEWFS)
|
||||||
*fp++ = msg_string(MSG_newfs_flag)[0];
|
*fp++ = msg_string(MSG_newfs_flag)[0];
|
||||||
|
if (pset->infos[ptn].flags & PUIFLG_CLONE_PARTS)
|
||||||
|
*fp++ = msg_string(MSG_clone_flag)[0];
|
||||||
*fp = 0;
|
*fp = 0;
|
||||||
if (pset->parts->pscheme->get_part_attr_str != NULL)
|
if (pset->parts->pscheme->get_part_attr_str != NULL)
|
||||||
pset->parts->pscheme->get_part_attr_str(pset->parts,
|
pset->parts->pscheme->get_part_attr_str(pset->parts,
|
||||||
|
@ -1244,6 +1300,155 @@ fmt_fspart_row(menudesc *m, int ptn, void *arg)
|
||||||
info.last_mounted[0] ? info.last_mounted : "");
|
info.last_mounted[0] ? info.last_mounted : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
static int
|
||||||
|
part_ext_clone(menudesc *m, void *arg)
|
||||||
|
{
|
||||||
|
struct selected_partitions selected, *clone_src;
|
||||||
|
struct clone_target_menu_data data;
|
||||||
|
struct partition_usage_set *pset = arg;
|
||||||
|
struct part_usage_info *p;
|
||||||
|
struct disk_part_info sinfo, cinfo;
|
||||||
|
struct disk_partitions *csrc;
|
||||||
|
struct disk_part_free_space space;
|
||||||
|
menu_ent *men;
|
||||||
|
daddr_t clone_size, free_size, offset, align;
|
||||||
|
int num_men, i;
|
||||||
|
size_t s, clone_cnt;
|
||||||
|
part_id cid;
|
||||||
|
struct clone_data {
|
||||||
|
struct disk_part_info info;
|
||||||
|
part_id new_id;
|
||||||
|
size_t ndx;
|
||||||
|
};
|
||||||
|
struct clone_data *clones = NULL;
|
||||||
|
|
||||||
|
if (!select_partitions(&selected, pm->parts))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
clone_size = selected_parts_size(&selected);
|
||||||
|
num_men = pset->num+1;
|
||||||
|
men = calloc(num_men, sizeof *men);
|
||||||
|
if (men == NULL)
|
||||||
|
return 0;
|
||||||
|
for (i = 0; i < num_men; i++) {
|
||||||
|
men[i].opt_action = clone_target_select;
|
||||||
|
if (i == 0)
|
||||||
|
free_size = pset->infos[i].cur_start;
|
||||||
|
else if (i > 0 && (size_t)i < pset->num)
|
||||||
|
free_size = pset->infos[i].cur_start -
|
||||||
|
pset->infos[i-1].cur_start - pset->infos[i-1].size;
|
||||||
|
else
|
||||||
|
free_size = pset->parts->free_space;
|
||||||
|
if (free_size < clone_size)
|
||||||
|
men[i].opt_flags = OPT_IGNORE;
|
||||||
|
}
|
||||||
|
men[num_men-1].opt_name = MSG_clone_target_end;
|
||||||
|
|
||||||
|
memset(&data, 0, sizeof data);
|
||||||
|
data.usage = *pset;
|
||||||
|
data.res = -1;
|
||||||
|
|
||||||
|
data.usage.menu = new_menu(MSG_clone_target_hdr,
|
||||||
|
men, num_men, 3, 2, 0, 65, MC_SCROLL,
|
||||||
|
NULL, fmt_fspart_row, NULL, NULL, MSG_cancel);
|
||||||
|
process_menu(data.usage.menu, &data);
|
||||||
|
free_menu(data.usage.menu);
|
||||||
|
free(men);
|
||||||
|
|
||||||
|
if (data.res < 0)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
/* create temporary infos for all clones that work out */
|
||||||
|
clone_cnt = 0;
|
||||||
|
clones = calloc(selected.num_sel, sizeof(*clones));
|
||||||
|
if (clones == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
clone_src = malloc(sizeof(selected));
|
||||||
|
if (clone_src == NULL)
|
||||||
|
goto err;
|
||||||
|
*clone_src = selected;
|
||||||
|
|
||||||
|
/* find selected offset from data.res and insert clones there */
|
||||||
|
align = pset->parts->pscheme->get_part_alignment(pset->parts);
|
||||||
|
offset = -1;
|
||||||
|
if (data.res > 0)
|
||||||
|
offset = pset->infos[data.res-1].cur_start
|
||||||
|
+ pset->infos[data.res-1].size;
|
||||||
|
else
|
||||||
|
offset = 0;
|
||||||
|
for (s = 0; s < selected.num_sel; s++) {
|
||||||
|
csrc = selected.selection[s].parts;
|
||||||
|
cid = selected.selection[s].id;
|
||||||
|
csrc->pscheme->get_part_info(csrc, cid, &sinfo);
|
||||||
|
if (!pset->parts->pscheme->adapt_foreign_part_info(
|
||||||
|
pset->parts, &cinfo, csrc->pscheme, &sinfo))
|
||||||
|
continue;
|
||||||
|
size_t cnt = pset->parts->pscheme->get_free_spaces(
|
||||||
|
pset->parts, &space, 1, cinfo.size-align, align,
|
||||||
|
offset, -1);
|
||||||
|
if (cnt == 0)
|
||||||
|
continue;
|
||||||
|
cinfo.start = space.start;
|
||||||
|
cid = pset->parts->pscheme->add_partition(
|
||||||
|
pset->parts, &cinfo, NULL);
|
||||||
|
if (cid == NO_PART)
|
||||||
|
continue;
|
||||||
|
pset->parts->pscheme->get_part_info(pset->parts, cid, &cinfo);
|
||||||
|
clones[clone_cnt].info = cinfo;
|
||||||
|
clones[clone_cnt].new_id = cid;
|
||||||
|
clones[clone_cnt].ndx = s;
|
||||||
|
clone_cnt++;
|
||||||
|
offset = rounddown(cinfo.start+cinfo.size+align, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* insert new clone records at offset data.res */
|
||||||
|
men = realloc(m->opts, (m->numopts+clone_cnt)*sizeof(*m->opts));
|
||||||
|
if (men == NULL)
|
||||||
|
goto err;
|
||||||
|
pset->menu_opts = men;
|
||||||
|
m->opts = men;
|
||||||
|
m->numopts += clone_cnt;
|
||||||
|
|
||||||
|
p = realloc(pset->infos, (pset->num+clone_cnt)*sizeof(*pset->infos));
|
||||||
|
if (p == NULL)
|
||||||
|
goto err;
|
||||||
|
pset->infos = p;
|
||||||
|
|
||||||
|
men += data.res;
|
||||||
|
p += data.res;
|
||||||
|
memmove(men+clone_cnt, men,
|
||||||
|
sizeof(*men)*(m->numopts-data.res-clone_cnt));
|
||||||
|
if (pset->num > (size_t)data.res)
|
||||||
|
memmove(p+clone_cnt, p, sizeof(*p)*(pset->num-data.res));
|
||||||
|
memset(men, 0, sizeof(*men)*clone_cnt);
|
||||||
|
memset(p, 0, sizeof(*p)*clone_cnt);
|
||||||
|
for (s = 0; s < clone_cnt; s++) {
|
||||||
|
p[s].cur_part_id = clones[s].new_id;
|
||||||
|
p[s].cur_start = clones[s].info.start;
|
||||||
|
p[s].size = clones[s].info.size;
|
||||||
|
p[s].cur_flags = clones[s].info.flags;
|
||||||
|
p[s].flags = PUIFLG_CLONE_PARTS;
|
||||||
|
p[s].parts = pset->parts;
|
||||||
|
p[s].clone_src = clone_src;
|
||||||
|
p[s].clone_ndx = s;
|
||||||
|
}
|
||||||
|
free(clones);
|
||||||
|
m->cursel = ((size_t)data.res >= pset->num) ? 0 : data.res+clone_cnt;
|
||||||
|
pset->num += clone_cnt;
|
||||||
|
m->h = 0;
|
||||||
|
resize_menu_height(m);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
err:
|
||||||
|
free(clones);
|
||||||
|
free_selected_partitions(&selected);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
edit_fspart_pack(menudesc *m, void *arg)
|
edit_fspart_pack(menudesc *m, void *arg)
|
||||||
{
|
{
|
||||||
|
@ -1395,8 +1600,13 @@ edit_and_check_label(struct pm_devs *p, struct partition_usage_set *pset)
|
||||||
pset->parts->pscheme->get_disk_pack_name != NULL &&
|
pset->parts->pscheme->get_disk_pack_name != NULL &&
|
||||||
pset->parts->pscheme->set_disk_pack_name != NULL;
|
pset->parts->pscheme->set_disk_pack_name != NULL;
|
||||||
|
|
||||||
|
#ifdef NO_CLONES
|
||||||
|
#define C_M_ITEMS 0
|
||||||
|
#else
|
||||||
|
#define C_M_ITEMS 1
|
||||||
|
#endif
|
||||||
pset->menu_opts = calloc(pset->parts->num_part
|
pset->menu_opts = calloc(pset->parts->num_part
|
||||||
+3+may_add+may_edit_pack,
|
+3+C_M_ITEMS+may_add+may_edit_pack,
|
||||||
sizeof *pset->menu_opts);
|
sizeof *pset->menu_opts);
|
||||||
if (pset->menu_opts == NULL)
|
if (pset->menu_opts == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1432,6 +1642,13 @@ edit_and_check_label(struct pm_devs *p, struct partition_usage_set *pset)
|
||||||
op->opt_action = edit_fspart_pack;
|
op->opt_action = edit_fspart_pack;
|
||||||
op++;
|
op++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
/* add a clone-from-elsewhere option */
|
||||||
|
op->opt_name = MSG_clone_from_elsewhere;
|
||||||
|
op->opt_action = part_ext_clone;
|
||||||
|
op++;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* and abort option */
|
/* and abort option */
|
||||||
op->opt_name = MSG_cancel;
|
op->opt_name = MSG_cancel;
|
||||||
|
@ -1439,7 +1656,7 @@ edit_and_check_label(struct pm_devs *p, struct partition_usage_set *pset)
|
||||||
op->opt_action = edit_fspart_abort;
|
op->opt_action = edit_fspart_abort;
|
||||||
op++;
|
op++;
|
||||||
cnt = op - pset->menu_opts;
|
cnt = op - pset->menu_opts;
|
||||||
assert(cnt == pset->parts->num_part+3+may_add+may_edit_pack);
|
assert(cnt == pset->parts->num_part+3+C_M_ITEMS+may_add+may_edit_pack);
|
||||||
|
|
||||||
pset->menu = new_menu(fspart_title, pset->menu_opts, cnt,
|
pset->menu = new_menu(fspart_title, pset->menu_opts, cnt,
|
||||||
0, -1, 0, 74,
|
0, -1, 0, 74,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: main.c,v 1.17 2019/06/22 20:46:07 christos Exp $ */
|
/* $NetBSD: main.c,v 1.17.2.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -281,6 +281,8 @@ main(int argc, char **argv)
|
||||||
pm_destroy_all();
|
pm_destroy_all();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
partitions_cleanup();
|
||||||
|
|
||||||
exit_cleanly = 1;
|
exit_cleanly = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: mbr.c,v 1.19.2.2 2019/08/28 10:01:57 msaitoh Exp $ */
|
/* $NetBSD: mbr.c,v 1.19.2.3 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -74,6 +74,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
#include <paths.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "mbr.h"
|
#include "mbr.h"
|
||||||
#include "md.h"
|
#include "md.h"
|
||||||
|
@ -89,6 +91,9 @@
|
||||||
#define MAXSECTOR 63
|
#define MAXSECTOR 63
|
||||||
|
|
||||||
|
|
||||||
|
#define MBR_UNKNOWN_PTYPE 94 /* arbitrary not widely used value */
|
||||||
|
|
||||||
|
|
||||||
/* A list of predefined partition types */
|
/* A list of predefined partition types */
|
||||||
const struct {
|
const struct {
|
||||||
unsigned int ptype;
|
unsigned int ptype;
|
||||||
|
@ -588,7 +593,7 @@ static int
|
||||||
write_mbr(const char *disk, mbr_info_t *mbri, int bsec, int bhead, int bcyl)
|
write_mbr(const char *disk, mbr_info_t *mbri, int bsec, int bhead, int bcyl)
|
||||||
{
|
{
|
||||||
char diskpath[MAXPATHLEN];
|
char diskpath[MAXPATHLEN];
|
||||||
int fd, i, ret = 0;
|
int fd, i, ret = 0, bits = 0;
|
||||||
struct mbr_partition *mbrp;
|
struct mbr_partition *mbrp;
|
||||||
u_int32_t pstart, psize;
|
u_int32_t pstart, psize;
|
||||||
#ifdef BOOTSEL
|
#ifdef BOOTSEL
|
||||||
|
@ -605,6 +610,10 @@ write_mbr(const char *disk, mbr_info_t *mbri, int bsec, int bhead, int bcyl)
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
/* Remove all wedges */
|
||||||
|
if (ioctl(fd, DIOCRMWEDGES, &bits) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
#ifdef BOOTSEL
|
#ifdef BOOTSEL
|
||||||
/*
|
/*
|
||||||
* If the main boot code (appears to) contain the netbsd bootcode,
|
* If the main boot code (appears to) contain the netbsd bootcode,
|
||||||
|
@ -646,6 +655,7 @@ write_mbr(const char *disk, mbr_info_t *mbri, int bsec, int bhead, int bcyl)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (ext = mbri; ext != NULL; ext = ext->extended) {
|
for (ext = mbri; ext != NULL; ext = ext->extended) {
|
||||||
|
memset(mbri->wedge, 0, sizeof mbri->wedge);
|
||||||
sector = ext->sector;
|
sector = ext->sector;
|
||||||
mbrsec = ext->mbr; /* copy sector */
|
mbrsec = ext->mbr; /* copy sector */
|
||||||
mbrp = &mbrsec.mbr_parts[0];
|
mbrp = &mbrsec.mbr_parts[0];
|
||||||
|
@ -830,7 +840,7 @@ mbr_create_new(const char *disk, daddr_t start, daddr_t len, daddr_t total,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
parts->dp.pscheme = &mbr_parts;
|
parts->dp.pscheme = &mbr_parts;
|
||||||
parts->dp.disk = disk;
|
parts->dp.disk = strdup(disk);
|
||||||
if (len > mbr_parts.size_limit)
|
if (len > mbr_parts.size_limit)
|
||||||
len = mbr_parts.size_limit;
|
len = mbr_parts.size_limit;
|
||||||
parts->dp.disk_start = start;
|
parts->dp.disk_start = start;
|
||||||
|
@ -894,7 +904,7 @@ mbr_read_from_disk(const char *disk, daddr_t start, daddr_t len,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
parts->dp.pscheme = scheme;
|
parts->dp.pscheme = scheme;
|
||||||
parts->dp.disk = disk;
|
parts->dp.disk = strdup(disk);
|
||||||
if (len >= mbr_parts.size_limit)
|
if (len >= mbr_parts.size_limit)
|
||||||
len = mbr_parts.size_limit;
|
len = mbr_parts.size_limit;
|
||||||
parts->dp.disk_start = start;
|
parts->dp.disk_start = start;
|
||||||
|
@ -1126,6 +1136,16 @@ mbr_custom_part_type(const char *custom, const char **err_msg)
|
||||||
return mbr_new_custom_part_type(v);
|
return mbr_new_custom_part_type(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct part_type_desc *
|
||||||
|
mbr_create_unknown_part_type(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (mbr_gen_type_desc[MBR_UNKNOWN_PTYPE].gen.short_desc != NULL)
|
||||||
|
return &mbr_gen_type_desc[MBR_UNKNOWN_PTYPE].gen;
|
||||||
|
|
||||||
|
return mbr_new_custom_part_type(MBR_UNKNOWN_PTYPE);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct part_type_desc *
|
static const struct part_type_desc *
|
||||||
mbr_get_gen_type_desc(unsigned int pt)
|
mbr_get_gen_type_desc(unsigned int pt)
|
||||||
{
|
{
|
||||||
|
@ -1231,11 +1251,79 @@ mbr_do_get_part_info(const struct disk_partitions *arg, part_id id,
|
||||||
mbr_partition_to_info(mp, mb->sector, info);
|
mbr_partition_to_info(mp, mb->sector, info);
|
||||||
if (mb->last_mounted[i] != NULL && mb->last_mounted[i][0] != 0)
|
if (mb->last_mounted[i] != NULL && mb->last_mounted[i][0] != 0)
|
||||||
info->last_mounted = mb->last_mounted[i];
|
info->last_mounted = mb->last_mounted[i];
|
||||||
info->fs_type = mb->fs_type[i];
|
if (mb->fs_type[i] != FS_UNUSED) {
|
||||||
info->fs_sub_type = mb->fs_sub_type[i];
|
info->fs_type = mb->fs_type[i];
|
||||||
|
info->fs_sub_type = mb->fs_sub_type[i];
|
||||||
|
} else {
|
||||||
|
info->fs_sub_type = 0;
|
||||||
|
switch (mp->mbrp_type) {
|
||||||
|
case MBR_PTYPE_FAT12:
|
||||||
|
case MBR_PTYPE_FAT16S:
|
||||||
|
case MBR_PTYPE_FAT16B:
|
||||||
|
case MBR_PTYPE_FAT32:
|
||||||
|
case MBR_PTYPE_FAT32L:
|
||||||
|
case MBR_PTYPE_FAT16L:
|
||||||
|
case MBR_PTYPE_OS2_DOS12:
|
||||||
|
case MBR_PTYPE_OS2_DOS16S:
|
||||||
|
case MBR_PTYPE_OS2_DOS16B:
|
||||||
|
case MBR_PTYPE_HID_FAT32:
|
||||||
|
case MBR_PTYPE_HID_FAT32_LBA:
|
||||||
|
case MBR_PTYPE_HID_FAT16_LBA:
|
||||||
|
case MBR_PTYPE_MDOS_FAT12:
|
||||||
|
case MBR_PTYPE_MDOS_FAT16S:
|
||||||
|
case MBR_PTYPE_MDOS_EXT:
|
||||||
|
case MBR_PTYPE_MDOS_FAT16B:
|
||||||
|
case MBR_PTYPE_SPEEDSTOR_16S:
|
||||||
|
case MBR_PTYPE_EFI:
|
||||||
|
info->fs_type = FS_MSDOS;
|
||||||
|
break;
|
||||||
|
case MBR_PTYPE_XENIX_ROOT:
|
||||||
|
case MBR_PTYPE_XENIX_USR:
|
||||||
|
info->fs_type = FS_SYSV;
|
||||||
|
break;
|
||||||
|
case MBR_PTYPE_NTFS:
|
||||||
|
info->fs_type = FS_NTFS;
|
||||||
|
break;
|
||||||
|
case MBR_PTYPE_APPLE_HFS:
|
||||||
|
info->fs_type = FS_HFS;
|
||||||
|
break;
|
||||||
|
case MBR_PTYPE_VMWARE:
|
||||||
|
info->fs_type = FS_VMFS;
|
||||||
|
break;
|
||||||
|
case MBR_PTYPE_AST_SWAP:
|
||||||
|
case MBR_PTYPE_DRDOS_LSWAP:
|
||||||
|
case MBR_PTYPE_LNXSWAP:
|
||||||
|
case MBR_PTYPE_BSDI_SWAP:
|
||||||
|
case MBR_PTYPE_HID_LNX_SWAP:
|
||||||
|
case MBR_PTYPE_VMWARE_SWAP:
|
||||||
|
info->fs_type = FS_SWAP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
get_wedge_devname(const struct disk_partitions *arg, part_id id,
|
||||||
|
const mbr_info_t *mb, int i, bool primary,
|
||||||
|
const struct mbr_partition *mp, void *cookie)
|
||||||
|
{
|
||||||
|
char **res = cookie;
|
||||||
|
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*res = __UNCONST(mb->wedge[i]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
mbr_part_get_wedge(const struct disk_partitions *arg, part_id id,
|
||||||
|
char **res)
|
||||||
|
{
|
||||||
|
return mbr_part_apply(arg, id, get_wedge_devname, res);
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
mbr_get_part_info(const struct disk_partitions *arg, part_id id,
|
mbr_get_part_info(const struct disk_partitions *arg, part_id id,
|
||||||
struct disk_part_info *info)
|
struct disk_part_info *info)
|
||||||
|
@ -2381,18 +2469,50 @@ mbr_can_add_partition(const struct disk_partitions *arg)
|
||||||
return free_primary;
|
return free_primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mbr_free_wedge(int *fd, const char *disk, const char *wedge)
|
||||||
|
{
|
||||||
|
struct dkwedge_info dkw;
|
||||||
|
char diskpath[MAXPATHLEN];
|
||||||
|
|
||||||
|
if (*fd == -1)
|
||||||
|
*fd = opendisk(disk, O_RDWR, diskpath,
|
||||||
|
sizeof(diskpath), 0);
|
||||||
|
if (*fd != -1) {
|
||||||
|
memset(&dkw, 0, sizeof(dkw));
|
||||||
|
strlcpy(dkw.dkw_devname, wedge,
|
||||||
|
sizeof(dkw.dkw_devname));
|
||||||
|
ioctl(*fd, DIOCDWEDGE, &dkw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mbr_free(struct disk_partitions *arg)
|
mbr_free(struct disk_partitions *arg)
|
||||||
{
|
{
|
||||||
struct mbr_disk_partitions *parts = (struct mbr_disk_partitions*)arg;
|
struct mbr_disk_partitions *parts = (struct mbr_disk_partitions*)arg;
|
||||||
|
mbr_info_t *m;
|
||||||
|
int i, fd;
|
||||||
|
|
||||||
assert(parts != NULL);
|
assert(parts != NULL);
|
||||||
|
|
||||||
|
fd = -1;
|
||||||
|
m = &parts->mbr;
|
||||||
|
do {
|
||||||
|
for (i = 0; i < MBR_PART_COUNT; i++) {
|
||||||
|
if (m->wedge[i][0] != 0)
|
||||||
|
mbr_free_wedge(&fd, arg->disk, m->wedge[i]);
|
||||||
|
}
|
||||||
|
} while ((m = m->extended));
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
|
close(fd);
|
||||||
|
|
||||||
if (parts->dlabel)
|
if (parts->dlabel)
|
||||||
parts->dlabel->pscheme->free(parts->dlabel);
|
parts->dlabel->pscheme->free(parts->dlabel);
|
||||||
|
|
||||||
free_mbr_info(parts->mbr.extended);
|
free_mbr_info(parts->mbr.extended);
|
||||||
free_last_mounted(&parts->mbr);
|
free_last_mounted(&parts->mbr);
|
||||||
|
free(__UNCONST(parts->dp.disk));
|
||||||
free(parts);
|
free(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2676,6 +2796,103 @@ mbr_part_alignment(const struct disk_partitions *arg)
|
||||||
return parts->ptn_alignment;
|
return parts->ptn_alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
add_wedge(const char *disk, daddr_t start, daddr_t size,
|
||||||
|
char *wname, size_t max_len)
|
||||||
|
{
|
||||||
|
struct dkwedge_info dkw;
|
||||||
|
char diskpath[MAXPATHLEN];
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
memset(&dkw, 0, sizeof(dkw));
|
||||||
|
dkw.dkw_offset = start;
|
||||||
|
dkw.dkw_size = size;
|
||||||
|
snprintf((char*)dkw.dkw_wname, sizeof dkw.dkw_wname,
|
||||||
|
"%s_%" PRIi64 "@%" PRIi64, (const char*)disk, size, start);
|
||||||
|
|
||||||
|
*wname = 0;
|
||||||
|
|
||||||
|
fd = opendisk(disk, O_RDWR, diskpath, sizeof(diskpath), 0);
|
||||||
|
if (fd < 0)
|
||||||
|
return false;
|
||||||
|
if (ioctl(fd, DIOCAWEDGE, &dkw) == -1) {
|
||||||
|
close(fd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
strlcpy(wname, dkw.dkw_devname, max_len);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
mbr_get_part_device(const struct disk_partitions *arg,
|
||||||
|
part_id ptn, char *devname, size_t max_devname_len, int *part,
|
||||||
|
enum dev_name_usage usage, bool with_path)
|
||||||
|
{
|
||||||
|
const struct mbr_disk_partitions *parts =
|
||||||
|
(const struct mbr_disk_partitions*)arg;
|
||||||
|
struct disk_part_info info, tmp;
|
||||||
|
part_id dptn;
|
||||||
|
char *wedge_dev;
|
||||||
|
|
||||||
|
if (!mbr_get_part_info(arg, ptn, &info))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!mbr_part_get_wedge(arg, ptn, &wedge_dev) || wedge_dev == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (wedge_dev[0] == 0) {
|
||||||
|
/*
|
||||||
|
* If we have secondary partitions, try to find a match there
|
||||||
|
* and use that...
|
||||||
|
*/
|
||||||
|
if (parts->dlabel != NULL) {
|
||||||
|
for (dptn = 0; dptn < parts->dlabel->num_part; dptn++) {
|
||||||
|
if (!parts->dlabel->pscheme->get_part_info(
|
||||||
|
parts->dlabel, dptn, &tmp))
|
||||||
|
continue;
|
||||||
|
if (tmp.start != info.start ||
|
||||||
|
tmp.size != info.size)
|
||||||
|
continue;
|
||||||
|
return parts->dlabel->pscheme->get_part_device(
|
||||||
|
parts->dlabel, dptn, devname,
|
||||||
|
max_devname_len,
|
||||||
|
part, usage, with_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configure a new wedge and remember the name
|
||||||
|
*/
|
||||||
|
if (!add_wedge(arg->disk, info.start, info.size, wedge_dev,
|
||||||
|
MBR_DEV_LEN))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(wedge_dev[0] != 0);
|
||||||
|
|
||||||
|
switch (usage) {
|
||||||
|
case logical_name:
|
||||||
|
case plain_name:
|
||||||
|
if (with_path)
|
||||||
|
snprintf(devname, max_devname_len, _PATH_DEV "%s",
|
||||||
|
wedge_dev);
|
||||||
|
else
|
||||||
|
strlcpy(devname, wedge_dev, max_devname_len);
|
||||||
|
return true;
|
||||||
|
case raw_dev_name:
|
||||||
|
if (with_path)
|
||||||
|
snprintf(devname, max_devname_len, _PATH_DEV "r%s",
|
||||||
|
wedge_dev);
|
||||||
|
else
|
||||||
|
snprintf(devname, max_devname_len, "r%s",
|
||||||
|
wedge_dev);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_custom_attribute_writable(const struct disk_partitions *arg, part_id id,
|
is_custom_attribute_writable(const struct disk_partitions *arg, part_id id,
|
||||||
const mbr_info_t *mb, int i, bool primary,
|
const mbr_info_t *mb, int i, bool primary,
|
||||||
|
@ -2766,16 +2983,19 @@ mbr_parts = {
|
||||||
.custom_attribute_toggle = mbr_custom_attribute_toggle,
|
.custom_attribute_toggle = mbr_custom_attribute_toggle,
|
||||||
.custom_attribute_set_str = mbr_custom_attribute_set_str,
|
.custom_attribute_set_str = mbr_custom_attribute_set_str,
|
||||||
.get_part_types_count = mbr_get_part_type_count,
|
.get_part_types_count = mbr_get_part_type_count,
|
||||||
|
.adapt_foreign_part_info = generic_adapt_foreign_part_info,
|
||||||
.get_part_type = mbr_get_part_type,
|
.get_part_type = mbr_get_part_type,
|
||||||
.get_fs_part_type = mbr_get_fs_part_type,
|
.get_fs_part_type = mbr_get_fs_part_type,
|
||||||
.get_generic_part_type = mbr_get_generic_part_type,
|
.get_generic_part_type = mbr_get_generic_part_type,
|
||||||
.create_custom_part_type = mbr_custom_part_type,
|
.create_custom_part_type = mbr_custom_part_type,
|
||||||
|
.create_unknown_part_type = mbr_create_unknown_part_type,
|
||||||
.secondary_partitions = mbr_read_disklabel,
|
.secondary_partitions = mbr_read_disklabel,
|
||||||
.write_to_disk = mbr_write_to_disk,
|
.write_to_disk = mbr_write_to_disk,
|
||||||
.read_from_disk = mbr_read_from_disk,
|
.read_from_disk = mbr_read_from_disk,
|
||||||
.create_new_for_disk = mbr_create_new,
|
.create_new_for_disk = mbr_create_new,
|
||||||
.guess_disk_geom = mbr_guess_geom,
|
.guess_disk_geom = mbr_guess_geom,
|
||||||
.change_disk_geom = mbr_change_disk_geom,
|
.change_disk_geom = mbr_change_disk_geom,
|
||||||
|
.get_part_device = mbr_get_part_device,
|
||||||
.max_free_space_at = mbr_max_part_size,
|
.max_free_space_at = mbr_max_part_size,
|
||||||
.get_free_spaces = mbr_get_free_spaces,
|
.get_free_spaces = mbr_get_free_spaces,
|
||||||
.set_part_info = mbr_set_part_info,
|
.set_part_info = mbr_set_part_info,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: mbr.h,v 1.3 2019/06/19 17:32:31 martin Exp $ */
|
/* $NetBSD: mbr.h,v 1.3.2.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997, 1988 Piermont Information Systems Inc.
|
* Copyright 1997, 1988 Piermont Information Systems Inc.
|
||||||
|
@ -54,6 +54,8 @@
|
||||||
#define MBR_PUT_LSCYL(c) ((c) & 0xff)
|
#define MBR_PUT_LSCYL(c) ((c) & 0xff)
|
||||||
#define MBR_PUT_MSCYLANDSEC(c,s) (((s) & 0x3f) | (((c) >> 2) & 0xc0))
|
#define MBR_PUT_MSCYLANDSEC(c,s) (((s) & 0x3f) | (((c) >> 2) & 0xc0))
|
||||||
|
|
||||||
|
#define MBR_DEV_LEN 16 /* for wedge names */
|
||||||
|
|
||||||
typedef struct mbr_info_t mbr_info_t;
|
typedef struct mbr_info_t mbr_info_t;
|
||||||
struct mbr_info_t {
|
struct mbr_info_t {
|
||||||
struct mbr_sector mbr;
|
struct mbr_sector mbr;
|
||||||
|
@ -69,6 +71,8 @@ struct mbr_info_t {
|
||||||
/* only in first item... */
|
/* only in first item... */
|
||||||
uint bootsec; /* start sector of bootmenu default */
|
uint bootsec; /* start sector of bootmenu default */
|
||||||
#endif
|
#endif
|
||||||
|
/* for temporary access */
|
||||||
|
char wedge[MBR_PART_COUNT][MBR_DEV_LEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef BOOTSEL
|
#ifdef BOOTSEL
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.mi.de,v 1.13.2.3 2019/11/17 07:04:34 martin Exp $ */
|
/* $NetBSD: msg.mi.de,v 1.13.2.4 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -318,7 +318,7 @@ message fspart
|
||||||
{Nachfolgend sehen Sie Ihre $2 Partitionen für $0.
|
{Nachfolgend sehen Sie Ihre $2 Partitionen für $0.
|
||||||
Dies ist die letzte Chance, diese zu ändern.
|
Dies ist die letzte Chance, diese zu ändern.
|
||||||
|
|
||||||
Flags: $3(F)ormatieren$4. Gesamtgröße: $5, noch frei: $6}
|
Flags: $3(F)ormatieren$4. Gesamtgröße: $5, frei: $6}
|
||||||
|
|
||||||
message ptnheaders_start {Start}
|
message ptnheaders_start {Start}
|
||||||
message ptnheaders_end {Ende}
|
message ptnheaders_end {Ende}
|
||||||
|
@ -1302,6 +1302,7 @@ message custom_type {Unbekannt}
|
||||||
message cancel {Abbrechen}
|
message cancel {Abbrechen}
|
||||||
|
|
||||||
message out_of_range {Ungültiger Wert}
|
message out_of_range {Ungültiger Wert}
|
||||||
|
message invalid_guid {Ungültige GUID}
|
||||||
|
|
||||||
message reedit_partitions {Erneut bearbeiten}
|
message reedit_partitions {Erneut bearbeiten}
|
||||||
message abort_installation {Installation abbrechen}
|
message abort_installation {Installation abbrechen}
|
||||||
|
@ -1459,6 +1460,9 @@ W
|
||||||
message ptn_install {Installation}
|
message ptn_install {Installation}
|
||||||
message ptn_instflag_desc {(I)nstalllieren, }
|
message ptn_instflag_desc {(I)nstalllieren, }
|
||||||
|
|
||||||
|
message clone_flag {C}
|
||||||
|
message clone_flag_desc {, (C)lone}
|
||||||
|
|
||||||
message parttype_gpt {Guid Partition Table (GPT)}
|
message parttype_gpt {Guid Partition Table (GPT)}
|
||||||
message parttype_gpt_short {GPT}
|
message parttype_gpt_short {GPT}
|
||||||
|
|
||||||
|
@ -1483,3 +1487,16 @@ message gpt_flag_desc {, (S)tart}
|
||||||
message size_ptn_not_mounted {(Sonstige: $0)}
|
message size_ptn_not_mounted {(Sonstige: $0)}
|
||||||
|
|
||||||
message running_system {aktuelles System}
|
message running_system {aktuelles System}
|
||||||
|
|
||||||
|
message clone_from_elsewhere {Externe Partition(en) duplizieren}
|
||||||
|
message select_foreign_part {Wählen Sie eine Quellpartition:}
|
||||||
|
message select_source_hdr
|
||||||
|
{Zur Zeit ausgwählte Quellpartitionen:}
|
||||||
|
message clone_with_data {Auch die Inhalte duplizieren}
|
||||||
|
message select_source_add {Weitere Partition hinzufügen}
|
||||||
|
message clone_target_end {Als letzte hinzufügen}
|
||||||
|
message clone_target_hdr
|
||||||
|
{Einfügen der duplizierten Partitionen vor:}
|
||||||
|
message clone_target_disp {duplizierte Partition(en)}
|
||||||
|
message clone_src_done
|
||||||
|
{Quellselektion OK, weiter mit der Zielauswahl}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.mi.en,v 1.19.2.4 2019/11/17 07:04:34 martin Exp $ */
|
/* $NetBSD: msg.mi.en,v 1.19.2.5 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -307,7 +307,7 @@ message fspart
|
||||||
{We now have your $2 partitions for $0 below.
|
{We now have your $2 partitions for $0 below.
|
||||||
This is your last chance to change them.
|
This is your last chance to change them.
|
||||||
|
|
||||||
Flags: $3(N)ewfs$4. Total size: $5, free space: $6}
|
Flags: $3(N)ewfs$4. Total size: $5, free: $6}
|
||||||
|
|
||||||
message ptnheaders_start {Start}
|
message ptnheaders_start {Start}
|
||||||
message ptnheaders_end {End}
|
message ptnheaders_end {End}
|
||||||
|
@ -1234,6 +1234,7 @@ message dl_type_invalid {Invalid file system type code (0 .. 255)}
|
||||||
message cancel {Cancel}
|
message cancel {Cancel}
|
||||||
|
|
||||||
message out_of_range {Invalid value}
|
message out_of_range {Invalid value}
|
||||||
|
message invalid_guid {Invalid GUID}
|
||||||
|
|
||||||
message reedit_partitions {Re-edit}
|
message reedit_partitions {Re-edit}
|
||||||
message abort_installation {Abort installation}
|
message abort_installation {Abort installation}
|
||||||
|
@ -1395,6 +1396,9 @@ Select the partition you wish to change:
|
||||||
message install_flag {I}
|
message install_flag {I}
|
||||||
message newfs_flag {N}
|
message newfs_flag {N}
|
||||||
|
|
||||||
|
message clone_flag {C}
|
||||||
|
message clone_flag_desc {, (C)lone}
|
||||||
|
|
||||||
message ptn_install {install}
|
message ptn_install {install}
|
||||||
message ptn_instflag_desc {(I)nstall, }
|
message ptn_instflag_desc {(I)nstall, }
|
||||||
|
|
||||||
|
@ -1423,3 +1427,16 @@ message size_ptn_not_mounted {(Other: $0)}
|
||||||
|
|
||||||
message running_system {current system}
|
message running_system {current system}
|
||||||
|
|
||||||
|
message clone_from_elsewhere {Clone external partition(s)}
|
||||||
|
message select_foreign_part
|
||||||
|
{Please select an external source partition:}
|
||||||
|
message select_source_hdr
|
||||||
|
{Your currently selected source partitions are:}
|
||||||
|
message clone_with_data {Clone with data}
|
||||||
|
message select_source_add {Add another partition}
|
||||||
|
message clone_target_end {Add at end}
|
||||||
|
message clone_target_hdr
|
||||||
|
{Insert cloned partitions before:}
|
||||||
|
message clone_target_disp {cloned partition(s)}
|
||||||
|
message clone_src_done
|
||||||
|
{Source selection OK, proceed to target selection}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.mi.es,v 1.14.2.3 2019/11/17 07:04:34 martin Exp $ */
|
/* $NetBSD: msg.mi.es,v 1.14.2.4 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -1284,6 +1284,7 @@ message dl_type_invalid {Invalid file system type code (0 .. 255)}
|
||||||
message cancel {Cancel}
|
message cancel {Cancel}
|
||||||
|
|
||||||
message out_of_range {Invalid value}
|
message out_of_range {Invalid value}
|
||||||
|
message invalid_guid {Invalid GUID}
|
||||||
|
|
||||||
message reedit_partitions {Re-edit}
|
message reedit_partitions {Re-edit}
|
||||||
message abort_installation {Abort installation}
|
message abort_installation {Abort installation}
|
||||||
|
@ -1446,6 +1447,9 @@ message newfs_flag {N}
|
||||||
message ptn_install {instalar}
|
message ptn_install {instalar}
|
||||||
message ptn_instflag_desc {(I)nstalar, }
|
message ptn_instflag_desc {(I)nstalar, }
|
||||||
|
|
||||||
|
message clone_flag {C}
|
||||||
|
message clone_flag_desc {, (C)lone}
|
||||||
|
|
||||||
message parttype_gpt {Guid Partition Table (GPT)}
|
message parttype_gpt {Guid Partition Table (GPT)}
|
||||||
message parttype_gpt_short {GPT}
|
message parttype_gpt_short {GPT}
|
||||||
|
|
||||||
|
@ -1471,3 +1475,17 @@ message size_ptn_not_mounted {(Other: $0)}
|
||||||
|
|
||||||
message running_system {current system}
|
message running_system {current system}
|
||||||
|
|
||||||
|
message clone_from_elsewhere {Clone external partition(s)}
|
||||||
|
message select_foreign_part
|
||||||
|
{Please select an external source partition:}
|
||||||
|
message select_source_hdr
|
||||||
|
{Your currently selected source partitions are:}
|
||||||
|
message clone_with_data {Clone with data}
|
||||||
|
message select_source_add {Add another partition}
|
||||||
|
message clone_target_end {Add at end}
|
||||||
|
message clone_target_hdr
|
||||||
|
{Insert cloned partitions before:}
|
||||||
|
message clone_target_disp {cloned partition(s)}
|
||||||
|
message clone_src_done
|
||||||
|
{Source selection OK, proceed to target selection}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.mi.fr,v 1.17.2.4 2019/11/17 07:04:34 martin Exp $ */
|
/* $NetBSD: msg.mi.fr,v 1.17.2.5 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -1336,6 +1336,7 @@ message dl_type_invalid {Invalid file system type code (0 .. 255)}
|
||||||
message cancel {Annuler}
|
message cancel {Annuler}
|
||||||
|
|
||||||
message out_of_range {Invalid value}
|
message out_of_range {Invalid value}
|
||||||
|
message invalid_guid {Invalid GUID}
|
||||||
|
|
||||||
message reedit_partitions {Re-edit}
|
message reedit_partitions {Re-edit}
|
||||||
message abort_installation {Abort installation}
|
message abort_installation {Abort installation}
|
||||||
|
@ -1490,6 +1491,8 @@ message newfs_flag {N}
|
||||||
message ptn_install {installation}
|
message ptn_install {installation}
|
||||||
message ptn_instflag_desc {(I)nstallation, }
|
message ptn_instflag_desc {(I)nstallation, }
|
||||||
|
|
||||||
|
message clone_flag {C}
|
||||||
|
message clone_flag_desc {, (C)lone}
|
||||||
|
|
||||||
message parttype_gpt {Guid Partition Table (GPT)}
|
message parttype_gpt {Guid Partition Table (GPT)}
|
||||||
message parttype_gpt_short {GPT}
|
message parttype_gpt_short {GPT}
|
||||||
|
@ -1516,3 +1519,17 @@ message size_ptn_not_mounted {(Other: $0)}
|
||||||
|
|
||||||
message running_system {current system}
|
message running_system {current system}
|
||||||
|
|
||||||
|
message clone_from_elsewhere {Clone external partition(s)}
|
||||||
|
message select_foreign_part
|
||||||
|
{Please select an external source partition:}
|
||||||
|
message select_source_hdr
|
||||||
|
{Your currently selected source partitions are:}
|
||||||
|
message clone_with_data {Clone with data}
|
||||||
|
message select_source_add {Add another partition}
|
||||||
|
message clone_target_end {Add at end}
|
||||||
|
message clone_target_hdr
|
||||||
|
{Insert cloned partitions before:}
|
||||||
|
message clone_target_disp {cloned partition(s)}
|
||||||
|
message clone_src_done
|
||||||
|
{Source selection OK, proceed to target selection}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: msg.mi.pl,v 1.20.2.4 2019/11/17 07:04:34 martin Exp $ */
|
/* $NetBSD: msg.mi.pl,v 1.20.2.5 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
/* Based on english version: */
|
/* Based on english version: */
|
||||||
/* NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp */
|
/* NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp */
|
||||||
|
|
||||||
|
@ -1234,6 +1234,7 @@ message dl_type_invalid {Nieznany typ systemu plikow (0 .. 255)}
|
||||||
message cancel {Anuluj}
|
message cancel {Anuluj}
|
||||||
|
|
||||||
message out_of_range {Nieprawidlowa wartosc}
|
message out_of_range {Nieprawidlowa wartosc}
|
||||||
|
message invalid_guid {Nieprawidlowa GUID}
|
||||||
|
|
||||||
message reedit_partitions {Edytuj ponownie}
|
message reedit_partitions {Edytuj ponownie}
|
||||||
message abort_installation {Anuluj instalacje}
|
message abort_installation {Anuluj instalacje}
|
||||||
|
@ -1385,6 +1386,8 @@ message newfs_flag {N}
|
||||||
message ptn_install {do instalacji}
|
message ptn_install {do instalacji}
|
||||||
message ptn_instflag_desc {(I)nstalacja, }
|
message ptn_instflag_desc {(I)nstalacja, }
|
||||||
|
|
||||||
|
message clone_flag {C}
|
||||||
|
message clone_flag_desc {, (C)lone}
|
||||||
|
|
||||||
message parttype_gpt {Guid Partition Table (GPT)}
|
message parttype_gpt {Guid Partition Table (GPT)}
|
||||||
message parttype_gpt_short {GPT}
|
message parttype_gpt_short {GPT}
|
||||||
|
@ -1411,3 +1414,17 @@ message size_ptn_not_mounted {(Inna: $0)}
|
||||||
|
|
||||||
message running_system {current system}
|
message running_system {current system}
|
||||||
|
|
||||||
|
message clone_from_elsewhere {Clone external partition(s)}
|
||||||
|
message select_foreign_part
|
||||||
|
{Please select an external source partition:}
|
||||||
|
message select_source_hdr
|
||||||
|
{Your currently selected source partitions are:}
|
||||||
|
message clone_with_data {Clone with data}
|
||||||
|
message select_source_add {Add another partition}
|
||||||
|
message clone_target_end {Add at end}
|
||||||
|
message clone_target_hdr
|
||||||
|
{Insert cloned partitions before:}
|
||||||
|
message clone_target_disp {cloned partition(s)}
|
||||||
|
message clone_src_done
|
||||||
|
{Source selection OK, proceed to target selection}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: net.c,v 1.33 2019/07/23 12:37:23 martin Exp $ */
|
/* $NetBSD: net.c,v 1.33.2.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -524,7 +524,7 @@ config_network(void)
|
||||||
menu_no = new_menu(MSG_netdevs,
|
menu_no = new_menu(MSG_netdevs,
|
||||||
net_menu, num_devs, -1, 4, 0, 0,
|
net_menu, num_devs, -1, 4, 0, 0,
|
||||||
MC_SCROLL,
|
MC_SCROLL,
|
||||||
NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, MSG_cancel);
|
||||||
again:
|
again:
|
||||||
selected_net = -1;
|
selected_net = -1;
|
||||||
msg_display(MSG_asknetdev);
|
msg_display(MSG_asknetdev);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: part_edit.c,v 1.7.2.2 2019/10/28 02:53:17 msaitoh Exp $ */
|
/* $NetBSD: part_edit.c,v 1.7.2.3 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 The NetBSD Foundation, Inc.
|
* Copyright (c) 2019 The NetBSD Foundation, Inc.
|
||||||
|
@ -57,8 +57,23 @@ struct part_edit_info {
|
||||||
bool num_changed; /* number of partitions has changed */
|
bool num_changed; /* number of partitions has changed */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
struct single_clone_data {
|
||||||
|
struct selected_partitions clone_src;
|
||||||
|
part_id *clone_ids; /* partition IDs in target */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
struct outer_parts_data {
|
||||||
|
struct arg_rv av;
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
struct single_clone_data *clones;
|
||||||
|
size_t num_clone_entries;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
static menu_ent *part_menu_opts; /* the currently edited partitions */
|
static menu_ent *part_menu_opts; /* the currently edited partitions */
|
||||||
static menu_ent *outer_fill_part_menu_opts(const struct disk_partitions *parts, size_t *cnt);
|
static menu_ent *outer_fill_part_menu_opts(const struct disk_partitions *parts, size_t *cnt);
|
||||||
|
static void draw_outer_part_line(menudesc *m, int opt, void *arg);
|
||||||
|
|
||||||
static char outer_part_sep_line[MENUSTRSIZE],
|
static char outer_part_sep_line[MENUSTRSIZE],
|
||||||
outer_part_title[2*MENUSTRSIZE];
|
outer_part_title[2*MENUSTRSIZE];
|
||||||
|
@ -388,15 +403,16 @@ fill_part_edit_menu_opts(struct disk_partitions *parts,
|
||||||
static int
|
static int
|
||||||
edit_part_entry(menudesc *m, void *arg)
|
edit_part_entry(menudesc *m, void *arg)
|
||||||
{
|
{
|
||||||
arg_rv *av = arg;
|
struct outer_parts_data *pdata = arg;
|
||||||
struct part_edit_info data = { .parts = av->arg, .cur_id = m->cursel,
|
struct part_edit_info data = { .parts = pdata->av.arg,
|
||||||
|
.cur_id = m->cursel,
|
||||||
.first_custom_opt = __arraycount(common_ptn_edit_opts) };
|
.first_custom_opt = __arraycount(common_ptn_edit_opts) };
|
||||||
int ptn_menu;
|
int ptn_menu;
|
||||||
const char *err;
|
const char *err;
|
||||||
menu_ent *opts;
|
menu_ent *opts;
|
||||||
size_t num_opts;
|
size_t num_opts;
|
||||||
|
|
||||||
opts = fill_part_edit_menu_opts(av->arg, true, ptn_edit_opts,
|
opts = fill_part_edit_menu_opts(data.parts, true, ptn_edit_opts,
|
||||||
__arraycount(ptn_edit_opts), &num_opts);
|
__arraycount(ptn_edit_opts), &num_opts);
|
||||||
if (opts == NULL)
|
if (opts == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -433,11 +449,121 @@ edit_part_entry(menudesc *m, void *arg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
static int
|
||||||
|
add_part_clone(menudesc *menu, void *arg)
|
||||||
|
{
|
||||||
|
struct outer_parts_data *pdata = arg;
|
||||||
|
struct disk_partitions *parts = pdata->av.arg;
|
||||||
|
struct clone_target_menu_data data;
|
||||||
|
menu_ent *men;
|
||||||
|
int num_men, i;
|
||||||
|
struct disk_part_info sinfo, cinfo;
|
||||||
|
struct disk_partitions *csrc;
|
||||||
|
struct disk_part_free_space space;
|
||||||
|
daddr_t offset, align;
|
||||||
|
size_t s;
|
||||||
|
part_id cid;
|
||||||
|
struct selected_partitions selected;
|
||||||
|
struct single_clone_data *new_clones;
|
||||||
|
|
||||||
|
if (!select_partitions(&selected, parts))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
new_clones = realloc(pdata->clones,
|
||||||
|
sizeof(*pdata->clones)*(pdata->num_clone_entries+1));
|
||||||
|
if (new_clones == NULL)
|
||||||
|
return 0;
|
||||||
|
pdata->num_clone_entries++;
|
||||||
|
pdata->clones = new_clones;
|
||||||
|
new_clones += (pdata->num_clone_entries-1);
|
||||||
|
memset(new_clones, 0, sizeof *new_clones);
|
||||||
|
new_clones->clone_src = selected;
|
||||||
|
|
||||||
|
memset(&data, 0, sizeof data);
|
||||||
|
data.usage.parts = parts;
|
||||||
|
|
||||||
|
/* if we already have partitions, ask for the target position */
|
||||||
|
if (parts->num_part > 0) {
|
||||||
|
data.res = -1;
|
||||||
|
num_men = parts->num_part+1;
|
||||||
|
men = calloc(num_men, sizeof *men);
|
||||||
|
if (men == NULL)
|
||||||
|
return 0;
|
||||||
|
for (i = 0; i < num_men; i++)
|
||||||
|
men[i].opt_action = clone_target_select;
|
||||||
|
men[num_men-1].opt_name = MSG_clone_target_end;
|
||||||
|
|
||||||
|
data.usage.menu = new_menu(MSG_clone_target_hdr,
|
||||||
|
men, num_men, 3, 2, 0, 65, MC_SCROLL,
|
||||||
|
NULL, draw_outer_part_line, NULL, NULL, MSG_cancel);
|
||||||
|
process_menu(data.usage.menu, &data);
|
||||||
|
free_menu(data.usage.menu);
|
||||||
|
free(men);
|
||||||
|
|
||||||
|
if (data.res < 0)
|
||||||
|
goto err;
|
||||||
|
} else {
|
||||||
|
data.res = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* find selected offset from data.res and insert clones there */
|
||||||
|
align = parts->pscheme->get_part_alignment(parts);
|
||||||
|
offset = -1;
|
||||||
|
if (data.res > 0) {
|
||||||
|
for (cid = 0; cid < (size_t)data.res; cid++) {
|
||||||
|
if (!parts->pscheme->get_part_info(parts, cid, &sinfo))
|
||||||
|
continue;
|
||||||
|
offset = sinfo.start + sinfo.size;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_clones->clone_ids = calloc(selected.num_sel,
|
||||||
|
sizeof(*new_clones->clone_ids));
|
||||||
|
if (new_clones->clone_ids == NULL)
|
||||||
|
goto err;
|
||||||
|
for (s = 0; s < selected.num_sel; s++) {
|
||||||
|
csrc = selected.selection[s].parts;
|
||||||
|
cid = selected.selection[s].id;
|
||||||
|
csrc->pscheme->get_part_info(csrc, cid, &sinfo);
|
||||||
|
if (!parts->pscheme->adapt_foreign_part_info(
|
||||||
|
parts, &cinfo, csrc->pscheme, &sinfo))
|
||||||
|
continue;
|
||||||
|
size_t cnt = parts->pscheme->get_free_spaces(
|
||||||
|
parts, &space, 1, cinfo.size-align, align,
|
||||||
|
offset, -1);
|
||||||
|
if (cnt == 0)
|
||||||
|
continue;
|
||||||
|
cinfo.start = space.start;
|
||||||
|
cid = parts->pscheme->add_partition(
|
||||||
|
parts, &cinfo, NULL);
|
||||||
|
new_clones->clone_ids[s] = cid;
|
||||||
|
if (cid == NO_PART)
|
||||||
|
continue;
|
||||||
|
parts->pscheme->get_part_info(parts, cid, &cinfo);
|
||||||
|
offset = rounddown(cinfo.start+cinfo.size+align, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reload menu and start again */
|
||||||
|
menu_opts_reload(menu, parts);
|
||||||
|
menu->cursel = parts->num_part+1;
|
||||||
|
if (parts->num_part == 0)
|
||||||
|
menu->cursel++;
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
err:
|
||||||
|
free_selected_partitions(&selected);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
add_part_entry(menudesc *m, void *arg)
|
add_part_entry(menudesc *m, void *arg)
|
||||||
{
|
{
|
||||||
arg_rv *av = arg;
|
struct outer_parts_data *pdata = arg;
|
||||||
struct part_edit_info data = { .parts = av->arg,
|
struct part_edit_info data = { .parts = pdata->av.arg,
|
||||||
.first_custom_opt = PTN_OPTS_COMMON };
|
.first_custom_opt = PTN_OPTS_COMMON };
|
||||||
int ptn_menu;
|
int ptn_menu;
|
||||||
daddr_t ptn_alignment;
|
daddr_t ptn_alignment;
|
||||||
|
@ -446,7 +572,7 @@ add_part_entry(menudesc *m, void *arg)
|
||||||
struct disk_part_free_space space;
|
struct disk_part_free_space space;
|
||||||
const char *err;
|
const char *err;
|
||||||
|
|
||||||
opts = fill_part_edit_menu_opts(av->arg, false, ptn_add_opts,
|
opts = fill_part_edit_menu_opts(data.parts, false, ptn_add_opts,
|
||||||
__arraycount(ptn_add_opts), &num_opts);
|
__arraycount(ptn_add_opts), &num_opts);
|
||||||
if (opts == NULL)
|
if (opts == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -617,8 +743,8 @@ draw_outer_ptn_header(menudesc *m, void *arg)
|
||||||
static void
|
static void
|
||||||
draw_outer_part_line(menudesc *m, int opt, void *arg)
|
draw_outer_part_line(menudesc *m, int opt, void *arg)
|
||||||
{
|
{
|
||||||
arg_rv *args = arg;
|
struct outer_parts_data *pdata = arg;
|
||||||
struct disk_partitions *parts = args->arg;
|
struct disk_partitions *parts = pdata->av.arg;
|
||||||
int len;
|
int len;
|
||||||
part_id pno = opt;
|
part_id pno = opt;
|
||||||
struct disk_part_info info;
|
struct disk_part_info info;
|
||||||
|
@ -677,9 +803,9 @@ draw_outer_part_line(menudesc *m, int opt, void *arg)
|
||||||
static int
|
static int
|
||||||
part_edit_abort(menudesc *m, void *arg)
|
part_edit_abort(menudesc *m, void *arg)
|
||||||
{
|
{
|
||||||
arg_rv *args = arg;
|
struct outer_parts_data *pdata = arg;
|
||||||
|
|
||||||
args->rv = -1;
|
pdata->av.rv = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,6 +819,9 @@ outer_fill_part_menu_opts(const struct disk_partitions *parts, size_t *cnt)
|
||||||
|
|
||||||
may_add = parts->pscheme->can_add_partition(parts);
|
may_add = parts->pscheme->can_add_partition(parts);
|
||||||
num_opts = 3 + parts->num_part;
|
num_opts = 3 + parts->num_part;
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
num_opts++;
|
||||||
|
#endif
|
||||||
if (parts->num_part == 0)
|
if (parts->num_part == 0)
|
||||||
num_opts++;
|
num_opts++;
|
||||||
if (may_add)
|
if (may_add)
|
||||||
|
@ -730,6 +859,13 @@ outer_fill_part_menu_opts(const struct disk_partitions *parts, size_t *cnt)
|
||||||
op++;
|
op++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
/* and a partition cloner */
|
||||||
|
op->opt_name = MSG_clone_from_elsewhere;
|
||||||
|
op->opt_action = add_part_clone;
|
||||||
|
op++;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* and unit changer */
|
/* and unit changer */
|
||||||
op->opt_name = MSG_askunits;
|
op->opt_name = MSG_askunits;
|
||||||
op->opt_menu = MENU_sizechoice;
|
op->opt_menu = MENU_sizechoice;
|
||||||
|
@ -743,6 +879,9 @@ outer_fill_part_menu_opts(const struct disk_partitions *parts, size_t *cnt)
|
||||||
op->opt_action = part_edit_abort;
|
op->opt_action = part_edit_abort;
|
||||||
op++;
|
op++;
|
||||||
|
|
||||||
|
/* counts are consistent? */
|
||||||
|
assert((op - opts) >= 0 && (size_t)(op - opts) == num_opts);
|
||||||
|
|
||||||
*cnt = num_opts;
|
*cnt = num_opts;
|
||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
|
@ -750,8 +889,8 @@ outer_fill_part_menu_opts(const struct disk_partitions *parts, size_t *cnt)
|
||||||
static void
|
static void
|
||||||
draw_outer_part_header(menudesc *m, void *arg)
|
draw_outer_part_header(menudesc *m, void *arg)
|
||||||
{
|
{
|
||||||
arg_rv *av = arg;
|
struct outer_parts_data *pdata = arg;
|
||||||
struct disk_partitions *parts = av->arg;
|
struct disk_partitions *parts = pdata->av.arg;
|
||||||
char start[SSTRSIZE], size[SSTRSIZE], col[SSTRSIZE],
|
char start[SSTRSIZE], size[SSTRSIZE], col[SSTRSIZE],
|
||||||
*disk_info, total[SSTRSIZE], avail[SSTRSIZE];
|
*disk_info, total[SSTRSIZE], avail[SSTRSIZE];
|
||||||
size_t sep;
|
size_t sep;
|
||||||
|
@ -1029,7 +1168,10 @@ ask_outer_partsizes(struct disk_partitions *parts)
|
||||||
int j;
|
int j;
|
||||||
int part_menu;
|
int part_menu;
|
||||||
size_t num_opts;
|
size_t num_opts;
|
||||||
arg_rv av;
|
#ifndef NO_CLONES
|
||||||
|
size_t i, ci;
|
||||||
|
#endif
|
||||||
|
struct outer_parts_data data;
|
||||||
|
|
||||||
part_menu_opts = outer_fill_part_menu_opts(parts, &num_opts);
|
part_menu_opts = outer_fill_part_menu_opts(parts, &num_opts);
|
||||||
part_menu = new_menu(outer_part_title, part_menu_opts, num_opts,
|
part_menu = new_menu(outer_part_title, part_menu_opts, num_opts,
|
||||||
|
@ -1048,18 +1190,18 @@ ask_outer_partsizes(struct disk_partitions *parts)
|
||||||
pm->current_cylsize = 16065; /* noone cares nowadays */
|
pm->current_cylsize = 16065; /* noone cares nowadays */
|
||||||
pm->ptstart = 0;
|
pm->ptstart = 0;
|
||||||
pm->ptsize = 0;
|
pm->ptsize = 0;
|
||||||
av.rv = 0;
|
memset(&data, 0, sizeof data);
|
||||||
|
data.av.arg = parts;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
av.arg = parts;
|
data.av.rv = 0;
|
||||||
av.rv = 0;
|
process_menu(part_menu, &data);
|
||||||
process_menu(part_menu, &av);
|
if (data.av.rv < 0)
|
||||||
if (av.rv < 0)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
j = verify_outer_parts(parts, false);
|
j = verify_outer_parts(parts, false);
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
av.rv = -1;
|
data.av.rv = -1;
|
||||||
return false;
|
return false;
|
||||||
} else if (j == 1) {
|
} else if (j == 1) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1067,10 +1209,31 @@ ask_outer_partsizes(struct disk_partitions *parts)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
/* handle cloned partitions content copies now */
|
||||||
|
for (i = 0; i < data.num_clone_entries; i++) {
|
||||||
|
for (ci = 0; ci < data.clones[i].clone_src.num_sel; ci++) {
|
||||||
|
if (data.clones[i].clone_src.with_data)
|
||||||
|
clone_partition_data(parts,
|
||||||
|
data.clones[i].clone_ids[ci],
|
||||||
|
data.clones[i].clone_src.selection[ci].
|
||||||
|
parts,
|
||||||
|
data.clones[i].clone_src.selection[ci].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free clone data */
|
||||||
|
if (data.clones) {
|
||||||
|
for (i = 0; i < data.num_clone_entries; i++)
|
||||||
|
free_selected_partitions(&data.clones[i].clone_src);
|
||||||
|
free(data.clones);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
free_menu(part_menu);
|
free_menu(part_menu);
|
||||||
free(part_menu_opts);
|
free(part_menu_opts);
|
||||||
|
|
||||||
return av.rv == 0;
|
return data.av.rv == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: partitions.c,v 1.1.2.2 2019/10/28 02:53:17 msaitoh Exp $ */
|
/* $NetBSD: partitions.c,v 1.1.2.3 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2018 The NetBSD Foundation, Inc.
|
* Copyright 2018 The NetBSD Foundation, Inc.
|
||||||
|
@ -65,6 +65,34 @@ partitions_read_disk(const char *dev, daddr_t disk_size, bool no_mbr)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
generic_adapt_foreign_part_info(const struct disk_partitions *myself,
|
||||||
|
struct disk_part_info *dest,
|
||||||
|
const struct disk_partitioning_scheme *src_scheme,
|
||||||
|
const struct disk_part_info *src)
|
||||||
|
{
|
||||||
|
*dest = *src;
|
||||||
|
if (myself->pscheme == src_scheme)
|
||||||
|
return true; /* no conversion needed */
|
||||||
|
|
||||||
|
if (src->nat_type == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* slightly simplistic, enhance when needed */
|
||||||
|
dest->nat_type = myself->pscheme->get_fs_part_type(dest->fs_type,
|
||||||
|
dest->fs_sub_type);
|
||||||
|
if (dest->nat_type == NULL)
|
||||||
|
dest->nat_type = myself->pscheme->get_generic_part_type(
|
||||||
|
src->nat_type->generic_ptype);
|
||||||
|
if (dest->nat_type == NULL)
|
||||||
|
dest->nat_type = myself->pscheme->create_unknown_part_type();
|
||||||
|
if (dest->nat_type == NULL)
|
||||||
|
dest->nat_type = myself->pscheme->get_generic_part_type(
|
||||||
|
PT_unknown);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*************** global init ****************************************/
|
/*************** global init ****************************************/
|
||||||
/*
|
/*
|
||||||
* Helper structure to fill our global list of available partitioning
|
* Helper structure to fill our global list of available partitioning
|
||||||
|
@ -171,3 +199,15 @@ static const struct part_scheme_desc all_descs[] = {
|
||||||
|
|
||||||
free(is_available);
|
free(is_available);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Final cleanup
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
partitions_cleanup(void)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < num_available_part_schemes; i++)
|
||||||
|
if (available_part_schemes[i]->cleanup != NULL)
|
||||||
|
available_part_schemes[i]->cleanup();
|
||||||
|
free(available_part_schemes);
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: partitions.h,v 1.4.2.3 2019/10/28 02:53:17 msaitoh Exp $ */
|
/* $NetBSD: partitions.h,v 1.4.2.4 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2018 The NetBSD Foundation, Inc.
|
* Copyright 2018 The NetBSD Foundation, Inc.
|
||||||
|
@ -233,6 +233,15 @@ struct disk_partitioning_scheme {
|
||||||
*/
|
*/
|
||||||
const struct part_type_desc * (*create_custom_part_type)
|
const struct part_type_desc * (*create_custom_part_type)
|
||||||
(const char *custom, const char **err_msg);
|
(const char *custom, const char **err_msg);
|
||||||
|
/*
|
||||||
|
* Return a usable internal partition type representation
|
||||||
|
* for types that are not otherwise mappable.
|
||||||
|
* This could be FS_OTHER for disklabel, or a randomly
|
||||||
|
* created type guid for GPT. This type may or may not be
|
||||||
|
* in the regular type list. If not, it needs to behave like a
|
||||||
|
* custom type.
|
||||||
|
*/
|
||||||
|
const struct part_type_desc * (*create_unknown_part_type)(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global attributes
|
* Global attributes
|
||||||
|
@ -343,8 +352,10 @@ struct disk_partitioning_scheme {
|
||||||
* This mostly adjusts flags and partition type pointers (using
|
* This mostly adjusts flags and partition type pointers (using
|
||||||
* more lose matching than add_partition would do).
|
* more lose matching than add_partition would do).
|
||||||
*/
|
*/
|
||||||
bool (*adapt_foreign_part_info)(const struct disk_partitions*,
|
bool (*adapt_foreign_part_info)(
|
||||||
const struct disk_part_info *src, struct disk_part_info *dest);
|
const struct disk_partitions *myself, struct disk_part_info *dest,
|
||||||
|
const struct disk_partitioning_scheme *src_scheme,
|
||||||
|
const struct disk_part_info *src);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update data for an existing partition
|
* Update data for an existing partition
|
||||||
|
@ -491,6 +502,9 @@ struct disk_partitioning_scheme {
|
||||||
|
|
||||||
/* Free all the data */
|
/* Free all the data */
|
||||||
void (*free)(struct disk_partitions*);
|
void (*free)(struct disk_partitions*);
|
||||||
|
|
||||||
|
/* Scheme global cleanup */
|
||||||
|
void (*cleanup)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -552,6 +566,16 @@ struct disk_partitions *
|
||||||
partitions_read_disk(const char *, daddr_t disk_size, bool no_mbr);
|
partitions_read_disk(const char *, daddr_t disk_size, bool no_mbr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* One time initialization
|
* Generic part info adaption, may be overriden by individual partitionin
|
||||||
|
* schemes
|
||||||
|
*/
|
||||||
|
bool generic_adapt_foreign_part_info(
|
||||||
|
const struct disk_partitions *myself, struct disk_part_info *dest,
|
||||||
|
const struct disk_partitioning_scheme *src_scheme,
|
||||||
|
const struct disk_part_info *src);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* One time initialization and clenaup
|
||||||
*/
|
*/
|
||||||
void partitions_init(void);
|
void partitions_init(void);
|
||||||
|
void partitions_cleanup(void);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: partman.c,v 1.41.2.1 2019/08/18 13:17:39 msaitoh Exp $ */
|
/* $NetBSD: partman.c,v 1.41.2.2 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2012 Eugene Lozovoy
|
* Copyright 2012 Eugene Lozovoy
|
||||||
|
@ -387,8 +387,9 @@ pm_dev_list(int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
menu_no = new_menu(MSG_avdisks,
|
menu_no = new_menu(MSG_avdisks,
|
||||||
menu_entries, num_devs, -1, -1, (num_devs+1<3)?3:num_devs+1, 13,
|
menu_entries, num_devs, -1, -1,
|
||||||
MC_SCROLL | MC_NOCLEAR, NULL, NULL, NULL, NULL, NULL);
|
(num_devs+1<3)?3:num_devs+1, 13,
|
||||||
|
MC_SCROLL | MC_NOCLEAR, NULL, NULL, NULL, NULL, MSG_cancel);
|
||||||
if (menu_no == -1)
|
if (menu_no == -1)
|
||||||
return (struct part_entry) { .retvalue = -1, };
|
return (struct part_entry) { .retvalue = -1, };
|
||||||
process_menu(menu_no, &dev_num);
|
process_menu(menu_no, &dev_num);
|
||||||
|
@ -589,7 +590,7 @@ pm_raid_set_value(menudesc *m, void *arg)
|
||||||
menu_disk_adddel = new_menu(NULL, menuent_disk_adddel,
|
menu_disk_adddel = new_menu(NULL, menuent_disk_adddel,
|
||||||
__arraycount(menuent_disk_adddel),
|
__arraycount(menuent_disk_adddel),
|
||||||
-1, -1, 0, 10, MC_NOCLEAR, NULL, NULL, NULL, NULL,
|
-1, -1, 0, 10, MC_NOCLEAR, NULL, NULL, NULL, NULL,
|
||||||
NULL);
|
MSG_cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m->cursel) {
|
switch (m->cursel) {
|
||||||
|
@ -762,8 +763,9 @@ pm_raid_disk_del(menudesc *m, void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
menu_no = new_menu(MSG_raid_disks,
|
menu_no = new_menu(MSG_raid_disks,
|
||||||
menu_entries, num_devs, -1, -1, (num_devs+1<3)?3:num_devs+1, 13,
|
menu_entries, num_devs, -1, -1,
|
||||||
MC_SCROLL | MC_NOCLEAR, NULL, NULL, NULL, NULL, NULL);
|
(num_devs+1<3)?3:num_devs+1, 13,
|
||||||
|
MC_SCROLL | MC_NOCLEAR, NULL, NULL, NULL, NULL, MSG_cancel);
|
||||||
if (menu_no == -1)
|
if (menu_no == -1)
|
||||||
return -1;
|
return -1;
|
||||||
process_menu(menu_no, &retvalue);
|
process_menu(menu_no, &retvalue);
|
||||||
|
@ -1488,8 +1490,9 @@ pm_lvm_disk_del(menudesc *m, void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
menu_no = new_menu(MSG_lvm_disks,
|
menu_no = new_menu(MSG_lvm_disks,
|
||||||
menu_entries, num_devs, -1, -1, (num_devs+1<3)?3:num_devs+1, 13,
|
menu_entries, num_devs, -1, -1,
|
||||||
MC_SCROLL | MC_NOCLEAR, NULL, NULL, NULL, NULL, NULL);
|
(num_devs+1<3)?3:num_devs+1, 13,
|
||||||
|
MC_SCROLL | MC_NOCLEAR, NULL, NULL, NULL, NULL, MSG_cancel);
|
||||||
if (menu_no == -1)
|
if (menu_no == -1)
|
||||||
return -1;
|
return -1;
|
||||||
process_menu(menu_no, &retvalue);
|
process_menu(menu_no, &retvalue);
|
||||||
|
@ -1597,7 +1600,7 @@ pm_lvm_set_value(menudesc *m, void *arg)
|
||||||
menu_disk_adddel = new_menu(NULL, menuent_disk_adddel,
|
menu_disk_adddel = new_menu(NULL, menuent_disk_adddel,
|
||||||
__arraycount(menuent_disk_adddel),
|
__arraycount(menuent_disk_adddel),
|
||||||
-1, -1, 0, 10, MC_NOCLEAR, NULL, NULL, NULL, NULL,
|
-1, -1, 0, 10, MC_NOCLEAR, NULL, NULL, NULL, NULL,
|
||||||
NULL);
|
MSG_cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m->cursel) {
|
switch (m->cursel) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: run.c,v 1.12 2019/06/22 20:46:07 christos Exp $ */
|
/* $NetBSD: run.c,v 1.12.2.1 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -99,7 +99,7 @@ do_logging(void)
|
||||||
|
|
||||||
menu_no = new_menu(MSG_Logging_functions, logmenu, 2, -1, 12,
|
menu_no = new_menu(MSG_Logging_functions, logmenu, 2, -1, 12,
|
||||||
0, 20, MC_SCROLL, NULL, log_menu_label, NULL,
|
0, 20, MC_SCROLL, NULL, log_menu_label, NULL,
|
||||||
MSG_Pick_an_option, NULL);
|
MSG_Pick_an_option, MSG_exit_menu_generic);
|
||||||
|
|
||||||
if (menu_no < 0) {
|
if (menu_no < 0) {
|
||||||
(void)fprintf(stderr, "Dynamic menu creation failed.\n");
|
(void)fprintf(stderr, "Dynamic menu creation failed.\n");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: util.c,v 1.29.2.4 2019/11/17 07:04:34 martin Exp $ */
|
/* $NetBSD: util.c,v 1.29.2.5 2019/11/17 13:45:26 msaitoh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
|
@ -972,7 +972,8 @@ extract_file(distinfo *dist, int update)
|
||||||
|
|
||||||
/* now extract set files into "./". */
|
/* now extract set files into "./". */
|
||||||
rval = run_program(RUN_DISPLAY | RUN_PROGRESS,
|
rval = run_program(RUN_DISPLAY | RUN_PROGRESS,
|
||||||
"progress -zf %s tar --chroot -xpf -", path);
|
"progress -zf %s tar --chroot "
|
||||||
|
TAR_EXTRACT_FLAGS " -", path);
|
||||||
|
|
||||||
chdir(owd);
|
chdir(owd);
|
||||||
free(owd);
|
free(owd);
|
||||||
|
@ -1147,9 +1148,16 @@ get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_
|
||||||
"> /tmp/boot.cfg.tmp'");
|
"> /tmp/boot.cfg.tmp'");
|
||||||
mv_within_target_or_die("/tmp/boot.cfg.tmp",
|
mv_within_target_or_die("/tmp/boot.cfg.tmp",
|
||||||
"/boot.cfg");
|
"/boot.cfg");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MD_BOOT_CFG_FINALIZE
|
||||||
|
if (target_file_exists_p("/boot.cfg")) {
|
||||||
|
MD_BOOT_CFG_FINALIZE("/boot.cfg");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Save keyboard type */
|
/* Save keyboard type */
|
||||||
save_kb_encoding();
|
save_kb_encoding();
|
||||||
|
|
||||||
|
@ -1463,7 +1471,8 @@ set_timezone(void)
|
||||||
menu_no = new_menu(NULL, NULL, 14, 23, 9,
|
menu_no = new_menu(NULL, NULL, 14, 23, 9,
|
||||||
12, 32, MC_ALWAYS_SCROLL | MC_NOSHORTCUT,
|
12, 32, MC_ALWAYS_SCROLL | MC_NOSHORTCUT,
|
||||||
tzm_set_names, NULL, NULL,
|
tzm_set_names, NULL, NULL,
|
||||||
"\nPlease consult the install documents.", NULL);
|
"\nPlease consult the install documents.",
|
||||||
|
MSG_exit_menu_generic);
|
||||||
if (menu_no < 0)
|
if (menu_no < 0)
|
||||||
goto done; /* error - skip timezone setting */
|
goto done; /* error - skip timezone setting */
|
||||||
|
|
||||||
|
@ -2040,41 +2049,47 @@ usage_set_from_parts(struct partition_usage_set *wanted,
|
||||||
return usage_info_list_from_parts(&wanted->infos, &wanted->num, parts);
|
return usage_info_list_from_parts(&wanted->infos, &wanted->num, parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct disk_partitions *
|
||||||
|
get_inner_parts(struct disk_partitions *parts)
|
||||||
|
{
|
||||||
|
daddr_t start, size;
|
||||||
|
part_id pno;
|
||||||
|
struct disk_part_info info;
|
||||||
|
|
||||||
|
if (parts->pscheme->secondary_scheme == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
start = -1;
|
||||||
|
size = -1;
|
||||||
|
if (parts->pscheme->guess_install_target == NULL ||
|
||||||
|
!parts->pscheme->guess_install_target(parts, &start, &size)) {
|
||||||
|
for (pno = 0; pno < parts->num_part; pno++) {
|
||||||
|
if (!parts->pscheme->get_part_info(parts, pno, &info))
|
||||||
|
continue;
|
||||||
|
if (!(info.flags & PTI_SEC_CONTAINER))
|
||||||
|
continue;
|
||||||
|
start = info.start;
|
||||||
|
size = info.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
|
return parts->pscheme->secondary_partitions(parts, start,
|
||||||
|
false);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
install_desc_from_parts(struct install_partition_desc *install,
|
install_desc_from_parts(struct install_partition_desc *install,
|
||||||
struct disk_partitions *parts)
|
struct disk_partitions *parts)
|
||||||
{
|
{
|
||||||
struct disk_partitions *inner_parts;
|
struct disk_partitions *inner_parts;
|
||||||
daddr_t start, size;
|
|
||||||
part_id pno;
|
|
||||||
struct disk_part_info info;
|
|
||||||
|
|
||||||
memset(install, 0, sizeof(*install));
|
memset(install, 0, sizeof(*install));
|
||||||
|
inner_parts = get_inner_parts(parts);
|
||||||
if (parts->pscheme->secondary_scheme != NULL) {
|
if (inner_parts != NULL)
|
||||||
start = -1;
|
parts = inner_parts;
|
||||||
size = -1;
|
|
||||||
if (parts->pscheme->guess_install_target != NULL &&
|
|
||||||
parts->pscheme->guess_install_target(parts,
|
|
||||||
&start, &size)) {
|
|
||||||
} else {
|
|
||||||
for (pno = 0; pno < parts->num_part; pno++) {
|
|
||||||
if (!parts->pscheme->get_part_info(parts, pno,
|
|
||||||
&info))
|
|
||||||
continue;
|
|
||||||
if (!(info.flags & PTI_SEC_CONTAINER))
|
|
||||||
continue;
|
|
||||||
start = info.start;
|
|
||||||
size = info.size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (size > 0) {
|
|
||||||
inner_parts = parts->pscheme->secondary_partitions(
|
|
||||||
parts, start, false);
|
|
||||||
if (inner_parts != NULL)
|
|
||||||
parts = inner_parts;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return usage_info_list_from_parts(&install->infos, &install->num,
|
return usage_info_list_from_parts(&install->infos, &install->num,
|
||||||
parts);
|
parts);
|
||||||
|
@ -2083,6 +2098,7 @@ install_desc_from_parts(struct install_partition_desc *install,
|
||||||
void
|
void
|
||||||
free_usage_set(struct partition_usage_set *wanted)
|
free_usage_set(struct partition_usage_set *wanted)
|
||||||
{
|
{
|
||||||
|
/* XXX - free parts? free clone src? */
|
||||||
free(wanted->menu_opts);
|
free(wanted->menu_opts);
|
||||||
free(wanted->infos);
|
free(wanted->infos);
|
||||||
}
|
}
|
||||||
|
@ -2090,6 +2106,20 @@ free_usage_set(struct partition_usage_set *wanted)
|
||||||
void
|
void
|
||||||
free_install_desc(struct install_partition_desc *install)
|
free_install_desc(struct install_partition_desc *install)
|
||||||
{
|
{
|
||||||
|
#ifndef NO_CLONES
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < install->num; i++) {
|
||||||
|
struct selected_partitions *src = install->infos[i].clone_src;
|
||||||
|
if (!(install->infos[i].flags & PUIFLG_CLONE_PARTS) ||
|
||||||
|
src == NULL)
|
||||||
|
continue;
|
||||||
|
free_selected_partitions(src);
|
||||||
|
for (j = i+1; j < install->num; j++)
|
||||||
|
if (install->infos[j].clone_src == src)
|
||||||
|
install->infos[j].clone_src = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
free(install->infos);
|
free(install->infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue