Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst Add a tmpfs for /var/shm on machines w...



details:   https://anonhg.NetBSD.org/src/rev/c7a75a3941e2
branches:  trunk
changeset: 325129:c7a75a3941e2
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Dec 07 20:40:42 2013 +0000

description:
Add a tmpfs for /var/shm on machines with more than 16MB ram to the created
/etc/fstab.

diffstat:

 distrib/utils/sysinst/disks.c |  25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diffs (57 lines):

diff -r 00d72ad52c04 -r c7a75a3941e2 distrib/utils/sysinst/disks.c
--- a/distrib/utils/sysinst/disks.c     Sat Dec 07 20:24:35 2013 +0000
+++ b/distrib/utils/sysinst/disks.c     Sat Dec 07 20:40:42 2013 +0000
@@ -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 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 @@
        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 @@
        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");
 



Home | Main Index | Thread Index | Old Index