[PATCH 1/2] mtd: print out the partition's read-only flag

Huang Shijie b32955 at freescale.com
Tue Apr 29 20:53:29 PDT 2014


We may set a partition to be read only with DT property or kernel cmdline,
such as the kernel cmdline:
  mtdparts=50000000.nor:2m(boot)ro,2m(dtb),5m(kernel),-(test)

This patch prints out the partition's read-only flag in the boot precedure,
which makes us more clear about the read-only partition.

Before this patch, the partitions show like this:
	0x000000000000-0x000000200000 : "boot"
	0x000000200000-0x000000400000 : "dtb"
	0x000000400000-0x000000900000 : "kernel"
	0x000000900000-0x000002000000 : "test"

After this patch, the partitions show like this:

	0x000000000000-0x000000200000 : "boot"	 (Read-Only)
	0x000000200000-0x000000400000 : "dtb"
	0x000000400000-0x000000900000 : "kernel"
	0x000000900000-0x000002000000 : "test"

Signed-off-by: Huang Shijie <b32955 at freescale.com>
---
 drivers/mtd/mtdpart.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 84f5866..f660658 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -458,9 +458,6 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
 	if (slave->mtd.size == MTDPART_SIZ_FULL)
 		slave->mtd.size = master->size - slave->offset;
 
-	printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\n", (unsigned long long)slave->offset,
-		(unsigned long long)(slave->offset + slave->mtd.size), slave->mtd.name);
-
 	/* let's do some sanity checks */
 	if (slave->offset >= master->size) {
 		/* let's register it anyway to preserve ordering */
@@ -517,6 +514,12 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
 			part->name);
 	}
 
+	printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\t%s\n",
+		(unsigned long long)slave->offset,
+		(unsigned long long)(slave->offset + slave->mtd.size),
+		slave->mtd.name,
+		slave->mtd.flags & MTD_WRITEABLE ? "" : " (Read-Only)");
+
 	slave->mtd.ecclayout = master->ecclayout;
 	slave->mtd.ecc_step_size = master->ecc_step_size;
 	slave->mtd.ecc_strength = master->ecc_strength;
-- 
1.7.2.rc3




More information about the linux-mtd mailing list