完善ipc对象&完善nsfs&完善文件接口
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#define __SHELL_CFG_USER_H__
|
||||
|
||||
#include <u_sys.h>
|
||||
#include <malloc.h>
|
||||
#include <u_malloc.h>
|
||||
/**
|
||||
* @brief 获取系统时间(ms)
|
||||
* 定义此宏为获取系统Tick,如`HAL_GetTick()`
|
||||
@@ -24,13 +24,13 @@
|
||||
* @brief shell内存分配
|
||||
* shell本身不需要此接口,若使用shell伴生对象,需要进行定义
|
||||
*/
|
||||
#define SHELL_MALLOC(size) malloc(size)
|
||||
#define SHELL_MALLOC(size) u_malloc(size)
|
||||
|
||||
/**
|
||||
* @brief shell内存释放
|
||||
* shell本身不需要此接口,若使用shell伴生对象,需要进行定义
|
||||
*/
|
||||
#define SHELL_FREE(obj) free(obj)
|
||||
#define SHELL_FREE(obj) u_free(obj)
|
||||
/**
|
||||
* @brief 使用函数签名
|
||||
* 使能后,可以在声明命令时,指定函数的签名,shell 会根据函数签名进行参数转换,
|
||||
@@ -43,5 +43,5 @@
|
||||
* 使能后,可以在命令中使用数组参数,如`cmd [1,2,3]`
|
||||
* 需要使能 `SHELL_USING_FUNC_SIGNATURE` 宏,并且配置 `SHELL_MALLOC`, `SHELL_FREE`
|
||||
*/
|
||||
#define SHELL_SUPPORT_ARRAY_PARAM 1
|
||||
#define SHELL_SUPPORT_ARRAY_PARAM 0
|
||||
#endif
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#include "shell.h"
|
||||
#include "cons_cli.h"
|
||||
#include "pm_cli.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include "shell.h"
|
||||
#include "u_malloc.h"
|
||||
#include "u_sys.h"
|
||||
#include "unistd.h"
|
||||
#include "u_malloc.h"
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
int ls(int argc, char *agrv[])
|
||||
{
|
||||
DIR *dir;
|
||||
@@ -25,7 +25,7 @@ int ls(int argc, char *agrv[])
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
in_path = ".";
|
||||
in_path = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -90,6 +90,16 @@ int cd(int argc, char *agrv[])
|
||||
return ret;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), cd, cd, cd command);
|
||||
int pwd(int argc, char *agrv[])
|
||||
{
|
||||
char *pwd;
|
||||
char path[64];
|
||||
|
||||
pwd = getcwd(path, sizeof(path));
|
||||
printf("%s\n", pwd);
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), pwd, pwd, pwd command);
|
||||
int cat(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
@@ -154,7 +164,7 @@ int kill(int argc, char *argv[])
|
||||
}
|
||||
int pid = atoi(argv[1]);
|
||||
|
||||
return pm_kill_task(pid, PM_KILL_TASK_ALL);
|
||||
return pm_kill_task(pid, PM_KILL_TASK_ALL, 0);
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), kill, kill, kill command);
|
||||
|
||||
@@ -168,7 +178,37 @@ int shell_symlink(int argc, char *argv[])
|
||||
return symlink(argv[1], argv[2]);
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), symlink, shell_symlink, symlink command);
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
int shell_touch(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int fd;
|
||||
|
||||
fd = open(argv[1], O_CREAT, 0777);
|
||||
if (fd < 0)
|
||||
{
|
||||
return fd;
|
||||
}
|
||||
close(fd);
|
||||
return fd;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), touch, shell_touch, touch command);
|
||||
int shell_mkdir(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int ret;
|
||||
|
||||
ret = mkdir(argv[1], 0777);
|
||||
return ret;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), mkdir, shell_mkdir, mkdir command);
|
||||
int shell_reboot(int argc, char *argv[])
|
||||
{
|
||||
printf("sys reboot.\n");
|
||||
|
||||
@@ -12,15 +12,18 @@
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#ifdef CONFIG_USING_SIG
|
||||
|
||||
static int sig_cn;
|
||||
static int shell_sig_call_back(pid_t pid, umword_t sig_val)
|
||||
{
|
||||
/*TODO:这个消息是init发送的,这里不能给init发送消息,否导致卡死*/
|
||||
// cons_write_str("test");
|
||||
/*TODO:这个消息是init发送的,这里不能给init发送消息,否导致卡死除非init增加多进程支持*/
|
||||
cons_write_str("test sig.\n");
|
||||
sig_cn++;
|
||||
return 0;
|
||||
}
|
||||
int shell_test_sig(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
return -1;
|
||||
@@ -28,7 +31,10 @@ int shell_test_sig(int argc, char *argv[])
|
||||
pm_sig_func_set(shell_sig_call_back);
|
||||
pid_t pid = atoi(argv[1]);
|
||||
|
||||
return pm_sig_watch(pid, 0 /*TODO:现在只有kill */);
|
||||
ret = pm_sig_watch(pid, 0 /*TODO:现在只有kill */);
|
||||
|
||||
printf("sig_cn:%d\n", sig_cn);
|
||||
return ret;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), test_sig, shell_test_sig, shell_test_sig command);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user