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