Commit Graph

819 Commits

Author SHA1 Message Date
chao.an
8721bc6847 nshlib: Fix the build break in nsh_telnetd.c when CONFIG_NSH_CONSOLE=n
set the config:
CONFIG_NSH_ROMFSETC=y
CONFIG_NSH_CONSOLE=n

nsh_telnetd.c: In function 'nsh_telnetstart':
nsh_telnetd.c:267:22: error: 'vtbl' undeclared (first use in this function)
  267 |       nsh_initscript(vtbl);
      |                      ^~~~

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-05-07 10:53:25 -07:00
chao.an
a5337af484 nsh/telnetd: bringup the network before telnetd init
bringup the network before telnetd init if without NSH_CONSOLE

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-05-06 19:14:47 -07:00
Anthony Merlino
267aba6467 addroute: inet_pton cannot accept slash notation. We must fixup the argument before calling. 2021-04-23 03:27:40 -05:00
Sungwoo Kim
6f4b133998 nshlib: Disable mb, mh, and mw by default
- Fix https://github.com/apache/incubator-nuttx/issues/3011

Co-authored-by: Gisu Yeo <wcharcode@gmail.com>
Co-authored-by: Taegyu Kim <tgkim@purdue.edu>
2021-04-03 09:40:18 -05:00
chao.an
960e63402e nsh/builtin: Ignore the child status if run the application on background.
N/A

fix the leak of child status if the background process
exceeds "CONFIG_PREALLOC_CHILDSTATUS".

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-21 02:18:09 -07:00
Jiuzhu Dong
4c6ded2661 app: delete NFILE_DESCRIPTORS limits
Change-Id: I3ced2b2b7440a2c79a712cfc97b4cd15d2bddd4c
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-12 21:12:07 -08:00
ligd
89e6fb9a42 apps/md5: fix md5 result error
MIRTOS-325

Change-Id: I0dd6c3e155b8fe41fe8ea6859271168a0d283829
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-03-03 22:12:24 -08:00
Gustavo Henrique Nihei
5cddb39b4e nshlib: Fix dependency on FSUTILS_MKFATFS 2021-02-16 04:04:59 -08:00
Alan C. Assis
382638c8c6 Add support in printf command to send 8-32 bits value 2021-01-28 05:15:59 -08:00
Xiang Xiao
28362eb6d1 nshlib: Remove fdopen for the stdin, stdout and stderr
not really need since these file stream should be opened automatically

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-12-16 07:53:38 +09:00
Masayuki Ishikawa
0c3ee06fb3 nshlib: Fix nsh_usbconsole.c
Summary:
- stdin/stdout/stderr are now preallocated in libc and fs_fd
  in file_struct are also initialized to -1
- So we need to call fdopen() for stdin again as we did before.
- Also, cn_outstream and cn_errstream are not needed to be set.
- See apps/nshlib/nsh_console.h as well

Impact:
- nsh_usbconsole.c only

Testing:
- Tested with stm32f4discovery:usbnsh

Signed-off-by: SUZUKI Keiji <zuki.ebetsu@gmail.com>
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-12-14 04:23:26 -06:00
chao.an
fe915679b1 style/Document: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:10 +01:00
YAMAMOTO Takashi
d6b67eb05e nshlib/nsh_dbgcmds.c: Fix a few printf warnings 2020-11-09 04:10:59 -08:00
Subhra Sankha Sarkar
3b884cfb87 Fixing coding style issues for rest of nshlib directory - except for the false +ve nsh_timcmds.c 2020-11-02 13:30:18 +01:00
Masayuki Ishikawa
305bd0e448 nshlib: Fix nsh_configstdio() in nsh_usbconsole.c
Summary:
- This commit fixes nsh_configstdio() to setup stdout and stderr

Impact:
- Affect nsh_usbconsole only

