Module Name: src
Committed By: martin
Date: Sat Dec 7 20:40:42 UTC 2013
Modified Files:
src/distrib/utils/sysinst: disks.c
Log Message:
Add a tmpfs for /var/shm on machines with more than 16MB ram to the created
/etc/fstab.
To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/distrib/utils/sysinst/disks.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/utils/sysinst/disks.c
diff -u src/distrib/utils/sysinst/disks.c:1.129 src/distrib/utils/sysinst/disks.c:1.130
--- src/distrib/utils/sysinst/disks.c:1.129 Wed Oct 30 15:37:49 2013
+++ src/distrib/utils/sysinst/disks.c Sat Dec 7 20:40:42 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: disks.c,v 1.129 2013/10/30 15:37:49 drochner Exp $ */
+/* $NetBSD: disks.c,v 1.130 2013/12/07 20:40:42 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -89,6 +89,8 @@ static void fixsb(const char *, const ch
static const char *disk_names[] = { DISK_NAMES, "vnd", NULL };
+static bool tmpfs_on_var_shm(void);
+
const char *
getfslabelname(uint8_t f)
{
@@ -97,6 +99,24 @@ getfslabelname(uint8_t f)
return fstypenames[f];
}
+/*
+ * Decide wether we want to mount a tmpfs on /var/shm: we do this always
+ * when the machine has more than 16 MB of user memory. On smaller machines,
+ * shm_open() and friends will not perform well anyway.
+ */
+static bool
+tmpfs_on_var_shm()
+{
+ uint64_t ram;
+ size_t len;
+
+ len = sizeof(ram);
+ if (sysctlbyname("hw.usermem64", &ram, &len, NULL, 0))
+ return false;
+
+ return ram > 16UL*1024UL*1024UL;
+}
+
/* from src/sbin/atactl/atactl.c
* extract_string: copy a block of bytes out of ataparams and make
* a proper string out of it, truncating trailing spaces and preserving
@@ -825,10 +845,13 @@ make_fstab(void)
scripting_fprintf(f, "procfs\t\t/proc\tprocfs\trw\n");
scripting_fprintf(f, "/dev/%s\t\t/cdrom\tcd9660\tro,noauto\n",
get_default_cdrom());
+ scripting_fprintf(f, "%stmpfs\t\t/var/shm\ttmpfs\trw,-m1777,-sram%%25\n",
+ tmpfs_on_var_shm() ? "" : "#");
make_target_dir("/kern");
make_target_dir("/proc");
make_target_dir("/dev/pts");
make_target_dir("/cdrom");
+ make_target_dir("/var/shm");
scripting_fprintf(NULL, "EOF\n");