Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions nshlib/nsh_mmcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <nuttx/config.h>

#include <stdio.h>
#include <string.h>

#include "nsh.h"
Expand Down Expand Up @@ -58,18 +59,29 @@ int cmd_free(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)

int cmd_memdump(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
{
char arg[LINE_MAX] = "";
FAR char *arg;
int ret;
Comment thread
Zhangshoukui marked this conversation as resolved.
int i;
Comment thread
Zhangshoukui marked this conversation as resolved.

arg = lib_get_tempbuffer(LINE_MAX);
if (arg == NULL)
{
return -ENOMEM;
}

arg[0] = '\0';

if (argc == 1)
{
strlcpy(arg, "used", LINE_MAX);
}
else if (argc >= 2 && (strcmp(argv[1], "-h") == 0 ||
strcmp(argv[1], "help") == 0))
{
return nsh_catfile(vtbl, argv[0],
CONFIG_NSH_PROC_MOUNTPOINT "/memdump");
ret = nsh_catfile(vtbl, argv[0],
CONFIG_NSH_PROC_MOUNTPOINT "/memdump");
lib_put_tempbuffer(arg);
return ret;
Comment thread
Zhangshoukui marked this conversation as resolved.
}
else
{
Expand All @@ -83,8 +95,10 @@ int cmd_memdump(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
}
}

return nsh_writefile(vtbl, argv[0], arg, strlen(arg),
CONFIG_NSH_PROC_MOUNTPOINT "/memdump");
ret = nsh_writefile(vtbl, argv[0], arg, strlen(arg),
CONFIG_NSH_PROC_MOUNTPOINT "/memdump");
lib_put_tempbuffer(arg);
return ret;
Comment thread
Zhangshoukui marked this conversation as resolved.
}

#endif /* !CONFIG_NSH_DISABLE_MEMDUMP && NSH_HAVE_WRITEFILE */