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