Expand PMF_FN_* macros.
[netbsd-mini2440.git] / distrib / utils / sysinst / defs.h
blobb2de7e4f68e81b42ef8dabfb5920e6bfb1be6ca8
1 /* $NetBSD: defs.h,v 1.146 2009/10/18 12:09:48 ahoka Exp $ */
3 /*
4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved.
7 * Written by Philip A. Nelson for Piermont Information Systems Inc.
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. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Piermont Information Systems Inc.
21 * 4. The name of Piermont Information Systems Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
23 * written permission.
25 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35 * THE POSSIBILITY OF SUCH DAMAGE.
39 #ifndef _DEFS_H_
40 #define _DEFS_H_
42 /* defs.h -- definitions for use in the sysinst program. */
44 /* System includes needed for this. */
45 #include <sys/types.h>
46 #include <sys/disklabel.h>
47 extern const char * const fstypenames[];
48 extern const char * const mountnames[];
50 static inline void *
51 deconst(const void *p)
53 return (char *)0 + ((const char *)p - (const char *)0);
56 #include "msg_defs.h"
57 #include "menu_defs.h"
59 #define min(a,b) ((a) < (b) ? (a) : (b))
60 #define max(a,b) ((a) > (b) ? (a) : (b))
62 /* constants */
63 #define MEG (1024 * 1024)
64 #define STRSIZE 255
65 #define SSTRSIZE 30
67 /* For run.c: collect() */
68 #define T_FILE 0
69 #define T_OUTPUT 1
71 /* Some install status/response values */
72 #define SET_OK 0 /* Set extracted */
73 #define SET_RETRY 1 /* Retry */
74 #define SET_SKIP 2 /* Skip this set */
75 #define SET_SKIP_GROUP 3 /* Skip this set and rest of group */
76 #define SET_ABANDON 4 /* Abandon installation */
77 #define SET_CONTINUE 5 /* Continue (copy from floppy loop) */
79 /* run_prog flags */
80 #define RUN_DISPLAY 0x0001 /* Display program output */
81 #define RUN_FATAL 0x0002 /* errors are fatal */
82 #define RUN_CHROOT 0x0004 /* chroot to target disk */
83 #define RUN_FULLSCREEN 0x0008 /* fullscreen (use with RUN_DISPLAY) */
84 #define RUN_SILENT 0x0010 /* Do not show output */
85 #define RUN_ERROR_OK 0x0040 /* Don't wait for error confirmation */
86 #define RUN_PROGRESS 0x0080 /* Output is just progess test */
87 #define RUN_NO_CLEAR 0x0100 /* Leave program output after error */
88 #define RUN_XFER_DIR 0x0200 /* cd to xfer_dir in child */
90 /* Installation sets */
91 enum {
92 SET_NONE,
93 SET_KERNEL_FIRST,
94 SET_KERNEL_1, /* Usually GENERIC */
95 SET_KERNEL_2, /* MD kernel... */
96 SET_KERNEL_3, /* MD kernel... */
97 SET_KERNEL_4, /* MD kernel... */
98 SET_KERNEL_5, /* MD kernel... */
99 SET_KERNEL_6, /* MD kernel... */
100 SET_KERNEL_7, /* MD kernel... */
101 SET_KERNEL_8, /* MD kernel... */
102 SET_KERNEL_LAST, /* allow 8 kernels */
104 /* System sets */
105 SET_BASE, /* base */
106 SET_ETC, /* /etc */
107 SET_COMPILER, /* compiler tools */
108 SET_GAMES, /* text games */
109 SET_MAN_PAGES, /* online manual pages */
110 SET_MISC, /* miscellaneuous */
111 SET_MODULES, /* kernel modules */
112 SET_TESTS, /* tests */
113 SET_TEXT_TOOLS, /* text processing tools */
115 /* X11 sets */
116 SET_X11_FIRST,
117 SET_X11_BASE, /* X11 base and clients */
118 SET_X11_FONTS, /* X11 fonts */
119 SET_X11_SERVERS, /* X11 servers */
120 SET_X11_PROG, /* X11 programming */
121 SET_X11_ETC, /* X11 config */
122 SET_X11_LAST,
124 /* Machine dependant sets */
125 SET_MD_1, /* Machine dependant set */
126 SET_MD_2, /* Machine dependant set */
127 SET_MD_3, /* Machine dependant set */
128 SET_MD_4, /* Machine dependant set */
130 SET_LAST,
131 SET_GROUP, /* Start of submenu */
132 SET_GROUP_END, /* End of submenu */
135 /* Initialisers to select sets */
136 /* All kernels */
137 #define SET_KERNEL SET_KERNEL_1, SET_KERNEL_2, SET_KERNEL_3, SET_KERNEL_4, \
138 SET_KERNEL_5, SET_KERNEL_6, SET_KERNEL_7, SET_KERNEL_8
139 /* Core system sets */
140 #define SET_CORE SET_MODULES, SET_BASE, SET_ETC
141 /* All system sets */
142 #define SET_SYSTEM SET_CORE, SET_COMPILER, SET_GAMES, \
143 SET_MAN_PAGES, SET_MISC, SET_TESTS, SET_TEXT_TOOLS
144 /* All X11 sets */
145 #define SET_X11_NOSERVERS SET_X11_BASE, SET_X11_FONTS, SET_X11_PROG, SET_X11_ETC
146 #define SET_X11 SET_X11_NOSERVERS, SET_X11_SERVERS
148 /* All machine dependant sets */
149 #define SET_MD SET_MD_1, SET_MD_2, SET_MD_3, SET_MD_4
151 /* Macros */
152 #define nelem(x) (sizeof (x) / sizeof *(x))
154 /* Round up to the next full cylinder size */
155 #define NUMSEC(size, sizemult, cylsize) \
156 ((size) == ~0u ? ~0u : (sizemult) == 1 ? (size) : \
157 roundup((size) * (sizemult), (cylsize)))
159 /* What FS type? */
160 #define PI_ISBSDFS(p) ((p)->pi_fstype == FS_BSDLFS || \
161 (p)->pi_fstype == FS_BSDFFS)
163 /* Types */
164 typedef struct distinfo {
165 const char *name;
166 uint set;
167 const char *desc;
168 const char *marker_file; /* set assumed installed if exists */
169 } distinfo;
171 typedef struct _partinfo {
172 struct partition pi_partition;
173 #define pi_size pi_partition.p_size
174 #define pi_offset pi_partition.p_offset
175 #define pi_fsize pi_partition.p_fsize
176 #define pi_fstype pi_partition.p_fstype
177 #define pi_frag pi_partition.p_frag
178 #define pi_cpg pi_partition.p_cpg
179 char pi_mount[20];
180 uint pi_isize; /* bytes per inode (for # inodes) */
181 uint pi_flags;
182 #define PIF_NEWFS 0x0001 /* need to 'newfs' partition */
183 #define PIF_FFSv2 0x0002 /* newfs with FFSv2, not FFSv1 */
184 #define PIF_MOUNT 0x0004 /* need to mount partition */
185 #define PIF_ASYNC 0x0010 /* mount -o async */
186 #define PIF_NOATIME 0x0020 /* mount -o noatime */
187 #define PIF_NODEV 0x0040 /* mount -o nodev */
188 #define PIF_NODEVMTIME 0x0080 /* mount -o nodevmtime */
189 #define PIF_NOEXEC 0x0100 /* mount -o noexec */
190 #define PIF_NOSUID 0x0200 /* mount -o nosuid */
191 #define PIF__UNUSED 0x0400 /* unused */
192 #define PIF_LOG 0x0800 /* mount -o log */
193 #define PIF_MOUNT_OPTS 0x0ff0 /* all above mount flags */
194 #define PIF_RESET 0x1000 /* internal - restore previous values */
195 } partinfo; /* Single partition from a disklabel */
197 struct ptn_info {
198 int menu_no;
199 struct ptn_size {
200 int ptn_id;
201 char mount[20];
202 daddr_t dflt_size;
203 daddr_t size;
204 int limit;
205 int changed;
206 } ptn_sizes[MAXPARTITIONS + 1]; /* +1 for delete code */
207 menu_ent ptn_menus[MAXPARTITIONS + 1]; /* +1 for unit chg */
208 int free_parts;
209 daddr_t free_space;
210 struct ptn_size *pool_part;
211 char exit_msg[70];
214 /* variables */
216 int debug; /* set by -D option */
218 char rel[SSTRSIZE];
219 char machine[SSTRSIZE];
221 int yesno;
222 int ignorerror;
223 int ttysig_ignore;
224 pid_t ttysig_forward;
225 int layoutkind;
226 int sizemult;
227 const char *multname;
229 /* loging variables */
231 int logging;
232 int scripting;
233 FILE *logfp;
234 FILE *script;
236 /* Actual name of the disk. */
237 char diskdev[SSTRSIZE];
238 int no_mbr; /* set for raid (etc) */
239 int rootpart; /* partition we install into */
240 const char *disktype; /* ST506, SCSI, ... */
242 /* Area of disk we can allocate, start and size in disk sectors. */
243 daddr_t ptstart, ptsize;
244 /* If we have an MBR boot partition, start and size in sectors */
245 int bootstart, bootsize;
247 /* Actual values for current disk - set by find_disks() or md_get_info() */
248 int sectorsize;
249 int dlcyl, dlhead, dlsec, dlcylsize;
250 daddr_t dlsize;
251 int current_cylsize;
252 unsigned int root_limit; /* BIOS (etc) read limit */
254 /* Information for the NetBSD disklabel */
255 enum DLTR { PART_A, PART_B, PART_C, PART_D, PART_E, PART_F, PART_G, PART_H,
256 PART_I, PART_J, PART_K, PART_L, PART_M, PART_N, PART_O, PART_P};
257 #define partition_name(x) ('a' + (x))
258 partinfo oldlabel[MAXPARTITIONS]; /* What we found on the disk */
259 partinfo bsdlabel[MAXPARTITIONS]; /* What we want it to look like */
260 daddr_t tmp_ramdisk_size;
262 #define DISKNAME_SIZE 16
263 char bsddiskname[DISKNAME_SIZE];
264 const char *doessf;
266 /* Relative file name for storing a distribution. */
267 char xfer_dir[STRSIZE];
268 int clean_xfer_dir;
270 #if !defined(SYSINST_FTP_HOST)
271 #define SYSINST_FTP_HOST "ftp.NetBSD.org"
272 #endif
274 #if !defined(SYSINST_FTP_DIR)
275 #define SYSINST_FTP_DIR "pub/NetBSD/NetBSD-" REL
276 #endif
278 /* Abs. path we extract from */
279 char ext_dir[STRSIZE];
281 /* Place we look in all fs types */
282 char set_dir[STRSIZE];
284 struct {
285 char host[STRSIZE];
286 char dir[STRSIZE] ;
287 char user[SSTRSIZE];
288 char pass[STRSIZE];
289 char proxy[STRSIZE];
290 const char *xfer_type; /* "ftp" or "http" */
291 } ftp;
293 int (*fetch_fn)(const char *);
294 char nfs_host[STRSIZE];
295 char nfs_dir[STRSIZE];
297 char cdrom_dev[SSTRSIZE]; /* Typically "cd0a" */
298 char fd_dev[SSTRSIZE]; /* Typically "/dev/fd0a" */
299 const char *fd_type; /* "msdos", "ffs" or maybe "ados" */
301 char localfs_dev[SSTRSIZE];
302 char localfs_fs[SSTRSIZE];
303 char localfs_dir[STRSIZE];
305 char targetroot_mnt[SSTRSIZE];
307 int mnt2_mounted;
309 char dist_postfix[SSTRSIZE];
311 /* needed prototypes */
312 void set_menu_numopts(int, int);
314 /* Machine dependent functions .... */
315 void md_init(void);
316 void md_init_set_status(int); /* minimal y/n */
318 /* MD functions if user selects install - in order called */
319 int md_get_info(void);
320 int md_make_bsd_partitions(void);
321 int md_check_partitions(void);
322 int md_pre_disklabel(void);
323 int md_post_disklabel(void);
324 int md_post_newfs(void);
325 int md_post_extract(void);
326 void md_cleanup_install(void);
328 /* MD functions if user selects upgrade - in order called */
329 int md_pre_update(void);
330 int md_update(void);
331 /* Also calls md_post_extract() */
333 /* from main.c */
334 void toplevel(void);
336 /* from disks.c */
337 int find_disks(const char *);
338 struct menudesc;
339 void fmt_fspart(struct menudesc *, int, void *);
340 void disp_cur_fspart(int, int);
341 int write_disklabel(void);
342 int make_filesystems(void);
343 int make_fstab(void);
344 int mount_disks(void);
345 int set_swap(const char *, partinfo *);
346 int check_swap(const char *, int);
347 char *bootxx_name(void);
349 /* from disks_lfs.c */
350 int fs_is_lfs(void *);
352 /* from label.c */
353 const char *get_last_mounted(int, int, partinfo *);
354 int savenewlabel(partinfo *, int);
355 int incorelabel(const char *, partinfo *);
356 int edit_and_check_label(partinfo *, int, int, int);
357 void set_bsize(partinfo *, int);
358 void set_fsize(partinfo *, int);
359 void set_ptype(partinfo *, int, int);
361 /* from install.c */
362 void do_install(void);
364 /* from factor.c */
365 void factor(long, long *, int, int *);
367 /* from fdisk.c */
368 void get_disk_info(char *);
369 void set_disk_info(char *);
371 /* from geom.c */
372 int get_geom(const char *, struct disklabel *);
373 int get_real_geom(const char *, struct disklabel *);
375 /* from net.c */
376 extern char net_namesvr6[STRSIZE];
377 int get_via_ftp(const char *);
378 int get_via_nfs(void);
379 int config_network(void);
380 void mnt_net_config(void);
382 /* From run.c */
383 int collect(int, char **, const char *, ...);
384 int run_program(int, const char *, ...);
385 void do_logging(void);
386 int do_system(const char *);
388 /* from upgrade.c */
389 void do_upgrade(void);
390 void do_reinstall_sets(void);
391 void restore_etc(void);
393 /* from util.c */
394 int dir_exists_p(const char *);
395 int file_exists_p(const char *);
396 int file_mode_match(const char *, unsigned int);
397 uint get_ramsize(void);
398 void ask_sizemult(int);
399 void run_makedev(void);
400 int get_via_floppy(void);
401 int get_via_cdrom(void);
402 int get_via_localfs(void);
403 int get_via_localdir(void);
404 void show_cur_distsets(void);
405 void make_ramdisk_dir(const char *);
406 void set_kernel_set(unsigned int);
407 unsigned int get_kernel_set(void);
408 unsigned int set_X11_selected(void);
409 int get_and_unpack_sets(int, msg, msg, msg);
410 int sanity_check(void);
411 int set_timezone(void);
412 int set_crypt_type(void);
413 int set_root_password(void);
414 int set_root_shell(void);
415 void scripting_fprintf(FILE *, const char *, ...);
416 void scripting_vfprintf(FILE *, const char *, va_list);
417 void add_rc_conf(const char *, ...);
418 void add_sysctl_conf(const char *, ...);
419 void enable_rc_conf(void);
420 void set_sizemultname_cyl(void);
421 void set_sizemultname_meg(void);
422 int check_lfs_progs(void);
423 void init_set_status(int);
424 void customise_sets(void);
425 void umount_mnt2(void);
427 /* from target.c */
428 #if defined(DEBUG) || defined(DEBUG_ROOT)
429 void backtowin(void);
430 #endif
431 const char *concat_paths(const char *, const char *);
432 const char *target_expand(const char *);
433 void make_target_dir(const char *);
434 void append_to_target_file(const char *, const char *);
435 void echo_to_target_file(const char *, const char *);
436 void sprintf_to_target_file(const char *, const char *, ...);
437 void trunc_target_file(const char *);
438 const char *target_prefix(void);
439 int target_chdir(const char *);
440 void target_chdir_or_die(const char *);
441 int target_already_root(void);
442 FILE *target_fopen(const char *, const char *);
443 int target_collect_file(int, char **, const char *);
444 int is_active_rootpart(const char *, int);
445 int cp_to_target(const char *, const char *);
446 void dup_file_into_target(const char *);
447 void mv_within_target_or_die(const char *, const char *);
448 int cp_within_target(const char *, const char *, int);
449 int target_mount(const char *, const char *, int, const char *);
450 int target_test(unsigned int, const char *);
451 int target_dir_exists_p(const char *);
452 int target_file_exists_p(const char *);
453 int target_symlink_exists_p(const char *);
454 void unwind_mounts(void);
456 /* from bsddisklabel.c */
457 int make_bsd_partitions(void);
458 int save_ptn(int, daddr_t, daddr_t, int, const char *);
459 void set_ptn_titles(menudesc *, int, void *);
460 void set_ptn_menu(struct ptn_info *);
461 int set_ptn_size(menudesc *, void *);
462 void get_ptn_sizes(daddr_t, daddr_t, int);
464 /* from aout2elf.c */
465 int move_aout_libs(void);
467 #ifdef WSKBD
468 void get_kb_encoding(void);
469 void save_kb_encoding(void);
470 #else
471 #define get_kb_encoding()
472 #define save_kb_encoding()
473 #endif
474 #endif /* _DEFS_H_ */