Sometimes users may want to calculate the MD5 of part of a file(e.g. check
partition contents for debug after flashing, size of which may be greater
than image). This can be done with the "dd" command and pipes, the "md5"
command just needs to support reading from standard input. For example:
`dd if=/dev/virtblk0 bs=512 count=1 | md5`.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Commit 5330966 replaced local static buffer with malloc allocated
lib_get_pathbuffer. This however prevents the usage of sizeof(buffer)
in the follow up read function, therefore the read size has to be
specified as PATH_MAX - 1.
This fixes the functionality of pidof function call (and subsequently
pkill call that uses pidof).
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
fix crash if:
CONFIG_SCHED_WAITPID=n
CONFIG_SCHED_CHILD_STATUS=y
The old signal will be restored only when sigaction is saved to avoid invaild access.
Signed-off-by: chao an <anchao.archer@bytedance.com>
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
Coverity Log
CID 1612757: (#1 of 1): UNUSED_VALUE
assigned_value: The value -1 is assigned to param.fd_in here, but the stored value is overwritten before it can be used.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Coverity Log
CID 1612743: (#1 of 1): Resource leak (RESOURCE_LEAK)
12. leaked_handle: The handle variable fd_out goes out of scope and leaks the handle.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This PR will still allow basic shell operations such as cd/ls/pwd to be used even when the environment is disabled.
Signed-off-by: chao an <anchao@lixiang.com>
stdio.h remove <nuttx/xxxx.h> Some .c previously depended on
<nuttx/xxx.h> and needed to be added to .c instead of stdio.h
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
1. Input redirect flags currently is hardcode, passing by arguments maybe better.
2. Only support redirect to path_name, redirect to fd is needed for pipeline.
Test
1. Redirect in
cat < /etc/init.d/rc.sysinit
2. Redirect with FIFO
mkfifo /dev/testfifo
cat /dev/testfifo &
ls > /dev/testfifo
3. NSH Params
set name `uname`
echo $name
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Without this patch
nsh> ls /etc/group | dd | dd
sh [13:100]
sh [14:100]
nsh: dd: read failed: 4
nsh>
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
There is no corresponding sched_lock() for this and therefore this causes
random crashes.
Found when running a long init script which utilizes shell variables in
SMP mode.
CC: mm_heap/mm_memalign.c misc/rwbuffer.c: In function 'rwb_readbytes':
misc/rwbuffer.c:1172:2: warning: #warning Not Implemented [-Wcpp]
1172 | #warning Not Implemented
| ^~~~~~~
CC: binfmt_unloadmodule.c In file included from nsh_console.c:40:
nsh_console.c: In function 'nsh_consoleredirect':
nsh_console.h:85:30: error: 'struct serialsave_s' has no member named 'cn_confd'; did you mean 'cn_infd'?
85 | # define INFD(p) ((p)->cn_confd)
| ^~~~~~~~
nsh_console.c:344:7: note: in expansion of macro 'INFD'
344 | INFD(ssave) = INFD(pstate);
| ^~~~
nsh_console.c: In function 'nsh_consoleundirect':
nsh_console.h:85:30: error: 'struct serialsave_s' has no member named 'cn_confd'; did you mean 'cn_infd'?
85 | # define INFD(p) ((p)->cn_confd)
| ^~~~~~~~
nsh_console.c:370:18: note: in expansion of macro 'INFD'
370 | INFD(pstate) = INFD(ssave);
| ^~~~
Signed-off-by: ligd <liguiding1@xiaomi.com>
pthread & detach will still quit when parent task exit,
cause nsh_parse clone args leak. nsh should use task instead of thread
this case can reproduce the memory leak.
int main(int argc, FAR char *argv[])
{
printf("Hello, World!!\n");
system("sleep 1 &");
return 0;
}
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Obtaining the heap usage size requires traversing all memory.
When the number of threads is large, it will become very slow.
ps -heap
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK HEAP STACK USED FILLED COMMAND
0 0 0 FIFO Kthread - Ready 0000000000000000 4338432 2162672 0005196 0.2% Idle_Task
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
arm-none-eabi/bin/ld: apps/libapps.a(nsh_proccmds.c.obj): in function `cmd_pkill':
apps/nshlib/nsh_proccmds.c:861:(.text.cmd_pkill+0x38): undefined reference to `nsh_getpid'
Signed-off-by: chao an <anchao@lixiang.com>