[PATCH 0/2] disk: part: sandbox support in dev_print()

Without the series the fatinfo command shows an error for host file backed block devices:
=> host bind 0 ../sandbox.img => fatinfo host 0:1 Interface: Unknown Device 0: Unhandled device type: 9 Filesystem: FAT16 "NO NAME " =>
With the series reasonable information is shown:
=> host bind 0 ../sandbox.img => fatinfo host 0:1 Interface: Unknown Device 0: Vendor: U-Boot Rev: 1.0 Prod: hostfile Type: Removable Hard Disk Capacity: 128.9 MB = 0.1 GB (264190 x 512) Filesystem: FAT16 "NO NAME " =>
The "Interface:" line is created in file_fat_detectfs() and still needs to be fixed.
Heinrich Schuchardt (2): sandbox: fill block device meta information disk: part: sandbox support in dev_print()
disk/part.c | 1 + drivers/block/sandbox.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
-- 2.29.2

Provide information about host backed block device.
Mark the device created by 'host bind' as removable.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- drivers/block/sandbox.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c index 34c26cda47..f57f690d3c 100644 --- a/drivers/block/sandbox.c +++ b/drivers/block/sandbox.c @@ -92,6 +92,7 @@ int host_dev_bind(int devnum, char *filename) { struct host_block_dev *host_dev; struct udevice *dev; + struct blk_desc *desc; char dev_name[20], *str, *fname; int ret, fd;
@@ -143,6 +144,12 @@ int host_dev_bind(int devnum, char *filename) goto err_file; }
+ desc = blk_get_devnum_by_type(IF_TYPE_HOST, devnum); + desc->removable = 1; + snprintf(desc->vendor, BLK_VEN_SIZE, "U-Boot"); + snprintf(desc->product, BLK_PRD_SIZE, "hostfile"); + snprintf(desc->revision, BLK_REV_SIZE, "1.0"); + return 0; err_file: os_close(fd); @@ -187,6 +194,10 @@ int host_dev_bind(int dev, char *filename) blk_dev->block_write = host_block_write; blk_dev->devnum = dev; blk_dev->part_type = PART_TYPE_UNKNOWN; + blk_dev->removable = 1; + snprintf(blk_dev->vendor, BLK_VEN_SIZE, "U-Boot"); + snprintf(blk_dev->product, BLK_PRD_SIZE, "hostfile"); + snprintf(blk_dev->revision, BLK_REV_SIZE, "1.0"); part_init(blk_dev);
return 0; -- 2.29.2

Provide information about host backed block device.
Mark the device created by 'host bind' as removable.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- drivers/block/sandbox.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
Applied to u-boot-dm, thanks!

Commands like 'fatinfo' call dev_print() to print device information. If the block device is created via 'host bind', we should print accurate information.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- disk/part.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/disk/part.c b/disk/part.c index b69fd345f3..85b1af55e2 100644 --- a/disk/part.c +++ b/disk/part.c @@ -150,6 +150,7 @@ void dev_print (struct blk_desc *dev_desc) case IF_TYPE_USB: case IF_TYPE_NVME: case IF_TYPE_PVBLOCK: + case IF_TYPE_HOST: printf ("Vendor: %s Rev: %s Prod: %s\n", dev_desc->vendor, dev_desc->revision, -- 2.29.2

Commands like 'fatinfo' call dev_print() to print device information. If the block device is created via 'host bind', we should print accurate information.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- disk/part.c | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm, thanks!
participants (2)
-
Heinrich Schuchardt
-
Simon Glass