Print error message for unknown device type
PATCH 1/1 Print error message for unknown device type
File system commands like "ls" etc. require a device type parameter. If an unknown type is specified, they return an error code but no visible feedback to the user:
-> ls FOOBAR 1:1 /
->
Add an error message to make clear what happens, and why.
--- disk/part.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
disk/part.c +3 -1
@@ -512,8 +512,10 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,/* Look up the device */ dev =blk_get_device_by_str (ifname, dev_str, dev_desc); -if (dev <0 ) +if (dev <0 ) { +printf ("** Unknown device type %s **\n" , ifname); goto cleanup; + }/* Convert partition ID string to number */ if (!part_str || !*part_str) {
Signature · 1 line
2.23.0
PATCH 1/1 Print error message for unknown device type
Hello Wolfgang,
Am 22.01.2020 um 12:08 schrieb Wolfgang Denk:
Quoted 7 lines
File system commands like "ls" etc. require a device type parameter. If an unknown type is specified, they return an error code but no visible feedback to the user:
-> ls FOOBAR 1:1 /
->
Quoted 6 lines
Add an error message to make clear what happens, and why.
Signed-off-by Wolfgang Denk <[email protected]>--- disk/part.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Tested on wandboard.
disk/part.c int blk_get_device_part_str(const char *ifname, const char *dev_part_str, · line 518
Quoted 13 lines
disk/part.c +3
-1@@ -512,8 +512,10 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,/* Look up the device */ dev =blk_get_device_by_str (ifname, dev_str, dev_desc); -if (dev <0 ) +if (dev <0 ) { +printf ("** Unknown device type %s **\n" , ifname); goto cleanup; + }
It would be nice to have here a list of supported devices, so a user can see what are valid arguments for ifname.
disk/part.c int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
Quoted 4 lines
disk/part.c +0
-0/* Convert partition ID string to number */ if (!part_str || !*part_str) {
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/1 Print error message for unknown device type
Dear Heiko,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 10 lines
File system commands like "ls" etc. require a device type parameter. If an unknown type is specified, they return an error code but no visible feedback to the user:
-> ls FOOBAR 1:1 /
->Add an error message to make clear what happens, and why.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Wolfgang Denk <[email protected]>--- disk/part.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Tested on wandboard.
Tested-by Heiko Schocher <[email protected]>
Thanks for testing.
Quoted 8 lines
disk/part.c int blk_get_device_part_str(const char *ifname, const char *dev_part_str, · line 518
Quoted 5 lines
disk/part.c +3
-1-if (dev <0 ) +if (dev <0 ) { +printf ("** Unknown device type %s **\n" , ifname); goto cleanup; + }It would be nice to have here a list of supported devices, so a user can see what are valid arguments for ifname.
Yes, you are absolutely right. I aready thought about this, but I have to admit that I got stuck in the code; there are several complexities - code for example for blk_driver_lookup_typename()
is duplicated both in drivers/block/blk_legacy.c and indrivers/block/blk-uclass.c; I was not able to find any exported interface that actually allows to get a list of supported device drivers, and the things I tried all looked really ugly to me.
Adding Simon to Cc: - he has designed and written all this code and should know better.
Simon, what would be a clean and elegant approach to get such a list of supported drivers ?
In any case I recommend to accept this patch as is; this other thing is additional information that can /should get added later in a spearate patch.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de People don't like to be lectured to, but if you can make them laugh, their defenses come down, and for the time being they've accepted whatever truth is embedded in your humor. - Paul Krassner
PATCH 1/1 Print error message for unknown device type
Hello Simon,
ping...
Quoted 48 lines · In message <[email protected]> I wrote:
Dear Heiko,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 10 lines
File system commands like "ls" etc. require a device type parameter. If an unknown type is specified, they return an error code but no visible feedback to the user:
-> ls FOOBAR 1:1 /
->Add an error message to make clear what happens, and why.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Wolfgang Denk <[email protected]>--- disk/part.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Tested on wandboard.
Tested-by Heiko Schocher <[email protected]>Thanks for testing.
Quoted 8 lines
disk/part.c int blk_get_device_part_str(const char *ifname, const char *dev_part_str, · line 518
Quoted 5 lines
disk/part.c +3
-1-if (dev <0 ) +if (dev <0 ) { +printf ("** Unknown device type %s **\n" , ifname); goto cleanup; + }It would be nice to have here a list of supported devices, so a user can see what are valid arguments for ifname.
Yes, you are absolutely right. I aready thought about this, but I have to admit that I got stuck in the code; there are several complexities - code for example for
blk_driver_lookup_typename()
is duplicated both indrivers/block/blk_legacy.cand indrivers/block/blk-uclass.c; I was not able to find any exported interface that actually allows to get a list of supported device drivers, and the things I tried all looked really ugly to me.Adding Simon to Cc: - he has designed and written all this code and should know better.
Simon, what would be a clean and elegant approach to get such a list of supported drivers ?
Quoted 7 lines
In any case I recommend to accept this patch as is; this other thing is additional information that can /should get added later in a spearate patch.
Best regards,
Wolfgang Denk
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Objects in mirror are closer than they appear.
PATCH 1/1 Print error message for unknown device type
Hi,
Quoted 35 lines · Wolfgang Denk
Hello Simon,
ping...
Quoted 29 lines · In message <[email protected]> I wrote:
Dear Heiko,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 10 lines
File system commands like "ls" etc. require a device type parameter. If an unknown type is specified, they return an error code but no visible feedback to the user:
-> ls FOOBAR 1:1 /
->Add an error message to make clear what happens, and why.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Wolfgang Denk <[email protected]>--- disk/part.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Tested on wandboard.
Tested-by Heiko Schocher <[email protected]>Thanks for testing.
Quoted 5 lines
Quoted 5 lines
- if (dev < 0)
+ if (dev < 0) {+ printf("** Unknown device type %s **\n", ifname); goto cleanup;+ }
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
It would be nice to have here a list of supported devices, so a user can see what are valid arguments for ifname.
There are two functions involved here, since we still support non-DM block devices. The function called is blk_get_devnum_by_typename(), with two implementations.
So we would need two different implementations to read the list of devices:
- blk_get_devnum_by_typename() has a uclass_foreach_dev() loop
- blk_driver_lookup_typename() shows how to iterate through the legacy block devices
Quoted 12 lines
Quoted 12 lines
Yes, you are absolutely right. I aready thought about this, but I have to admit that I got stuck in the code; there are several complexities - code for example for
blk_driver_lookup_typename()
is duplicated both indrivers/block/blk_legacy.cand indrivers/block/blk-uclass.c; I was not able to find any exported interface that actually allows to get a list of supported device drivers, and the things I tried all looked really ugly to me.Adding Simon to Cc: - he has designed and written all this code and should know better.
Quoted 7 lines
Quoted 7 lines
Simon, what would be a clean and elegant approach to get such a list of supported drivers ?
In any case I recommend to accept this patch as is; this other thing is additional information that can /should get added later in a spearate patch.
Regards,
Simon
PATCH 1/1 Print error message for unknown device type
In reply to Wolfgang DenkQuoted 31 lines · Wolfgang Denk
File system commands like "ls" etc. require a device type parameter. If an unknown type is specified, they return an error code but no visible feedback to the user:
-> ls FOOBAR 1:1 /
->Add an error message to make clear what happens, and why.
Signed-off-by Wolfgang Denk <[email protected]>--- disk/part.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)disk/part.c +3
-1@@ -512,8 +512,10 @@ int blk_get_device_part_str(const char *ifname, constchar *dev_part_str,/* Look up the device */ dev =blk_get_device_by_str (ifname, dev_str, dev_desc); -if (dev <0 ) +if (dev <0 ) { +printf ("** Unknown device type %s **\n" , ifname); goto cleanup; + }/* Convert partition ID string to number */ if (!part_str || !*part_str) {
Quoted 4 lines
--
2.23.0
Oww, I've submitted the similar patch to this mailing list recently but it is waiting for moderator approval :)
Signature · 3 lines
Thanks, Nikita B8 00 4C CD 21