linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Shmulik Ladkani <shmulik.ladkani@gmail.com>
To: Huang Shijie <b32955@freescale.com>
Cc: Huang Shijie <shijie8@gmail.com>,
	linux-mtd@lists.infradead.org, dedekind1@gmail.com
Subject: Re: [PATCH 1/3] mtd: cmdlinepart: make the partitions rule more strict
Date: Wed, 5 Sep 2012 08:30:20 +0300	[thread overview]
Message-ID: <20120905083020.0bf6b0bd@halley> (raw)
In-Reply-To: <5046B504.6000608@freescale.com>

On Wed, 5 Sep 2012 10:12:20 +0800 Huang Shijie <b32955@freescale.com> wrote:
> yes, it's really simple and flexible.
> But I think it's not wise to export the 0-size partition to user.
> The user may confused at this.
> 
> And the mtd-utils, such as mtd-info/mtd-debug, do they can work with a 
> 0-size partition?

I think the 0 sized partition case is really seldom, don't worth the
trouble, the user will probably observe something went wrong in his
cmdline parts specification.

But nevertheless, if we think it's a MUST to forbid the 0 sized
partitions, then amend my patch as follows:

(sorry, didn't even compile tested this, please review and test, if the
approach is acceptible)

diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index 17b0bd4..aed1b8a 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -319,12 +319,22 @@ static int parse_cmdline_partitions(struct mtd_info *master,
 				if (part->parts[i].size == SIZE_REMAINING)
 					part->parts[i].size = master->size - offset;
 
+				if (part->parts[i].size == 0) {
+					printk(KERN_WARNING ERRP
+					       "%s: skipping zero sized partition\n",
+					       part->mtd_id);
+					part->num_parts--;
+					memmove(&part->parts[i],
+						&part->parts[i + 1],
+						sizeof(*part->parts) * (part->num_parts - i));
+					continue;
+				}
+
 				if (offset + part->parts[i].size > master->size) {
 					printk(KERN_WARNING ERRP
 					       "%s: partitioning exceeds flash size, truncating\n",
 					       part->mtd_id);
 					part->parts[i].size = master->size - offset;
-					part->num_parts = i;
 				}
 				offset += part->parts[i].size;
 			}

Also, I'll send a short coding cleanup patch, this loop's indent level
is horrible...

Regards,
Shmulik

  reply	other threads:[~2012-09-05  5:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-26 17:21 [PATCH 1/3] mtd: cmdlinepart: make the partitions rule more strict Huang Shijie
2012-08-26 17:21 ` [PATCH 2/3] mtd: cmdlinepart: sort the unsorted partitions Huang Shijie
2012-08-31 13:59   ` Artem Bityutskiy
2012-08-31 14:29     ` Huang Shijie
2012-09-03  7:21   ` Artem Bityutskiy
2012-08-26 17:21 ` [PATCH 3/3] mtd: cmdlinepart: fix the wrong partitions number when truncating occurs Huang Shijie
2012-08-30  6:43   ` Artem Bityutskiy
2012-08-30  6:39     ` Huang Shijie
2012-08-31 11:45 ` [PATCH 1/3] mtd: cmdlinepart: make the partitions rule more strict Artem Bityutskiy
2012-08-31 13:36   ` Huang Shijie
2012-08-31 14:30   ` Huang Shijie
2012-09-03  7:18 ` Artem Bityutskiy
2012-09-03 15:09   ` Huang Shijie
2012-09-03 15:35     ` Artem Bityutskiy
2012-09-04  3:23       ` Huang Shijie
2012-09-04 11:48       ` Shmulik Ladkani
2012-09-05  2:12         ` Huang Shijie
2012-09-05  5:30           ` Shmulik Ladkani [this message]
2012-09-22 16:01             ` Artem Bityutskiy
2012-12-17  1:11           ` Christopher Cordahi
2012-12-18  5:27             ` Brian Norris
2013-01-15 11:49             ` Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120905083020.0bf6b0bd@halley \
    --to=shmulik.ladkani@gmail.com \
    --cc=b32955@freescale.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=shijie8@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).