From ff77aac2d43ed97621f1b8697cb97dd6b65aba8f Mon Sep 17 00:00:00 2001 From: ahoka Date: Sun, 18 Oct 2009 12:09:48 +0000 Subject: [PATCH] Give the option to use tmpfs for /tmp in sysinst instead of the older mfs on i386 and amd64. Should be enabled on other platforms with reliable tmpfs too. --- distrib/utils/sysinst/arch/amd64/md.h | 5 ++++- distrib/utils/sysinst/arch/i386/md.h | 5 ++++- distrib/utils/sysinst/bsddisklabel.c | 24 ++++++++++++++---------- distrib/utils/sysinst/defs.h | 4 ++-- distrib/utils/sysinst/disks.c | 13 +++++++++---- distrib/utils/sysinst/main.c | 4 ++-- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/distrib/utils/sysinst/arch/amd64/md.h b/distrib/utils/sysinst/arch/amd64/md.h index 41b090ed594e..36ef84e7de07 100644 --- a/distrib/utils/sysinst/arch/amd64/md.h +++ b/distrib/utils/sysinst/arch/amd64/md.h @@ -1,4 +1,4 @@ -/* $NetBSD: md.h,v 1.25 2009/04/07 10:45:05 tsutsui Exp $ */ +/* $NetBSD: md.h,v 1.26 2009/10/18 12:09:48 ahoka Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -62,6 +62,9 @@ /* have support for booting form UFS2 */ #define HAVE_UFS2_BOOT +/* allow using tmpfs for /tmp instead of mfs */ +#define HAVE_TMPFS + /* have file system specific primary boot loader */ #define HAVE_BOOTXX_xFS #define BOOTXXDIR "/usr/mdec" diff --git a/distrib/utils/sysinst/arch/i386/md.h b/distrib/utils/sysinst/arch/i386/md.h index b0e20586fdd4..c59e264af5db 100644 --- a/distrib/utils/sysinst/arch/i386/md.h +++ b/distrib/utils/sysinst/arch/i386/md.h @@ -1,4 +1,4 @@ -/* $NetBSD: md.h,v 1.66 2009/04/07 10:45:05 tsutsui Exp $ */ +/* $NetBSD: md.h,v 1.67 2009/10/18 12:09:48 ahoka Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -63,6 +63,9 @@ /* have support for booting from UFS2 */ #define HAVE_UFS2_BOOT +/* allow using tmpfs for /tmp instead of mfs */ +#define HAVE_TMPFS + /* have file system specific primary boot loader */ #define HAVE_BOOTXX_xFS #define BOOTXXDIR "/usr/mdec" diff --git a/distrib/utils/sysinst/bsddisklabel.c b/distrib/utils/sysinst/bsddisklabel.c index 7223cea01b31..5fae9f2d6c86 100644 --- a/distrib/utils/sysinst/bsddisklabel.c +++ b/distrib/utils/sysinst/bsddisklabel.c @@ -1,4 +1,4 @@ -/* $NetBSD: bsddisklabel.c,v 1.52 2009/05/14 16:23:38 sborrill Exp $ */ +/* $NetBSD: bsddisklabel.c,v 1.53 2009/10/18 12:09:48 ahoka Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -61,9 +61,9 @@ static int check_partitions(void); /* For the current state of this file blame abs@NetBSD.org */ /* Even though he wasn't the last to hack it, but he did admit doing so :-) */ -#define PART_ANY -1 -#define PART_EXTRA -2 -#define PART_TMP_MFS -3 +#define PART_ANY -1 +#define PART_EXTRA -2 +#define PART_TMP_RAMDISK -3 /* Defaults for things that might be defined in md.h */ #ifndef PART_ROOT @@ -290,7 +290,7 @@ set_ptn_size(menudesc *m, void *arg) } size = NUMSEC(size, mult, dlcylsize); - if (p->ptn_id == PART_TMP_MFS) { + if (p->ptn_id == PART_TMP_RAMDISK) { p->size = size; return 0; } @@ -357,9 +357,13 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap) #define PI_SWAP 1 { PART_SWAP, { 's', 'w', 'a', 'p', '\0' }, DEFSWAPSIZE, DEFSWAPSIZE, 0, 0 }, - { PART_TMP_MFS, + { PART_TMP_RAMDISK, +#ifdef HAVE_TMPFS + { 't', 'm', 'p', ' ', '(', 't', 'm', 'p', 'f', 's', ')', '\0' }, +#else { 't', 'm', 'p', ' ', '(', 'm', 'f', 's', ')', '\0' }, - 64, 0, 0, 0 }, +#endif + 64, 0, 0, 0 }, #define PI_USR 3 { PART_USR, { '/', 'u', 's', 'r', '\0' }, DEFUSRSIZE, 0, 0, 0 }, @@ -495,7 +499,7 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap) break; continue; } - if (p->ptn_id == PART_TMP_MFS) + if (p->ptn_id == PART_TMP_RAMDISK) continue; p->size += pi.free_space % dlcylsize; break; @@ -510,8 +514,8 @@ get_ptn_sizes(daddr_t part_start, daddr_t sectors, int no_swap) size = p->limit; } i = p->ptn_id; - if (i == PART_TMP_MFS) { - tmp_mfs_size = size; + if (i == PART_TMP_RAMDISK) { + tmp_ramdisk_size = size; size = 0; continue; } diff --git a/distrib/utils/sysinst/defs.h b/distrib/utils/sysinst/defs.h index 110a79d128eb..52be53c44ce2 100644 --- a/distrib/utils/sysinst/defs.h +++ b/distrib/utils/sysinst/defs.h @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.145 2009/09/19 14:57:27 abs Exp $ */ +/* $NetBSD: defs.h,v 1.146 2009/10/18 12:09:48 ahoka Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -257,7 +257,7 @@ enum DLTR { PART_A, PART_B, PART_C, PART_D, PART_E, PART_F, PART_G, PART_H, #define partition_name(x) ('a' + (x)) partinfo oldlabel[MAXPARTITIONS]; /* What we found on the disk */ partinfo bsdlabel[MAXPARTITIONS]; /* What we want it to look like */ -int tmp_mfs_size; +daddr_t tmp_ramdisk_size; #define DISKNAME_SIZE 16 char bsddiskname[DISKNAME_SIZE]; diff --git a/distrib/utils/sysinst/disks.c b/distrib/utils/sysinst/disks.c index 5947cbd46944..3831f8516580 100644 --- a/distrib/utils/sysinst/disks.c +++ b/distrib/utils/sysinst/disks.c @@ -1,4 +1,4 @@ -/* $NetBSD: disks.c,v 1.108 2009/10/03 12:00:00 martin Exp $ */ +/* $NetBSD: disks.c,v 1.109 2009/10/18 12:09:48 ahoka Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -746,13 +746,18 @@ make_fstab(void) dump_freq, fsck_pass); } - if (tmp_mfs_size != 0) { + if (tmp_ramdisk_size != 0) { +#ifdef HAVE_TMPFS + scripting_fprintf(f, "tmpfs\t\t/tmp\ttmpfs\trw,-m=1777,-s=%d\n", + tmp_ramdisk_size * 512); +#else if (swap_dev != -1) scripting_fprintf(f, "/dev/%s%c\t\t/tmp\tmfs\trw,-s=%d\n", - diskdev, 'a' + swap_dev, tmp_mfs_size); + diskdev, 'a' + swap_dev, tmp_ramdisk_size); else scripting_fprintf(f, "swap\t\t/tmp\tmfs\trw,-s=%d\n", - tmp_mfs_size); + tmp_ramdisk_size); +#endif } /* Add /kern, /proc and /dev/pts to fstab and make mountpoint. */ diff --git a/distrib/utils/sysinst/main.c b/distrib/utils/sysinst/main.c index 437aec70f4fc..d1e3c8ee8f43 100644 --- a/distrib/utils/sysinst/main.c +++ b/distrib/utils/sysinst/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.53 2008/12/21 11:02:41 martin Exp $ */ +/* $NetBSD: main.c,v 1.54 2009/10/18 12:09:48 ahoka Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -114,7 +114,7 @@ init(void) sizemult = 1; disktype = "unknown"; - tmp_mfs_size = 0; + tmp_ramdisk_size = 0; doessf = ""; clean_xfer_dir = 0; mnt2_mounted = 0;