mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] devfs: be more lax with partition boundaries
Date: Thu,  7 May 2015 10:45:45 +0200	[thread overview]
Message-ID: <1430988346-25450-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)

If a partition starts inside its parent device but is too big such that
it extends over the device boundary, just chop it to the device's end.

This matches the behaviour of Linux.

The motivation for this change is that it makes it possible in some
cases to have the partitioning in a device tree fixed and still allow
different flash sizes.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 fs/devfs-core.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index f45f8cadf1b0..d456ebccaf06 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -290,12 +290,20 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
 
 	*end = offset + size;
 
-	if (offset < 0 || *end > cdev->size) {
-		pr_warn("partition %s not completely inside device %s\n",
-				partinfo->name, cdev->name);
+	if (offset < 0 || offset > cdev->size) {
+		pr_warn("start of partition %s not inside of device %s\n",
+			partinfo->name, cdev->name);
 		return ERR_PTR(-EINVAL);
 	}
 
+	if (*end > cdev->size) {
+		pr_warn("end of partition %s after end of device %s, chopping\n",
+			partinfo->name, cdev->name);
+
+		*end = cdev->size;
+		size = *end - offset;
+	}
+
 	if (IS_ENABLED(CONFIG_MTD) && cdev->mtd) {
 		struct mtd_info *mtd;
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-05-07  8:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07  8:45 Uwe Kleine-König [this message]
2015-05-07  8:57 ` Sascha Hauer
2015-05-07  9:09   ` Uwe Kleine-König

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=1430988346-25450-1-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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