home: hub: mkinitfs

Download patch

ref: 5cd586c09e381a530da9abdb86e5cff3e2bc6caa
parent: 9d2040756a0b701c79140f14ce7c8d53d66a2d40
author: Sören Tempel <soeren+git@soeren-tempel.net>
date: Thu Aug 3 16:44:15 CDT 2017

init: add cryptdiscards option

When enabled allows the use of discard (TRIM) requests for the device.
See cryptsetup(1) for more information.

--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -263,8 +263,8 @@
 set -- $(cat /proc/cmdline)
 
 myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm cryptheader cryptoffset
-	debug_init dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root
-	usbdelay ip alpine_repo apkovl alpine_start splash blacklist
+	cryptdiscards debug_init dma init_args keep_apk_new modules ovl_dev pkgs quiet
+	root_size root usbdelay ip alpine_repo apkovl alpine_start splash blacklist
 	overlaytmpfs rootfstype rootflags nbd resume"
 
 for opt; do
@@ -355,6 +355,9 @@
 
 if [ -n "$KOPT_cryptroot" ]; then
 	cryptopts="-c ${KOPT_cryptroot}"
+	if [ "$KOPT_cryptdiscards" = "yes" ]; then
+		cryptopts="$cryptopts -D"
+	fi
 	if [ -n "$KOPT_cryptdm" ]; then
 		cryptopts="$cryptopts -m ${KOPT_cryptdm}"
 	fi
--- a/nlplug-findfs.c
+++ b/nlplug-findfs.c
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
+#include <stdint.h>
 
 #include <sys/eventfd.h>
 #include <sys/signalfd.h>
@@ -317,6 +318,7 @@
 	size_t payload_offset;
 	pthread_t tid;
 	pthread_mutex_t mutex;
+	uint32_t flags;
 };
 
 struct ueventconf {
@@ -605,7 +607,8 @@
 		pthread_mutex_lock(&c->crypt.mutex);
 		r = crypt_activate_by_passphrase(cd, c->crypt.data.name,
 						 CRYPT_ANY_SLOT,
-						 pass, strlen(pass), 0);
+						 pass, strlen(pass),
+						 c->crypt.flags);
 		pthread_mutex_unlock(&c->crypt.mutex);
 		memset(pass, 0, sizeof(pass)); /* wipe pass after use */
 
@@ -1239,6 +1242,9 @@
 		break;
 	case 'n':
 		not_found_is_ok = 1;
+		break;
+	case 'D':
+		conf.crypt.flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS;
 		break;
 	case 'd':
 		dodebug = 1;