Patch from Bruno kernel for verity error support.
Orginal change message:
Author: Ke Dong <kedong@google.com>
Date: Tue May 8 11:41:50 2012 -0700
Add verity error handler for bruno.
Change-Id: Ifcf43a3733762c1d6140fad6ee77fe0a2643cdeb
diff --git a/arch/arm/configs/gfrg200_defconfig b/arch/arm/configs/gfrg200_defconfig
index 8dff045..bc5ff42 100644
--- a/arch/arm/configs/gfrg200_defconfig
+++ b/arch/arm/configs/gfrg200_defconfig
@@ -179,6 +179,7 @@
CONFIG_MD=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_VERITY=y
+CONFIG_DM_VERITY_BRUNO=y
CONFIG_NETDEVICES=y
CONFIG_MII=y
CONFIG_TUN=y
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 3e572e7..af0a60a 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -400,4 +400,18 @@
If unsure, say N.
+config DM_VERITY_BRUNO
+ tristate "Verity bruno specific error handling"
+ depends on DM_VERITY
+ ---help---
+ This device-mapper target handles verity check error
+ specifically for bruno platform.
+
+ To compile this code as a module, choose M here: the module will
+ be called dm-verity-bruno.
+
+ If unsure, say N.
+
+
+
endif # MD
diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index c069953..0e357a5 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -41,6 +41,7 @@
obj-$(CONFIG_DM_LOG_USERSPACE) += dm-log-userspace.o
obj-$(CONFIG_DM_BHT) += dm-bht.o
obj-$(CONFIG_DM_VERITY) += dm-verity.o
+obj-$(CONFIG_DM_VERITY_BRUNO) += dm-verity-bruno.o
obj-$(CONFIG_DM_ZERO) += dm-zero.o
obj-$(CONFIG_DM_RAID) += dm-raid.o
obj-$(CONFIG_DM_THIN_PROVISIONING) += dm-thin-pool.o
diff --git a/drivers/md/dm-verity-bruno.c b/drivers/md/dm-verity-bruno.c
new file mode 100644
index 0000000..d7fe9b3
--- /dev/null
+++ b/drivers/md/dm-verity-bruno.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012 Google Inc. All Rights Reserved.
+ * Author: kedong@google.com (Ke Dong)
+ *
+ * This file is released under the GPLv2.
+ *
+ * Implements a BRUNO platform specific error handler.
+ */
+#include <linux/err.h>
+#include <linux/genhd.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/notifier.h>
+#include <linux/device-mapper.h>
+#include <asm/page.h>
+
+#include "dm-verity.h"
+
+#define DM_MSG_PREFIX "verity-bruno"
+
+static int error_handler(struct notifier_block *nb, unsigned long transient,
+ void *opaque_err)
+{
+ struct dm_verity_error_state *err =
+ (struct dm_verity_error_state *) opaque_err;
+ u32 failure_count = 0;
+ err->behavior = DM_VERITY_ERROR_BEHAVIOR_PANIC;
+ if (transient)
+ return 0;
+
+ // TODO(jnewlin): Need to increment the error count for failing back
+ // to the previous image.
+ return 0;
+}
+
+static struct notifier_block bruno_nb = {
+ .notifier_call = &error_handler,
+ .next = NULL,
+ .priority = 1,
+};
+
+static int __init dm_verity_bruno_init(void)
+{
+ int r;
+
+ r = dm_verity_register_error_notifier(&bruno_nb);
+ if (r < 0)
+ DMERR("failed to register handler: %d", r);
+ else
+ DMINFO("registered");
+ return r;
+}
+
+static void __exit dm_verity_bruno_exit(void)
+{
+ dm_verity_unregister_error_notifier(&bruno_nb);
+}
+
+module_init(dm_verity_bruno_init);
+module_exit(dm_verity_bruno_exit);
+
+MODULE_AUTHOR("Ke Dong <kedong@google.com>");
+MODULE_DESCRIPTION("bruno-specific error handler for dm-verity");
+MODULE_LICENSE("GPL");