nshlib: add relative image path support in boot command

cmd_boot passed the image path straight to boardctl(), which resolves
it in a context that does not inherit the NSH shell cwd, so relative
paths failed and only absolute paths worked. Use nsh_getfullpath() to
resolve relative paths against the cwd before calling boardctl().

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
This commit is contained in:
Junbo Zheng 2026-07-24 23:47:44 +08:00 committed by Alan C. Assis
parent 8d5e9f3754
commit fabafbc361

View file

@ -405,6 +405,7 @@ int cmd_switchboot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
int cmd_boot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
{
struct boardioc_boot_info_s info;
FAR char *fullpath = NULL;
memset(&info, 0, sizeof(info));
@ -421,7 +422,8 @@ int cmd_boot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
/* Go through */
case 1:
info.path = argv[1];
fullpath = nsh_getfullpath(vtbl, argv[1]);
info.path = fullpath;
/* Go through */
@ -439,6 +441,7 @@ int cmd_boot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
*/
nsh_error(vtbl, g_fmtcmdfailed, argv[0], "boardctl", NSH_ERRNO);
nsh_freefullpath(fullpath);
return ERROR;
}
#endif