mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] devfs: be more lax with partition boundaries
@ 2015-05-07  8:45 Uwe Kleine-König
  2015-05-07  8:57 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2015-05-07  8:45 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-07  9:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-07  8:45 [PATCH] devfs: be more lax with partition boundaries Uwe Kleine-König
2015-05-07  8:57 ` Sascha Hauer
2015-05-07  9:09   ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox