[PATCH v2 1/2] cdev: allow overriding partition overlap check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux