summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHanhui <sylixos@gmail.com>2019-06-19 09:03:02 (GMT)
committer Hanhui <sylixos@gmail.com>2019-06-19 09:03:02 (GMT)
commit093720f12a0604b713cd6a071019c2ed12aa93b4 (patch)
treecb0a1bf5f2e7fad1f4ffe844945c4cf561940a65
parent41b399fa2e7b23a8f03a11b30555bfb99ee9ba52 (diff)
downloadAIC-OS-093720f12a0604b713cd6a071019c2ed12aa93b4.zip
Updated pipe to support EdgerOS.
-rw-r--r--SylixOS/README7
-rw-r--r--SylixOS/kernel/include/k_kernel.h14
-rw-r--r--SylixOS/net/lwip/tools/npf/lwip_npf.c48
-rw-r--r--SylixOS/shell/fsLib/ttinyShellFsCmd.c14
-rw-r--r--SylixOS/system/device/pipe/pipeLib.c2
-rw-r--r--SylixOS/system/device/spipe/spipe.h2
-rw-r--r--SylixOS/system/device/spipe/spipeLib.c51
-rw-r--r--SylixOS/system/include/s_option.h1
8 files changed, 98 insertions, 41 deletions
diff --git a/SylixOS/README b/SylixOS/README
index bcf3cfe..1c10995 100644
--- a/SylixOS/README
+++ b/SylixOS/README
@@ -123,7 +123,12 @@ kernel MUST NOT compiler with VFP instructions!
18:49 2018-01-18
SylixOS 开始支持全功能核心网路由技术, 升级项目代号: Octopus(八爪鱼).
-
+
+----------------------------------------------------------------------------------------------------------------------
+18:49 2019-06-19
+
+ SylixOS 开始面向万物互联时代, 为 EdgerOS 提供完善支撑, 升级项目代号: Tangram(七巧板).
+
----------------------------------------------------------------------------------------------------------------------
23:58 2009-5-12
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index 7582a18..d48364b 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -31,6 +31,7 @@
2015.11.20 修改项目代号为: NeZha(哪吒).
2016.10.08 修改项目代号为: LongYuan(龙渊).
2018.01.18 修改项目代号为: Octopus(八爪鱼).
+2019.06.19 修改项目代号为: Tangram(七巧板).
*********************************************************************************************************/
#ifndef __K_KERNEL_H
@@ -49,8 +50,8 @@
*********************************************************************************************************/
#define __SYLIXOS_MAJOR_VER 1
-#define __SYLIXOS_MINOR_VER 9
-#define __SYLIXOS_PATCH_VER 10
+#define __SYLIXOS_MINOR_VER 10
+#define __SYLIXOS_PATCH_VER 0
#define __SYLIXOS_PATCH_PAD 0
/*********************************************************************************************************
@@ -80,10 +81,11 @@
__SYLIXOS_PATCH_VER, \
__SYLIXOS_PATCH_PAD)
-#define __SYLIXOS_VERINFO "AIC-OS kernel version: " \
- __SYLIXOS_VERSTR \
- " Code name: " __SYLIXOS_RELSTR
-#define __SYLIXOS_LICENSE "SylixOS license: Commercial & GPL."
+#define __SYLIXOS_RELSTR "Tangram"
+#define __SYLIXOS_VERINFO "SylixOS kernel version: " \
+ __SYLIXOS_VERSTR \
+ " Code name: " __SYLIXOS_RELSTR
+#define __SYLIXOS_LICENSE "SylixOS license: Commercial & GPL."
/*********************************************************************************************************
版本匹配弱符号 (__sylixos_version 版本信息将保留在使用此版本头文件编译的库中)
diff --git a/SylixOS/net/lwip/tools/npf/lwip_npf.c b/SylixOS/net/lwip/tools/npf/lwip_npf.c
index 3278988..ede62b3 100644
--- a/SylixOS/net/lwip/tools/npf/lwip_npf.c
+++ b/SylixOS/net/lwip/tools/npf/lwip_npf.c
@@ -356,12 +356,18 @@ static BOOL __npfIpRuleCheck (__PNPF_NETIF_CB pnpfni, BOOL bIn, struct ip_hdr
while (plineTemp) {
pnpfri = _LIST_ENTRY(plineTemp, __NPF_RULE_IP, NPFRI_lineManage);
- if ((ipaddrHbo.addr >= pnpfri->NPFRI_ipaddrHboS.addr) &&
- (ipaddrHbo.addr <= pnpfri->NPFRI_ipaddrHboE.addr)) {
- if (pnpfri->NPFRI_bAllow) {
+ if (pnpfri->NPFRI_bAllow) {
+ if ((ipaddrHbo.addr >= pnpfri->NPFRI_ipaddrHboS.addr) &&
+ (ipaddrHbo.addr <= pnpfri->NPFRI_ipaddrHboE.addr)) {
return (LW_TRUE); /* 白名单, 立即放行 */
}
bAllow = LW_FALSE; /* 禁止通过 */
+
+ } else {
+ if ((ipaddrHbo.addr >= pnpfri->NPFRI_ipaddrHboS.addr) &&
+ (ipaddrHbo.addr <= pnpfri->NPFRI_ipaddrHboE.addr)) {
+ bAllow = LW_FALSE; /* 禁止通过 */
+ }
}
plineTemp = _list_line_get_next(plineTemp);
}
@@ -401,14 +407,22 @@ static BOOL __npfUdpRuleCheck (__PNPF_NETIF_CB pnpfni, BOOL bIn,
while (plineTemp) {
pnpfru = _LIST_ENTRY(plineTemp, __NPF_RULE_UDP, NPFRU_lineManage);
- if ((ipaddrHbo.addr >= pnpfru->NPFRU_ipaddrHboS.addr) &&
- (ipaddrHbo.addr <= pnpfru->NPFRU_ipaddrHboE.addr) &&
- (usPortHbo >= pnpfru->NPFRU_usPortHboS) &&
- (usPortHbo <= pnpfru->NPFRU_usPortHboE)) {
- if (pnpfru->NPFRU_bAllow) {
+ if (pnpfru->NPFRU_bAllow) {
+ if ((ipaddrHbo.addr >= pnpfru->NPFRU_ipaddrHboS.addr) &&
+ (ipaddrHbo.addr <= pnpfru->NPFRU_ipaddrHboE.addr) &&
+ (usPortHbo >= pnpfru->NPFRU_usPortHboS) &&
+ (usPortHbo <= pnpfru->NPFRU_usPortHboE)) {
return (LW_TRUE); /* 白名单, 立即放行 */
}
bAllow = LW_FALSE; /* 禁止通过 */
+
+ } else {
+ if ((ipaddrHbo.addr >= pnpfru->NPFRU_ipaddrHboS.addr) &&
+ (ipaddrHbo.addr <= pnpfru->NPFRU_ipaddrHboE.addr) &&
+ (usPortHbo >= pnpfru->NPFRU_usPortHboS) &&
+ (usPortHbo <= pnpfru->NPFRU_usPortHboE)) {
+ bAllow = LW_FALSE; /* 禁止通过 */
+ }
}
plineTemp = _list_line_get_next(plineTemp);
}
@@ -447,14 +461,22 @@ static BOOL __npfTcpRuleCheck (__PNPF_NETIF_CB pnpfni, BOOL bIn,
while (plineTemp) {
pnpfrt = _LIST_ENTRY(plineTemp, __NPF_RULE_TCP, NPFRT_lineManage);
- if ((ipaddrHbo.addr >= pnpfrt->NPFRT_ipaddrHboS.addr) &&
- (ipaddrHbo.addr <= pnpfrt->NPFRT_ipaddrHboE.addr) &&
- (usPortHbo >= pnpfrt->NPFRT_usPortHboS) &&
- (usPortHbo <= pnpfrt->NPFRT_usPortHboE)) {
- if (pnpfrt->NPFRT_bAllow) {
+ if (pnpfrt->NPFRT_bAllow) {
+ if ((ipaddrHbo.addr >= pnpfrt->NPFRT_ipaddrHboS.addr) &&
+ (ipaddrHbo.addr <= pnpfrt->NPFRT_ipaddrHboE.addr) &&
+ (usPortHbo >= pnpfrt->NPFRT_usPortHboS) &&
+ (usPortHbo <= pnpfrt->NPFRT_usPortHboE)) {
return (LW_TRUE); /* 白名单, 立即放行 */
}
bAllow = LW_FALSE; /* 禁止通过 */
+
+ } else {
+ if ((ipaddrHbo.addr >= pnpfrt->NPFRT_ipaddrHboS.addr) &&
+ (ipaddrHbo.addr <= pnpfrt->NPFRT_ipaddrHboE.addr) &&
+ (usPortHbo >= pnpfrt->NPFRT_usPortHboS) &&
+ (usPortHbo <= pnpfrt->NPFRT_usPortHboE)) {
+ bAllow = LW_FALSE; /* 禁止通过 */
+ }
}
plineTemp = _list_line_get_next(plineTemp);
}
diff --git a/SylixOS/shell/fsLib/ttinyShellFsCmd.c b/SylixOS/shell/fsLib/ttinyShellFsCmd.c
index 9987f76..f29a65a 100644
--- a/SylixOS/shell/fsLib/ttinyShellFsCmd.c
+++ b/SylixOS/shell/fsLib/ttinyShellFsCmd.c
@@ -343,9 +343,10 @@ static INT __tshellFsCmdRm (INT iArgC, PCHAR ppcArgV[])
*********************************************************************************************************/
static INT __tshellFsCmdMv (INT iArgC, PCHAR ppcArgV[])
{
- REGISTER INT iError = PX_ERROR;
- REGISTER INT iFd;
- CHAR cTemp[16];
+ REGISTER INT iError = PX_ERROR;
+ REGISTER INT iFd;
+ CHAR cTemp[16];
+ struct stat statGet;
if (iArgC != 3) {
fprintf(stderr, "arguments error!\n");
@@ -368,6 +369,13 @@ __re_select:
goto __error_handle;
} else if ((cTemp[0] == 'Y') ||
(cTemp[0] == 'y')) { /* 覆盖 */
+ if (stat(ppcArgV[2], &statGet)) {
+ goto __error_handle;
+ }
+ if (S_ISDIR(statGet.st_mode)) { /* 不允许覆盖目录 */
+ fprintf(stderr, "Error: %s is an existing directory!\n", ppcArgV[2]);
+ goto __error_handle;
+ }
if (unlink(ppcArgV[2]) != ERROR_NONE) {
goto __error_handle;
}
diff --git a/SylixOS/system/device/pipe/pipeLib.c b/SylixOS/system/device/pipe/pipeLib.c
index 5edf25c..9f0f7c7 100644
--- a/SylixOS/system/device/pipe/pipeLib.c
+++ b/SylixOS/system/device/pipe/pipeLib.c
@@ -64,7 +64,7 @@ LONG _PipeOpen (PLW_PIPE_DEV p_pipedev,
return (PX_ERROR);
} else {
- if (iFlags & O_CREAT) {
+ if ((iFlags & O_CREAT) && (iFlags & O_EXCL)) {
_ErrorHandle(ERROR_IO_FILE_EXIST); /* 不能重复创建 */
return (PX_ERROR);
}
diff --git a/SylixOS/system/device/spipe/spipe.h b/SylixOS/system/device/spipe/spipe.h
index 92ccb1c..c69e353 100644
--- a/SylixOS/system/device/spipe/spipe.h
+++ b/SylixOS/system/device/spipe/spipe.h
@@ -76,9 +76,9 @@ typedef LW_SPIPE_DEV *PLW_SPIPE_DEV;
typedef struct {
PLW_SPIPE_DEV SPIPEFIL_pspipedev;
-
INT SPIPEFIL_iFlags; /* 建立属性 */
INT SPIPEFIL_iMode; /* 操作方式 */
+ INT SPIPEFIL_iExtMode;
} LW_SPIPE_FILE;
typedef LW_SPIPE_FILE *PLW_SPIPE_FILE;
diff --git a/SylixOS/system/device/spipe/spipeLib.c b/SylixOS/system/device/spipe/spipeLib.c
index 4d4cb10..a7372af 100644
--- a/SylixOS/system/device/spipe/spipeLib.c
+++ b/SylixOS/system/device/spipe/spipeLib.c
@@ -49,6 +49,10 @@
#include "../SylixOS/system/include/s_system.h"
#include "limits.h"
/*********************************************************************************************************
+ EXT MODE
+*********************************************************************************************************/
+#define LW_SPIPE_EXT_MODE_NOSIG 0x1
+/*********************************************************************************************************
共享锁操作
*********************************************************************************************************/
#define LW_SPIPE_LOCK(pspipedev, code) \
@@ -177,7 +181,7 @@ LONG _SpipeOpen (PLW_SPIPE_DEV pspipedev,
return (PX_ERROR);
} else {
- if (iFlags & O_CREAT) {
+ if ((iFlags & O_CREAT) && (iFlags & O_EXCL)) {
_ErrorHandle(ERROR_IO_FILE_EXIST); /* 不能重复创建 */
return (PX_ERROR);
}
@@ -208,6 +212,7 @@ LONG _SpipeOpen (PLW_SPIPE_DEV pspipedev,
pspipefil->SPIPEFIL_iFlags = iFlags;
pspipefil->SPIPEFIL_iMode = iMode;
+ pspipefil->SPIPEFIL_iExtMode = 0;
pspipefil->SPIPEFIL_pspipedev = pspipedev;
if (!(iFlags & O_PEEKONLY)) {
@@ -364,14 +369,14 @@ ssize_t _SpipeRead (PLW_SPIPE_FILE pspipefil,
PLW_SPIPE_DEV pspipedev = pspipefil->SPIPEFIL_pspipedev;
- if (!pcBuffer) {
- _ErrorHandle(EINVAL);
- return (PX_ERROR);
- }
+ if (!pcBuffer) {
+ _ErrorHandle(EINVAL);
+ return (PX_ERROR);
+ }
- if (!stMaxBytes) {
- return (0);
- }
+ if (!stMaxBytes) {
+ return (0);
+ }
if (LW_CPU_GET_CUR_NESTING()) { /* 是否在中断中调用 */
_DebugHandle(__ERRORMESSAGE_LEVEL, "called from ISR.\r\n");
@@ -383,7 +388,9 @@ ssize_t _SpipeRead (PLW_SPIPE_FILE pspipefil,
if (pspipedev->SPIPEDEV_uiWriteCnt == 0) { /* 没有写端且没有数据 */
if (pspipedev->SPIPEDEV_ringbufferBuffer.RINGBUFFER_stMsgBytes == 0) {
- return (0);
+ if (!(pspipefil->SPIPEFIL_iExtMode & LW_SPIPE_EXT_MODE_NOSIG)) {
+ return (0);
+ }
}
}
@@ -534,13 +541,14 @@ __continue_write:
if (pspipedev->SPIPEDEV_uiReadCnt == 0) { /* 没有读端 */
#if LW_CFG_SIGNAL_EN > 0
- sigevent_t sigeventPipe;
-
- sigeventPipe.sigev_signo = SIGPIPE;
- sigeventPipe.sigev_value.sival_ptr = LW_NULL;
- sigeventPipe.sigev_notify = SIGEV_SIGNAL;
-
- _doSigEvent(API_ThreadIdSelf(), &sigeventPipe, SI_MESGQ); /* 产生 SIGPIPE 信号 */
+ if (!(pspipefil->SPIPEFIL_iExtMode & LW_SPIPE_EXT_MODE_NOSIG)) {
+ sigevent_t sigeventPipe;
+
+ sigeventPipe.sigev_signo = SIGPIPE;
+ sigeventPipe.sigev_value.sival_ptr = LW_NULL;
+ sigeventPipe.sigev_notify = SIGEV_SIGNAL;
+ _doSigEvent(API_ThreadIdSelf(), &sigeventPipe, SI_MESGQ); /* 产生 SIGPIPE 信号 */
+ }
#endif /* LW_CFG_SIGNAL_EN > 0 */
_ErrorHandle(EPIPE);
return (PX_ERROR);
@@ -549,6 +557,7 @@ __continue_write:
if (pspipefil->SPIPEFIL_iFlags & O_NONBLOCK) { /* 非阻塞 IO */
ulTimeout = LW_OPTION_NOT_WAIT;
bNonblock = LW_TRUE;
+
} else {
ulTimeout = pspipedev->SPIPEDEV_ulWTimeout;
bNonblock = LW_FALSE;
@@ -849,6 +858,16 @@ INT _SpipeIoctl (PLW_SPIPE_FILE pspipefil,
LW_SPIPE_UNLOCK(pspipedev);
break;
+ case FIOPIPENOSIG: /* 不需要信号 */
+ LW_SPIPE_LOCK(pspipedev, return (PX_ERROR));
+ if ((INT)piArgPtr) {
+ pspipefil->SPIPEFIL_iExtMode |= LW_SPIPE_EXT_MODE_NOSIG;
+ } else {
+ pspipefil->SPIPEFIL_iExtMode &= ~LW_SPIPE_EXT_MODE_NOSIG;
+ }
+ LW_SPIPE_UNLOCK(pspipedev);
+ break;
+
default:
iErrCode = PX_ERROR;
_ErrorHandle(ERROR_IO_UNKNOWN_REQUEST);
diff --git a/SylixOS/system/include/s_option.h b/SylixOS/system/include/s_option.h
index fc9d68b..0b4b0a8 100644
--- a/SylixOS/system/include/s_option.h
+++ b/SylixOS/system/include/s_option.h
@@ -98,6 +98,7 @@
#ifdef __SYLIXOS_KERNEL /* ONLY pipe() can use this! */
#define FIOPIPEBLOCK LW_OSIO( 'f', 15) /* block until events happen */
#define FIOPIPERDONLY LW_OSIO( 'f', 18) /* make pipe rdwr fd to rdonly */
+#define FIOPIPENOSIG LW_OSIOD('f', 40, INT) /* no write broken pipe raise signal */
#endif
#define FIOGETOPTIONS LW_OSIOR('f', 19, INT) /* get options */