From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 1/2] cdev: allow overriding partition overlap check
Date: Mon, 6 Jan 2025 10:00:47 +0100 [thread overview]
Message-ID: <20250106090048.3420243-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2025-01-06 9:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 9:00 Ahmad Fatoum [this message]
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
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=20250106090048.3420243-1-a.fatoum@pengutronix.de \
--to=a.fatoum@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