[projects/geninitrd] add bcache support; depends on udev

glen glen at pld-linux.org
Thu Jan 16 22:22:56 CET 2014


commit 2d769917ac202be0a1c4ee7c35246a8b403c6f46
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu Jan 16 23:20:46 2014 +0200

    add bcache support; depends on udev

 Makefile      |  2 +-
 geninitrd     |  8 ++++----
 mod-bcache.sh | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 5 deletions(-)
---
diff --git a/Makefile b/Makefile
index d0a773c..3220945 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # when making release, make sure you do it as RELEASE document describes
 NAME		:= geninitrd
 VERSION		:= $(shell test -d .git && git describe --tags || echo git)
-MODS		:= ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd
+MODS		:= ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd bcache
 FILES_MODS  := $(MODS:%=mod-%.sh)
 FILES_ADDON := extract-ikconfig
 FILES_UDEV  := 01-ignore.rules 59-persistent-storage.rules 61-persistent-storage.rules 11-dm.rules
diff --git a/geninitrd b/geninitrd
index 44b254b..bb98dd6 100755
--- a/geninitrd
+++ b/geninitrd
@@ -1120,7 +1120,7 @@ if [ ! -f /proc/mounts ]; then
 	warn "/proc filesystem not mounted, may cause wrong results or failure."
 fi
 
-geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd
+geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd bcache
 
 while [ $# -gt 0 ]; do
 	case $1 in
@@ -1419,6 +1419,8 @@ if is_yes "$USE_TUXONICE"; then
 	find_module "-lzf"
 fi
 
+find_modules_bcache
+find_modules_uvesafb
 find_modules_fbsplash
 
 if [ -n "$ifneeded" -a -z "$MODULES" ]; then
@@ -1519,8 +1521,6 @@ add_linuxrc <<-'EOF'
 	fi
 EOF
 
-find_modules_uvesafb
-
 modules_add_linuxrc $MODULES
 
 # TODO: rewrite for busybox
@@ -1544,7 +1544,6 @@ else
 fi
 
 initrd_gen_uvesafb
-
 initrd_gen_luks
 initrd_gen_dmraid
 initrd_gen_multipath
@@ -1555,6 +1554,7 @@ if is_yes "$have_nfs"; then
 else
 	initrd_gen_md
 	initrd_gen_lvm
+	initrd_gen_bcache
 	initrd_gen_blkid
 	initrd_gen_luks
 	initrd_gen_setrootdev
diff --git a/mod-bcache.sh b/mod-bcache.sh
new file mode 100644
index 0000000..1de38db
--- /dev/null
+++ b/mod-bcache.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+# geninitrd mod: bcache
+# requires 3.10 kernel
+# http://bcache.evilpiepirate.org/
+USE_BCACHE=${USE_BCACHE:-yes}
+
+# setup geninitrd module
+# @access   public
+setup_mod_bcache() {
+	if [ ! -d /sys/fs/bcache ]; then
+		USE_BCACHE=no
+	fi
+
+	if [ ! -x /lib/udev/bcache-register ]; then
+		USE_BCACHE=no
+	fi
+}
+
+# find modules for for bcache
+# @access	public
+find_modules_bcache() {
+	if ! is_yes "$USE_BCACHE"; then
+		return
+	fi
+
+	find_module "-bcache"
+}
+
+
+# generate initrd fragment
+# @access   public
+initrd_gen_bcache() {
+	if ! is_yes "$USE_BCACHE"; then
+		return
+	fi
+
+	verbose "Adding bcache support to initrd"
+
+	inst_rules 69-bcache.rules
+	inst_exec /lib/udev/bcache-register /lib/udev
+}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/geninitrd.git/commitdiff/2d769917ac202be0a1c4ee7c35246a8b403c6f46



More information about the pld-cvs-commit mailing list