From 64e2b749b9606d456beefea2e5e54731bc1dcc75 Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 20 Jul 2021 16:40:12 +0000 Subject: [PATCH] RAM size will not change during installation, do the sysctl() dance only once. --- usr.sbin/sysinst/util.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/usr.sbin/sysinst/util.c b/usr.sbin/sysinst/util.c index 77f51da281b3..0b5ea18fcdb7 100644 --- a/usr.sbin/sysinst/util.c +++ b/usr.sbin/sysinst/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.57 2021/01/31 22:45:47 rillig Exp $ */ +/* $NetBSD: util.c,v 1.58 2021/07/20 16:40:12 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -264,11 +264,14 @@ file_mode_match(const char *path, unsigned int mode) uint64_t get_ramsize(void) { - uint64_t ramsize; - size_t len = sizeof ramsize; - int mib[2] = {CTL_HW, HW_PHYSMEM64}; + static uint64_t ramsize; - sysctl(mib, 2, &ramsize, &len, NULL, 0); + if (ramsize == 0) { + size_t len = sizeof ramsize; + int mib[2] = {CTL_HW, HW_PHYSMEM64}; + + sysctl(mib, 2, &ramsize, &len, NULL, 0); + } /* Find out how many Megs ... round up. */ return (ramsize + MEG - 1) / MEG;