Testing:
- Tested with stm32f4discovery:usbnsh

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-10-29 20:43:59 +09:00
Xiang Xiao
e76ab9c868 Remove all fclose with stdin, stdout and stderr
since it is wrong to close the builtin stream and specially note
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fclose.html:

Since after the call to fclose() any use of stream results in
undefined behavior, fclose() should not be used on stdin, stdout,
or stderr except immediately before process termination (see XBD
Process Termination), so as to avoid triggering undefined behavior
in other standard interfaces that rely on these streams. If there
are any atexit() handlers registered by the application, such a
call to fclose() should not occur until the last handler is
finishing. Once fclose() has been used to close stdin, stdout, or
stderr, there is no standard way to reopen any of these streams.

and it is also unnecessary because the stream always get flushed.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-10-29 20:43:59 +09:00
Subhra Sankha Sarkar
36b1be0609 Fixed coding std issues 2020-10-29 04:20:17 -07:00
Subhra Sankha Sarkar
76e58d9e55 Fixed coding std violations in nsh_fsutils.h 2020-10-28 06:43:43 -07:00
Subhra Sankha Sarkar
0d74608b2c Fixed build issues 2020-10-28 05:57:47 -07:00
Subhra Sankha Sarkar
23ec80fa30 Addressed review comments from @v01d and @xiaoxiang781216 2020-10-28 05:57:47 -07:00
YAMAMOTO Takashi
aa0aa73250 nsh_netcmds.c: Adapt to the new webclient api
As a bonus, check and report errors from write().

tested as: "nsh> wget http://example.com/"
2020-10-01 15:32:25 +08:00
Xiang Xiao
ecae66fe59 Replace all CONFIG_NFILE_STREAMS with CONFIG_FILE_STREAM
follow up the kernel side change

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic27ad65d7cc2ea570921e0c17098dcb6bfe1893a
2020-09-11 17:57:58 +08:00
spiriou
06c7f06b1d nshlib: remove NSH_HAVE_WRITABLE_MOUNTPOINT to enable mkrd again 2020-08-23 11:38:08 -07:00
Xiang Xiao
9d80399bd5 nsh: Accept the command line arguments like sh
Usage: nsh [<script-path>|-c <command>]

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ifb76b27e7fd09d26b1f6e48c391fed0972018041
2020-08-19 14:32:53 -07:00
Xiang Xiao
74c506b4d1 nsh: Don't check CONFIG_NFILE_STREAMS for mkdir/rename/rmdir/fs_unlink
since these function don't depend on standard input/output function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I320659eff933d49c4872e43320fa30696d8b8a54
2020-08-17 00:16:21 +01:00
Masayuki Ishikawa
7f48576218 nshlib: Fix memory corruption in nsh_parse.c
Summary:
- Fix memory corruption when pthread_create() failed in nsh_execute()

Impact:

- nsh builtin command execution in background with errors

Testing:

- Tested with hifive1-revb:nsh
- Set CONFIG_MAX_TASKS=4
- Run 'sleep 1000 &' in 3 times will cause pthread_create error
- Run free, ps command

Reported-by: Yoshinori Sugino <ysgn0101@gmail.com>
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-08-11 13:57:02 +02:00
Maciej Wójcik
21049ece6e Rewritten READMEs to Markdown 2020-07-25 01:01:51 -07:00
Maciej Wójcik
51e6645f71 Rename README and README.txt to README.md 2020-07-25 01:01:51 -07:00
Xiang Xiao
942f32e22a Fix nxsytle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I36099dc6c07c7ada2f9fcb06fe0267b8d213a61a
2020-07-12 13:56:00 +01:00
Xiang Xiao
deaa6c5b7b build: Replace $(TOPDIR)/Make.defs with $(APPDIR)/Make.defs
and move NUTTXLIB defintion to the common place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-09 15:17:37 -03:00
Xiang Xiao
95d7e9b191 nshlib: Call symlink if user pass -s for ln command
since NuttX kernel support really support symlink not link.
Note: link equal symlink now because the hard link doesn't support yet

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I47437f5fd8bbab3a5539d0eb6f690f633b422345
2020-07-01 11:59:00 +02:00
Gregory Nutt
192273da2e Revert "nshlib: remove the dependency of date on RTC"
This is a bad change.  It has been show to cause an increase in size by around 2.3Kb in minimal configurations that cannot tolerate that massive size increase.

