From b0708886fac097b950de38c9f15ccba29cbbaae3 Mon Sep 17 00:00:00 2001 From: zwx1232718 Date: Thu, 25 May 2023 15:06:02 +0800 Subject: [PATCH] container dir change Signed-off-by: zwx1232718 --- kernel/Kconfig | 45 ------------- kernel/base/BUILD.gn | 9 --- kernel/base/Makefile | 1 - kernel/extended/BUILD.gn | 2 + kernel/extended/Kconfig | 48 ++++++++++++++ kernel/extended/container/BUILD.gn | 65 +++++++++++++++++++ kernel/extended/container/Makefile | 63 ++++++++++++++++++ .../container/los_container.c | 0 .../container/los_credentials.c | 0 .../container/los_ipc_container.c | 0 .../container/los_mnt_container.c | 0 .../container/los_net_container.c | 0 .../container/los_pid_container.c | 0 .../container/los_time_container.c | 0 .../container/los_user_container.c | 0 .../container/los_uts_container.c | 0 testsuites/unittest/container/BUILD.gn | 3 - testsuites/unittest/container/config.gni | 2 + testsuites/unittest/process/fs/BUILD.gn | 3 - testsuites/unittest/process/fs/config.gni | 1 + testsuites/unittest/process/plimits/BUILD.gn | 3 - .../unittest/process/plimits/config.gni | 3 +- 22 files changed, 183 insertions(+), 65 deletions(-) create mode 100644 kernel/extended/container/BUILD.gn create mode 100644 kernel/extended/container/Makefile rename kernel/{base => extended}/container/los_container.c (100%) rename kernel/{base => extended}/container/los_credentials.c (100%) rename kernel/{base => extended}/container/los_ipc_container.c (100%) rename kernel/{base => extended}/container/los_mnt_container.c (100%) rename kernel/{base => extended}/container/los_net_container.c (100%) rename kernel/{base => extended}/container/los_pid_container.c (100%) rename kernel/{base => extended}/container/los_time_container.c (100%) rename kernel/{base => extended}/container/los_user_container.c (100%) rename kernel/{base => extended}/container/los_uts_container.c (100%) diff --git a/kernel/Kconfig b/kernel/Kconfig index 197ddb71..03fea0d9 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -67,51 +67,6 @@ config PAGE_TABLE_FINE_LOCK help This option will enable fine lock for page table. -######################### config options of container #################### -config KERNEL_CONTAINER - bool "Enable container Feature" - default n - depends on KERNEL_VM - -config PID_CONTAINER - bool "Enable pid container Feature" - default n - depends on KERNEL_CONTAINER - -config UTS_CONTAINER - bool "Enable uts container Feature" - default n - depends on KERNEL_CONTAINER - -config MNT_CONTAINER - bool "Enable mnt container Feature" - default n - depends on KERNEL_CONTAINER - -config CHROOT - bool "Enable chroot" - default n - depends on MNT_CONTAINER - -config IPC_CONTAINER - bool "Enable ipc container Feature" - default n - depends on KERNEL_CONTAINER - -config TIME_CONTAINER - bool "Enable time container" - default n - depends on KERNEL_CONTAINER - -config USER_CONTAINER - bool "Enable user container" - default n - depends on KERNEL_CONTAINER - -config NET_CONTAINER - bool "Enable net container" - default n - depends on KERNEL_CONTAINER ######################### config options of extended ##################### source "kernel/extended/Kconfig" diff --git a/kernel/base/BUILD.gn b/kernel/base/BUILD.gn index 45fdb56b..f3d9b457 100644 --- a/kernel/base/BUILD.gn +++ b/kernel/base/BUILD.gn @@ -32,15 +32,6 @@ import("//kernel/liteos_a/liteos.gni") module_name = get_path_info(rebase_path("."), "name") kernel_module(module_name) { sources = [ - "container/los_container.c", - "container/los_credentials.c", - "container/los_ipc_container.c", - "container/los_mnt_container.c", - "container/los_net_container.c", - "container/los_pid_container.c", - "container/los_time_container.c", - "container/los_user_container.c", - "container/los_uts_container.c", "core/los_bitmap.c", "core/los_info.c", "core/los_process.c", diff --git a/kernel/base/Makefile b/kernel/base/Makefile index 262c37ea..73fa7ceb 100644 --- a/kernel/base/Makefile +++ b/kernel/base/Makefile @@ -39,7 +39,6 @@ LOCAL_SRCS := $(wildcard ipc/*.c) $(wildcard core/*.c) $(wildcard mem/membox/*. $(wildcard mp/*.c) \ $(wildcard sched/*.c) \ $(wildcard vm/*.c) \ - $(wildcard container/*.c) LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) -Wno-frame-address diff --git a/kernel/extended/BUILD.gn b/kernel/extended/BUILD.gn index 6bada0f1..0a322355 100644 --- a/kernel/extended/BUILD.gn +++ b/kernel/extended/BUILD.gn @@ -32,6 +32,7 @@ import("//kernel/liteos_a/liteos.gni") group("extended") { deps = [ "blackbox", + "container", "cppsupport", "cpup", "dynload", @@ -52,6 +53,7 @@ group("extended") { config("public") { configs = [ "blackbox:public", + "container:public", "cpup:public", "dynload:public", "hidumper:public", diff --git a/kernel/extended/Kconfig b/kernel/extended/Kconfig index 45dababf..d7d133ec 100644 --- a/kernel/extended/Kconfig +++ b/kernel/extended/Kconfig @@ -113,6 +113,54 @@ config KERNEL_HOOK default n depends on KERNEL_EXTKERNEL && DEBUG_VERSION + +######################### config options of container #################### +config KERNEL_CONTAINER + bool "Enable container Feature" + default n + depends on KERNEL_VM + +config PID_CONTAINER + bool "Enable pid container Feature" + default n + depends on KERNEL_CONTAINER + +config UTS_CONTAINER + bool "Enable uts container Feature" + default n + depends on KERNEL_CONTAINER + +config MNT_CONTAINER + bool "Enable mnt container Feature" + default n + depends on KERNEL_CONTAINER + +config CHROOT + bool "Enable chroot" + default n + depends on MNT_CONTAINER + +config IPC_CONTAINER + bool "Enable ipc container Feature" + default n + depends on KERNEL_CONTAINER + +config TIME_CONTAINER + bool "Enable time container" + default n + depends on KERNEL_CONTAINER + +config USER_CONTAINER + bool "Enable user container" + default n + depends on KERNEL_CONTAINER + +config NET_CONTAINER + bool "Enable net container" + default n + depends on KERNEL_CONTAINER + + ######################### config options of trace ######################### source "kernel/extended/trace/Kconfig" diff --git a/kernel/extended/container/BUILD.gn b/kernel/extended/container/BUILD.gn new file mode 100644 index 00000000..85bc8ea8 --- /dev/null +++ b/kernel/extended/container/BUILD.gn @@ -0,0 +1,65 @@ +# 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. + +import("//kernel/liteos_a/liteos.gni") + +module_switch = defined(LOSCFG_KERNEL_CONTAINER) +module_name = get_path_info(rebase_path("."), "name") +kernel_module(module_name) { + sources = [ "los_container.c" ] + if (defined(LOSCFG_IPC_CONTAINER)) { + sources += [ "los_ipc_container.c" ] + } + if (defined(LOSCFG_MNT_CONTAINER)) { + sources += [ "los_mnt_container.c" ] + } + if (defined(LOSCFG_NET_CONTAINER)) { + sources += [ "los_net_container.c" ] + } + if (defined(LOSCFG_PID_CONTAINER)) { + sources += [ "los_pid_container.c" ] + } + if (defined(LOSCFG_TIME_CONTAINER)) { + sources += [ "los_time_container.c" ] + } + if (defined(LOSCFG_USER_CONTAINER)) { + sources += [ + "los_credentials.c", + "los_user_container.c", + ] + } + if (defined(LOSCFG_UTS_CONTAINER)) { + sources += [ "los_uts_container.c" ] + } + + public_configs = [ ":public" ] +} + +config("public") { + include_dirs = [ "." ] +} diff --git a/kernel/extended/container/Makefile b/kernel/extended/container/Makefile new file mode 100644 index 00000000..194ff867 --- /dev/null +++ b/kernel/extended/container/Makefile @@ -0,0 +1,63 @@ +# 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 $(LITEOSTOPDIR)/config.mk + +MODULE_NAME := $(notdir $(shell pwd)) + +LOCAL_SRCS := $(wildcard *.c) + +ifneq ($(LOSCFG_IPC_CONTAINER), y) +LOCAL_SRCS += $(filter-out los_ipc_container.c, $(LOCAL_SRCS)) +endif + +ifneq ($(LOSCFG_MNT_CONTAINER), y) +LOCAL_SRCS += $(filter-out los_mnt_container.c, $(LOCAL_SRCS)) +endif + +ifneq ($(LOSCFG_NET_CONTAINER), y) +LOCAL_SRCS += $(filter-out los_net_container.c, $(LOCAL_SRCS)) +endif + +ifneq ($(LOSCFG_PID_CONTAINER), y) +LOCAL_SRCS += $(filter-out los_pid_container.c, $(LOCAL_SRCS)) +endif + +ifneq ($(LOSCFG_TIME_CONTAINER), y) +LOCAL_SRCS += $(filter-out los_time_container.c, $(LOCAL_SRCS)) +endif + +ifneq ($(LOSCFG_USER_CONTAINER), y) +LOCAL_SRCS += $(filter-out los_credentials.c los_user_container.c, $(LOCAL_SRCS)) +endif + +ifneq ($(LOSCFG_UTS_CONTAINER), y) +LOCAL_SRCS += $(filter-out los_uts_container.c, $(LOCAL_SRCS)) +endif + +include $(MODULE) \ No newline at end of file diff --git a/kernel/base/container/los_container.c b/kernel/extended/container/los_container.c similarity index 100% rename from kernel/base/container/los_container.c rename to kernel/extended/container/los_container.c diff --git a/kernel/base/container/los_credentials.c b/kernel/extended/container/los_credentials.c similarity index 100% rename from kernel/base/container/los_credentials.c rename to kernel/extended/container/los_credentials.c diff --git a/kernel/base/container/los_ipc_container.c b/kernel/extended/container/los_ipc_container.c similarity index 100% rename from kernel/base/container/los_ipc_container.c rename to kernel/extended/container/los_ipc_container.c diff --git a/kernel/base/container/los_mnt_container.c b/kernel/extended/container/los_mnt_container.c similarity index 100% rename from kernel/base/container/los_mnt_container.c rename to kernel/extended/container/los_mnt_container.c diff --git a/kernel/base/container/los_net_container.c b/kernel/extended/container/los_net_container.c similarity index 100% rename from kernel/base/container/los_net_container.c rename to kernel/extended/container/los_net_container.c diff --git a/kernel/base/container/los_pid_container.c b/kernel/extended/container/los_pid_container.c similarity index 100% rename from kernel/base/container/los_pid_container.c rename to kernel/extended/container/los_pid_container.c diff --git a/kernel/base/container/los_time_container.c b/kernel/extended/container/los_time_container.c similarity index 100% rename from kernel/base/container/los_time_container.c rename to kernel/extended/container/los_time_container.c diff --git a/kernel/base/container/los_user_container.c b/kernel/extended/container/los_user_container.c similarity index 100% rename from kernel/base/container/los_user_container.c rename to kernel/extended/container/los_user_container.c diff --git a/kernel/base/container/los_uts_container.c b/kernel/extended/container/los_uts_container.c similarity index 100% rename from kernel/base/container/los_uts_container.c rename to kernel/extended/container/los_uts_container.c diff --git a/testsuites/unittest/container/BUILD.gn b/testsuites/unittest/container/BUILD.gn index bc53409a..20273997 100644 --- a/testsuites/unittest/container/BUILD.gn +++ b/testsuites/unittest/container/BUILD.gn @@ -26,9 +26,6 @@ # 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/liteos.gni") -import("//kernel/liteos_a/testsuites/unittest/config.gni") import("./config.gni") config("container_config") { diff --git a/testsuites/unittest/container/config.gni b/testsuites/unittest/container/config.gni index 35c55da9..9bfa4dd6 100644 --- a/testsuites/unittest/container/config.gni +++ b/testsuites/unittest/container/config.gni @@ -26,6 +26,8 @@ # 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/liteos.gni") import("//kernel/liteos_a/testsuites/unittest/config.gni") common_include_dirs = [ diff --git a/testsuites/unittest/process/fs/BUILD.gn b/testsuites/unittest/process/fs/BUILD.gn index 02902a41..2308401a 100644 --- a/testsuites/unittest/process/fs/BUILD.gn +++ b/testsuites/unittest/process/fs/BUILD.gn @@ -26,9 +26,6 @@ # 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/liteos.gni") -import("//kernel/liteos_a/testsuites/unittest/config.gni") import("./config.gni") if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) { diff --git a/testsuites/unittest/process/fs/config.gni b/testsuites/unittest/process/fs/config.gni index 54c04390..a12552a1 100644 --- a/testsuites/unittest/process/fs/config.gni +++ b/testsuites/unittest/process/fs/config.gni @@ -27,6 +27,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import("//build/lite/config/test.gni") +import("//kernel/liteos_a/liteos.gni") import("//kernel/liteos_a/testsuites/unittest/config.gni") common_include_dirs = [ diff --git a/testsuites/unittest/process/plimits/BUILD.gn b/testsuites/unittest/process/plimits/BUILD.gn index aff7786a..cdcf7a29 100644 --- a/testsuites/unittest/process/plimits/BUILD.gn +++ b/testsuites/unittest/process/plimits/BUILD.gn @@ -26,9 +26,6 @@ # 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/liteos.gni") -import("//kernel/liteos_a/testsuites/unittest/config.gni") import("./config.gni") if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) { diff --git a/testsuites/unittest/process/plimits/config.gni b/testsuites/unittest/process/plimits/config.gni index cfb6d636..bba4b0aa 100644 --- a/testsuites/unittest/process/plimits/config.gni +++ b/testsuites/unittest/process/plimits/config.gni @@ -27,6 +27,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import("//build/lite/config/test.gni") +import("//kernel/liteos_a/liteos.gni") import("//kernel/liteos_a/testsuites/unittest/config.gni") common_include_dirs = [ @@ -92,7 +93,7 @@ process_plimits_sources_smoke = [ process_plimits_sources_full = [] # plimits module -if (LOSCFG_USER_TEST_PROCESS == true) { +if (LOSCFG_USER_TEST_PROCESS_PLIMITS == true) { common_include_dirs += process_plimits_include_dirs sources_entry += process_plimits_sources_entry sources_smoke += process_plimits_sources_smoke -- GitLab