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

* Re: [PATCH] devfs: be more lax with partition boundaries
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2015-05-07  8:57 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox

On Thu, May 07, 2015 at 10:45:45AM +0200, Uwe Kleine-König wrote:
> 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.

When doing it someone is probably annoyed about the warning pretty soon.
I know we just talked whether I would accept this patch, but now I
realized that the correct way to extend the last partition to the end of
the device is to use size 0. This works under barebox and Linux.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH] devfs: be more lax with partition boundaries
  2015-05-07  8:57 ` Sascha Hauer
@ 2015-05-07  9:09   ` Uwe Kleine-König
  0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2015-05-07  9:09 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hello Sascha,

On Thu, May 07, 2015 at 10:57:02AM +0200, Sascha Hauer wrote:
> On Thu, May 07, 2015 at 10:45:45AM +0200, Uwe Kleine-König wrote:
> > 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.
> 
> When doing it someone is probably annoyed about the warning pretty soon.
> I know we just talked whether I would accept this patch, but now I
well, we talked about a change in barebox that makes it match the
behaviour of Linux. So critic to the actual implementation is fine.

> realized that the correct way to extend the last partition to the end of
> the device is to use size 0. This works under barebox and Linux.
Great. Just tested this and it works fine. (I don't know if Linux really
handles this this way, but barebox does and gives the right explicit
size to Linux.)

\o/
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
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