diff mbox series

[v2,1/3] cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions

Message ID 20210412225307.3217317-1-sean.anderson@seco.com
State Accepted
Commit 7194527b6a456abaa24198dc4b6c289905c4cffd
Delegated to: Tom Rini
Headers show
Series [v2,1/3] cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions | expand

Commit Message

Sean Anderson April 12, 2021, 10:53 p.m. UTC
This allows using dev#partlabel syntax.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

Changes in v2:
- Add stub for when CONFIG_PARTITIONS=n

 fs/fs.c        |  4 ++--
 include/part.h | 12 +++++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

Comments

Tom Rini April 23, 2021, 4:24 p.m. UTC | #1
On Mon, Apr 12, 2021 at 06:53:05PM -0400, Sean Anderson wrote:

> This allows using dev#partlabel syntax.
> 
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>

Applied to u-boot/master, thanks!
Heinrich Schuchardt May 15, 2021, 12:36 p.m. UTC | #2
On 4/13/21 12:53 AM, Sean Anderson wrote:
> This allows using dev#partlabel syntax.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>

Since this patch was merged as commit 7194527b the command 'ls host'
leads to a segmentation violation:

=> host bind 0 ../sandbox.img
=> setenv bootdevice 0:1
=> ls host

Segmentation violation
pc = 0x55a5b66b7ec1, pc_reloc = 0x55a5a66b7ec1

Writing sandbox state

Before the patch:

=> host bind 0 ../sandbox.img
=> setenv bootdevice 0:1
=> ls host
       148   boot.scr
             Test/

1 file(s), 1 dir(s)

Please, provide a fix for your patch and a unit test using 'setenv
bootdevice' to avoid future mischief.

Best regards

Heinrich
diff mbox series

Patch

diff --git a/fs/fs.c b/fs/fs.c
index 900928c394..b7936fd4cf 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -385,8 +385,8 @@  int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
 	}
 #endif
 
-	part = blk_get_device_part_str(ifname, dev_part_str, &fs_dev_desc,
-					&fs_partition, 1);
+	part = part_get_info_by_dev_and_name_or_num(ifname, dev_part_str, &fs_dev_desc,
+						    &fs_partition, 1);
 	if (part < 0)
 		return -1;
 
diff --git a/include/part.h b/include/part.h
index 7f78271a98..419c859708 100644
--- a/include/part.h
+++ b/include/part.h
@@ -230,7 +230,7 @@  int part_get_info_by_name(struct blk_desc *dev_desc,
  * @param[in] allow_whole_dev true to allow the user to select partition 0
  *		(which means the whole device), false to require a valid
  *		partition number >= 1
- * @return 0 on success, or a negative on error
+ * @return the partition number on success, or negative errno on error
  */
 int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 					 const char *dev_part_str,
@@ -275,6 +275,16 @@  static inline int blk_get_device_part_str(const char *ifname,
 					  struct disk_partition *info,
 					  int allow_whole_dev)
 { *dev_desc = NULL; return -1; }
+static inline int
+part_get_info_by_dev_and_name_or_num(const char *dev_iface,
+				     const char *dev_part_str,
+				     struct blk_desc **dev_desc,
+				     struct disk_partition *part_info,
+				     int allow_whole_dev)
+{
+	*dev_desc = NULL;
+	return -ENOSYS;
+}
 #endif
 
 /*