Home | History | Annotate | Line # | Download | only in sysinst
defs.h revision 1.88.2.1
      1  1.88.2.1       snj /*	$NetBSD: defs.h,v 1.88.2.1 2023/12/26 05:54:15 snj Exp $	*/
      2       1.1  dholland 
      3       1.1  dholland /*
      4       1.1  dholland  * Copyright 1997 Piermont Information Systems Inc.
      5       1.1  dholland  * All rights reserved.
      6       1.1  dholland  *
      7       1.1  dholland  * Written by Philip A. Nelson for Piermont Information Systems Inc.
      8       1.1  dholland  *
      9       1.1  dholland  * Redistribution and use in source and binary forms, with or without
     10       1.1  dholland  * modification, are permitted provided that the following conditions
     11       1.1  dholland  * are met:
     12       1.1  dholland  * 1. Redistributions of source code must retain the above copyright
     13       1.1  dholland  *    notice, this list of conditions and the following disclaimer.
     14       1.1  dholland  * 2. Redistributions in binary form must reproduce the above copyright
     15       1.1  dholland  *    notice, this list of conditions and the following disclaimer in the
     16       1.1  dholland  *    documentation and/or other materials provided with the distribution.
     17       1.1  dholland  * 3. The name of Piermont Information Systems Inc. may not be used to endorse
     18       1.1  dholland  *    or promote products derived from this software without specific prior
     19       1.1  dholland  *    written permission.
     20       1.1  dholland  *
     21       1.1  dholland  * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
     22       1.1  dholland  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23       1.1  dholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24       1.1  dholland  * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
     25       1.1  dholland  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26       1.1  dholland  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27       1.1  dholland  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28       1.1  dholland  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29       1.1  dholland  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30       1.1  dholland  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31       1.1  dholland  * THE POSSIBILITY OF SUCH DAMAGE.
     32       1.1  dholland  *
     33       1.1  dholland  */
     34       1.1  dholland 
     35       1.1  dholland #ifndef _DEFS_H_
     36       1.1  dholland #define _DEFS_H_
     37       1.1  dholland 
     38       1.1  dholland /* defs.h -- definitions for use in the sysinst program. */
     39       1.1  dholland 
     40       1.1  dholland /* System includes needed for this. */
     41       1.2    martin #include <sys/queue.h>
     42       1.1  dholland #include <sys/types.h>
     43       1.2    martin #include <sys/disk.h>
     44      1.69    martin #include <limits.h>
     45      1.34    martin #include <uuid.h>
     46       1.1  dholland 
     47      1.34    martin const char *getfslabelname(uint, uint);
     48       1.1  dholland 
     49       1.1  dholland #include "msg_defs.h"
     50       1.1  dholland #include "menu_defs.h"
     51      1.34    martin #include "partitions.h"
     52       1.1  dholland 
     53       1.1  dholland #define min(a,b)	((a) < (b) ? (a) : (b))
     54       1.1  dholland #define max(a,b)	((a) > (b) ? (a) : (b))
     55       1.1  dholland 
     56       1.1  dholland /* constants */
     57      1.34    martin #define MEG (1024UL * 1024UL)
     58      1.34    martin #define GIG (1024UL * MEG)
     59      1.34    martin #define STRSIZE		255
     60      1.34    martin #define	MENUSTRSIZE	80
     61      1.34    martin #define SSTRSIZE	30
     62      1.79    martin #define	DISKNAMESIZE	24	/* max(strlen("/dev/rsd22c")) */
     63      1.34    martin 
     64      1.53    martin /* these are used for different alignment defaults */
     65      1.34    martin #define	HUGE_DISK_SIZE	(daddr_t)(128 * (GIG / 512))
     66      1.34    martin #define	TINY_DISK_SIZE	(daddr_t)(1800 * (MEG / 512))
     67      1.34    martin 
     68      1.53    martin /*
     69      1.53    martin  * if a system does not have more ram (in MB) than this, swap will be enabled
     70      1.53    martin  * very early (as soon as the swap partition has been created)
     71      1.53    martin  */
     72      1.71    martin #ifdef	EXTRACT_NEEDS_BIG_RAM	/* we use an expensive decompressor */
     73      1.71    martin #define	TINY_RAM_SIZE		256
     74      1.71    martin #else
     75      1.53    martin #define	TINY_RAM_SIZE		32
     76      1.71    martin #endif
     77      1.71    martin 
     78      1.53    martin /*
     79      1.53    martin  * if a system has less ram (in MB) than this, we will not create a
     80      1.53    martin  * tmpfs /tmp by default (to workaround PR misc/54886)
     81      1.53    martin  */
     82      1.57    martin #define	SMALL_RAM_SIZE		384
     83      1.53    martin 
     84      1.34    martin /* helper macros to create unique internal error messages */
     85      1.34    martin #define STR_NO(STR)	#STR
     86      1.34    martin #define	TO_STR(NO)	STR_NO(NO)
     87      1.34    martin #define	INTERNAL_ERROR __FILE__ ":" TO_STR(__LINE__) ": internal error"
     88       1.1  dholland 
     89       1.1  dholland /* For run.c: collect() */
     90       1.1  dholland #define T_FILE		0
     91       1.1  dholland #define T_OUTPUT	1
     92       1.1  dholland 
     93       1.1  dholland /* Some install status/response values */
     94       1.1  dholland #define	SET_OK		0		/* Set extracted */
     95       1.1  dholland #define	SET_RETRY	1		/* Retry */
     96       1.1  dholland #define	SET_SKIP	2		/* Skip this set */
     97       1.1  dholland #define	SET_SKIP_GROUP	3		/* Skip this set and rest of group */
     98       1.1  dholland #define	SET_ABANDON	4		/* Abandon installation */
     99       1.1  dholland #define	SET_CONTINUE	5		/* Continue (copy from floppy loop) */
    100       1.1  dholland 
    101       1.1  dholland /* run_prog flags */
    102       1.1  dholland #define RUN_DISPLAY	0x0001		/* Display program output */
    103       1.1  dholland #define RUN_FATAL	0x0002		/* errors are fatal */
    104       1.1  dholland #define RUN_CHROOT	0x0004		/* chroot to target disk */
    105       1.1  dholland #define RUN_FULLSCREEN	0x0008		/* fullscreen (use with RUN_DISPLAY) */
    106       1.1  dholland #define RUN_SILENT	0x0010		/* Do not show output */
    107       1.1  dholland #define RUN_ERROR_OK	0x0040		/* Don't wait for error confirmation */
    108       1.1  dholland #define RUN_PROGRESS	0x0080		/* Output is just progess test */
    109       1.1  dholland #define RUN_NO_CLEAR	0x0100		/* Leave program output after error */
    110       1.1  dholland #define RUN_XFER_DIR	0x0200		/* cd to xfer_dir in child */
    111      1.81    martin #define	RUN_STDSCR	0x0400		/* run program in standard screen */
    112       1.1  dholland 
    113       1.2    martin /* for bsddisklabel.c */
    114      1.66    martin enum layout_type {
    115      1.76   msaitoh 	LY_KEEPEXISTING,	/* keep existing partitions */
    116      1.66    martin 	LY_OTHERSCHEME,		/* delete all, select new partitioning scheme */
    117      1.66    martin 	LY_SETSIZES,		/* edit sizes */
    118      1.66    martin 	LY_USEDEFAULT,		/* use default sizes */
    119      1.66    martin 	LY_USEFULL,		/* use full disk for NetBSD */
    120      1.88    martin 	LY_USENONE,		/* start with empty partitions, manual mode */
    121      1.66    martin 	LY_ERROR		/* used for "abort" in menu */
    122      1.66    martin };
    123      1.66    martin 
    124      1.34    martin enum setup_type { SY_NEWRAID, SY_NEWCGD, SY_NEWLVM };
    125       1.2    martin 
    126       1.1  dholland /* Installation sets */
    127       1.1  dholland enum {
    128       1.1  dholland     SET_NONE,
    129       1.1  dholland     SET_KERNEL_FIRST,
    130       1.1  dholland     SET_KERNEL_1,	/* Usually GENERIC */
    131       1.1  dholland     SET_KERNEL_2,	/* MD kernel... */
    132       1.1  dholland     SET_KERNEL_3,	/* MD kernel... */
    133       1.1  dholland     SET_KERNEL_4,	/* MD kernel... */
    134       1.1  dholland     SET_KERNEL_5,	/* MD kernel... */
    135       1.1  dholland     SET_KERNEL_6,	/* MD kernel... */
    136       1.1  dholland     SET_KERNEL_7,	/* MD kernel... */
    137       1.1  dholland     SET_KERNEL_8,	/* MD kernel... */
    138       1.1  dholland     SET_KERNEL_9,	/* MD kernel... */
    139       1.1  dholland     SET_KERNEL_LAST,	/* allow 9 kernels */
    140       1.1  dholland 
    141       1.1  dholland     /* System sets */
    142       1.1  dholland     SET_BASE,		/* base */
    143       1.1  dholland     SET_ETC,		/* /etc */
    144       1.1  dholland     SET_COMPILER,	/* compiler tools */
    145      1.62  jmcneill     SET_DTB,		/* devicetree hardware descriptions */
    146       1.1  dholland     SET_GAMES,		/* text games */
    147      1.73      maya     SET_GPUFW,		/* GPU firmware files */
    148       1.1  dholland     SET_MAN_PAGES,	/* online manual pages */
    149       1.1  dholland     SET_MISC,		/* miscellaneuous */
    150       1.1  dholland     SET_MODULES,	/* kernel modules */
    151      1.45      maya     SET_RESCUE,		/* /rescue recovery tools */
    152       1.1  dholland     SET_TESTS,		/* tests */
    153       1.1  dholland     SET_TEXT_TOOLS,	/* text processing tools */
    154       1.1  dholland 
    155       1.1  dholland     /* X11 sets */
    156       1.1  dholland     SET_X11_FIRST,
    157       1.1  dholland     SET_X11_BASE,	/* X11 base and clients */
    158       1.1  dholland     SET_X11_FONTS,	/* X11 fonts */
    159       1.1  dholland     SET_X11_SERVERS,	/* X11 servers */
    160       1.1  dholland     SET_X11_PROG,	/* X11 programming */
    161       1.1  dholland     SET_X11_ETC,	/* X11 config */
    162       1.1  dholland     SET_X11_LAST,
    163       1.1  dholland 
    164       1.1  dholland     /* Machine dependent sets */
    165       1.1  dholland     SET_MD_1,		/* Machine dependent set */
    166       1.1  dholland     SET_MD_2,		/* Machine dependent set */
    167       1.1  dholland     SET_MD_3,		/* Machine dependent set */
    168       1.1  dholland     SET_MD_4,		/* Machine dependent set */
    169      1.70    rillig 
    170       1.1  dholland     /* Source sets */
    171       1.1  dholland     SET_SYSSRC,
    172       1.1  dholland     SET_SRC,
    173       1.1  dholland     SET_SHARESRC,
    174       1.1  dholland     SET_GNUSRC,
    175       1.1  dholland     SET_XSRC,
    176       1.1  dholland 
    177       1.1  dholland     /* Debug sets */
    178       1.1  dholland     SET_DEBUG,
    179       1.1  dholland     SET_X11_DEBUG,
    180       1.1  dholland 
    181       1.1  dholland     SET_LAST,
    182       1.1  dholland     SET_GROUP,		/* Start of submenu */
    183       1.1  dholland     SET_GROUP_END,	/* End of submenu */
    184       1.1  dholland     SET_PKGSRC,		/* pkgsrc, not counted as regular set */
    185       1.1  dholland };
    186       1.1  dholland 
    187       1.1  dholland /* Initialisers to select sets */
    188       1.1  dholland /* All kernels */
    189       1.1  dholland #define SET_KERNEL SET_KERNEL_1, SET_KERNEL_2, SET_KERNEL_3, SET_KERNEL_4, \
    190       1.1  dholland 		    SET_KERNEL_5, SET_KERNEL_6, SET_KERNEL_7, SET_KERNEL_8
    191      1.68    martin #ifdef HAVE_MODULES
    192      1.68    martin #define	WITH_MODULES	SET_MODULES,
    193      1.68    martin #else
    194      1.68    martin #define	WITH_MODULES
    195      1.68    martin #endif
    196       1.1  dholland /* Core system sets */
    197      1.62  jmcneill #ifdef HAVE_DTB
    198      1.73      maya #define	WITH_DTB	SET_DTB,
    199      1.62  jmcneill #else
    200      1.73      maya #define	WITH_DTB
    201      1.62  jmcneill #endif
    202      1.74      maya #define SET_CORE WITH_MODULES SET_BASE, WITH_DTB SET_GPUFW, SET_ETC
    203       1.1  dholland /* All system sets */
    204       1.1  dholland #define SET_SYSTEM SET_CORE, SET_COMPILER, SET_GAMES, \
    205      1.45      maya 		    SET_MAN_PAGES, SET_MISC, SET_RESCUE, \
    206      1.45      maya 		    SET_TESTS, SET_TEXT_TOOLS
    207       1.1  dholland /* All X11 sets */
    208       1.1  dholland #define SET_X11_NOSERVERS SET_X11_BASE, SET_X11_FONTS, SET_X11_PROG, SET_X11_ETC
    209       1.1  dholland #define SET_X11 SET_X11_NOSERVERS, SET_X11_SERVERS
    210       1.1  dholland 
    211       1.1  dholland /* All machine dependent sets */
    212       1.1  dholland #define SET_MD SET_MD_1, SET_MD_2, SET_MD_3, SET_MD_4
    213       1.1  dholland 
    214       1.1  dholland /* All source sets */
    215       1.1  dholland #define SET_SOURCE SET_SYSSRC, SET_SRC, SET_SHARESRC, SET_GNUSRC, SET_XSRC
    216       1.1  dholland 
    217       1.1  dholland /* All debug sets */
    218       1.1  dholland #define SET_DEBUGGING SET_DEBUG, SET_X11_DEBUG
    219       1.1  dholland 
    220       1.1  dholland /* Set list flags */
    221       1.1  dholland #define SFLAG_MINIMAL	1
    222       1.1  dholland #define	SFLAG_NOX	2
    223       1.1  dholland 
    224       1.1  dholland /* Round up to the next full cylinder size */
    225       1.1  dholland #define NUMSEC(size, sizemult, cylsize) \
    226      1.34    martin 	((sizemult) == 1 ? (size) : \
    227       1.1  dholland 	 roundup((size) * (sizemult), (cylsize)))
    228       1.1  dholland 
    229       1.1  dholland /* What FS type? */
    230      1.34    martin #define PI_ISBSDFS(PI) (PI_FSTYPE(PI) == FS_BSDLFS || \
    231      1.34    martin 		        PI_FSTYPE(PI) == FS_BSDFFS)
    232       1.1  dholland 
    233      1.23    martin /*
    234      1.23    martin  * We do not offer CDs or floppies as installation target usually.
    235      1.23    martin  * Architectures might want to undefine if they want to allow
    236      1.23    martin  * these devices or redefine if they have unusual CD device names.
    237      1.23    martin  * Do not define to empty or an empty string, undefine instead.
    238      1.23    martin  */
    239      1.21    martin #define CD_NAMES "cd*"
    240      1.23    martin #define FLOPPY_NAMES "fd*"
    241       1.1  dholland 
    242       1.1  dholland /* Types */
    243       1.8    martin 
    244       1.8    martin /* pass a void* argument into a menu and also provide a int return value */
    245       1.8    martin typedef struct arg_rv {
    246       1.8    martin 	void *arg;
    247       1.8    martin 	int rv;
    248       1.8    martin } arg_rv;
    249       1.8    martin 
    250      1.34    martin /*
    251      1.34    martin  * A minimal argument for menus using string replacements
    252      1.34    martin  */
    253      1.34    martin typedef struct arg_replace {
    254      1.34    martin 	const char **argv;
    255      1.34    martin 	size_t argc;
    256      1.34    martin } arg_replace;
    257      1.34    martin 
    258      1.34    martin /*
    259      1.34    martin  * pass a parameter array (for string replacements) into a menu and provide
    260      1.34    martin  * an integer return value
    261      1.34    martin  */
    262      1.34    martin typedef struct arg_rep_int {
    263      1.34    martin 	arg_replace args;
    264      1.34    martin 	int rv;
    265      1.34    martin } arg_rep_int;
    266      1.34    martin 
    267       1.1  dholland typedef struct distinfo {
    268       1.1  dholland 	const char	*name;
    269       1.1  dholland 	uint		set;
    270      1.20    martin 	bool		force_tgz;	/* this set is always in .tgz format */
    271       1.1  dholland 	const char	*desc;
    272       1.1  dholland 	const char	*marker_file;	/* set assumed installed if exists */
    273       1.1  dholland } distinfo;
    274       1.1  dholland 
    275       1.2    martin #define MOUNTLEN 20
    276      1.34    martin 
    277      1.34    martin 
    278      1.34    martin /*
    279      1.34    martin  * A description of a future partition and its usage.
    280      1.34    martin  * A list of this is the output of the first stage partition
    281      1.34    martin  * editor, before it gets transformed into a concrete partition
    282      1.34    martin  * layout according to the partitioning scheme backend.
    283      1.34    martin  */
    284      1.34    martin struct part_usage_info {
    285      1.51    martin 	daddr_t	size;			/* thumb guestimate of size,
    286      1.51    martin 					 * [sec if positive, %-of-ram
    287      1.51    martin 					 * if TMPFS and negative]
    288      1.51    martin 					 */
    289      1.34    martin 	daddr_t def_size;		/* default size */
    290      1.34    martin 	daddr_t limit;			/* max size */
    291      1.34    martin 	char 	mount[MOUNTLEN];	/* where will we mount this? */
    292      1.34    martin 	enum part_type type;		/* PT_root/PT_swap/PT_EFI_SYSTEM */
    293      1.34    martin 
    294      1.34    martin #define	PUIFLAG_EXTEND		1	/* extend this part if free space
    295      1.34    martin 					 * is available */
    296      1.34    martin #define	PUIFLAG_ADD_OUTER	2	/* Add this partition to the outer
    297      1.34    martin 					 * partitions (if available) */
    298      1.37    martin #define	PUIFLG_IS_OUTER		4	/* this is an existing outer one */
    299      1.46    martin #define	PUIFLG_ADD_INNER	8	/* add outer also to inner */
    300      1.37    martin #define	PUIFLG_JUST_MOUNTPOINT	16	/* tmpfs of mfs mountpoints */
    301      1.46    martin #define	PUIFLG_CLONE_PARTS	32	/* clone external partitions */
    302      1.34    martin 	uint flags;
    303      1.34    martin 	struct disk_partitions *parts;	/* Where does this partition live?
    304      1.34    martin 					 * We currently only support
    305      1.34    martin 					 * a single disk, but we plan to
    306      1.34    martin 					 * extend that.
    307      1.34    martin 					 * Use pm->parts to access
    308      1.34    martin 					 * the partitions. */
    309      1.34    martin 	part_id cur_part_id;		/* this may change, but we try to
    310      1.34    martin 					 * fix it up after all changes */
    311      1.34    martin 	daddr_t cur_start;		/* may change during editing, just
    312      1.34    martin 					 * used as a unique identifier */
    313      1.34    martin 	uint32_t cur_flags;		/* PTI_* flags from disk_part_info */
    314      1.34    martin 
    315      1.34    martin #define PUIMNT_ASYNC		0x0001	/* mount -o async */
    316      1.34    martin #define PUIMNT_NOATIME		0x0002	/* mount -o noatime */
    317      1.34    martin #define PUIMNT_NODEV		0x0004	/* mount -o nodev */
    318      1.34    martin #define PUIMNT_NODEVMTIME	0x0008	/* mount -o nodevmtime */
    319      1.34    martin #define PUIMNT_NOEXEC		0x0010	/* mount -o noexec */
    320      1.34    martin #define PUIMNT_NOSUID		0x0020	/* mount -o nosuid */
    321      1.34    martin #define PUIMNT_LOG		0x0040	/* mount -o log */
    322      1.34    martin #define PUIMNT_NOAUTO		0x0080	/* "noauto" fstab flag */
    323      1.34    martin 	unsigned int mountflags;	/* flags for fstab */
    324      1.34    martin #define PUIINST_NEWFS	0x0001		/* need to 'newfs' partition */
    325      1.34    martin #define PUIINST_MOUNT	0x0002		/* need to mount partition */
    326      1.34    martin #define	PUIINST_BOOT	0x0004		/* this is a boot partition */
    327      1.34    martin 	unsigned int instflags;		/* installer handling flags */
    328      1.34    martin 	uint fs_type, fs_version;	/* e.g. FS_LFS, or FS_BSDFS,
    329      1.34    martin 					 * version = 2 for FFSv2 */
    330      1.67    martin 	uint fs_opt1, fs_opt2, fs_opt3;	/* FS specific, FFS: block/frag */
    331      1.47    martin #ifndef	NO_CLONES
    332      1.46    martin 	/*
    333      1.46    martin 	 * Only != NULL when PUIFLG_CLONE_PARTS is set, describes the
    334      1.46    martin 	 * source partitions to clone here.
    335      1.46    martin 	 */
    336      1.46    martin 	struct selected_partitions *clone_src;
    337      1.46    martin 	/*
    338      1.46    martin 	 * If clone_src != NULL, this record corresponds to a single
    339      1.46    martin 	 * selected source partition, if clone_ndx is a valid index in clone_src
    340      1.46    martin 	 * (>= 0 && <= clone_src->num_sel, or all of them if clone_ndx = ~0U.
    341      1.46    martin 	 */
    342      1.46    martin 	size_t clone_ndx;
    343      1.47    martin #endif
    344      1.34    martin };
    345      1.34    martin 
    346      1.34    martin /*
    347      1.34    martin  * A list of partition suggestions, bundled for editing
    348      1.34    martin  */
    349      1.34    martin struct partition_usage_set {
    350      1.63    martin 	struct disk_partitions *parts;	/* main partition table */
    351      1.63    martin 	size_t num;			/* number of infos */
    352      1.34    martin 	struct part_usage_info *infos;	/* 0 .. num-1 */
    353      1.63    martin 	struct disk_partitions **write_back;
    354      1.63    martin 					/* partition tables from which we
    355      1.63    martin 					 * did delete some partitions and
    356      1.63    martin 					 * that need updating, even if
    357      1.63    martin 					 * no active partition remains. */
    358      1.63    martin 	size_t num_write_back;		/* number of write_back */
    359      1.34    martin 	daddr_t cur_free_space;		/* estimate of free sectors */
    360      1.65    martin 	daddr_t reserved_space;		/* space we are not allowed to use */
    361      1.34    martin 	menu_ent *menu_opts;		/* 0 .. num+N */
    362      1.34    martin 	int menu;			/* the menu to edit this */
    363      1.34    martin 	bool ok;			/* ok to continue (all fit) */
    364      1.34    martin };
    365      1.34    martin 
    366      1.34    martin /*
    367      1.34    martin  * A structure we pass around in menus that edit a single partition out
    368      1.34    martin  * of a partition_usage_set.
    369      1.34    martin  */
    370      1.34    martin struct single_part_fs_edit {
    371      1.34    martin  	struct partition_usage_set *pset;
    372      1.67    martin 	size_t index, first_custom_attr, offset, mode;
    373      1.34    martin 	part_id id;
    374      1.34    martin 	struct disk_part_info info;	/* current partition data */
    375      1.34    martin 	struct part_usage_info *wanted;	/* points at our edit data */
    376      1.34    martin 
    377      1.34    martin 	/*
    378      1.34    martin 	 * "Backup" of old data, so we can restore previous values
    379      1.34    martin 	 * ("undo").
    380      1.34    martin 	 */
    381      1.34    martin 	struct part_usage_info old_usage;
    382      1.34    martin 	struct disk_part_info old_info;
    383      1.34    martin 
    384      1.34    martin 	/* menu return value */
    385      1.34    martin 	int rv;
    386      1.34    martin };
    387      1.34    martin 
    388      1.34    martin /*
    389      1.34    martin  * Description of a full target installation, all partitions and
    390      1.83    andvar  * devices (may be across several struct pm_devs / disks).
    391      1.34    martin  */
    392      1.34    martin struct install_partition_desc {
    393      1.34    martin 	size_t num;				/* how many entries in infos */
    394      1.34    martin 	struct part_usage_info *infos;		/* individual partitions */
    395      1.70    rillig 	struct disk_partitions **write_back;	/* partition tables from
    396      1.63    martin 						 * which we did delete some
    397      1.63    martin 						 * partitions and that need
    398      1.63    martin 						 * updating, even if no
    399      1.63    martin 						 * active partition remains. */
    400      1.63    martin 	size_t num_write_back;			/* number of write_back */
    401      1.41    martin 	bool cur_system;			/* target is the life system */
    402       1.1  dholland };
    403       1.1  dholland 
    404       1.1  dholland /* variables */
    405       1.1  dholland 
    406      1.58     joerg extern int debug;		/* set by -D option */
    407       1.1  dholland 
    408      1.58     joerg extern char machine[SSTRSIZE];
    409       1.1  dholland 
    410      1.58     joerg extern int ignorerror;
    411      1.58     joerg extern int ttysig_ignore;
    412      1.58     joerg extern pid_t ttysig_forward;
    413      1.58     joerg extern uint sizemult;
    414      1.34    martin extern const char *multname;
    415      1.34    martin extern const char *err_outofmem;
    416      1.58     joerg extern int partman_go; /* run extended partition manager */
    417       1.1  dholland 
    418       1.2    martin /* logging variables */
    419       1.1  dholland 
    420      1.58     joerg extern FILE *logfp;
    421      1.58     joerg extern FILE *script;
    422       1.1  dholland 
    423       1.2    martin #define MAX_DISKS 15
    424       1.2    martin 
    425      1.58     joerg extern daddr_t root_limit;    /* BIOS (etc) read limit */
    426       1.2    martin 
    427      1.50    martin enum SHRED_T { SHRED_NONE=0, SHRED_ZEROS, SHRED_RANDOM };
    428       1.1  dholland 
    429       1.2    martin /* All information that is unique for each drive */
    430      1.58     joerg extern SLIST_HEAD(pm_head_t, pm_devs) pm_head;
    431       1.2    martin 
    432      1.34    martin struct pm_devs {
    433      1.34    martin 	/*
    434      1.34    martin 	 * If device is blocked (e.g. part of a raid)
    435      1.34    martin 	 * this is a pointers to the  parent dev
    436      1.34    martin 	 */
    437      1.34    martin 	void *refdev;
    438      1.34    martin 
    439      1.34    martin 	char diskdev[SSTRSIZE];		/* Actual name of the disk. */
    440      1.34    martin 	char diskdev_descr[STRSIZE];	/* e.g. IDENTIFY result */
    441      1.34    martin 
    442      1.34    martin 	/*
    443      1.34    martin 	 * What the disk layout should look like.
    444      1.34    martin 	 */
    445      1.34    martin 	struct disk_partitions *parts;
    446      1.34    martin 
    447      1.34    martin 	/*
    448      1.34    martin 	 * The device does not take a MBR, even if we usually use
    449      1.34    martin 	 * MBR master / disklabel secondary partitioning.
    450      1.34    martin 	 * Used e.g. for raid* pseudo-disks.
    451      1.34    martin 	 */
    452      1.34    martin 	bool no_mbr;	/* userd for raid (etc) */
    453      1.34    martin 
    454      1.34    martin 	/*
    455      1.34    martin 	 * This device can not be partitioned (in any way).
    456      1.34    martin 	 * Used for wedges (dk*) or LVM devices.
    457      1.34    martin 	 */
    458      1.34    martin 	bool no_part;
    459      1.34    martin 
    460      1.41    martin 	/*
    461      1.41    martin 	 * This is a pseudo-device representing the currently running
    462      1.41    martin 	 * system (i.e. all mounted file systems).
    463      1.41    martin 	 */
    464      1.41    martin 	bool cur_system;
    465      1.41    martin 
    466      1.54    martin 	/* Actual values for current disk geometry - set by find_disks() or
    467      1.54    martin 	 *  md_get_info()
    468      1.54    martin 	 */
    469      1.54    martin 	uint sectorsize, dlcyl, dlhead, dlsec, dlcylsize, current_cylsize;
    470      1.54    martin 	/*
    471      1.54    martin 	 * Total size of the disk - in 'sectorsize' units (!)
    472      1.54    martin 	 */
    473      1.54    martin 	daddr_t dlsize;	/* total number of disk sectors */
    474      1.34    martin 
    475      1.54    martin 	/* Area of disk we can allocate, start and size in sectors. */
    476      1.34    martin 	daddr_t ptstart, ptsize;
    477      1.34    martin 
    478      1.34    martin 	/* For some bootblocks we need to know the CHS addressable limit */
    479      1.34    martin 	daddr_t max_chs;	/* bcyl * bhead * bsec */
    480      1.34    martin 
    481      1.34    martin 	/* If we have an MBR boot partition, start and size in sectors */
    482      1.34    martin 	daddr_t bootstart, bootsize;
    483      1.34    martin 
    484      1.34    martin 	/*
    485      1.34    martin 	 * In extended partitioning: all partitions in parts (number of
    486      1.34    martin 	 * entries is parts->num_part) may actually be mounted (temporarily)
    487      1.34    martin 	 * somewhere, e.g. to access a vnd device on them. This list has
    488      1.34    martin 	 * a pointer to the current mount point (strdup()'d) if mounted,
    489      1.34    martin 	 * or NULL if not.
    490      1.34    martin 	 */
    491      1.34    martin 	char **mounted;
    492      1.34    martin 
    493      1.34    martin 	bool unsaved;	/* Flag indicating to partman that device need saving */
    494      1.34    martin 	bool found;	/* Flag to delete unplugged and unconfigured devices */
    495      1.34    martin 	int blocked;	/* Device is busy and cannot be changed */
    496      1.34    martin 
    497      1.34    martin 	SLIST_ENTRY(pm_devs) l;
    498      1.34    martin };
    499      1.58     joerg extern struct pm_devs *pm; /* Pointer to current device with which we work */
    500      1.58     joerg extern struct pm_devs *pm_new; /* Pointer for next allocating device in find_disks() */
    501       1.2    martin 
    502       1.2    martin /* Generic structure for partman */
    503      1.34    martin struct part_entry {
    504      1.34    martin 	part_id id;
    505      1.34    martin 	struct disk_partitions *parts;
    506      1.34    martin 	void *dev_ptr;
    507      1.86    martin 	struct install_partition_desc *install;
    508      1.50    martin 	size_t index;	/* e.g. if PM_RAID: this is raids[index] */
    509      1.34    martin 	int dev_ptr_delta;
    510      1.34    martin 	char fullname[SSTRSIZE];
    511      1.34    martin 	enum {PM_DISK=1, PM_PART, PM_SPEC,
    512      1.34    martin 	    PM_RAID, PM_CGD, PM_VND, PM_LVM, PM_LVMLV} type;
    513      1.34    martin };
    514       1.1  dholland 
    515       1.1  dholland /* Relative file name for storing a distribution. */
    516      1.58     joerg extern char xfer_dir[STRSIZE];
    517      1.58     joerg extern int  clean_xfer_dir;
    518       1.1  dholland 
    519       1.1  dholland #if !defined(SYSINST_FTP_HOST)
    520       1.1  dholland #define SYSINST_FTP_HOST	"ftp.NetBSD.org"
    521       1.1  dholland #endif
    522       1.1  dholland 
    523      1.16    martin #if !defined(SYSINST_HTTP_HOST)
    524      1.16    martin #define SYSINST_HTTP_HOST	"cdn.NetBSD.org"
    525      1.16    martin #endif
    526      1.16    martin 
    527       1.1  dholland #if !defined(SYSINST_FTP_DIR)
    528      1.12    martin #if defined(NETBSD_OFFICIAL_RELEASE)
    529       1.1  dholland #define SYSINST_FTP_DIR		"pub/NetBSD/NetBSD-" REL
    530      1.13    martin #elif defined(REL_PATH)
    531      1.18    martin #define SYSINST_FTP_DIR		"pub/NetBSD-daily/" REL_PATH "/latest"
    532      1.12    martin #else
    533      1.13    martin #define SYSINST_FTP_DIR		"pub/NetBSD/NetBSD-" REL
    534      1.12    martin #endif
    535       1.1  dholland #endif
    536       1.1  dholland 
    537      1.29    martin #if !defined(ARCH_SUBDIR)
    538      1.29    martin #define	ARCH_SUBDIR	MACH
    539      1.29    martin #endif
    540      1.29    martin #if !defined(PKG_ARCH_SUBDIR)
    541      1.29    martin #define	PKG_ARCH_SUBDIR	MACH
    542      1.29    martin #endif
    543      1.29    martin 
    544       1.1  dholland #if !defined(SYSINST_PKG_HOST)
    545      1.15    martin #define SYSINST_PKG_HOST	"ftp.NetBSD.org"
    546       1.1  dholland #endif
    547      1.16    martin #if !defined(SYSINST_PKG_HTTP_HOST)
    548      1.16    martin #define SYSINST_PKG_HTTP_HOST	"cdn.NetBSD.org"
    549      1.16    martin #endif
    550       1.1  dholland 
    551       1.1  dholland #if !defined(SYSINST_PKG_DIR)
    552       1.1  dholland #define SYSINST_PKG_DIR		"pub/pkgsrc/packages/NetBSD"
    553       1.1  dholland #endif
    554       1.1  dholland 
    555      1.17    martin #if !defined(PKG_SUBDIR)
    556      1.17    martin #define	PKG_SUBDIR		REL
    557      1.17    martin #endif
    558      1.17    martin 
    559       1.1  dholland #if !defined(SYSINST_PKGSRC_HOST)
    560       1.1  dholland #define SYSINST_PKGSRC_HOST	SYSINST_PKG_HOST
    561       1.1  dholland #endif
    562      1.16    martin #if !defined(SYSINST_PKGSRC_HTTP_HOST)
    563      1.16    martin #define SYSINST_PKGSRC_HTTP_HOST	SYSINST_PKG_HTTP_HOST
    564      1.16    martin #endif
    565       1.1  dholland 
    566      1.20    martin #ifndef SETS_TAR_SUFF
    567      1.20    martin #define	SETS_TAR_SUFF	 "tgz"
    568      1.20    martin #endif
    569      1.20    martin 
    570      1.48    martin #ifdef	USING_PAXASTAR
    571      1.48    martin #define	TAR_EXTRACT_FLAGS	"-xhepf"
    572      1.48    martin #else
    573      1.55    martin #define	TAR_EXTRACT_FLAGS	"-xpf"
    574      1.48    martin #endif
    575      1.48    martin 
    576       1.1  dholland /* Abs. path we extract binary sets from */
    577      1.58     joerg extern char ext_dir_bin[STRSIZE];
    578       1.1  dholland 
    579       1.1  dholland /* Abs. path we extract source sets from */
    580      1.58     joerg extern char ext_dir_src[STRSIZE];
    581       1.1  dholland 
    582       1.1  dholland /* Abs. path we extract pkgsrc from */
    583      1.58     joerg extern char ext_dir_pkgsrc[STRSIZE];
    584       1.1  dholland 
    585       1.1  dholland /* Place we look for binary sets in all fs types */
    586      1.58     joerg extern char set_dir_bin[STRSIZE];
    587       1.1  dholland 
    588       1.1  dholland /* Place we look for source sets in all fs types */
    589      1.58     joerg extern char set_dir_src[STRSIZE];
    590       1.1  dholland 
    591       1.1  dholland /* Place we look for pkgs in all fs types */
    592      1.58     joerg extern char pkg_dir[STRSIZE];
    593       1.1  dholland 
    594       1.1  dholland /* Place we look for pkgsrc in all fs types */
    595      1.58     joerg extern char pkgsrc_dir[STRSIZE];
    596       1.1  dholland 
    597       1.1  dholland /* User shell */
    598      1.58     joerg extern const char *ushell;
    599       1.1  dholland 
    600      1.16    martin #define	XFER_FTP	0
    601      1.16    martin #define	XFER_HTTP	1
    602  1.88.2.1       snj #define	XFER_HTTPS	2
    603  1.88.2.1       snj #define	XFER_MAX	XFER_HTTPS
    604  1.88.2.1       snj #define	XFER_HOST_MAX	XFER_HTTP	/* http and https share a server name */
    605  1.88.2.1       snj #define	XFER_HOST(XFER)	((XFER) == XFER_FTP ? 0 : 1)
    606      1.16    martin 
    607       1.1  dholland struct ftpinfo {
    608  1.88.2.1       snj 	char xfer_host[XFER_HOST_MAX+1][STRSIZE];
    609      1.34    martin 	char dir[STRSIZE] ;
    610      1.34    martin 	char user[SSTRSIZE];
    611      1.34    martin 	char pass[STRSIZE];
    612      1.34    martin 	char proxy[STRSIZE];
    613      1.34    martin 	unsigned int xfer;	/* XFER_FTP for "ftp" or XFER_HTTP for "http" */
    614       1.1  dholland };
    615       1.1  dholland 
    616       1.1  dholland /* use the same struct for sets ftp and to build pkgpath */
    617      1.58     joerg extern struct ftpinfo ftp, pkg, pkgsrc;
    618       1.1  dholland 
    619      1.58     joerg extern int (*fetch_fn)(const char *);
    620      1.58     joerg extern char nfs_host[STRSIZE];
    621      1.58     joerg extern char nfs_dir[STRSIZE];
    622      1.69    martin extern char entropy_file[PATH_MAX];
    623       1.1  dholland 
    624      1.58     joerg extern char cdrom_dev[SSTRSIZE];		/* Typically "cd0a" */
    625      1.58     joerg extern char fd_dev[SSTRSIZE];			/* Typically "/dev/fd0a" */
    626      1.58     joerg extern const char *fd_type;			/* "msdos", "ffs" or maybe "ados" */
    627       1.1  dholland 
    628      1.58     joerg extern char localfs_dev[SSTRSIZE];
    629      1.58     joerg extern char localfs_fs[SSTRSIZE];
    630      1.58     joerg extern char localfs_dir[STRSIZE];
    631       1.1  dholland 
    632      1.58     joerg extern char targetroot_mnt[SSTRSIZE];
    633       1.1  dholland 
    634      1.58     joerg extern int  mnt2_mounted;
    635       1.1  dholland 
    636      1.58     joerg extern char dist_postfix[SSTRSIZE];
    637      1.58     joerg extern char dist_tgz_postfix[SSTRSIZE];
    638       1.1  dholland 
    639       1.1  dholland /* needed prototypes */
    640       1.1  dholland void set_menu_numopts(int, int);
    641       1.2    martin void remove_color_options(void);
    642      1.75    martin #ifdef CHECK_ENTROPY
    643      1.75    martin bool do_add_entropy(void);
    644      1.75    martin size_t entropy_needed(void);
    645      1.75    martin #endif
    646       1.3    martin void remove_raid_options(void);
    647       1.3    martin void remove_lvm_options(void);
    648       1.3    martin void remove_cgd_options(void);
    649       1.1  dholland 
    650       1.1  dholland /* Machine dependent functions .... */
    651       1.1  dholland void	md_init(void);
    652       1.1  dholland void	md_init_set_status(int); /* SFLAG_foo */
    653       1.1  dholland 
    654       1.1  dholland  /* MD functions if user selects install - in order called */
    655      1.34    martin bool	md_get_info(struct install_partition_desc*);
    656      1.66    martin /* returns -1 to restart partitioning, 0 for error, 1 for success */
    657      1.66    martin int	md_make_bsd_partitions(struct install_partition_desc*);
    658      1.34    martin bool	md_check_partitions(struct install_partition_desc*);
    659      1.34    martin #ifdef HAVE_GPT
    660      1.34    martin /*
    661      1.34    martin  * New GPT partitions have been written, update bootloader or remember
    662      1.34    martin  * data untill needed in md_post_newfs
    663      1.34    martin  */
    664      1.34    martin bool	md_gpt_post_write(struct disk_partitions*, part_id root_id,
    665      1.34    martin 	    bool root_is_new, part_id efi_id, bool efi_is_new);
    666      1.34    martin #endif
    667      1.34    martin /*
    668      1.34    martin  * md_pre_disklabel and md_post_disklabel may be called
    669      1.34    martin  * multiple times, for each affected device, with the
    670      1.34    martin  * "inner" partitions pointer of the relevant partitions
    671      1.34    martin  * passed.
    672      1.34    martin  */
    673      1.34    martin bool	md_pre_disklabel(struct install_partition_desc*, struct disk_partitions*);
    674      1.34    martin bool	md_post_disklabel(struct install_partition_desc*, struct disk_partitions*);
    675      1.85   tsutsui bool	md_disklabel_is_default(const struct disklabel *);
    676      1.38    martin int	md_pre_mount(struct install_partition_desc*, size_t);
    677      1.34    martin int	md_post_newfs(struct install_partition_desc*);
    678      1.78    martin int	md_post_extract(struct install_partition_desc*, bool upgrade);
    679      1.34    martin void	md_cleanup_install(struct install_partition_desc*);
    680       1.1  dholland 
    681       1.1  dholland  /* MD functions if user selects upgrade - in order called */
    682      1.34    martin int	md_pre_update(struct install_partition_desc*);
    683      1.34    martin int	md_update(struct install_partition_desc*);
    684       1.1  dholland /* Also calls md_post_extract() */
    685       1.1  dholland 
    686       1.1  dholland /* from main.c */
    687       1.1  dholland void	toplevel(void);
    688       1.1  dholland 
    689       1.1  dholland /* from disks.c */
    690      1.21    martin bool	get_default_cdrom(char *, size_t);
    691      1.41    martin int	find_disks(const char *, bool);
    692      1.22    martin bool enumerate_disks(void *state,bool (*func)(void *state, const char *dev));
    693      1.24    martin bool is_cdrom_device(const char *dev, bool as_target);
    694      1.25    martin bool is_bootable_device(const char *dev);
    695      1.25    martin bool is_partitionable_device(const char *dev);
    696      1.34    martin bool convert_scheme(struct pm_devs *p, bool is_boot_drive, const char **err_msg);
    697      1.47    martin 
    698      1.47    martin #ifndef	NO_CLONES
    699      1.46    martin /* a single partition selected for cloning (etc) */
    700      1.46    martin struct selected_partition {
    701      1.46    martin 	struct disk_partitions *parts;
    702      1.46    martin 	part_id id;
    703      1.46    martin };
    704      1.46    martin struct selected_partitions {
    705      1.46    martin 	struct selected_partition *selection;
    706      1.46    martin 	size_t num_sel;
    707      1.46    martin 	bool with_data;		/* partitions and their data selected */
    708      1.46    martin 	bool free_parts;	/* caller should free parts */
    709      1.46    martin };
    710      1.46    martin bool select_partitions(struct selected_partitions *res,
    711      1.46    martin     const struct disk_partitions *ignore);
    712      1.46    martin daddr_t	selected_parts_size(struct selected_partitions *);
    713      1.46    martin void	free_selected_partitions(struct selected_partitions *);
    714      1.46    martin 
    715      1.46    martin struct clone_target_menu_data {
    716      1.46    martin 	struct partition_usage_set usage;
    717      1.46    martin 	int res;
    718      1.46    martin };
    719      1.46    martin 
    720      1.46    martin int	clone_target_select(menudesc *m, void *arg);
    721      1.46    martin bool	clone_partition_data(struct disk_partitions *dest_parts, part_id did,
    722      1.46    martin 	struct disk_partitions *src_parts, part_id sid);
    723      1.47    martin #endif
    724      1.22    martin 
    725       1.1  dholland struct menudesc;
    726       1.1  dholland void	disp_cur_fspart(int, int);
    727      1.84    martin bool	can_newfs_fstype(unsigned int);
    728      1.34    martin int	make_filesystems(struct install_partition_desc *);
    729      1.34    martin int	make_fstab(struct install_partition_desc *);
    730      1.34    martin int	mount_disks(struct install_partition_desc *);
    731      1.72    martin void	set_swap_if_low_ram(struct install_partition_desc *);
    732      1.72    martin void	set_swap(struct install_partition_desc *);
    733      1.61    martin void	clear_swap(void);
    734       1.1  dholland int	check_swap(const char *, int);
    735      1.34    martin char *bootxx_name(struct install_partition_desc *);
    736       1.2    martin int get_dkwedges(struct dkwedge_info **, const char *);
    737       1.1  dholland 
    738       1.1  dholland /* from disks_lfs.c */
    739       1.1  dholland int	fs_is_lfs(void *);
    740       1.1  dholland 
    741       1.1  dholland /* from label.c */
    742      1.34    martin /*
    743      1.34    martin  * Bits valid for "flags" in get_last_mounted.
    744      1.34    martin  * Currently we return the real last mount from FFS, the volume label
    745      1.34    martin  * from FAT32, and nothing otherwise. The NTFS support is currently
    746      1.34    martin  * restricted to verify the partition has an NTFS (as some partitioning
    747      1.34    martin  * schemes do not tell NTFS from FAT).
    748      1.34    martin  */
    749      1.34    martin #define GLM_LIKELY_FFS		1U
    750      1.34    martin #define	GLM_MAYBE_FAT32		2U
    751      1.34    martin #define	GLM_MAYBE_NTFS		4U
    752      1.34    martin /*
    753      1.34    martin  * possible fs_sub_types are currently:
    754      1.34    martin  *  FS_BSDFFS:
    755      1.34    martin  *	0	unknown
    756      1.34    martin  *	1	FFSv1
    757      1.34    martin  *	2	FFSv2
    758      1.34    martin  * FS_MSDOS:
    759      1.34    martin  *	0	unknown
    760      1.34    martin  *	else	MBR_PTYPE_FAT* for the current FAT variant
    761      1.34    martin  * FS_NTFS:
    762      1.34    martin  *	0	unknown
    763      1.34    martin  *	else	MBR_PTYPE_NTFS (if valid NTFS was found)
    764      1.34    martin  *
    765      1.34    martin  * The fs_type and fs_sub_type pointers may be NULL.
    766      1.34    martin  */
    767      1.34    martin const char *get_last_mounted(int fd, daddr_t offset, uint *fs_type,
    768      1.34    martin      uint *fs_sub_type, uint flags);
    769      1.42    martin void	canonicalize_last_mounted(char*);
    770      1.50    martin int	edit_and_check_label(struct pm_devs *p, struct partition_usage_set *pset, bool install);
    771       1.2    martin int edit_ptn(menudesc *, void *);
    772      1.34    martin int checkoverlap(struct disk_partitions *parts);
    773      1.64    martin daddr_t getpartsize(struct disk_partitions *parts, daddr_t orig_start,
    774      1.64    martin     daddr_t partstart, daddr_t defpartsize);
    775      1.34    martin daddr_t getpartoff(struct disk_partitions *parts, daddr_t defpartstart);
    776       1.1  dholland 
    777       1.1  dholland /* from install.c */
    778       1.1  dholland void	do_install(void);
    779       1.1  dholland 
    780       1.1  dholland /* from factor.c */
    781       1.1  dholland void	factor(long, long *, int, int *);
    782       1.1  dholland 
    783       1.1  dholland /* from fdisk.c */
    784       1.1  dholland void	get_disk_info(char *);
    785       1.1  dholland void	set_disk_info(char *);
    786       1.1  dholland 
    787       1.1  dholland /* from geom.c */
    788      1.36  christos bool	disk_ioctl(const char *, unsigned long, void *);
    789      1.36  christos bool	get_wedge_list(const char *, struct dkwedge_list *);
    790      1.36  christos bool	get_wedge_info(const char *, struct dkwedge_info *);
    791      1.36  christos bool	get_disk_geom(const char *, struct disk_geom *);
    792      1.36  christos bool	get_label_geom(const char *, struct disklabel *);
    793       1.1  dholland 
    794       1.1  dholland /* from net.c */
    795       1.1  dholland extern int network_up;
    796       1.4       roy extern char net_namesvr[STRSIZE];
    797      1.16    martin int	get_via_ftp(unsigned int);
    798       1.1  dholland int	get_via_nfs(void);
    799      1.82    martin int	config_network(int force);
    800       1.1  dholland void	mnt_net_config(void);
    801       1.1  dholland void	make_url(char *, struct ftpinfo *, const char *);
    802       1.1  dholland int	get_pkgsrc(void);
    803      1.16    martin const char *url_proto(unsigned int);
    804       1.1  dholland 
    805       1.1  dholland /* From run.c */
    806       1.1  dholland int	collect(int, char **, const char *, ...) __printflike(3, 4);
    807       1.1  dholland int	run_program(int, const char *, ...) __printflike(2, 3);
    808       1.1  dholland void	do_logging(void);
    809       1.1  dholland int	do_system(const char *);
    810       1.1  dholland 
    811       1.1  dholland /* from upgrade.c */
    812       1.1  dholland void	do_upgrade(void);
    813      1.40    martin void	do_reinstall_sets(void);
    814       1.1  dholland void	restore_etc(void);
    815       1.1  dholland 
    816      1.34    martin /* from part_edit.c */
    817      1.34    martin int	err_msg_win(const char*);
    818      1.34    martin const struct disk_partitioning_scheme *select_part_scheme(struct pm_devs *dev,
    819      1.34    martin     const struct disk_partitioning_scheme *skip, bool bootable,
    820      1.34    martin     const char *title);
    821      1.66    martin /*
    822      1.66    martin  * return value:
    823      1.66    martin  *  0 -> abort
    824      1.66    martin  *  1 -> ok, continue
    825      1.66    martin  *  -1 -> partitions have been deleted, start from scratch
    826      1.66    martin */
    827      1.66    martin int	edit_outer_parts(struct disk_partitions*);
    828      1.34    martin bool	parts_use_wholedisk(struct disk_partitions*,
    829      1.34    martin 	     size_t add_ext_parts, const struct disk_part_info *ext_parts);
    830      1.34    martin 
    831      1.34    martin /*
    832      1.34    martin  * Machine dependent partitioning function, only used when
    833      1.34    martin  * innern/outer partitioning schemes are in use - this sets
    834      1.34    martin  * up the outer scheme for maximum NetBSD usage.
    835      1.34    martin  */
    836      1.34    martin bool	md_parts_use_wholedisk(struct disk_partitions*);
    837      1.34    martin 
    838       1.1  dholland /* from util.c */
    839      1.44    martin bool	root_is_read_only(void);
    840      1.34    martin void	get_ptn_alignment(const struct disk_partitions *parts, daddr_t *align, daddr_t *p0off);
    841      1.46    martin struct disk_partitions *get_inner_parts(struct disk_partitions *parts);
    842      1.27    martin char*	str_arg_subst(const char *, size_t, const char **);
    843      1.26    martin void	msg_display_subst(const char *, size_t, ...);
    844      1.34    martin void	msg_display_add_subst(const char *, size_t, ...);
    845       1.9    martin int	ask_yesno(const char *);
    846       1.9    martin int	ask_noyes(const char *);
    847      1.34    martin void	hit_enter_to_continue(const char *msg, const char *title);
    848      1.34    martin /*
    849      1.34    martin  * return value:
    850      1.34    martin  *  0 -> abort
    851      1.34    martin  *  1 -> re-edit
    852      1.34    martin  *  2 -> continue installation
    853      1.34    martin */
    854      1.34    martin int	ask_reedit(const struct disk_partitions *);
    855       1.1  dholland int	dir_exists_p(const char *);
    856       1.1  dholland int	file_exists_p(const char *);
    857       1.1  dholland int	file_mode_match(const char *, unsigned int);
    858      1.34    martin uint64_t	get_ramsize(void);	/* in MB! */
    859       1.1  dholland void	ask_sizemult(int);
    860       1.1  dholland void	run_makedev(void);
    861       1.1  dholland int	boot_media_still_needed(void);
    862       1.1  dholland int	get_via_floppy(void);
    863       1.1  dholland int	get_via_cdrom(void);
    864       1.1  dholland int	get_via_localfs(void);
    865       1.1  dholland int	get_via_localdir(void);
    866       1.1  dholland void	show_cur_distsets(void);
    867       1.1  dholland void	make_ramdisk_dir(const char *);
    868       1.1  dholland void    set_kernel_set(unsigned int);
    869      1.52    martin void    set_noextract_set(unsigned int);
    870       1.1  dholland unsigned int    get_kernel_set(void);
    871       1.1  dholland unsigned int    set_X11_selected(void);
    872       1.1  dholland int 	get_and_unpack_sets(int, msg, msg, msg);
    873       1.1  dholland int	sanity_check(void);
    874       1.1  dholland int	set_timezone(void);
    875       1.1  dholland void	scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3);
    876       1.1  dholland void	scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0);
    877      1.35  christos void	add_rc_conf(const char *, ...) __printflike(1, 2);
    878       1.1  dholland int	del_rc_conf(const char *);
    879       1.1  dholland void	add_sysctl_conf(const char *, ...) __printflike(1, 2);
    880       1.1  dholland void	enable_rc_conf(void);
    881      1.54    martin void	set_sizemult(daddr_t, uint bps);
    882      1.54    martin void	set_default_sizemult(const char *disk, daddr_t unit, uint bps);
    883       1.1  dholland int	check_lfs_progs(void);
    884       1.1  dholland void	init_set_status(int);
    885       1.1  dholland void	customise_sets(void);
    886       1.1  dholland void	umount_mnt2(void);
    887       1.1  dholland int 	set_is_source(const char *);
    888       1.1  dholland const char *set_dir_for_set(const char *);
    889       1.1  dholland const char *ext_dir_for_set(const char *);
    890      1.35  christos void	replace(const char *, const char *, ...) __printflike(2, 3);
    891       1.1  dholland void	get_tz_default(void);
    892      1.52    martin distinfo*	get_set_distinfo(int);
    893       1.1  dholland int	extract_file(distinfo *, int);
    894      1.52    martin int extract_file_to(distinfo *dist, int update, const char *dest_dir,
    895      1.52    martin     const char *extr_pattern, bool do_stats);
    896       1.2    martin void	do_coloring (unsigned int, unsigned int);
    897       1.2    martin int set_menu_select(menudesc *, void *);
    898       1.5  christos const char *safectime(time_t *);
    899      1.20    martin bool	use_tgz_for_set(const char*);
    900      1.20    martin const char *set_postfix(const char*);
    901      1.88    martin bool	empty_usage_set_from_parts(struct partition_usage_set*,
    902      1.88    martin 	    struct disk_partitions*);
    903      1.34    martin bool	usage_set_from_parts(struct partition_usage_set*,
    904      1.34    martin 	    struct disk_partitions*);
    905      1.86    martin bool	usage_set_from_install_desc(struct partition_usage_set*,
    906      1.86    martin 	    const struct install_partition_desc*,
    907      1.86    martin 	    struct disk_partitions*);
    908      1.86    martin bool	merge_usage_set_into_install_desc(struct install_partition_desc*,
    909      1.86    martin 	    const struct partition_usage_set*);
    910      1.34    martin void	free_usage_set(struct partition_usage_set*);
    911      1.34    martin bool	install_desc_from_parts(struct install_partition_desc *,
    912      1.34    martin 	    struct disk_partitions*);
    913      1.34    martin void	free_install_desc(struct install_partition_desc*);
    914      1.52    martin bool	may_swap_if_not_sdmmc(const char*);
    915       1.1  dholland 
    916       1.1  dholland /* from target.c */
    917       1.1  dholland #if defined(DEBUG)  ||	defined(DEBUG_ROOT)
    918       1.1  dholland void	backtowin(void);
    919       1.1  dholland #endif
    920      1.39    martin bool	is_root_part_mount(const char *);
    921       1.1  dholland const	char *concat_paths(const char *, const char *);
    922       1.1  dholland const	char *target_expand(const char *);
    923      1.34    martin bool	needs_expanding(const char *, size_t);
    924       1.1  dholland void	make_target_dir(const char *);
    925       1.1  dholland void	append_to_target_file(const char *, const char *);
    926       1.1  dholland void	echo_to_target_file(const char *, const char *);
    927       1.1  dholland void	trunc_target_file(const char *);
    928       1.1  dholland const	char *target_prefix(void);
    929       1.1  dholland int	target_chdir(const char *);
    930       1.1  dholland void	target_chdir_or_die(const char *);
    931       1.1  dholland int	target_already_root(void);
    932       1.1  dholland FILE	*target_fopen(const char *, const char *);
    933       1.1  dholland int	target_collect_file(int, char **, const char *);
    934       1.1  dholland int	is_active_rootpart(const char *, int);
    935       1.1  dholland int	cp_to_target(const char *, const char *);
    936       1.1  dholland void	dup_file_into_target(const char *);
    937       1.1  dholland void	mv_within_target_or_die(const char *, const char *);
    938       1.1  dholland int	cp_within_target(const char *, const char *, int);
    939      1.34    martin int	target_mount(const char *, const char *, const char *);
    940      1.80    martin int	target_unmount(const char *);
    941      1.34    martin int	target_mount_do(const char *, const char *, const char *);
    942       1.1  dholland int	target_test(unsigned int, const char *);
    943       1.1  dholland int	target_dir_exists_p(const char *);
    944       1.1  dholland int	target_file_exists_p(const char *);
    945       1.1  dholland int	target_symlink_exists_p(const char *);
    946       1.1  dholland void	unwind_mounts(void);
    947      1.77    martin void	register_post_umount_delwedge(const char *disk, const char *wedge);
    948       1.1  dholland int	target_mounted(void);
    949      1.43    martin void	umount_root(void);
    950       1.1  dholland 
    951       1.2    martin /* from partman.c */
    952      1.19       rin #ifndef NO_PARTMAN
    953      1.86    martin int partman(struct install_partition_desc*);
    954      1.34    martin int pm_getrefdev(struct pm_devs *);
    955      1.19       rin void update_wedges(const char *);
    956      1.34    martin void pm_destroy_all(void);
    957      1.19       rin #else
    958      1.87    martin static inline int partman(struct install_partition_desc *i __unused) { return -1; }
    959      1.34    martin static inline int pm_getrefdev(struct pm_devs *x __unused) { return -1; }
    960      1.19       rin #define update_wedges(x) __nothing
    961      1.19       rin #endif
    962      1.50    martin void pmdiskentry_enable(menudesc*, struct part_entry *);
    963      1.34    martin int pm_partusage(struct pm_devs *, int, int);
    964      1.34    martin void pm_setfstype(struct pm_devs *, part_id, int, int);
    965      1.50    martin void pm_set_lvmpv(struct pm_devs *, part_id, bool);
    966      1.50    martin bool pm_is_lvmpv(struct pm_devs *, part_id, const struct disk_part_info*);
    967       1.2    martin int pm_editpart(int);
    968      1.34    martin void pm_rename(struct pm_devs *);
    969      1.50    martin void pm_shred(struct part_entry *, int);
    970      1.34    martin void pm_umount(struct pm_devs *, int);
    971      1.34    martin int pm_unconfigure(struct pm_devs *);
    972      1.50    martin int pm_cgd_edit_new(struct pm_devs *pm, part_id id);
    973      1.50    martin int pm_cgd_edit_old(struct part_entry *);
    974      1.34    martin void pm_wedges_fill(struct pm_devs *);
    975      1.50    martin void pm_edit_partitions(struct part_entry *);
    976      1.50    martin part_id pm_whole_disk(struct part_entry *, int);
    977      1.50    martin struct pm_devs * pm_from_pe(struct part_entry *);
    978      1.50    martin bool pm_force_parts(struct pm_devs *);
    979      1.34    martin 
    980      1.34    martin /*
    981      1.34    martin  * Parse a file system position or size in a common way, return
    982      1.34    martin  * sector count and multiplicator.
    983      1.34    martin  * If "extend" is supported, things like 120+ will be parsed as
    984      1.34    martin  * 120 plus "extend this" flag.
    985      1.34    martin  * Caller needs to init muliplicator upfront to the default value.
    986      1.34    martin  */
    987      1.34    martin daddr_t parse_disk_pos(
    988      1.34    martin 	const char *,	/* in: input string */
    989      1.34    martin 	daddr_t *,	/* in/out: multiplicator for return value */
    990      1.54    martin 	daddr_t bps,	/* in: sector size in bytes */
    991      1.54    martin 	daddr_t,	/* in: cylinder size in sectors */
    992      1.34    martin 	bool *);	/* NULL if "extend" is not supported, & of
    993      1.34    martin 			 * "extend" flag otherwise */
    994       1.7    martin 
    995       1.7    martin /* flags whether to offer the respective options (depending on helper
    996       1.7    martin    programs available on install media */
    997      1.34    martin extern int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk;
    998       1.7    martin /* initialize above variables */
    999       1.7    martin void check_available_binaries(void);
   1000       1.2    martin 
   1001       1.1  dholland /* from bsddisklabel.c */
   1002      1.66    martin /* returns -1 to restart partitioning, 0 for error, 1 for success */
   1003      1.66    martin int	make_bsd_partitions(struct install_partition_desc*);
   1004       1.1  dholland void	set_ptn_titles(menudesc *, int, void *);
   1005       1.1  dholland int	set_ptn_size(menudesc *, void *);
   1006      1.34    martin bool	get_ptn_sizes(struct partition_usage_set*);
   1007      1.34    martin bool	check_partitions(struct install_partition_desc*);
   1008       1.1  dholland 
   1009       1.1  dholland /* from aout2elf.c */
   1010       1.1  dholland int move_aout_libs(void);
   1011       1.1  dholland 
   1012       1.1  dholland #ifdef WSKBD
   1013       1.1  dholland void	get_kb_encoding(void);
   1014       1.1  dholland void	save_kb_encoding(void);
   1015       1.1  dholland #else
   1016       1.1  dholland #define	get_kb_encoding()
   1017       1.1  dholland #define	save_kb_encoding()
   1018       1.1  dholland #endif
   1019       1.1  dholland 
   1020       1.1  dholland /* from configmenu.c */
   1021      1.34    martin void	do_configmenu(struct install_partition_desc*);
   1022      1.81    martin void	root_pw_setup(void);
   1023       1.1  dholland 
   1024       1.1  dholland /* from checkrc.c */
   1025       1.1  dholland int	check_rcvar(const char *);
   1026       1.1  dholland int	check_rcdefault(const char *);
   1027      1.58     joerg extern	WINDOW *mainwin;
   1028       1.2    martin 
   1029      1.34    martin /* in menus.mi */
   1030      1.34    martin void expand_all_option_texts(menudesc *menu, void *arg);
   1031      1.34    martin void resize_menu_height(menudesc *);
   1032      1.34    martin 
   1033       1.1  dholland #endif	/* _DEFS_H_ */
   1034