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