Commit Graph

133 Commits

Author SHA1 Message Date
fangxinyong
2234c3a2e6 nshlib: support list numeric user and group IDs
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-09 15:06:09 +08:00
chenrun1
046fe00b96 nsh_fscmd.c:fix "implicit declaration" warning.
Fix error: implicit declaration of function 'nsh_foreach_direntry' [-Werror=implicit-function-declaration] on file nsh_fscmds on some compiler versions.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-07-16 16:39:11 +08:00
chenrun1
415168dde6 nshlib: Add fdinfo to get information about the process associated fd
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-07-16 16:39:11 +08:00
Junbo Zheng
9de5a2550e nshlib: add -h option for ls command
config: ./tools/configure.sh sim:nsh
CONFIG_LIBC_FLOATINGPOINT=y
```
nsh> ls -l /dev
/dev:
 crw-rw-rw-       0 console
 crw-rw-rw-       0 gpio0
 crw-rw-rw-       0 gpio1
 crw-rw-rw-       0 gpio2
 crw-rw-rw-       0 gpio3
 crw-rw-rw-       0 loop
 crw-rw-rw-       0 null
 crw-rw-rw-       0 oneshot
 brw-rw-rw- 1048576 ram0
 brw-rw-rw-    1024 ram1
 brw-rw-rw-  524288 ram2
 crw-rw-rw-       0 zero
nsh> ls /lh /dev
nsh: ls: too many arguments
nsh> ls -lh /dev
/dev:
 crw-rw-rw-       0 console
 crw-rw-rw-       0 gpio0
 crw-rw-rw-       0 gpio1
 crw-rw-rw-       0 gpio2
 crw-rw-rw-       0 gpio3
 crw-rw-rw-       0 loop
 crw-rw-rw-       0 null
 crw-rw-rw-       0 oneshot
 brw-rw-rw-    1.0M ram0
 brw-rw-rw-    1.0K ram1
 brw-rw-rw-  512.0K ram2
 crw-rw-rw-       0 zero
```

config: ./tools/configure.sh ../vendor/sim/boards/miwear/configs/miwear -j16
```
nsh> ls -l /resource/misc/media
/resource/misc/media:
 -rwxrwxr-x  384044 AlexaTimer.wav
 -rwxrwxr-x   57001 AlexaReminder.mp3
 -rwxrwxr-x  384132 AlexaAlarm.wav
 -rw-rw-r--   20733 Clank.mp3
 -rw-rw-r--   45183 NotificationXylophone.mp3
 -rw-rw-r--   27420 Robot.mp3
 -rw-rw-r--   21986 FadeIn.mp3
 -rw-rw-r--   42049 Flute.mp3
 -rw-rw-r--  362748 Latona-15s.mp3
 drwxrwxr-x    4096 .
 -rw-rw-r--   47198 alarm_volume_adjust.mp3
 -rw-rw-r--   95338 Expect.mp3
 drwxrwxr-x    4096 ..
 -rw-rw-r--  409435 Sunrise.mp3
 -rw-rw-r--   55841 Fresh.mp3
 -rw-rw-r--   36685 Bells-1s.mp3
 -rw-rw-r--    4432 camera_click.mp3
 -rw-rw-r--  469621 MiRemix.mp3
nsh>
nsh> ls -lh /resource/misc/media
/resource/misc/media:
 -rwxrwxr-x  375.0K AlexaTimer.wav
 -rwxrwxr-x   55.7K AlexaReminder.mp3
 -rwxrwxr-x  375.1K AlexaAlarm.wav
 -rw-rw-r--   20.2K Clank.mp3
 -rw-rw-r--   44.1K NotificationXylophone.mp3
 -rw-rw-r--   26.8K Robot.mp3
 -rw-rw-r--   21.5K FadeIn.mp3
 -rw-rw-r--   41.1K Flute.mp3
 -rw-rw-r--  354.2K Latona-15s.mp3
 drwxrwxr-x    4.0K .
 -rw-rw-r--   46.1K alarm_volume_adjust.mp3
 -rw-rw-r--   93.1K Expect.mp3
 drwxrwxr-x    4.0K ..
 -rw-rw-r--  399.8K Sunrise.mp3
 -rw-rw-r--   54.5K Fresh.mp3
 -rw-rw-r--   35.8K Bells-1s.mp3
 -rw-rw-r--    4.3K camera_click.mp3
 -rw-rw-r--  458.6K MiRemix.mp3
```

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2023-07-05 16:25:27 +08:00
chao an
ec63217b48 nshlib: disable nsh error print if NSH_DISABLE_ERROR_PRINT enabled
text	   data	    bss	    dec	    hex	filename
 398953	  27088	   4128	 430169	  69059	nuttx    /* before */
 389241	  27072	   4128	 420441	  66a59	nuttx    /* after  */
  -9712     -16

