From 23ec80fa3087d079f72b0d7190c4ce59a1e513a3 Mon Sep 17 00:00:00 2001 From: Subhra Sankha Sarkar Date: Wed, 28 Oct 2020 15:34:16 +0530 Subject: [PATCH] Addressed review comments from @v01d and @xiaoxiang781216 --- nshlib/nsh_fsutils.c | 26 ++++++++++++++++++++++++-- nshlib/nsh_netcmds.c | 4 +++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/nshlib/nsh_fsutils.c b/nshlib/nsh_fsutils.c index fe18b4812..722976d89 100644 --- a/nshlib/nsh_fsutils.c +++ b/nshlib/nsh_fsutils.c @@ -84,7 +84,18 @@ int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, fd = open(filepath, O_RDONLY); if (fd < 0) { - nsh_error(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO); + if (strncmp(filepath, CONFIG_NSH_PROC_MOUNTPOINT, + strlen(CONFIG_NSH_PROC_MOUNTPOINT)) == 0) + { + nsh_error(vtbl, + "nsh: %s: Could not open %s (is procfs mounted?): %d\n", + cmd, filepath, NSH_ERRNO); + } + else + { + nsh_error(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO); + } + return ERROR; } @@ -319,7 +330,18 @@ int nsh_foreach_direntry(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, { /* Failed to open the directory */ - nsh_error(vtbl, g_fmtnosuch, cmd, "directory", dirpath); + if (strncmp(dirpath, CONFIG_NSH_PROC_MOUNTPOINT, + strlen(CONFIG_NSH_PROC_MOUNTPOINT)) == 0) + { + nsh_error(vtbl, + "nsh: %s: Could not open %s (is procfs mounted?): %d\n", + cmd, dirpath, NSH_ERRNO); + } + else + { + nsh_error(vtbl, g_fmtnosuch, cmd, "directory", dirpath); + } + return ERROR; } diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c index b158ed39a..d4633e10c 100644 --- a/nshlib/nsh_netcmds.c +++ b/nshlib/nsh_netcmds.c @@ -391,7 +391,9 @@ static int nsh_foreach_netdev(nsh_netdev_callback_t callback, dir = opendir(CONFIG_NSH_PROC_MOUNTPOINT "/net"); if (dir == NULL) { - nsh_error(vtbl, g_fmtcmdfailed, cmd, "opendir", NSH_ERRNO); + nsh_error(vtbl, + "nsh: %s: Could not open %s/net (is procfs mounted?): %d\n", + cmd, CONFIG_NSH_PROC_MOUNTPOINT, NSH_ERRNO); return ERROR; }