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