Signed-off-by: chao an <anchao@xiaomi.com>
2023-06-12 13:37:27 +08:00
chenrun1
cf54069487 nshlib/nsh_fscmds.c:Add whether or not to pass in empty arguments when rm -r
When rm -r is passed with no address specified, it will automatically recursively unlink all files under the root path ('/') until unlinking to the mounted folder causes the unlink to fail. In this change, rm -r without a specified path will prompt for missing arguments
2023-04-22 12:47:57 +08:00
Xiang Xiao
359f66ad37 nshlib: Remove the remaining CONFIG_FILE_STREAM dependence
continue the change from https://github.com/apache/nuttx-apps/pull/1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-24 17:38:19 +08:00
Oreh
f63a3cac0e Add NSH lomtd command (creates MTD loop device) 2023-02-19 19:55:52 +08:00
dongjiuzhu1
542558f2c1 nshlib/script: avoid output unnecessary log when missing rc.sysinit file
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-12-31 00:40:00 +08:00
Xiang Xiao
757552e759 Fix nsh_fscmds.c:92:19: error: unused function 'ls_specialdir' [-Werror,-Wunused-function]
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-31 06:28:17 +01:00
Junbo Zheng
79e770b0c6 apps/nshlib: add the missing FAR macro for all source files
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2022-09-22 14:22:13 +08:00
Fotis Panagiotopoulos
0cdb2cfa48 Fixed compiler warnings. 2022-08-23 01:39:59 +08:00
Jiuzhu Dong
45615a8d9d nshlib/dmesg: update config about enable dmesg
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-07-25 08:27:48 +02:00
Xiang Xiao
c252ec1481 Add printflike to all printf like functions
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-18 14:09:10 +03:00
YAMAMOTO Takashi
c7fcffd09a nshlib/nsh_fscmds.c: Make losetup command take optional sector size 2022-04-11 22:19:19 +08:00
ligd
d6a187efed nshlib: merge nsh_getdirpath() to nsh_fsutils.c
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 02:36:13 +08:00
anjiahao
7d10751037 nshlib/nsh_fscmds:use strchr instead of strstr
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-03-16 20:05:51 +08:00
anjiahao
eabba4ca20 cmd_mkdir:support mkdir opthon -p
use "mkdir -p /test/test" to ceate a dir

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-03-16 13:53:45 +08:00
Norman Rasmussen
374cb9230a Fix boarctl typos 2022-01-16 08:07:47 +01:00
Norman Rasmussen
41ce7d40f6 Fix incorrect argument count error message
The `too many arguments` and `missing required argument(s)` messages
should be switched in order for the correct message to be shown to the
user.
2021-12-31 20:54:05 +08:00
SPRESENSE
8e0892b2f2 nshlib: Fix write buffer position in nsh cp command
The iobuffer for write buffer position need to be update if write
API cannot write data at once.
2021-08-19 08:31:34 -07:00
liuhaitao
4b8e0fde62 nshlib: Add 'rm -r' recursive remove directory support
Change-Id: Iafecb0a25cc9d091a1aee8f381b217e67d6e3925
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2021-07-01 14:55:04 -07: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
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
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
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
Gregory Nutt
da31673ddf Run nxstyle against all modified .c and .h files 2020-03-22 08:23:28 -05:00
Gregory Nutt
1a9444a68b Remove support for CONFIG_FS_WRITABLE and CONFIG_FS_READABLE 2020-03-22 08:23:28 -05:00
Xiang Xiao
41d88f06e7 Run codespell -w with the latest dictonary again 2020-02-23 07:10:14 -06:00
Xiang Xiao
e0dcfa0c55 Remove extra whitespace from files (#43)
* Remove multiple newlines at the end of file
* Remove the white space from the end of line
2020-01-31 08:29:24 -06:00
Alin Jerpelea
5c936ce0e4 Various fixes (#6)
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .c and .h affected by this PR through nxstyle.

Author: Alin Jerpelea <alin.jerpelea@sony.com>

    * system/usbmsc: Fix accessing uninitialized pointer
    * fsutils/inifile: Fix a memory leak in inifile error case
    * fsutils/mksmartfs: Fix uninitialized return code
    * system/zmodem: Fix a compile error in zmodem debug enabled
    * nshlib/nsh_fscmds.c: Add syntax check to cp command

    If the destication of NutShell cp command is the same with the source,
    it may cause the file corruption. Add the syntax check of argument to
    avoid this problem.
2020-01-07 09:01:23 -06:00
Xiang Xiao
857158451b Unify the void cast usage
1.Remove void cast for function because many place ignore the returned value witout cast
2.Replace void cast for variable with UNUSED macro

Change-Id: Ie644129a563244a6397036789c4c3ea83c4e9b09
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-01-02 23:21:01 +08:00
Gregory Nutt
0bc798c7a9 apps/examples/mount: Replace illegal call to ramdisk_register() with a call to boardctl(BOARDIOC_MKRD). 2019-10-26 10:22:34 -06:00
Gregory Nutt
c8a066f699 apps/nshlib/nsh_fscmds.c: The NSH mkrd command was in violation of the NuttX portable POSIX interface. it was calling the internal OS function ramdisk_register() directly. No only is this a violation of the interface specification, but also prevents use of mkrd in PROTECTED or KERNEL buils.
With this commit, the NSH mkrd command now used the BOARDIOC_MKRD boardctl() command.  This command is availabe in all build modes.  The effect of this change is to move the hear of the NSH mkrd command into to OS and provide user-space access via boardctl().
2019-10-26 09:42:51 -06:00
Gregory Nutt
3457c30c33 apps/nshlib: Fix some typos and minor coding staqndard problems. 2019-09-12 15:38:53 -06:00
Gregory Nutt
8f5944c4a8 Squashed commit of the following:
include/ and netutils/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
    nshlib/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
    system/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
    testing/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
    examples/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
2019-04-29 14:53:38 -06:00
Gregory Nutt
9db029e318 The file system can no longer be disabled. Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS==0 2019-02-11 13:10:10 -06:00
GregoryN
3bf4b6d245 Merged altconsole into master 2018-12-08 18:53:54 -06:00
Gregory Nutt
4bbfdbb9fa nshlib/, examples/: Update to show newer file system object types returned by stat(). 2018-09-22 13:24:24 -06:00
Xiang Xiao
8116d10da3 apps/fsutils/mksmartfs: Add a check to see if the SmartFS is already formatted. apps/nshlib: Add a force flag (-f) to mksmartfs. SmartFS will be formatted only if (1) the FLASH does not already hold a SmartFS, or (2) the force flag is set 2018-08-23 07:14:30 -06:00
Boris Astardzhiev
2c2fc512d6 nshlib/nsh_fscmds.c: Add the -r option which can be used to specify the number of entries in the FAT12/FAT16 root directory. 2018-05-11 09:50:54 -06:00
Gregory Nutt
99512b90db apps/nshlib: truncate command will now use ftruncate (vs. truncate) if it had to create the file with creat(). 2018-01-10 07:26:21 -06:00
Gregory Nutt
7a2aac8876 apps/nshlib: Add support for a truncate command. This will be used to test the new ftruncate file system support. 2018-01-04 12:52:17 -06:00
Gregory Nutt
35ec1b9244 Squashed commit of the following:
apps/fsutils/mkfatfs:  New user-space fatfs appears to work fine.
    apps/fsutils/mkfatfs:  Move mkfatfs from the OS to here.  Not fully integrated on the intial commit.
2017-10-20 12:35:19 -06:00
Gregory Nutt
740b528199 apps/examples/stat: Add a simple test for stat(), fstat(), and statfs(). 2017-02-13 14:08:19 -06:00
Gregory Nutt
bf9ca8868e NSH: Both arguments of 'ln' command may be relative paths 2017-02-07 07:56:54 -06:00
Gregory Nutt
1a696b0367 Fix a memory leak in the 'ln' command when a failure occurs. 2017-02-06 10:20:29 -06:00
Gregory Nutt
7a0e08c37b NSH: Add readlink command. 2017-02-05 10:35:11 -06:00
Gregory Nutt
bb81a3d11d NSH ls command: if node is a symobolic link, use readlink() to get and the display the target of the symblic link. 2017-02-03 14:13:25 -06:00