Home | History | Annotate | Line # | Download | only in sysinst
defs.h revision 1.29
      1 /*	$NetBSD: defs.h,v 1.29 2018/12/16 11:36:08 martin Exp $	*/
      2 
      3 /*
      4  * Copyright 1997 Piermont Information Systems Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Philip A. Nelson for Piermont Information Systems Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. The name of Piermont Information Systems Inc. may not be used to endorse
     18  *    or promote products derived from this software without specific prior
     19  *    written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
     22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
     25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31  * THE POSSIBILITY OF SUCH DAMAGE.
     32  *
     33  */
     34 
     35 #ifndef _DEFS_H_
     36 #define _DEFS_H_
     37 
     38 /* defs.h -- definitions for use in the sysinst program. */
     39 
     40 /* System includes needed for this. */
     41 #include <sys/queue.h>
     42 #include <sys/types.h>
     43 #include <sys/disklabel.h>
     44 #include <sys/disk.h>
     45 
     46 const char *getfslabelname(uint8_t);
     47 
     48 #include "msg_defs.h"
     49 #include "menu_defs.h"
     50 
     51 #define min(a,b)	((a) < (b) ? (a) : (b))
     52 #define max(a,b)	((a) > (b) ? (a) : (b))
     53 
     54 /* constants */
     55 #define MEG (1024 * 1024UL)
     56 #define GIG (1024 * MEG)
     57 #define STRSIZE 255
     58 #define SSTRSIZE 30
     59 
     60 /* For run.c: collect() */
     61 #define T_FILE		0
     62 #define T_OUTPUT	1
     63 
     64 /* Some install status/response values */
     65 #define	SET_OK		0		/* Set extracted */
     66 #define	SET_RETRY	1		/* Retry */
     67 #define	SET_SKIP	2		/* Skip this set */
     68 #define	SET_SKIP_GROUP	3		/* Skip this set and rest of group */
     69 #define	SET_ABANDON	4		/* Abandon installation */
     70 #define	SET_CONTINUE	5		/* Continue (copy from floppy loop) */
     71 
     72 /* run_prog flags */
     73 #define RUN_DISPLAY	0x0001		/* Display program output */
     74 #define RUN_FATAL	0x0002		/* errors are fatal */
     75 #define RUN_CHROOT	0x0004		/* chroot to target disk */
     76 #define RUN_FULLSCREEN	0x0008		/* fullscreen (use with RUN_DISPLAY) */
     77 #define RUN_SILENT	0x0010		/* Do not show output */
     78 #define RUN_ERROR_OK	0x0040		/* Don't wait for error confirmation */
     79 #define RUN_PROGRESS	0x0080		/* Output is just progess test */
     80 #define RUN_NO_CLEAR	0x0100		/* Leave program output after error */
     81 #define RUN_XFER_DIR	0x0200		/* cd to xfer_dir in child */
     82 
     83 /* for bsddisklabel.c */
     84 enum { LY_SETNEW, LY_NEWRAID, LY_NEWCGD, LY_NEWLVM, LY_USEEXIST };
     85 
     86 /* Installation sets */
     87 enum {
     88     SET_NONE,
     89     SET_KERNEL_FIRST,
     90     SET_KERNEL_1,	/* Usually GENERIC */
     91     SET_KERNEL_2,	/* MD kernel... */
     92     SET_KERNEL_3,	/* MD kernel... */
     93     SET_KERNEL_4,	/* MD kernel... */
     94     SET_KERNEL_5,	/* MD kernel... */
     95     SET_KERNEL_6,	/* MD kernel... */
     96     SET_KERNEL_7,	/* MD kernel... */
     97     SET_KERNEL_8,	/* MD kernel... */
     98     SET_KERNEL_9,	/* MD kernel... */
     99     SET_KERNEL_LAST,	/* allow 9 kernels */
    100 
    101     /* System sets */
    102     SET_BASE,		/* base */
    103     SET_ETC,		/* /etc */
    104     SET_COMPILER,	/* compiler tools */
    105     SET_GAMES,		/* text games */
    106     SET_MAN_PAGES,	/* online manual pages */
    107     SET_MISC,		/* miscellaneuous */
    108     SET_MODULES,	/* kernel modules */
    109     SET_TESTS,		/* tests */
    110     SET_TEXT_TOOLS,	/* text processing tools */
    111 
    112     /* X11 sets */
    113     SET_X11_FIRST,
    114     SET_X11_BASE,	/* X11 base and clients */
    115     SET_X11_FONTS,	/* X11 fonts */
    116     SET_X11_SERVERS,	/* X11 servers */
    117     SET_X11_PROG,	/* X11 programming */
    118     SET_X11_ETC,	/* X11 config */
    119     SET_X11_LAST,
    120 
    121     /* Machine dependent sets */
    122     SET_MD_1,		/* Machine dependent set */
    123     SET_MD_2,		/* Machine dependent set */
    124     SET_MD_3,		/* Machine dependent set */
    125     SET_MD_4,		/* Machine dependent set */
    126 
    127     /* Source sets */
    128     SET_SYSSRC,
    129     SET_SRC,
    130     SET_SHARESRC,
    131     SET_GNUSRC,
    132     SET_XSRC,
    133 
    134     /* Debug sets */
    135     SET_DEBUG,
    136     SET_X11_DEBUG,
    137 
    138     SET_LAST,
    139     SET_GROUP,		/* Start of submenu */
    140     SET_GROUP_END,	/* End of submenu */
    141     SET_PKGSRC,		/* pkgsrc, not counted as regular set */
    142 };
    143 
    144 /* Initialisers to select sets */
    145 /* All kernels */
    146 #define SET_KERNEL SET_KERNEL_1, SET_KERNEL_2, SET_KERNEL_3, SET_KERNEL_4, \
    147 		    SET_KERNEL_5, SET_KERNEL_6, SET_KERNEL_7, SET_KERNEL_8
    148 /* Core system sets */
    149 #define SET_CORE SET_MODULES, SET_BASE, SET_ETC
    150 /* All system sets */
    151 #define SET_SYSTEM SET_CORE, SET_COMPILER, SET_GAMES, \
    152 		    SET_MAN_PAGES, SET_MISC, SET_TESTS, SET_TEXT_TOOLS
    153 /* All X11 sets */
    154 #define SET_X11_NOSERVERS SET_X11_BASE, SET_X11_FONTS, SET_X11_PROG, SET_X11_ETC
    155 #define SET_X11 SET_X11_NOSERVERS, SET_X11_SERVERS
    156 
    157 /* All machine dependent sets */
    158 #define SET_MD SET_MD_1, SET_MD_2, SET_MD_3, SET_MD_4
    159 
    160 /* All source sets */
    161 #define SET_SOURCE SET_SYSSRC, SET_SRC, SET_SHARESRC, SET_GNUSRC, SET_XSRC
    162 
    163 /* All debug sets */
    164 #define SET_DEBUGGING SET_DEBUG, SET_X11_DEBUG
    165 
    166 /* Set list flags */
    167 #define SFLAG_MINIMAL	1
    168 #define	SFLAG_NOX	2
    169 
    170 /* Macros */
    171 #define nelem(x) (sizeof (x) / sizeof *(x))
    172 
    173 /* Round up to the next full cylinder size */
    174 #define NUMSEC(size, sizemult, cylsize) \
    175 	((size) == ~0u ? ~0u : (sizemult) == 1 ? (size) : \
    176 	 roundup((size) * (sizemult), (cylsize)))
    177 
    178 /* What FS type? */
    179 #define PI_ISBSDFS(p) ((p)->pi_fstype == FS_BSDLFS || \
    180 		       (p)->pi_fstype == FS_BSDFFS)
    181 
    182 /*
    183  * We do not offer CDs or floppies as installation target usually.
    184  * Architectures might want to undefine if they want to allow
    185  * these devices or redefine if they have unusual CD device names.
    186  * Do not define to empty or an empty string, undefine instead.
    187  */
    188 #define CD_NAMES "cd*"
    189 #define FLOPPY_NAMES "fd*"
    190 
    191 /* Types */
    192 
    193 /* pass a void* argument into a menu and also provide a int return value */
    194 typedef struct arg_rv {
    195 	void *arg;
    196 	int rv;
    197 } arg_rv;
    198 
    199 typedef struct distinfo {
    200 	const char	*name;
    201 	uint		set;
    202 	bool		force_tgz;	/* this set is always in .tgz format */
    203 	const char	*desc;
    204 	const char	*marker_file;	/* set assumed installed if exists */
    205 } distinfo;
    206 
    207 #define MOUNTLEN 20
    208 typedef struct _partinfo {
    209 	struct partition pi_partition;
    210 #define pi_size		pi_partition.p_size
    211 #define pi_offset	pi_partition.p_offset
    212 #define pi_fsize	pi_partition.p_fsize
    213 #define pi_fstype	pi_partition.p_fstype
    214 #define pi_frag		pi_partition.p_frag
    215 #define pi_cpg		pi_partition.p_cpg
    216 	char	pi_mount[MOUNTLEN];
    217 	uint	pi_isize;		/* bytes per inode (for # inodes) */
    218 	uint	pi_flags;
    219 #define PIF_NEWFS	0x0001		/* need to 'newfs' partition */
    220 #define PIF_FFSv2	0x0002		/* newfs with FFSv2, not FFSv1 */
    221 #define PIF_MOUNT	0x0004		/* need to mount partition */
    222 #define PIF_ASYNC	0x0010		/* mount -o async */
    223 #define PIF_NOATIME	0x0020		/* mount -o noatime */
    224 #define PIF_NODEV	0x0040		/* mount -o nodev */
    225 #define PIF_NODEVMTIME	0x0080		/* mount -o nodevmtime */
    226 #define PIF_NOEXEC	0x0100		/* mount -o noexec */
    227 #define PIF_NOSUID	0x0200		/* mount -o nosuid */
    228 #define PIF__UNUSED	0x0400		/* unused */
    229 #define PIF_LOG		0x0800		/* mount -o log */
    230 #define PIF_MOUNT_OPTS	0x0ff0		/* all above mount flags */
    231 #define PIF_RESET	0x1000		/* internal - restore previous values */
    232     const char *mnt_opts;
    233     const char *fsname;
    234     char mounted[MOUNTLEN];
    235     int lvmpv; /* should we use partition as LVM PV? */
    236 } partinfo;	/* Single partition from a disklabel */
    237 
    238 struct ptn_info {
    239 	int		menu_no;
    240 	struct ptn_size {
    241 		int	ptn_id;
    242 		char	mount[MOUNTLEN];
    243 		daddr_t	dflt_size;
    244 		daddr_t	size;
    245 		int	limit;
    246 		int	changed;
    247 	}		ptn_sizes[MAXPARTITIONS + 1];	/* +1 for delete code */
    248 	menu_ent	ptn_menus[MAXPARTITIONS + 1];	/* +1 for unit chg */
    249 	int		free_parts;
    250 	daddr_t		free_space;
    251 	struct ptn_size	*pool_part;
    252 	char		exit_msg[70];
    253 };
    254 
    255 /* variables */
    256 
    257 int debug;		/* set by -D option */
    258 
    259 char rel[SSTRSIZE];
    260 char machine[SSTRSIZE];
    261 
    262 int ignorerror;
    263 int ttysig_ignore;
    264 pid_t ttysig_forward;
    265 int layoutkind;
    266 int sizemult;
    267 const char *multname;
    268 int partman_go; /* run extended partition manager */
    269 
    270 /* logging variables */
    271 
    272 FILE *logfp;
    273 FILE *script;
    274 
    275 /* Information for the NetBSD disklabel */
    276 
    277 enum DLTR { PART_A, PART_B, PART_C, PART_D, PART_E, PART_F, PART_G, PART_H,
    278 	    PART_I, PART_J, PART_K, PART_L, PART_M, PART_N, PART_O, PART_P};
    279 #define partition_name(x)	('a' + (x))
    280 daddr_t tmp_ramdisk_size;
    281 #define MAX_DISKS 15
    282 
    283 unsigned int root_limit;    /* BIOS (etc) read limit */
    284 
    285 enum SHRED_T { SHRED_NONE=0, SHRED_ZEROS, SHRED_RANDOM, SHRED_CRYPTO };
    286 
    287 /* All information that is unique for each drive */
    288 SLIST_HEAD(pm_head_t, pm_devs_t) pm_head;
    289 
    290 typedef struct pm_devs_t {
    291     int unsaved; /* Flag indicating to partman that device need saving */
    292     int found; /* Flag to delete unplugged and unconfigured devices */
    293     int blocked; /* Device is busy and cannot be changed */
    294     void *refdev; /* If device is blocked thats is a pointers to a parent dev */
    295     int isspecial; /* LVM LV or DK device that doesnot accept disklabel */
    296     char diskdev[SSTRSIZE]; /* Actual name of the disk. */
    297     char diskdev_descr[STRSIZE];
    298     int bootable;
    299 #define DISKNAME_SIZE 16
    300     char bsddiskname[DISKNAME_SIZE];
    301     partinfo oldlabel[MAXPARTITIONS]; /* What we found on the disk */
    302     partinfo bsdlabel[MAXPARTITIONS]; /* What we want it to look like */
    303     int gpt;
    304     int no_mbr; /* set for raid (etc) */
    305     int no_part;	/* can not be partitioned, e.g. dk0 */
    306     int rootpart; /* partition we install into */
    307     const char *disktype; /* ST506, SCSI, ... */
    308     const char *doessf;
    309     /* Actual values for current disk - set by find_disks() or md_get_info() */
    310     int sectorsize, dlcyl, dlhead, dlsec, dlcylsize, current_cylsize;
    311     daddr_t dlsize;
    312     /* Area of disk we can allocate, start and size in disk sectors. */
    313     daddr_t ptstart, ptsize;
    314     /* If we have an MBR boot partition, start and size in sectors */
    315     int bootstart, bootsize;
    316     struct ptn_info pi;
    317     SLIST_ENTRY(pm_devs_t) l;
    318 } pm_devs_t;
    319 pm_devs_t *pm; /* Pointer to currend device with which we work */
    320 pm_devs_t *pm_new; /* Pointer for next allocating device in find_disks() */
    321 
    322 #define MAX_WEDGES 16 /* num of dk* devices */
    323 typedef struct pm_wedge_t {
    324     int allocated;
    325     int todel;
    326     pm_devs_t *pm;
    327     int ptn;
    328 } pm_wedge_t;
    329 pm_wedge_t wedges[MAX_WEDGES];
    330 
    331 /* Generic structure for partman */
    332 typedef struct {
    333     int retvalue;
    334     int dev_num;
    335     int wedge_num;
    336     void *dev_ptr;
    337     int dev_ptr_delta;
    338     char fullname[SSTRSIZE];
    339     enum {PM_DISK_T=1, PM_PART_T, PM_WEDGE_T, PM_SPEC_T, PM_RAID_T, PM_CGD_T,
    340         PM_VND_T, PM_LVM_T, PM_LVMLV_T} type;
    341 } part_entry_t;
    342 
    343 /* Relative file name for storing a distribution. */
    344 char xfer_dir[STRSIZE];
    345 int  clean_xfer_dir;
    346 
    347 #if !defined(SYSINST_FTP_HOST)
    348 #define SYSINST_FTP_HOST	"ftp.NetBSD.org"
    349 #endif
    350 
    351 #if !defined(SYSINST_HTTP_HOST)
    352 #define SYSINST_HTTP_HOST	"cdn.NetBSD.org"
    353 #endif
    354 
    355 #if !defined(SYSINST_FTP_DIR)
    356 #if defined(NETBSD_OFFICIAL_RELEASE)
    357 #define SYSINST_FTP_DIR		"pub/NetBSD/NetBSD-" REL
    358 #elif defined(REL_PATH)
    359 #define SYSINST_FTP_DIR		"pub/NetBSD-daily/" REL_PATH "/latest"
    360 #else
    361 #define SYSINST_FTP_DIR		"pub/NetBSD/NetBSD-" REL
    362 #endif
    363 #endif
    364 
    365 #if !defined(ARCH_SUBDIR)
    366 #define	ARCH_SUBDIR	MACH
    367 #endif
    368 #if !defined(PKG_ARCH_SUBDIR)
    369 #define	PKG_ARCH_SUBDIR	MACH
    370 #endif
    371 
    372 #if !defined(SYSINST_PKG_HOST)
    373 #define SYSINST_PKG_HOST	"ftp.NetBSD.org"
    374 #endif
    375 #if !defined(SYSINST_PKG_HTTP_HOST)
    376 #define SYSINST_PKG_HTTP_HOST	"cdn.NetBSD.org"
    377 #endif
    378 
    379 #if !defined(SYSINST_PKG_DIR)
    380 #define SYSINST_PKG_DIR		"pub/pkgsrc/packages/NetBSD"
    381 #endif
    382 
    383 #if !defined(PKG_SUBDIR)
    384 #define	PKG_SUBDIR		REL
    385 #endif
    386 
    387 #if !defined(SYSINST_PKGSRC_HOST)
    388 #define SYSINST_PKGSRC_HOST	SYSINST_PKG_HOST
    389 #endif
    390 #if !defined(SYSINST_PKGSRC_HTTP_HOST)
    391 #define SYSINST_PKGSRC_HTTP_HOST	SYSINST_PKG_HTTP_HOST
    392 #endif
    393 
    394 #ifndef SETS_TAR_SUFF
    395 #define	SETS_TAR_SUFF	 "tgz"
    396 #endif
    397 
    398 /* Abs. path we extract binary sets from */
    399 char ext_dir_bin[STRSIZE];
    400 
    401 /* Abs. path we extract source sets from */
    402 char ext_dir_src[STRSIZE];
    403 
    404 /* Abs. path we extract pkgsrc from */
    405 char ext_dir_pkgsrc[STRSIZE];
    406 
    407 /* Place we look for binary sets in all fs types */
    408 char set_dir_bin[STRSIZE];
    409 
    410 /* Place we look for source sets in all fs types */
    411 char set_dir_src[STRSIZE];
    412 
    413 /* Place we look for pkgs in all fs types */
    414 char pkg_dir[STRSIZE];
    415 
    416 /* Place we look for pkgsrc in all fs types */
    417 char pkgsrc_dir[STRSIZE];
    418 
    419 /* User shell */
    420 const char *ushell;
    421 
    422 #define	XFER_FTP	0
    423 #define	XFER_HTTP	1
    424 #define	XFER_MAX	XFER_HTTP
    425 
    426 struct ftpinfo {
    427     char xfer_host[XFER_MAX+1][STRSIZE];
    428     char dir[STRSIZE] ;
    429     char user[SSTRSIZE];
    430     char pass[STRSIZE];
    431     char proxy[STRSIZE];
    432     unsigned int xfer;	/* XFER_FTP for "ftp" or XFER_HTTP for "http" */
    433 };
    434 
    435 /* use the same struct for sets ftp and to build pkgpath */
    436 struct ftpinfo ftp, pkg, pkgsrc;
    437 
    438 int (*fetch_fn)(const char *);
    439 char nfs_host[STRSIZE];
    440 char nfs_dir[STRSIZE];
    441 
    442 char cdrom_dev[SSTRSIZE];		/* Typically "cd0a" */
    443 char fd_dev[SSTRSIZE];			/* Typically "/dev/fd0a" */
    444 const char *fd_type;			/* "msdos", "ffs" or maybe "ados" */
    445 
    446 char localfs_dev[SSTRSIZE];
    447 char localfs_fs[SSTRSIZE];
    448 char localfs_dir[STRSIZE];
    449 
    450 char targetroot_mnt[SSTRSIZE];
    451 
    452 int  mnt2_mounted;
    453 
    454 char dist_postfix[SSTRSIZE];
    455 char dist_tgz_postfix[SSTRSIZE];
    456 
    457 /* needed prototypes */
    458 void set_menu_numopts(int, int);
    459 void remove_color_options(void);
    460 void remove_raid_options(void);
    461 void remove_lvm_options(void);
    462 void remove_cgd_options(void);
    463 void remove_gpt_options(void);
    464 
    465 /* Machine dependent functions .... */
    466 void	md_init(void);
    467 void	md_prelim_menu(void);
    468 void	md_init_set_status(int); /* SFLAG_foo */
    469 
    470  /* MD functions if user selects install - in order called */
    471 int	md_get_info(void);
    472 int	md_make_bsd_partitions(void);
    473 int	md_check_partitions(void);
    474 int	md_pre_disklabel(void);
    475 int	md_post_disklabel(void);
    476 int	md_pre_mount(void);
    477 int	md_post_newfs(void);
    478 int	md_post_extract(void);
    479 void	md_cleanup_install(void);
    480 
    481  /* MD functions if user selects upgrade - in order called */
    482 int	md_pre_update(void);
    483 int	md_update(void);
    484 /* Also calls md_post_extract() */
    485 
    486 /* from main.c */
    487 void	toplevel(void);
    488 
    489 /* from disks.c */
    490 bool	get_default_cdrom(char *, size_t);
    491 int	find_disks(const char *);
    492 bool enumerate_disks(void *state,bool (*func)(void *state, const char *dev));
    493 bool is_cdrom_device(const char *dev, bool as_target);
    494 bool is_bootable_device(const char *dev);
    495 bool is_partitionable_device(const char *dev);
    496 
    497 struct menudesc;
    498 void	fmt_fspart(struct menudesc *, int, void *);
    499 void	disp_cur_fspart(int, int);
    500 int	write_disklabel(void);
    501 int	make_filesystems(void);
    502 int	make_fstab(void);
    503 int	mount_disks(void);
    504 int	set_swap_if_low_ram(const char *, partinfo *);
    505 int	set_swap(const char *, partinfo *);
    506 int	check_swap(const char *, int);
    507 char *bootxx_name(void);
    508 void label_read(void);
    509 int get_dkwedges(struct dkwedge_info **, const char *);
    510 const char *get_gptfs_by_id(int);
    511 
    512 
    513 /* from disks_lfs.c */
    514 int	fs_is_lfs(void *);
    515 
    516 /* from label.c */
    517 const char *get_last_mounted(int, int, partinfo *);
    518 int	savenewlabel(partinfo *, int);
    519 int	incorelabel(const char *, partinfo *);
    520 int	edit_and_check_label(partinfo *, int, int, int);
    521 void	set_bsize(partinfo *, int);
    522 void	set_fsize(partinfo *, int);
    523 void	set_ptype(partinfo *, int, int);
    524 int edit_ptn(menudesc *, void *);
    525 int checkoverlap(partinfo *, int, int, int);
    526 
    527 /* from install.c */
    528 void	do_install(void);
    529 
    530 /* from factor.c */
    531 void	factor(long, long *, int, int *);
    532 
    533 /* from fdisk.c */
    534 void	get_disk_info(char *);
    535 void	set_disk_info(char *);
    536 
    537 /* from geom.c */
    538 int	get_geom(const char *, struct disklabel *);
    539 int	get_real_geom(const char *, struct disklabel *);
    540 
    541 /* from net.c */
    542 extern int network_up;
    543 extern char net_namesvr[STRSIZE];
    544 int	get_via_ftp(unsigned int);
    545 int	get_via_nfs(void);
    546 int	config_network(void);
    547 void	mnt_net_config(void);
    548 void	make_url(char *, struct ftpinfo *, const char *);
    549 int	get_pkgsrc(void);
    550 const char *url_proto(unsigned int);
    551 
    552 /* From run.c */
    553 int	collect(int, char **, const char *, ...) __printflike(3, 4);
    554 int	run_program(int, const char *, ...) __printflike(2, 3);
    555 void	do_logging(void);
    556 int	do_system(const char *);
    557 
    558 /* from upgrade.c */
    559 void	do_upgrade(void);
    560 void	do_reinstall_sets(void);
    561 void	restore_etc(void);
    562 
    563 /* from util.c */
    564 char*	str_arg_subst(const char *, size_t, const char **);
    565 void	msg_display_subst(const char *, size_t, ...);
    566 int	ask_yesno(const char *);
    567 int	ask_noyes(const char *);
    568 int	dir_exists_p(const char *);
    569 int	file_exists_p(const char *);
    570 int	file_mode_match(const char *, unsigned int);
    571 uint	get_ramsize(void);
    572 void	ask_sizemult(int);
    573 void	run_makedev(void);
    574 int	boot_media_still_needed(void);
    575 int	get_via_floppy(void);
    576 int	get_via_cdrom(void);
    577 int	get_via_localfs(void);
    578 int	get_via_localdir(void);
    579 void	show_cur_distsets(void);
    580 void	make_ramdisk_dir(const char *);
    581 void    set_kernel_set(unsigned int);
    582 unsigned int    get_kernel_set(void);
    583 unsigned int    set_X11_selected(void);
    584 int 	get_and_unpack_sets(int, msg, msg, msg);
    585 int	sanity_check(void);
    586 int	set_timezone(void);
    587 void	scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3);
    588 void	scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0);
    589 void	add_rc_conf(const char *, ...);
    590 int	del_rc_conf(const char *);
    591 void	add_sysctl_conf(const char *, ...) __printflike(1, 2);
    592 void	enable_rc_conf(void);
    593 void	set_sizemultname_cyl(void);
    594 void	set_sizemultname_meg(void);
    595 int	binary_available(const char *);
    596 int	check_lfs_progs(void);
    597 void	init_set_status(int);
    598 void	customise_sets(void);
    599 void	umount_mnt2(void);
    600 int 	set_is_source(const char *);
    601 const char *set_dir_for_set(const char *);
    602 const char *ext_dir_for_set(const char *);
    603 void	replace(const char *, const char *, ...);
    604 void	get_tz_default(void);
    605 int	extract_file(distinfo *, int);
    606 void	do_coloring (unsigned int, unsigned int);
    607 int set_menu_select(menudesc *, void *);
    608 const char *safectime(time_t *);
    609 bool	use_tgz_for_set(const char*);
    610 const char *set_postfix(const char*);
    611 
    612 /* from target.c */
    613 #if defined(DEBUG)  ||	defined(DEBUG_ROOT)
    614 void	backtowin(void);
    615 #endif
    616 const	char *concat_paths(const char *, const char *);
    617 const	char *target_expand(const char *);
    618 void	make_target_dir(const char *);
    619 void	append_to_target_file(const char *, const char *);
    620 void	echo_to_target_file(const char *, const char *);
    621 void	sprintf_to_target_file(const char *, const char *, ...)
    622     __printflike(2, 3);
    623 void	trunc_target_file(const char *);
    624 const	char *target_prefix(void);
    625 int	target_chdir(const char *);
    626 void	target_chdir_or_die(const char *);
    627 int	target_already_root(void);
    628 FILE	*target_fopen(const char *, const char *);
    629 int	target_collect_file(int, char **, const char *);
    630 int	is_active_rootpart(const char *, int);
    631 int	cp_to_target(const char *, const char *);
    632 void	dup_file_into_target(const char *);
    633 void	mv_within_target_or_die(const char *, const char *);
    634 int	cp_within_target(const char *, const char *, int);
    635 int	target_mount(const char *, const char *, int, const char *);
    636 int target_mount_do(const char *, const char *, const char *);
    637 int	target_test(unsigned int, const char *);
    638 int	target_dir_exists_p(const char *);
    639 int	target_file_exists_p(const char *);
    640 int	target_symlink_exists_p(const char *);
    641 void	unwind_mounts(void);
    642 int	target_mounted(void);
    643 
    644 /* from partman.c */
    645 #ifndef NO_PARTMAN
    646 int partman(void);
    647 int pm_getrefdev(pm_devs_t *);
    648 void update_wedges(const char *);
    649 #else
    650 static inline int partman(void) { return -1; }
    651 static inline int pm_getrefdev(pm_devs_t *x __unused) { return -1; }
    652 #define update_wedges(x) __nothing
    653 #endif
    654 int pm_partusage(pm_devs_t *, int, int);
    655 void pm_setfstype(pm_devs_t *, int, int);
    656 int pm_editpart(int);
    657 void pm_rename(pm_devs_t *);
    658 int pm_shred(pm_devs_t *, int, int);
    659 void pm_umount(pm_devs_t *, int);
    660 int pm_unconfigure(pm_devs_t *);
    661 int pm_cgd_edit(void *, part_entry_t *);
    662 int pm_gpt_convert(pm_devs_t *);
    663 void pm_wedges_fill(pm_devs_t *);
    664 void pm_make_bsd_partitions(pm_devs_t *);
    665 
    666 /* flags whether to offer the respective options (depending on helper
    667    programs available on install media */
    668 int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk;
    669 /* initialize above variables */
    670 #ifndef NO_PARTMAN
    671 void check_available_binaries(void);
    672 #else
    673 #define check_available_binaries() __nothing
    674 #endif
    675 
    676 /* from bsddisklabel.c */
    677 int	make_bsd_partitions(void);
    678 int	save_ptn(int, daddr_t, daddr_t, int, const char *);
    679 void	set_ptn_titles(menudesc *, int, void *);
    680 void	set_ptn_menu(struct ptn_info *);
    681 int	set_ptn_size(menudesc *, void *);
    682 void	get_ptn_sizes(daddr_t, daddr_t, int);
    683 int check_partitions(void);
    684 
    685 /* from aout2elf.c */
    686 int move_aout_libs(void);
    687 
    688 #ifdef WSKBD
    689 void	get_kb_encoding(void);
    690 void	save_kb_encoding(void);
    691 #else
    692 #define	get_kb_encoding()
    693 #define	save_kb_encoding()
    694 #endif
    695 
    696 /* from configmenu.c */
    697 void	do_configmenu(void);
    698 
    699 /* from checkrc.c */
    700 int	check_rcvar(const char *);
    701 int	check_rcdefault(const char *);
    702 	WINDOW *mainwin;
    703 
    704 #endif	/* _DEFS_H_ */
    705