同步官方几处修改

    站点访问 | http://weharmonyos.com (国内)
            | https://weharmony.github.io (国外)
    论坛 | http://bbs.weharmonyos.com
    文档中心 | http://open.weharmonyos.com
    参考手册 | http://doxygen.weharmonyos.com
上级 3694d537
......@@ -80,6 +80,7 @@
## 四大码仓发布 | 源码同步官方
内核注解同时在 [gitee](https://gitee.com/weharmony/kernel_liteos_a_note) | [github](https://github.com/kuangyufei/kernel_liteos_a_note) | [coding](https://weharmony.coding.net/public/harmony/kernel_liteos_a_note/git/files) | [gitcode](https://gitcode.net/kuangyufei/kernel_liteos_a_note) 发布,并与官方源码按月保持同步,同步历史如下:
* `2024/04/13` -- 官方几处小修正
* `2024/03/04` -- 官方修改很小
* `2023/11/24` -- 几处小的修改
* `2023/10/11` -- 近五个月官方很少更新
......@@ -177,11 +178,11 @@
## 特此感谢
特此感谢过程中(**统计至 2024/3/04**)无私赞助的 **24** 位热心朋友,有企事业单位职工,有在校学生,有行业内资深大佬,也有非专业的纯粹爱好者,在此一并谢过,作者将带着这份温暖继续前行。 [ >> 进入详细了解](./zzz/donate.md)
特此感谢过程中(**统计至 2024/4/13**)无私赞助的 **25** 位热心朋友,有企事业单位职工,有在校学生,有行业内资深大佬,也有非专业的纯粹爱好者,在此一并谢过,作者将带着这份温暖继续前行。 [ >> 进入详细了解](./zzz/donate.md)
|历史捐赠|最新捐赠|
|:-:|:-:|
|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/pay.gif)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/24.png)|
|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/pay.gif)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/25.png)|
## 链接
......
......@@ -8667,7 +8667,7 @@ diff -Nupr old/fs/jffs2/writev.c new/fs/jffs2/writev.c
diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
--- old/fs/jffs2/xattr.c 2022-05-09 17:15:24.360000000 +0800
+++ new/fs/jffs2/xattr.c 1970-01-01 08:00:00.000000000 +0800
@@ -1,1347 +0,0 @@
@@ -1,1352 +0,0 @@
-/*
- * JFFS2 -- Journalling Flash File System, Version 2.
- *
......@@ -9442,10 +9442,10 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
-}
-
-#define XREF_TMPHASH_SIZE (128)
-void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c)
-int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c)
-{
- struct jffs2_xattr_ref *ref, *_ref;
- struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE];
- struct jffs2_xattr_ref **xref_tmphash;
- struct jffs2_xattr_datum *xd, *_xd;
- struct jffs2_inode_cache *ic;
- struct jffs2_raw_node_ref *raw;
......@@ -9454,9 +9454,12 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
-
- BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING));
-
- xref_tmphash = kcalloc(XREF_TMPHASH_SIZE,
- sizeof(struct jffs2_xattr_ref *), GFP_KERNEL);
- if (!xref_tmphash)
- return -ENOMEM;
-
- /* Phase.1 : Merge same xref */
- for (i=0; i < XREF_TMPHASH_SIZE; i++)
- xref_tmphash[i] = NULL;
- for (ref=c->xref_temp; ref; ref=_ref) {
- struct jffs2_xattr_ref *tmp;
-
......@@ -9554,6 +9557,8 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
- "%u of xref (%u dead, %u orphan) found.\n",
- xdatum_count, xdatum_unchecked_count, xdatum_orphan_count,
- xref_count, xref_dead_count, xref_orphan_count);
- kfree(xref_tmphash);
- return 0;
-}
-
-struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
......
......@@ -103,7 +103,7 @@ STATIC VOID SortQueueIndexArray(UINT32 *indexArray, UINT32 count)
IpcSortParam queueSortParam;
queueSortParam.buf = (CHAR *)g_queueDebugArray;
queueSortParam.ipcDebugCBSize = sizeof(QueueDebugCB);
queueSortParam.ipcDebugCBCnt = LOSCFG_BASE_IPC_SEM_LIMIT;
queueSortParam.ipcDebugCBCnt = LOSCFG_BASE_IPC_QUEUE_LIMIT;
queueSortParam.sortElemOff = LOS_OFF_SET_OF(QueueDebugCB, lastAccessTime);
if (count > 0) {
......
......@@ -44,7 +44,7 @@ http://open.weharmonyos.com/zh-cn/device-dev/kernel/kernel-small-plimits.html
//容器限额统一接口
typedef struct PlimiteOperations {
VOID (*LimiterInit)(UINTPTR);//初始化
VOID (*LimiterAlloc)(VOID);//分配
VOID *(*LimiterAlloc)(VOID);
VOID (*LimiterFree)(UINTPTR);
VOID (*LimiterCopy)(UINTPTR, UINTPTR);
BOOL (*LimiterAddProcessCheck)(UINTPTR, UINTPTR);
......
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sys/resource.h"
#include "sys/wait.h"
#include "pthread.h"
#include "sched.h"
#include "It_container_test.h"
const int MAX_PID_RANGE = 100000;
const int SLEEP_TIME_US = 1000;
const int LOOP_NUM = 100;
static int ChildFunc(void *arg)
{
usleep(SLEEP_TIME_US);
exit(EXIT_CODE_ERRNO_5);
}
static int GroupProcess(void *arg)
{
(void)arg;
int ret;
int status = 0;
for (int i = 0; i < LOOP_NUM; i++) {
int argTmp = CHILD_FUNC_ARG;
auto pid = CloneWrapper(ChildFunc, CLONE_NEWNET, &argTmp);
if (pid == -1) {
return EXIT_CODE_ERRNO_1;
}
ret = waitpid(pid, &status, 0);
status = WEXITSTATUS(status);
if (status != EXIT_CODE_ERRNO_5) {
return EXIT_CODE_ERRNO_2;
}
}
exit(EXIT_CODE_ERRNO_5);
}
void ItNetContainer010(void)
{
int ret;
int status = 0;
int arg = CHILD_FUNC_ARG;
auto pid = CloneWrapper(GroupProcess, CLONE_NEWNET, &arg);
ASSERT_NE(pid, -1);
ret = waitpid(pid, &status, 0);
ASSERT_EQ(ret, pid);
status = WEXITSTATUS(status);
ASSERT_EQ(status, EXIT_CODE_ERRNO_5);
}
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/test.gni")
import("//kernel/liteos_a/testsuites/unittest/config.gni")
import("./config.gni")
config("libc_config") {
if (LOSCFG_USER_TEST_POSIX_MQUEUE == true ||
LOSCFG_USER_TEST_POSIX_PTHREAD == true) {
cflags = [ "-O1" ]
cflags_cc = cflags
}
}
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
unittest("liteos_a_libc_unittest_door") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/kernel"
include_dirs = common_include_dirs
sources = sources_entry
sources += sources_smoke
sources_full = []
sources += sources_full
configs = [ "..:public_config_for_door" ]
configs += [ ":libc_config" ]
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
}
}
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
unittest("liteos_a_libc_unittest") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/kernel"
include_dirs = common_include_dirs
sources = sources_entry
sources += sources_smoke
sources += sources_full
configs = [ "..:public_config_for_all" ]
configs += [ ":libc_config" ]
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
}
}
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/test.gni")
import("//kernel/liteos_a/testsuites/unittest/config.gni")
common_include_dirs = [
"//third_party/googletest/googletest/include",
"../common/include",
]
sources_entry = [ "../common/osTest.cpp" ]
sources_smoke = []
sources_full = []
# io module
if (LOSCFG_USER_TEST_IO == true) {
import("./io/config.gni")
common_include_dirs += io_include_dirs
sources_entry += io_sources_entry
sources_smoke += io_sources_smoke
sources_full += io_sources_full
}
# misc module
if (LOSCFG_USER_TEST_MISC == true) {
import("./misc/config.gni")
common_include_dirs += misc_include_dirs
sources_entry += misc_sources_entry
sources_smoke += misc_sources_smoke
sources_full += misc_sources_full
}
# posix mem module
if (LOSCFG_USER_TEST_POSIX_MEM == true) {
import("./posix/mem/config.gni")
common_include_dirs += posix_mem_include_dirs
sources_entry += posix_mem_sources_entry
sources_smoke += posix_mem_sources_smoke
sources_full += posix_mem_sources_full
}
# posix mqueue module
if (LOSCFG_USER_TEST_POSIX_MQUEUE == true) {
import("./posix/mqueue/config.gni")
common_include_dirs += posix_mqueue_include_dirs
sources_entry += posix_mqueue_sources_entry
sources_smoke += posix_mqueue_sources_smoke
sources_full += posix_mqueue_sources_full
}
# posix pthread module
if (LOSCFG_USER_TEST_POSIX_PTHREAD == true) {
import("./posix/pthread/config.gni")
common_include_dirs += posix_pthread_include_dirs
sources_entry += posix_pthread_sources_entry
sources_smoke += posix_pthread_sources_smoke
sources_full += posix_pthread_sources_full
}
# sys module
if (LOSCFG_USER_TEST_SYS == true) {
import("./sys/config.gni")
common_include_dirs += sys_include_dirs
sources_entry += sys_sources_entry
sources_smoke += sys_sources_smoke
sources_full += sys_sources_full
}
# time module
if (LOSCFG_USER_TEST_TIME_CLOCK == true) {
import("./time/clock/config.gni")
common_include_dirs += time_clock_include_dirs
sources_entry += time_clock_sources_entry
sources_smoke += time_clock_sources_smoke
sources_full += time_clock_sources_full
}
if (LOSCFG_USER_TEST_TIME_TIMER == true) {
import("./time/timer/config.gni")
common_include_dirs += time_timer_include_dirs
sources_entry += time_timer_sources_entry
sources_smoke += time_timer_sources_smoke
sources_full += time_timer_sources_full
}
# util module
if (LOSCFG_USER_TEST_UTIL == true) {
import("./util/config.gni")
common_include_dirs += util_include_dirs
sources_entry += util_sources_entry
sources_smoke += util_sources_smoke
sources_full += util_sources_full
}
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/test.gni")
import("//kernel/liteos_a/testsuites/unittest/config.gni")
import("./config.gni")
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
unittest("liteos_a_process_basic_unittest_door") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/kernel"
include_dirs = common_include_dirs
sources = sources_entry
sources += sources_smoke
sources_full = []
sources += sources_full
configs = [ "../..:public_config_for_door" ]
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
}
}
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
unittest("liteos_a_process_basic_unittest") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/kernel"
include_dirs = common_include_dirs
sources = sources_entry
sources += sources_smoke
sources += sources_full
configs = [ "../..:public_config_for_all" ]
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
}
}
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/test.gni")
import("//kernel/liteos_a/testsuites/unittest/config.gni")
common_include_dirs = [
"//third_party/googletest/googletest/include",
"../../common/include",
]
sources_entry = [ "../../common/osTest.cpp" ]
sources_smoke = []
sources_full = []
# basic module
if (LOSCFG_USER_TEST_PROCESS == true) {
import("./process/config.gni")
common_include_dirs += process_include_dirs
sources_entry += process_sources_entry
sources_smoke += process_sources_smoke
sources_full += process_sources_full
}
if (LOSCFG_USER_TEST_PTHREAD == true) {
import("./pthread/config.gni")
common_include_dirs += pthread_include_dirs
sources_entry += pthread_sources_entry
sources_smoke += pthread_sources_smoke
sources_full += pthread_sources_full
}
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstdio>
#include "It_process_fs_test.h"
static int const maxContainerNum = 5;
static int const configLen = 16;
static int nInitArry[maxContainerNum] = {61, 54, 49, 44, 41};
static std::string arryEntries[maxContainerNum] = {
"max_mnt_container",
"max_pid_container",
"max_user_container",
"max_net_container",
"max_uts_container"
};
static void WriteContainer(const char *filepath, int value)
{
PrintTest("writeproc %d >> %s\n", value, filepath);
int fd = open(filepath, O_WRONLY);
ASSERT_NE(fd, -1);
char buf[configLen];
size_t twd = sprintf_s(buf, configLen, "%d", value);
ASSERT_GT(twd, 0);
twd = write(fd, buf, (strlen(buf)+1));
ASSERT_EQ(twd, -1);
(void)close(fd);
}
static void ReadContainer(std::string strFile, int value)
{
char szStatBuf[configLen];
FILE *fp = fopen(strFile.c_str(), "rb");
ASSERT_NE(fp, nullptr);
int ret;
(void)memset_s(szStatBuf, configLen, 0, configLen);
ret = fread(szStatBuf, 1, configLen, fp);
ASSERT_NE(ret, 0);
PrintTest("cat %s\n", strFile.c_str());
PrintTest("%s\n", szStatBuf);
ret = atoi(szStatBuf);
ASSERT_EQ(ret, value);
(void)fclose(fp);
}
static void ErrWriteContainer0(const char *filepath)
{
int fd = open(filepath, O_WRONLY);
ASSERT_NE(fd, -1);
char buf[configLen];
int invalidNum = 0;
size_t twd1 = sprintf_s(buf, configLen, "%d", invalidNum);
ASSERT_GT(twd1, 0);
PrintTest("writeproc %d >> %s\n", invalidNum, filepath);
twd1 = write(fd, buf, (strlen(buf)+1));
(void)close(fd);
ASSERT_EQ(twd1, -1);
}
static void ErrWriteContainer65(const char *filepath)
{
int fd = open(filepath, O_WRONLY);
ASSERT_NE(fd, -1);
char buf[configLen];
int invalidNum = 65;
size_t twd2 = sprintf_s(buf, configLen, "%d", invalidNum);
ASSERT_GT(twd2, 0);
PrintTest("writeproc %d >> %s\n", invalidNum, filepath);
twd2 = write(fd, buf, (strlen(buf)+1));
(void)close(fd);
ASSERT_EQ(twd2, -1);
}
void ItProcessFs006(void)
{
const int CONFIG_FILE_LEN = 1024;
char szFile[CONFIG_FILE_LEN] = {0};
for (int i = 0; i < maxContainerNum; i++) {
size_t count = sprintf_s(szFile, CONFIG_FILE_LEN, "/proc/sys/user/%s", arryEntries[i].c_str());
ASSERT_GT(count, 0);
WriteContainer(szFile, nInitArry[i]);
ReadContainer(szFile, nInitArry[i]);
}
for (int i = 0; i < maxContainerNum; i++) {
size_t count = sprintf_s(szFile, CONFIG_FILE_LEN, "/proc/sys/user/%s", arryEntries[i].c_str());
ASSERT_GT(count, 0);
ErrWriteContainer0(szFile);
ErrWriteContainer65(szFile);
}
}
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstdio>
#include "It_process_fs_test.h"
static int const configLen = 16;
static int const invalidNum = 2;
static const int CHILD_FUNC_ARG = 0x2088;
const int STACK_SIZE = (1024 * 1024);
static int childFunc(void *arg)
{
(void)arg;
sleep(2); /* 2: delay 2s */
return 0;
}
void ItProcessFs016(void)
{
std::string path = "/proc/sys/user/max_uts_container";
int fd = open(path.c_str(), O_WRONLY);
ASSERT_NE(fd, -1);
char buf[configLen];
(void)sprintf(buf, "%d", invalidNum);
size_t ret = write(fd, buf, (strlen(buf) + 1));
ASSERT_NE(ret, -1);
int arg = CHILD_FUNC_ARG;
char *stack = (char *)mmap(nullptr, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK,
-1, 0);
ASSERT_NE(stack, nullptr);
char *stackTop = stack + STACK_SIZE;
auto pid = clone(childFunc, stackTop, CLONE_NEWUTS, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWUTS, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWUTS, &arg);
ASSERT_EQ(pid, -1);
(void)close(fd);
}
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstdio>
#include "It_process_fs_test.h"
static int const configLen = 16;
static int const invalidNum = 2;
static const int CHILD_FUNC_ARG = 0x2088;
const int STACK_SIZE = (1024 * 1024);
static int childFunc(void *arg)
{
(void)arg;
sleep(2); /* 2: delay 2s */
return 0;
}
void ItProcessFs017(void)
{
std::string path = "/proc/sys/user/max_user_container";
int fd = open(path.c_str(), O_WRONLY);
ASSERT_NE(fd, -1);
char buf[configLen];
size_t ret = sprintf_s(buf, configLen, "%d", invalidNum);
ASSERT_GT(ret, 0);
ret = write(fd, buf, (strlen(buf) + 1));
ASSERT_NE(ret, -1);
int arg = CHILD_FUNC_ARG;
char *stack = (char *)mmap(nullptr, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK,
-1, 0);
ASSERT_NE(stack, nullptr);
char *stackTop = stack + STACK_SIZE;
auto pid = clone(childFunc, stackTop, CLONE_NEWUSER, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWUSER, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWUSER, &arg);
ASSERT_EQ(pid, -1);
(void)close(fd);
}
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstdio>
#include "It_process_fs_test.h"
static int const configLen = 16;
static int const invalidNum = 2;
static const int CHILD_FUNC_ARG = 0x2088;
const int STACK_SIZE = (1024 * 1024);
static int childFunc(void *arg)
{
(void)arg;
sleep(2); /* 2: delay 2s */
return 0;
}
void ItProcessFs018(void)
{
std::string path = "/proc/sys/user/max_mnt_container";
int fd = open(path.c_str(), O_WRONLY);
ASSERT_NE(fd, -1);
char buf[configLen];
size_t ret = sprintf_s(buf, configLen, "%d", invalidNum);
ASSERT_GT(ret, 0);
ret = write(fd, buf, (strlen(buf) + 1));
ASSERT_NE(ret, -1);
int arg = CHILD_FUNC_ARG;
char *stack = (char *)mmap(nullptr, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK,
-1, 0);
ASSERT_NE(stack, nullptr);
char *stackTop = stack + STACK_SIZE;
auto pid = clone(childFunc, stackTop, CLONE_NEWNS, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWNS, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWNS, &arg);
ASSERT_EQ(pid, -1);
(void)close(fd);
}
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstdio>
#include "It_process_fs_test.h"
static int const configLen = 16;
static int const invalidNum = 2;
static const int CHILD_FUNC_ARG = 0x2088;
const int STACK_SIZE = (1024 * 1024);
static int childFunc(void *arg)
{
(void)arg;
sleep(2); /* 2: delay 2s */
return 0;
}
void ItProcessFs019(void)
{
std::string path = "/proc/sys/user/max_pid_container";
int fd = open(path.c_str(), O_WRONLY);
ASSERT_NE(fd, -1);
char buf[configLen];
size_t ret = sprintf_s(buf, configLen, "%d", invalidNum);
ASSERT_GT(ret, 0);
ret = write(fd, buf, (strlen(buf) + 1));
ASSERT_NE(ret, -1);
int arg = CHILD_FUNC_ARG;
char *stack = (char *)mmap(nullptr, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK,
-1, 0);
ASSERT_NE(stack, nullptr);
char *stackTop = stack + STACK_SIZE;
auto pid = clone(childFunc, stackTop, CLONE_NEWPID, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWPID, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWPID, &arg);
ASSERT_EQ(pid, -1);
(void)close(fd);
}
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstdio>
#include "It_process_fs_test.h"
static int const configLen = 16;
static int const invalidNum = 2;
static const int CHILD_FUNC_ARG = 0x2088;
const int STACK_SIZE = (1024 * 1024);
static int childFunc(void *arg)
{
(void)arg;
sleep(2); /* 2: delay 2s */
return 0;
}
void ItProcessFs020(void)
{
std::string path = "/proc/sys/user/max_net_container";
int fd = open(path.c_str(), O_WRONLY);
ASSERT_NE(fd, -1);
char buf[configLen];
size_t ret = sprintf_s(buf, configLen, "%d", invalidNum);
ASSERT_GT(ret, 0);
ret = write(fd, buf, (strlen(buf) + 1));
ASSERT_NE(ret, -1);
int arg = CHILD_FUNC_ARG;
char *stack = (char *)mmap(nullptr, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK,
-1, 0);
ASSERT_NE(stack, nullptr);
char *stackTop = stack + STACK_SIZE;
auto pid = clone(childFunc, stackTop, CLONE_NEWNET, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWNET, &arg);
ASSERT_NE(pid, -1);
pid = clone(childFunc, stackTop, CLONE_NEWNET, &arg);
ASSERT_EQ(pid, -1);
(void)close(fd);
}
......@@ -11,4 +11,5 @@
|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/16.png)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/17.png)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/18.png)|
|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/19.png)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/20.png)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/21.png)|
|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/22.png)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/23.png)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/24.png)
|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/25.png)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/25.png)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/25.png)
|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/weixin.jpg)|![](https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/donate/zfb.jpg)|||
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册