* [U-Boot] [PATCH v3 1/2] common: cmd_part: Proper alignment
@ 2015-06-15 19:35 Paul Kocialkowski
2015-06-15 19:35 ` [U-Boot] [PATCH v3 2/2] common: cmd_part: start and size sub-commands introduction Paul Kocialkowski
2015-06-19 20:25 ` [U-Boot] [U-Boot,v3,1/2] common: cmd_part: Proper alignment Tom Rini
0 siblings, 2 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2015-06-15 19:35 UTC (permalink / raw)
To: u-boot
This fixes a misaligned declaration.
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
common/cmd_part.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/cmd_part.c b/common/cmd_part.c
index 8483c12..4bdbf90 100644
--- a/common/cmd_part.c
+++ b/common/cmd_part.c
@@ -88,7 +88,7 @@ static int do_part_list(int argc, char * const argv[])
if (var != NULL) {
int p;
char str[512] = { '\0', };
- disk_partition_t info;
+ disk_partition_t info;
for (p = 1; p < 128; p++) {
char t[5];
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v3 2/2] common: cmd_part: start and size sub-commands introduction
2015-06-15 19:35 [U-Boot] [PATCH v3 1/2] common: cmd_part: Proper alignment Paul Kocialkowski
@ 2015-06-15 19:35 ` Paul Kocialkowski
2015-06-15 23:19 ` Stephen Warren
2015-06-19 20:25 ` [U-Boot] [U-Boot, v3, " Tom Rini
2015-06-19 20:25 ` [U-Boot] [U-Boot,v3,1/2] common: cmd_part: Proper alignment Tom Rini
1 sibling, 2 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2015-06-15 19:35 UTC (permalink / raw)
To: u-boot
This introduces the part start and part size sub-commands. The purpose of these
is to store the start block and size of a partition in a variable, given the
device and partition number.
This allows reading raw data that fits a single partition more easily.
For instance, this could be used to figure out the start block and size of a
kernel partition when a partition table is present, given the partition number.
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
common/cmd_part.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 77 insertions(+), 1 deletion(-)
diff --git a/common/cmd_part.c b/common/cmd_part.c
index 4bdbf90..8085d26 100644
--- a/common/cmd_part.c
+++ b/common/cmd_part.c
@@ -112,6 +112,74 @@ static int do_part_list(int argc, char * const argv[])
return 0;
}
+static int do_part_start(int argc, char * const argv[])
+{
+ block_dev_desc_t *desc;
+ disk_partition_t info;
+ char buf[512] = { 0 };
+ int part;
+ int err;
+ int ret;
+
+ if (argc < 3)
+ return CMD_RET_USAGE;
+ if (argc > 4)
+ return CMD_RET_USAGE;
+
+ part = simple_strtoul(argv[2], NULL, 0);
+
+ ret = get_device(argv[0], argv[1], &desc);
+ if (ret < 0)
+ return 1;
+
+ err = get_partition_info(desc, part, &info);
+ if (err)
+ return 1;
+
+ snprintf(buf, sizeof(buf), "%lx", info.start);
+
+ if (argc > 3)
+ setenv(argv[3], buf);
+ else
+ printf("%s\n", buf);
+
+ return 0;
+}
+
+static int do_part_size(int argc, char * const argv[])
+{
+ block_dev_desc_t *desc;
+ disk_partition_t info;
+ char buf[512] = { 0 };
+ int part;
+ int err;
+ int ret;
+
+ if (argc < 3)
+ return CMD_RET_USAGE;
+ if (argc > 4)
+ return CMD_RET_USAGE;
+
+ part = simple_strtoul(argv[2], NULL, 0);
+
+ ret = get_device(argv[0], argv[1], &desc);
+ if (ret < 0)
+ return 1;
+
+ err = get_partition_info(desc, part, &info);
+ if (err)
+ return 1;
+
+ snprintf(buf, sizeof(buf), "%lx", info.size);
+
+ if (argc > 3)
+ setenv(argv[3], buf);
+ else
+ printf("%s\n", buf);
+
+ return 0;
+}
+
static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
if (argc < 2)
@@ -121,6 +189,10 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return do_part_uuid(argc - 2, argv + 2);
else if (!strcmp(argv[1], "list"))
return do_part_list(argc - 2, argv + 2);
+ else if (!strcmp(argv[1], "start"))
+ return do_part_start(argc - 2, argv + 2);
+ else if (!strcmp(argv[1], "size"))
+ return do_part_size(argc - 2, argv + 2);
return CMD_RET_USAGE;
}
@@ -136,5 +208,9 @@ U_BOOT_CMD(
" - print a device's partition table\n"
"part list <interface> <dev> [flags] <varname>\n"
" - set environment variable to the list of partitions\n"
- " flags can be -bootable (list only bootable partitions)"
+ " flags can be -bootable (list only bootable partitions)\n"
+ "part start <interface> <dev> <part> <varname>\n"
+ " - set environment variable to the start of the partition (in blocks)\n"
+ "part size <interface> <dev> <part> <varname>\n"
+ " - set environment variable to the size of the partition (in blocks)"
);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v3 2/2] common: cmd_part: start and size sub-commands introduction
2015-06-15 19:35 ` [U-Boot] [PATCH v3 2/2] common: cmd_part: start and size sub-commands introduction Paul Kocialkowski
@ 2015-06-15 23:19 ` Stephen Warren
2015-06-19 20:25 ` [U-Boot] [U-Boot, v3, " Tom Rini
1 sibling, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2015-06-15 23:19 UTC (permalink / raw)
To: u-boot
On 06/15/2015 01:35 PM, Paul Kocialkowski wrote:
> This introduces the part start and part size sub-commands. The purpose of these
> is to store the start block and size of a partition in a variable, given the
> device and partition number.
>
> This allows reading raw data that fits a single partition more easily.
> For instance, this could be used to figure out the start block and size of a
> kernel partition when a partition table is present, given the partition number.
The series,
Acked-by: Stephen Warren <swarren@nvidia.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [U-Boot,v3,1/2] common: cmd_part: Proper alignment
2015-06-15 19:35 [U-Boot] [PATCH v3 1/2] common: cmd_part: Proper alignment Paul Kocialkowski
2015-06-15 19:35 ` [U-Boot] [PATCH v3 2/2] common: cmd_part: start and size sub-commands introduction Paul Kocialkowski
@ 2015-06-19 20:25 ` Tom Rini
1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2015-06-19 20:25 UTC (permalink / raw)
To: u-boot
On Mon, Jun 15, 2015 at 09:35:04PM +0200, Paul Kocialkowski wrote:
> This fixes a misaligned declaration.
>
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150619/671ef3d8/attachment.sig>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [U-Boot, v3, 2/2] common: cmd_part: start and size sub-commands introduction
2015-06-15 19:35 ` [U-Boot] [PATCH v3 2/2] common: cmd_part: start and size sub-commands introduction Paul Kocialkowski
2015-06-15 23:19 ` Stephen Warren
@ 2015-06-19 20:25 ` Tom Rini
1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2015-06-19 20:25 UTC (permalink / raw)
To: u-boot
On Mon, Jun 15, 2015 at 09:35:05PM +0200, Paul Kocialkowski wrote:
> This introduces the part start and part size sub-commands. The purpose of these
> is to store the start block and size of a partition in a variable, given the
> device and partition number.
>
> This allows reading raw data that fits a single partition more easily.
> For instance, this could be used to figure out the start block and size of a
> kernel partition when a partition table is present, given the partition number.
>
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> Acked-by: Stephen Warren <swarren@nvidia.com>
After changing it to use LBAF instead of "%lx" to fix some warnings,
applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150619/8b2a5a0b/attachment.sig>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-19 20:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-15 19:35 [U-Boot] [PATCH v3 1/2] common: cmd_part: Proper alignment Paul Kocialkowski
2015-06-15 19:35 ` [U-Boot] [PATCH v3 2/2] common: cmd_part: start and size sub-commands introduction Paul Kocialkowski
2015-06-15 23:19 ` Stephen Warren
2015-06-19 20:25 ` [U-Boot] [U-Boot, v3, " Tom Rini
2015-06-19 20:25 ` [U-Boot] [U-Boot,v3,1/2] common: cmd_part: Proper alignment Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox