Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151261387
D53106.id164238.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D53106.id164238.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D53106: partedit: limit default swap to maximum supported by kernel
Attached
Detach File
Event Timeline
Log In to Comment