Page MenuHomeFreeBSD

D53106.id164238.diff
No OneTemporary

D53106.id164238.diff

Index: usr.sbin/bsdinstall/partedit/part_wizard.c
===================================================================
--- usr.sbin/bsdinstall/partedit/part_wizard.c
+++ usr.sbin/bsdinstall/partedit/part_wizard.c
@@ -27,6 +27,7 @@
*/
#include <sys/param.h>
+#include <sys/sysctl.h>
#include <errno.h>
#include <inttypes.h>
@@ -34,6 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <libgeom.h>
#include <bsddialog.h>
@@ -41,10 +43,28 @@
#include "partedit.h"
#define MIN_FREE_SPACE (1023*1024*1024) /* Just under 1 GB */
-#define SWAP_SIZE(available) MIN(available/20, 4*1024*1024*1024LL)
static char *wizard_partition(struct gmesh *mesh, const char *disk);
+/*
+ * Determine default swap (partition) size for a given amount of free disk
+ * space. All values in bytes.
+ */
+static intmax_t
+swap_size(intmax_t available)
+{
+ intmax_t swapsize;
+ unsigned long maxswap;
+ size_t sz;
+
+ swapsize = MIN(available/20, 4*1024*1024*1024LL);
+ sz = sizeof(maxswap);
+ if (sysctlbyname("vm.swap_maxpages", &maxswap, &sz, NULL, 0) == 0)
+ swapsize = MIN(swapsize, (intmax_t)maxswap * getpagesize());
+
+ return (swapsize);
+}
+
int
part_wizard(const char *fsreq)
{
@@ -383,7 +403,7 @@
return (!retval); /* Editor -> return 0 */
}
- swapsize = SWAP_SIZE(available);
+ swapsize = swap_size(available);
humanize_number(swapsizestr, 7, swapsize, "B", HN_AUTOSCALE,
HN_NOSPACE | HN_DECIMAL);
humanize_number(rootsizestr, 7, available - swapsize - 1024*1024,

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 8, 4:34 AM (12 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31076177
Default Alt Text
D53106.id164238.diff (1 KB)

Event Timeline