This reverts commit 4adb83c754.
2020-06-24 16:07:55 -07:00
Xiang Xiao
69f013e74e build: Remve the unnecessary .gitignore
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-23 15:56:35 +01:00
Xiang Xiao
ead498a788 build: Remove the workaround for the inexistence of .config/Make.defs
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-21 17:43:42 +01:00
Masayuki Ishikawa
bd47c468c5 nshlib: Introduce CONFIG_NSH_WGET_BUFF_SIZE
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-05-18 20:00:28 -06:00
chao.an
898c1ce4d2 Revert "This critical behavior was broken by this commit:"
This reverts commit 9b06b508f9.

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-05-18 06:53:57 -06:00
Gregory Nutt
4f54a75c48 apps/nshlib/nsh_parse.c: Add some comments.
Add some comments to nsh_parse.c emphasizing the reason that things are done in the order that they are.  Perhaps such comments will avoid similar breakage in the future.
2020-05-18 10:03:17 +08:00
Gregory Nutt
60428baed6 apps/nshlib/nsh_parse.c: Run through nxstyle. 2020-05-17 23:38:05 +01:00
Gregory Nutt
9b06b508f9 This critical behavior was broken by this commit:
commit 9a28ccf836
    Author: chao.an <anchao@xiaomi.com>
    Date:   Fri Feb 21 09:54:47 2020 +0800

        nsh/parse: try the builtin configuration first

        In the case of enable the BUILTIN_APPS/FILE_APPS at the same time,
        try the builtin list first to ensure that the relevant configuration
        (stacksize, priority) can be set normally.

This commit breaks the feature because it changes the order to that the built-in application is tried first.  Hence, the version on the file system will never replace the built-in version.

That commit must be reverted in order to restore the correct functionality.

    Revert "nsh/parse: try the builtin configuration first"

    This reverts commit 9a28ccf836.
2020-05-17 23:38:05 +01:00
Gregory Nutt
b2d8c501f6 Remove use of set_errno() from application code.
The normal assignment errno = errcode should work fine now.
2020-05-07 22:23:19 +01:00
Xiang Xiao
e72608e0d8 Fix nxstyle issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-02 09:45:44 -06:00
Ouss4
679896328d nshlib/nsh_telnetd.c: Print the end line of the MOTD correctly. 2020-04-29 14:46:13 +08:00
Juha Niskanen
f18b283ea8 nshlib: add printf command to README.TXT
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-04-21 08:02:32 -06:00
Xiang Xiao
a82d74b8a1 nshlib: Call BOARDIOC_FINALINIT in nsh_telnetstart if CONFIG_NSH_CONSOLE not define
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 10:15:23 -06:00
Xiang Xiao
b1b45de3db Revert "nshlib: Move BOARDIOC_FINALINIT into nsh_initscript"
This reverts commit ac5632fc50.
2020-04-19 10:15:23 -06:00
Xiang Xiao
650b58d6b2 nshlib: Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
3f9302561c nshlib: Enhance nsh to execute the shell script
and support the interactive shell too

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
d307758c3c nshlib: Rename 'sh' command to 'source' command
since this command change the parent environment variable and
add new '.' command which has the same functionality as 'source'

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
9ab5e2ff45 nshlib: Add login argument to nsh_session for controling the login process
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
9dbdc73df6 nshlib: Reset NSH_NP_SET_OPTIONS_INIT in nsh_initscript
to ensure the reset get executed in all console implementation

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00