mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/2] cdev: allow overriding partition overlap check
@ 2025-01-06  9:00 Ahmad Fatoum
  2025-01-06  9:00 ` [PATCH v2 2/2] commands: addpart: allow force creation of overlapping partition Ahmad Fatoum
  2025-01-06  9:18 ` [PATCH v2 1/2] cdev: allow overriding partition overlap check Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-01-06  9:00 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

barebox will refuse to create overlapping partitions that are not
completely identical to an existing one.

The user on the shell may still want to allocate partitions that are
known to overlap, e.g. because they place multiple fixed partition into
one MBR partition or because we want to operate as a part of a cdev
interactively as if it were once device.

Don't preclude such use cases by adding a flag that just disables
overlap checks.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - allow force creation of partition at offset 0
---
 fs/devfs-core.c  | 16 +++++++++-------
 include/driver.h |  1 +
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 0651be3d8fc4..133fd9ec026a 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -530,14 +530,16 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
 		return ERR_PTR(-EINVAL);
 	}
 
-	overlap = check_overlap(cdev, partinfo->name, offset, size);
-	if (overlap) {
-		if (!IS_ERR(overlap)) {
-			/* only fails with -EEXIST, which is fine */
-			(void)devfs_create_link(overlap, partinfo->name);
-		}
+	if (!(partinfo->flags & DEVFS_PARTITION_CAN_OVERLAP)) {
+		overlap = check_overlap(cdev, partinfo->name, offset, size);
+		if (overlap) {
+			if (!IS_ERR(overlap)) {
+				/* only fails with -EEXIST, which is fine */
+				(void)devfs_create_link(overlap, partinfo->name);
+			}
 
-		return overlap;
+			return overlap;
+		}
 	}
 
 	/* Filter flags that we want to pass along to children */
diff --git a/include/driver.h b/include/driver.h
index 3aef385bc837..267e34294511 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -583,6 +583,7 @@ extern struct list_head cdev_list;
 #define DEVFS_PARTITION_BOOTABLE_ESP	(1U << 12)
 #define DEVFS_PARTITION_FOR_FIXUP	(1U << 13)
 #define DEVFS_WRITE_AUTOERASE		(1U << 14)
+#define DEVFS_PARTITION_CAN_OVERLAP	(1U << 15)
 
 /**
  * cdev_write_requires_erase - Check whether writes must be done to erased blocks
-- 
2.39.5




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

end of thread, other threads:[~2025-01-06  9:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-06  9:00 [PATCH v2 1/2] cdev: allow overriding partition overlap check Ahmad Fatoum
2025-01-06  9:00 ` [PATCH v2 2/2] commands: addpart: allow force creation of overlapping partition Ahmad Fatoum
2025-01-06  9:18 ` [PATCH v2 1/2] cdev: allow overriding partition overlap check Sascha Hauer

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