* [PATCH] partitions: Align partition numbering with that of Linux kernel
@ 2018-02-05 17:18 Andrey Smirnov
2018-02-16 13:41 ` Andrey Smirnov
2018-02-16 13:50 ` Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Andrey Smirnov @ 2018-02-05 17:18 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
Change the way Barebox numbers DOS/EFI partitions, such that it would
be consistent with how Linux kernel does it. With this change:
- Both types of partitions are numbered starting from 1, not 0
- Extended DOS partitions always start from 5, leaving first 4 to
non-extended ones.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
common/partitions.c | 7 +++----
common/partitions/dos.c | 2 ++
common/partitions/efi.c | 1 +
common/partitions/parser.h | 1 +
4 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/common/partitions.c b/common/partitions.c
index 574b31fbb..53d55a49a 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -42,8 +42,7 @@ static LIST_HEAD(partition_parser_list);
* @param no Partition number
* @return 0 on success
*/
-static int register_one_partition(struct block_device *blk,
- struct partition *part, int no)
+static int register_one_partition(struct block_device *blk, struct partition *part)
{
char *partition_name;
int ret;
@@ -51,7 +50,7 @@ static int register_one_partition(struct block_device *blk,
uint64_t size = part->size * SECTOR_SIZE;
struct cdev *cdev;
- partition_name = basprintf("%s.%d", blk->cdev.name, no);
+ partition_name = basprintf("%s.%d", blk->cdev.name, part->number);
if (!partition_name)
return -ENOMEM;
dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
@@ -150,7 +149,7 @@ int parse_partition_table(struct block_device *blk)
/* at least one partition description found */
for (i = 0; i < pdesc->used_entries; i++) {
- rc = register_one_partition(blk, &pdesc->parts[i], i);
+ rc = register_one_partition(blk, &pdesc->parts[i]);
if (rc != 0)
dev_err(blk->dev,
"Failed to register partition %d on %s (%d)\n",
diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 488c2936f..2ee9b2bd6 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -170,6 +170,7 @@ static void dos_extended_partition(struct block_device *blk, struct partition_de
get_unaligned_le32(&table[0].partition_start);
pd->parts[n].size = get_unaligned_le32(&table[0].partition_size);
pd->parts[n].dos_partition_type = table[0].type;
+ pd->parts[n].number = partno;
if (signature)
sprintf(pd->parts[n].partuuid, "%08x-%02u",
signature, partno);
@@ -224,6 +225,7 @@ static void dos_partition(void *buf, struct block_device *blk,
pd->parts[n].first_sec = pentry.first_sec;
pd->parts[n].size = pentry.size;
pd->parts[n].dos_partition_type = pentry.dos_partition_type;
+ pd->parts[n].number = i + 1;
if (signature)
sprintf(pd->parts[n].partuuid, "%08x-%02d",
signature, i + 1);
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 88734f166..5dc9e1ad8 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -456,6 +456,7 @@ static void efi_partition(void *buf, struct block_device *blk,
pentry = &pd->parts[pd->used_entries];
pentry->first_sec = le64_to_cpu(ptes[i].starting_lba);
pentry->size = le64_to_cpu(ptes[i].ending_lba) - pentry->first_sec;
+ pentry->number = pd->used_entries + 1;
pentry->size++;
part_set_efi_name(&ptes[i], pentry->name);
snprintf(pentry->partuuid, sizeof(pentry->partuuid), "%pUl", &ptes[i].unique_partition_guid);
diff --git a/common/partitions/parser.h b/common/partitions/parser.h
index 8ad134a9a..713933794 100644
--- a/common/partitions/parser.h
+++ b/common/partitions/parser.h
@@ -20,6 +20,7 @@ struct partition {
char partuuid[MAX_PARTUUID_STR];
uint64_t first_sec;
uint64_t size;
+ int number;
};
struct partition_desc {
--
2.14.3
_______________________________________________
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] partitions: Align partition numbering with that of Linux kernel
2018-02-05 17:18 [PATCH] partitions: Align partition numbering with that of Linux kernel Andrey Smirnov
@ 2018-02-16 13:41 ` Andrey Smirnov
2018-02-16 13:50 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Andrey Smirnov @ 2018-02-16 13:41 UTC (permalink / raw)
To: Barebox List, Sascha Hauer; +Cc: Andrey Smirnov
On Mon, Feb 5, 2018 at 9:18 AM, Andrey Smirnov <andrew.smirnov@gmail.com> wrote:
> Change the way Barebox numbers DOS/EFI partitions, such that it would
> be consistent with how Linux kernel does it. With this change:
>
> - Both types of partitions are numbered starting from 1, not 0
>
> - Extended DOS partitions always start from 5, leaving first 4 to
> non-extended ones.
>
Sascha, any opinion on this patch?
Thanks,
Andrey Smirnov
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> common/partitions.c | 7 +++----
> common/partitions/dos.c | 2 ++
> common/partitions/efi.c | 1 +
> common/partitions/parser.h | 1 +
> 4 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/common/partitions.c b/common/partitions.c
> index 574b31fbb..53d55a49a 100644
> --- a/common/partitions.c
> +++ b/common/partitions.c
> @@ -42,8 +42,7 @@ static LIST_HEAD(partition_parser_list);
> * @param no Partition number
> * @return 0 on success
> */
> -static int register_one_partition(struct block_device *blk,
> - struct partition *part, int no)
> +static int register_one_partition(struct block_device *blk, struct partition *part)
> {
> char *partition_name;
> int ret;
> @@ -51,7 +50,7 @@ static int register_one_partition(struct block_device *blk,
> uint64_t size = part->size * SECTOR_SIZE;
> struct cdev *cdev;
>
> - partition_name = basprintf("%s.%d", blk->cdev.name, no);
> + partition_name = basprintf("%s.%d", blk->cdev.name, part->number);
> if (!partition_name)
> return -ENOMEM;
> dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
> @@ -150,7 +149,7 @@ int parse_partition_table(struct block_device *blk)
>
> /* at least one partition description found */
> for (i = 0; i < pdesc->used_entries; i++) {
> - rc = register_one_partition(blk, &pdesc->parts[i], i);
> + rc = register_one_partition(blk, &pdesc->parts[i]);
> if (rc != 0)
> dev_err(blk->dev,
> "Failed to register partition %d on %s (%d)\n",
> diff --git a/common/partitions/dos.c b/common/partitions/dos.c
> index 488c2936f..2ee9b2bd6 100644
> --- a/common/partitions/dos.c
> +++ b/common/partitions/dos.c
> @@ -170,6 +170,7 @@ static void dos_extended_partition(struct block_device *blk, struct partition_de
> get_unaligned_le32(&table[0].partition_start);
> pd->parts[n].size = get_unaligned_le32(&table[0].partition_size);
> pd->parts[n].dos_partition_type = table[0].type;
> + pd->parts[n].number = partno;
> if (signature)
> sprintf(pd->parts[n].partuuid, "%08x-%02u",
> signature, partno);
> @@ -224,6 +225,7 @@ static void dos_partition(void *buf, struct block_device *blk,
> pd->parts[n].first_sec = pentry.first_sec;
> pd->parts[n].size = pentry.size;
> pd->parts[n].dos_partition_type = pentry.dos_partition_type;
> + pd->parts[n].number = i + 1;
> if (signature)
> sprintf(pd->parts[n].partuuid, "%08x-%02d",
> signature, i + 1);
> diff --git a/common/partitions/efi.c b/common/partitions/efi.c
> index 88734f166..5dc9e1ad8 100644
> --- a/common/partitions/efi.c
> +++ b/common/partitions/efi.c
> @@ -456,6 +456,7 @@ static void efi_partition(void *buf, struct block_device *blk,
> pentry = &pd->parts[pd->used_entries];
> pentry->first_sec = le64_to_cpu(ptes[i].starting_lba);
> pentry->size = le64_to_cpu(ptes[i].ending_lba) - pentry->first_sec;
> + pentry->number = pd->used_entries + 1;
> pentry->size++;
> part_set_efi_name(&ptes[i], pentry->name);
> snprintf(pentry->partuuid, sizeof(pentry->partuuid), "%pUl", &ptes[i].unique_partition_guid);
> diff --git a/common/partitions/parser.h b/common/partitions/parser.h
> index 8ad134a9a..713933794 100644
> --- a/common/partitions/parser.h
> +++ b/common/partitions/parser.h
> @@ -20,6 +20,7 @@ struct partition {
> char partuuid[MAX_PARTUUID_STR];
> uint64_t first_sec;
> uint64_t size;
> + int number;
> };
>
> struct partition_desc {
> --
> 2.14.3
>
_______________________________________________
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] partitions: Align partition numbering with that of Linux kernel
2018-02-05 17:18 [PATCH] partitions: Align partition numbering with that of Linux kernel Andrey Smirnov
2018-02-16 13:41 ` Andrey Smirnov
@ 2018-02-16 13:50 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2018-02-16 13:50 UTC (permalink / raw)
To: Andrey Smirnov; +Cc: barebox
Hi Andrey,
On Mon, Feb 05, 2018 at 09:18:15AM -0800, Andrey Smirnov wrote:
> Change the way Barebox numbers DOS/EFI partitions, such that it would
> be consistent with how Linux kernel does it. With this change:
>
> - Both types of partitions are numbered starting from 1, not 0
>
> - Extended DOS partitions always start from 5, leaving first 4 to
> non-extended ones.
I am not very happy with this change because it breaks boards expecting
a certain numbering. See for example:
arch/arm/mach-omap/omap_generic.c:116:static char *envpath = "/mnt/mmc0.0/barebox.env";
arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/mmc:3:global.bootm.image=/mnt/mmc0.0/linuximage
arch/arm/boards/embedsky-e9/defaultenv-e9/boot/mmc1:3:mount /dev/mmc1.0
There are more examples in-tree and for sure more out of tree.
We need very strong reasons to change this numbering.
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
end of thread, other threads:[~2018-02-16 13:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-05 17:18 [PATCH] partitions: Align partition numbering with that of Linux kernel Andrey Smirnov
2018-02-16 13:41 ` Andrey Smirnov
2018-02-16 13:50 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox