1 /* $NetBSD: defs.h,v 1.57 2020/03/16 06:48:17 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 int debug; /* set by -D option */ 364 365 char machine[SSTRSIZE]; 366 367 int ignorerror; 368 int ttysig_ignore; 369 pid_t ttysig_forward; 370 uint sizemult; 371 extern const char *multname; 372 extern const char *err_outofmem; 373 int partman_go; /* run extended partition manager */ 374 375 /* logging variables */ 376 377 FILE *logfp; 378 FILE *script; 379 380 #define MAX_DISKS 15 381 382 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 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 struct pm_devs *pm; /* Pointer to current device with which we work */ 457 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 char xfer_dir[STRSIZE]; 473 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 char ext_dir_bin[STRSIZE]; 534 535 /* Abs. path we extract source sets from */ 536 char ext_dir_src[STRSIZE]; 537 538 /* Abs. path we extract pkgsrc from */ 539 char ext_dir_pkgsrc[STRSIZE]; 540 541 /* Place we look for binary sets in all fs types */ 542 char set_dir_bin[STRSIZE]; 543 544 /* Place we look for source sets in all fs types */ 545 char set_dir_src[STRSIZE]; 546 547 /* Place we look for pkgs in all fs types */ 548 char pkg_dir[STRSIZE]; 549 550 /* Place we look for pkgsrc in all fs types */ 551 char pkgsrc_dir[STRSIZE]; 552 553 /* User shell */ 554 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 struct ftpinfo ftp, pkg, pkgsrc; 571 572 int (*fetch_fn)(const char *); 573 char nfs_host[STRSIZE]; 574 char nfs_dir[STRSIZE]; 575 576 char cdrom_dev[SSTRSIZE]; /* Typically "cd0a" */ 577 char fd_dev[SSTRSIZE]; /* Typically "/dev/fd0a" */ 578 const char *fd_type; /* "msdos", "ffs" or maybe "ados" */ 579 580 char localfs_dev[SSTRSIZE]; 581 char localfs_fs[SSTRSIZE]; 582 char localfs_dir[STRSIZE]; 583 584 char targetroot_mnt[SSTRSIZE]; 585 586 int mnt2_mounted; 587 588 char dist_postfix[SSTRSIZE]; 589 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 int set_swap_if_low_ram(struct install_partition_desc *); 677 int set_swap(struct install_partition_desc *); 678 int check_swap(const char *, int); 679 char *bootxx_name(struct install_partition_desc *); 680 int get_dkwedges(struct dkwedge_info **, const char *); 681 682 /* from disks_lfs.c */ 683 int fs_is_lfs(void *); 684 685 /* from label.c */ 686 /* 687 * Bits valid for "flags" in get_last_mounted. 688 * Currently we return the real last mount from FFS, the volume label 689 * from FAT32, and nothing otherwise. The NTFS support is currently 690 * restricted to verify the partition has an NTFS (as some partitioning 691 * schemes do not tell NTFS from FAT). 692 */ 693 #define GLM_LIKELY_FFS 1U 694 #define GLM_MAYBE_FAT32 2U 695 #define GLM_MAYBE_NTFS 4U 696 /* 697 * possible fs_sub_types are currently: 698 * FS_BSDFFS: 699 * 0 unknown 700 * 1 FFSv1 701 * 2 FFSv2 702 * FS_MSDOS: 703 * 0 unknown 704 * else MBR_PTYPE_FAT* for the current FAT variant 705 * FS_NTFS: 706 * 0 unknown 707 * else MBR_PTYPE_NTFS (if valid NTFS was found) 708 * 709 * The fs_type and fs_sub_type pointers may be NULL. 710 */ 711 const char *get_last_mounted(int fd, daddr_t offset, uint *fs_type, 712 uint *fs_sub_type, uint flags); 713 void canonicalize_last_mounted(char*); 714 int edit_and_check_label(struct pm_devs *p, struct partition_usage_set *pset, bool install); 715 int edit_ptn(menudesc *, void *); 716 int checkoverlap(struct disk_partitions *parts); 717 daddr_t getpartsize(struct disk_partitions *parts, daddr_t partstart, 718 daddr_t defpartsize); 719 daddr_t getpartoff(struct disk_partitions *parts, daddr_t defpartstart); 720 721 /* from install.c */ 722 void do_install(void); 723 724 /* from factor.c */ 725 void factor(long, long *, int, int *); 726 727 /* from fdisk.c */ 728 void get_disk_info(char *); 729 void set_disk_info(char *); 730 731 /* from geom.c */ 732 bool disk_ioctl(const char *, unsigned long, void *); 733 bool get_wedge_list(const char *, struct dkwedge_list *); 734 bool get_wedge_info(const char *, struct dkwedge_info *); 735 bool get_disk_geom(const char *, struct disk_geom *); 736 bool get_label_geom(const char *, struct disklabel *); 737 738 /* from net.c */ 739 extern int network_up; 740 extern char net_namesvr[STRSIZE]; 741 int get_via_ftp(unsigned int); 742 int get_via_nfs(void); 743 int config_network(void); 744 void mnt_net_config(void); 745 void make_url(char *, struct ftpinfo *, const char *); 746 int get_pkgsrc(void); 747 const char *url_proto(unsigned int); 748 749 /* From run.c */ 750 int collect(int, char **, const char *, ...) __printflike(3, 4); 751 int run_program(int, const char *, ...) __printflike(2, 3); 752 void do_logging(void); 753 int do_system(const char *); 754 755 /* from upgrade.c */ 756 void do_upgrade(void); 757 void do_reinstall_sets(void); 758 void restore_etc(void); 759 760 /* from part_edit.c */ 761 int err_msg_win(const char*); 762 const struct disk_partitioning_scheme *select_part_scheme(struct pm_devs *dev, 763 const struct disk_partitioning_scheme *skip, bool bootable, 764 const char *title); 765 bool edit_outer_parts(struct disk_partitions*); 766 bool parts_use_wholedisk(struct disk_partitions*, 767 size_t add_ext_parts, const struct disk_part_info *ext_parts); 768 769 /* 770 * Machine dependent partitioning function, only used when 771 * innern/outer partitioning schemes are in use - this sets 772 * up the outer scheme for maximum NetBSD usage. 773 */ 774 bool md_parts_use_wholedisk(struct disk_partitions*); 775 776 /* from util.c */ 777 bool root_is_read_only(void); 778 void get_ptn_alignment(const struct disk_partitions *parts, daddr_t *align, daddr_t *p0off); 779 struct disk_partitions *get_inner_parts(struct disk_partitions *parts); 780 char* str_arg_subst(const char *, size_t, const char **); 781 void msg_display_subst(const char *, size_t, ...); 782 void msg_display_add_subst(const char *, size_t, ...); 783 int ask_yesno(const char *); 784 int ask_noyes(const char *); 785 void hit_enter_to_continue(const char *msg, const char *title); 786 /* 787 * return value: 788 * 0 -> abort 789 * 1 -> re-edit 790 * 2 -> continue installation 791 */ 792 int ask_reedit(const struct disk_partitions *); 793 int dir_exists_p(const char *); 794 int file_exists_p(const char *); 795 int file_mode_match(const char *, unsigned int); 796 uint64_t get_ramsize(void); /* in MB! */ 797 void ask_sizemult(int); 798 void run_makedev(void); 799 int boot_media_still_needed(void); 800 int get_via_floppy(void); 801 int get_via_cdrom(void); 802 int get_via_localfs(void); 803 int get_via_localdir(void); 804 void show_cur_distsets(void); 805 void make_ramdisk_dir(const char *); 806 void set_kernel_set(unsigned int); 807 void set_noextract_set(unsigned int); 808 unsigned int get_kernel_set(void); 809 unsigned int set_X11_selected(void); 810 int get_and_unpack_sets(int, msg, msg, msg); 811 int sanity_check(void); 812 int set_timezone(void); 813 void scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3); 814 void scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0); 815 void add_rc_conf(const char *, ...) __printflike(1, 2); 816 int del_rc_conf(const char *); 817 void add_sysctl_conf(const char *, ...) __printflike(1, 2); 818 void enable_rc_conf(void); 819 void set_sizemult(daddr_t, uint bps); 820 void set_default_sizemult(const char *disk, daddr_t unit, uint bps); 821 int check_lfs_progs(void); 822 void init_set_status(int); 823 void customise_sets(void); 824 void umount_mnt2(void); 825 int set_is_source(const char *); 826 const char *set_dir_for_set(const char *); 827 const char *ext_dir_for_set(const char *); 828 void replace(const char *, const char *, ...) __printflike(2, 3); 829 void get_tz_default(void); 830 distinfo* get_set_distinfo(int); 831 int extract_file(distinfo *, int); 832 int extract_file_to(distinfo *dist, int update, const char *dest_dir, 833 const char *extr_pattern, bool do_stats); 834 void do_coloring (unsigned int, unsigned int); 835 int set_menu_select(menudesc *, void *); 836 const char *safectime(time_t *); 837 bool use_tgz_for_set(const char*); 838 const char *set_postfix(const char*); 839 bool usage_set_from_parts(struct partition_usage_set*, 840 struct disk_partitions*); 841 void free_usage_set(struct partition_usage_set*); 842 bool install_desc_from_parts(struct install_partition_desc *, 843 struct disk_partitions*); 844 void free_install_desc(struct install_partition_desc*); 845 bool may_swap_if_not_sdmmc(const char*); 846 847 /* from target.c */ 848 #if defined(DEBUG) || defined(DEBUG_ROOT) 849 void backtowin(void); 850 #endif 851 bool is_root_part_mount(const char *); 852 const char *concat_paths(const char *, const char *); 853 const char *target_expand(const char *); 854 bool needs_expanding(const char *, size_t); 855 void make_target_dir(const char *); 856 void append_to_target_file(const char *, const char *); 857 void echo_to_target_file(const char *, const char *); 858 void trunc_target_file(const char *); 859 const char *target_prefix(void); 860 int target_chdir(const char *); 861 void target_chdir_or_die(const char *); 862 int target_already_root(void); 863 FILE *target_fopen(const char *, const char *); 864 int target_collect_file(int, char **, const char *); 865 int is_active_rootpart(const char *, int); 866 int cp_to_target(const char *, const char *); 867 void dup_file_into_target(const char *); 868 void mv_within_target_or_die(const char *, const char *); 869 int cp_within_target(const char *, const char *, int); 870 int target_mount(const char *, const char *, const char *); 871 int target_mount_do(const char *, const char *, const char *); 872 int target_test(unsigned int, const char *); 873 int target_dir_exists_p(const char *); 874 int target_file_exists_p(const char *); 875 int target_symlink_exists_p(const char *); 876 void unwind_mounts(void); 877 int target_mounted(void); 878 void umount_root(void); 879 880 /* from partman.c */ 881 #ifndef NO_PARTMAN 882 int partman(void); 883 int pm_getrefdev(struct pm_devs *); 884 void update_wedges(const char *); 885 void pm_destroy_all(void); 886 #else 887 static inline int partman(void) { return -1; } 888 static inline int pm_getrefdev(struct pm_devs *x __unused) { return -1; } 889 #define update_wedges(x) __nothing 890 #endif 891 void pmdiskentry_enable(menudesc*, struct part_entry *); 892 int pm_partusage(struct pm_devs *, int, int); 893 void pm_setfstype(struct pm_devs *, part_id, int, int); 894 void pm_set_lvmpv(struct pm_devs *, part_id, bool); 895 bool pm_is_lvmpv(struct pm_devs *, part_id, const struct disk_part_info*); 896 int pm_editpart(int); 897 void pm_rename(struct pm_devs *); 898 void pm_shred(struct part_entry *, int); 899 void pm_umount(struct pm_devs *, int); 900 int pm_unconfigure(struct pm_devs *); 901 int pm_cgd_edit_new(struct pm_devs *pm, part_id id); 902 int pm_cgd_edit_old(struct part_entry *); 903 void pm_wedges_fill(struct pm_devs *); 904 void pm_edit_partitions(struct part_entry *); 905 part_id pm_whole_disk(struct part_entry *, int); 906 struct pm_devs * pm_from_pe(struct part_entry *); 907 bool pm_force_parts(struct pm_devs *); 908 909 /* 910 * Parse a file system position or size in a common way, return 911 * sector count and multiplicator. 912 * If "extend" is supported, things like 120+ will be parsed as 913 * 120 plus "extend this" flag. 914 * Caller needs to init muliplicator upfront to the default value. 915 */ 916 daddr_t parse_disk_pos( 917 const char *, /* in: input string */ 918 daddr_t *, /* in/out: multiplicator for return value */ 919 daddr_t bps, /* in: sector size in bytes */ 920 daddr_t, /* in: cylinder size in sectors */ 921 bool *); /* NULL if "extend" is not supported, & of 922 * "extend" flag otherwise */ 923 924 /* flags whether to offer the respective options (depending on helper 925 programs available on install media */ 926 extern int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk; 927 /* initialize above variables */ 928 void check_available_binaries(void); 929 930 /* from bsddisklabel.c */ 931 bool make_bsd_partitions(struct install_partition_desc*); 932 void set_ptn_titles(menudesc *, int, void *); 933 int set_ptn_size(menudesc *, void *); 934 bool get_ptn_sizes(struct partition_usage_set*); 935 bool check_partitions(struct install_partition_desc*); 936 937 /* from aout2elf.c */ 938 int move_aout_libs(void); 939 940 #ifdef WSKBD 941 void get_kb_encoding(void); 942 void save_kb_encoding(void); 943 #else 944 #define get_kb_encoding() 945 #define save_kb_encoding() 946 #endif 947 948 /* from configmenu.c */ 949 void do_configmenu(struct install_partition_desc*); 950 951 /* from checkrc.c */ 952 int check_rcvar(const char *); 953 int check_rcdefault(const char *); 954 WINDOW *mainwin; 955 956 /* in menus.mi */ 957 void expand_all_option_texts(menudesc *menu, void *arg); 958 void resize_menu_height(menudesc *); 959 960 #endif /* _DEFS_H_ */ 961