Pack parameters of nsh_execute() as struct nsh_exec_param_s

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>
This commit is contained in:
wangjianyu3
2024-10-14 23:27:14 +08:00
committed by Xiang Xiao
parent 27b5021e0d
commit 3da204c23e
8 changed files with 183 additions and 135 deletions

View File

@@ -65,6 +65,25 @@
# define SCHED_NSH SCHED_FIFO
#endif
struct nsh_param_s
{
/* Redirect input/output through `fd` OR `path_name`
*
* Select one:
* 1. Using fd_in/fd_out as oldfd for dup2() if greater than -1.
* 2. Using file_in/file_out as full path to the file if it is
* not NULL, and oflags_in/oflags_out as flags for open().
*/
int fd_in;
int fd_out;
int oflags_in;
int oflags_out;
FAR const char *file_in;
FAR const char *file_out;
};
/****************************************************************************
* Public Data
****************************************************************************/