Compare commits
6 Commits
master
...
monthly_20
Author | SHA1 | Date |
---|---|---|
|
bf19a69b3c | |
|
ddb8c8f2ca | |
|
f86ead69d2 | |
|
fc761badd0 | |
|
38a9313a1b | |
|
7fc770192d |
|
@ -10,12 +10,6 @@
|
||||||
### 测试用例(新增、改动、可能影响的功能)
|
### 测试用例(新增、改动、可能影响的功能)
|
||||||
|
|
||||||
|
|
||||||
### 是否涉及对外变更(典型的如:对外API规格变更、新增对外接口等等)
|
|
||||||
|
|
||||||
必须选择一项(在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
|
|
||||||
- [ ] 是,涉及对外变更: 需要在commit message中按【[模板要求](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)】描述变更点
|
|
||||||
- [ ] 否,不涉及对外变更
|
|
||||||
|
|
||||||
### 是否需要同步至release(如:3.0LTS ... )分支?
|
### 是否需要同步至release(如:3.0LTS ... )分支?
|
||||||
|
|
||||||
必须选择一项(在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
|
必须选择一项(在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
|
||||||
|
|
36
BUILD.gn
36
BUILD.gn
|
@ -34,7 +34,6 @@ LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||||
declare_args() {
|
declare_args() {
|
||||||
tee_enable = false
|
tee_enable = false
|
||||||
liteos_name = "OHOS_Image"
|
liteos_name = "OHOS_Image"
|
||||||
liteos_container_enable = false
|
|
||||||
liteos_skip_make = false
|
liteos_skip_make = false
|
||||||
liteos_is_mini = false
|
liteos_is_mini = false
|
||||||
}
|
}
|
||||||
|
@ -202,10 +201,6 @@ config("warn_config") {
|
||||||
]
|
]
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||||
cflags += [ "-Wno-address-of-packed-member" ]
|
cflags += [ "-Wno-address-of-packed-member" ]
|
||||||
cflags += [
|
|
||||||
"-Wno-unused-but-set-variable",
|
|
||||||
"-Wno-strict-prototypes",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
asmflags = cflags
|
asmflags = cflags
|
||||||
}
|
}
|
||||||
|
@ -244,28 +239,6 @@ config("misc_config") {
|
||||||
asmflags = cflags
|
asmflags = cflags
|
||||||
}
|
}
|
||||||
|
|
||||||
config("container_config") {
|
|
||||||
if (liteos_container_enable) {
|
|
||||||
cflags = [
|
|
||||||
"-DLOSCFG_KERNEL_CONTAINER",
|
|
||||||
"-DLOSCFG_PID_CONTAINER",
|
|
||||||
"-DLOSCFG_UTS_CONTAINER",
|
|
||||||
"-DLOSCFG_MNT_CONTAINER",
|
|
||||||
"-DLOSCFG_CHROOT",
|
|
||||||
"-DLOSCFG_IPC_CONTAINER",
|
|
||||||
"-DLOSCFG_TIME_CONTAINER",
|
|
||||||
"-DLOSCFG_USER_CONTAINER",
|
|
||||||
"-DLOSCFG_NET_CONTAINER",
|
|
||||||
"-DLOSCFG_PROC_PROCESS_DIR",
|
|
||||||
"-DLOSCFG_KERNEL_PLIMITS",
|
|
||||||
"-DLOSCFG_KERNEL_MEM_PLIMIT",
|
|
||||||
"-DLOSCFG_KERNEL_IPC_PLIMIT",
|
|
||||||
"-DLOSCFG_KERNEL_DEV_PLIMIT",
|
|
||||||
"-DLOSCFG_KERNEL_SCHED_PLIMIT",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config("los_config") {
|
config("los_config") {
|
||||||
configs = [
|
configs = [
|
||||||
":arch_config",
|
":arch_config",
|
||||||
|
@ -276,7 +249,6 @@ config("los_config") {
|
||||||
":ssp_config",
|
":ssp_config",
|
||||||
":warn_config",
|
":warn_config",
|
||||||
":misc_config",
|
":misc_config",
|
||||||
":container_config",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +271,7 @@ config("public") {
|
||||||
|
|
||||||
configs += [
|
configs += [
|
||||||
"$HDFTOPDIR:public",
|
"$HDFTOPDIR:public",
|
||||||
"$DRIVERS_LITEOS_DIR:public",
|
"//drivers/liteos:public",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (HAVE_DEVICE_SDK) {
|
if (HAVE_DEVICE_SDK) {
|
||||||
|
@ -324,8 +296,8 @@ group("modules") {
|
||||||
]
|
]
|
||||||
|
|
||||||
deps += [
|
deps += [
|
||||||
"$DRIVERS_LITEOS_DIR",
|
"//drivers/liteos",
|
||||||
"$HDFTOPDIR",
|
HDFTOPDIR,
|
||||||
]
|
]
|
||||||
|
|
||||||
if (HAVE_DEVICE_SDK) {
|
if (HAVE_DEVICE_SDK) {
|
||||||
|
@ -351,7 +323,7 @@ group("liteos_a") {
|
||||||
deps += [
|
deps += [
|
||||||
":apps",
|
":apps",
|
||||||
":tests",
|
":tests",
|
||||||
"$THIRDPARTY_MUSL_DIR/scripts/build_lite:strip",
|
"//third_party/musl/scripts/build_lite:strip",
|
||||||
]
|
]
|
||||||
if (liteos_skip_make == false) {
|
if (liteos_skip_make == false) {
|
||||||
deps += [ ":make" ]
|
deps += [ ":make" ]
|
||||||
|
|
338
CHANGELOG.md
338
CHANGELOG.md
|
@ -1,338 +0,0 @@
|
||||||
# (2022-03-30)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
|
|
||||||
* **arm-virt:** HW_RANDOM_ENABLE配置支持arm virt平台 ([68f9f49](https://gitee.com/openharmony/kernel_liteos_a/commits/68f9f49c2a62d3271db14ccb896c9f9fc78a60e4))
|
|
||||||
* A核代码静态告警定期清理 ([9ba725c](https://gitee.com/openharmony/kernel_liteos_a/commits/9ba725c3d486dd28fe9b2489b0f95a65354d7d86)), closes [#I4I0O8](https://gitee.com/openharmony/kernel_liteos_a/issues/I4I0O8)
|
|
||||||
* change default permission of procfs to 0550 ([a776c04](https://gitee.com/openharmony/kernel_liteos_a/commits/a776c04a3da414f73ef7136a543c029cc6dd75be)), closes [#I4NY49](https://gitee.com/openharmony/kernel_liteos_a/issues/I4NY49)
|
|
||||||
* change the execFile field in TCB to execVnode ([e4a0662](https://gitee.com/openharmony/kernel_liteos_a/commits/e4a06623ceb49b5bead60d45c0534db88b9c666f)), closes [#I4CLL9](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CLL9)
|
|
||||||
* close file when process interpretor failed ([a375bf5](https://gitee.com/openharmony/kernel_liteos_a/commits/a375bf5668a5e86e082d0e124b538e423023a259)), closes [#I4ATQX](https://gitee.com/openharmony/kernel_liteos_a/issues/I4ATQX)
|
|
||||||
* codex 清理 ([9ab3e35](https://gitee.com/openharmony/kernel_liteos_a/commits/9ab3e351d38cdae2ec083048a50a253bc2a3b604)), closes [#I4BL3S](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BL3S)
|
|
||||||
* dyload open close failed ([5e87d8c](https://gitee.com/openharmony/kernel_liteos_a/commits/5e87d8c183471166294e2caa041ab4da8570c6a1)), closes [#I452Z7](https://gitee.com/openharmony/kernel_liteos_a/issues/I452Z7)
|
|
||||||
* fix ppoll ([a55f68f](https://gitee.com/openharmony/kernel_liteos_a/commits/a55f68f957e9f8ad74bd9e0c1b3d27775e0f8c75))
|
|
||||||
* fix some function declarations ([63fd8bc](https://gitee.com/openharmony/kernel_liteos_a/commits/63fd8bc39b21fffb6990f74e879eefecafad6c88))
|
|
||||||
* implicit declaration of function 'syscall' in apps/shell ([bd0c083](https://gitee.com/openharmony/kernel_liteos_a/commits/bd0c0835fc58ed5f941dbbc9adfac74253eeb874))
|
|
||||||
* LOS_Panic和魔法键功能中的使用PRINTK打印,依赖任务调度,特殊情况下存在打印不出来的问题 ([53addea](https://gitee.com/openharmony/kernel_liteos_a/commits/53addea304de09e0df457b690403ac652bbcea72)), closes [#I4NOC7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4NOC7)
|
|
||||||
* los_stat_pri.h中缺少依赖的头文件 ([2cd03c5](https://gitee.com/openharmony/kernel_liteos_a/commits/2cd03c55b7a614c648adc965ebfe494d491fe20f)), closes [#I4KEZ1](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KEZ1)
|
|
||||||
* los_trace.h接口注释错误修正 ([6d24961](https://gitee.com/openharmony/kernel_liteos_a/commits/6d249618aecc216388f9b1a2b48fe0ac6dd19ff2)), closes [#I4CYPZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CYPZ)
|
|
||||||
* MMU竞态问题修复 ([748e0d8](https://gitee.com/openharmony/kernel_liteos_a/commits/748e0d8ffb6ee9c8757ed056f575e3abc6c10702)), closes [#I2WARC](https://gitee.com/openharmony/kernel_liteos_a/issues/I2WARC)
|
|
||||||
* **mtd:** 去除mtd对hisilicon驱动的依赖 ([f7d010d](https://gitee.com/openharmony/kernel_liteos_a/commits/f7d010dfa4cb825096267528e131a9e2735d7505)), closes [#I49FKL](https://gitee.com/openharmony/kernel_liteos_a/issues/I49FKL)
|
|
||||||
* OsFutexWaitParamCheck函数中absTime为0时,直接返回,不需要打印 ([3f71be7](https://gitee.com/openharmony/kernel_liteos_a/commits/3f71be75355f11037d9de80cc4d7da0f01905003)), closes [#I4D67E](https://gitee.com/openharmony/kernel_liteos_a/issues/I4D67E)
|
|
||||||
* OsLockDepCheckIn异常处理中存在g_lockdepAvailable锁嵌套调用, ([bf030b6](https://gitee.com/openharmony/kernel_liteos_a/commits/bf030b6bb5843151a5b8b8736246a1376a5fb9d0)), closes [#I457ZZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I457ZZ)
|
|
||||||
* pr模板补充说明 ([e3cd485](https://gitee.com/openharmony/kernel_liteos_a/commits/e3cd485db528490a16a8932d734faab263b44bc9))
|
|
||||||
* same file mode for procfs files ([c79bcd0](https://gitee.com/openharmony/kernel_liteos_a/commits/c79bcd028e1be34b45cba000077230fa2ef95e68)), closes [#I4ACTC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4ACTC)
|
|
||||||
* shell支持exit退出,完善帮助信息,特殊处理不可见字符 ([cc6e112](https://gitee.com/openharmony/kernel_liteos_a/commits/cc6e11281e63b6bdc9be8e5d3c39f1258eb2ceaa))
|
|
||||||
* smp初始化中副核冗余的启动框架调用 ([5ce70a5](https://gitee.com/openharmony/kernel_liteos_a/commits/5ce70a50c3733b6ec8cc4b444837e366ec837f69)), closes [#I4F8A5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F8A5)
|
|
||||||
* solve SIGCHLD ignored in sigsuspend() ([5a80d4e](https://gitee.com/openharmony/kernel_liteos_a/commits/5a80d4e1a34c94204a0bb01443bf25a4fdb12750)), closes [#I47CKK](https://gitee.com/openharmony/kernel_liteos_a/issues/I47CKK)
|
|
||||||
* syscall review bugfix ([214f44e](https://gitee.com/openharmony/kernel_liteos_a/commits/214f44e935277c29d347c50b553a31ea7df36448)), closes [#149](https://gitee.com/openharmony/kernel_liteos_a/issues/149)
|
|
||||||
* **test:** misc09用例因依赖hosts文件而失败 ([f2f5c5f](https://gitee.com/openharmony/kernel_liteos_a/commits/f2f5c5fdc3202610de173e7046adab4df5e59142)), closes [#I48IZ0](https://gitee.com/openharmony/kernel_liteos_a/issues/I48IZ0)
|
|
||||||
* **test:** 修复sys部分用例因依赖passwd、group文件而失败 ([614cdcc](https://gitee.com/openharmony/kernel_liteos_a/commits/614cdccf91bd2d220c4c76418b53400ce714c6cb)), closes [#I48IUC](https://gitee.com/openharmony/kernel_liteos_a/issues/I48IUC)
|
|
||||||
* 中断中调用PRINTK概率卡死,导致系统不能正常响应中断 ([9726ba1](https://gitee.com/openharmony/kernel_liteos_a/commits/9726ba11a79f3d2d1e616e12ef0bb44e4fc5cd20)), closes [#I4C9GC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4C9GC)
|
|
||||||
* 临终遗言重定向内容缺失task相关信息,对应的shell命令中申请的内存需要cacheline对齐 ([48ca854](https://gitee.com/openharmony/kernel_liteos_a/commits/48ca854bf07f8dcda9657f950601043a485a1b33)), closes [#I482S5](https://gitee.com/openharmony/kernel_liteos_a/issues/I482S5)
|
|
||||||
* 优化liteipc任务状态,删除功能重复字段 ([5004ef4](https://gitee.com/openharmony/kernel_liteos_a/commits/5004ef4d87b54fb6d7f748ca8212ae155bcefac5)), closes [#I4FVHK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FVHK)
|
|
||||||
* 优化trace buffer初始化,删除swtmr 桩中的无效参数 ([b551270](https://gitee.com/openharmony/kernel_liteos_a/commits/b551270ef50cb206360e2eee3dd20ace5cecccb7)), closes [#I4DQ1X](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DQ1X)
|
|
||||||
* 修复 virpart.c 不适配的格式化打印问题 ([de29140](https://gitee.com/openharmony/kernel_liteos_a/commits/de29140edf2567f4847876cb1ed5e0b6857420f3)), closes [#I4PEVP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4PEVP)
|
|
||||||
* 修复A核文档失效的问题 ([456d255](https://gitee.com/openharmony/kernel_liteos_a/commits/456d255a81c2031be8ebecc2bf897af80c3d3c7a)), closes [#I4U7TF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4U7TF)
|
|
||||||
* 修复A核测试用例失败的问题 ([59329ce](https://gitee.com/openharmony/kernel_liteos_a/commits/59329ce7c6b6a00084df427748e6283287a773c0)), closes [#I4SQDR](https://gitee.com/openharmony/kernel_liteos_a/issues/I4SQDR)
|
|
||||||
* 修复A核测试用例失败的问题 ([be68dc8](https://gitee.com/openharmony/kernel_liteos_a/commits/be68dc8bcaf8d965039ae1d792775f00a08adfac)), closes [#I4SQDP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4SQDP)
|
|
||||||
* 修复dispatch单词拼写错误。 ([9b07aec](https://gitee.com/openharmony/kernel_liteos_a/commits/9b07aece2dfa3494cf35e8b388410341508d6224)), closes [#I4BLE8](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BLE8)
|
|
||||||
* 修复futime提示错误22的BUG ([f2861dd](https://gitee.com/openharmony/kernel_liteos_a/commits/f2861ddfb424af7b99c278273601ce0fab1f37e6))
|
|
||||||
* 修复jffs2适配层错误释放锁的BUG ([011a55f](https://gitee.com/openharmony/kernel_liteos_a/commits/011a55ff21d95f969abac60bcff96f4c4d7a326d)), closes [#I4FH9M](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FH9M)
|
|
||||||
* 修复los_vm_scan.c中内部函数OsInactiveListIsLow冗余代码 ([bc32a1e](https://gitee.com/openharmony/kernel_liteos_a/commits/bc32a1ec0fa5d19c6d2672bcf4a01de5e1be3afb)), closes [#I4HKFF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HKFF)
|
|
||||||
* 修复LOSCFG_FS_FAT_CACHE宏关闭后编译失败的BUG ([63e71fe](https://gitee.com/openharmony/kernel_liteos_a/commits/63e71feca05a8d46a49822c713258738740f0712)), closes [#I3T3N0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T3N0)
|
|
||||||
* 修复OsVmPhysFreeListAdd和OsVmPhysFreeListAddUnsafe函数内容重复 ([6827bd2](https://gitee.com/openharmony/kernel_liteos_a/commits/6827bd2a22b78aa05e20d6460412fc7b2d738929)), closes [#I4FL95](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FL95)
|
|
||||||
* 修复PR520缺陷 ([4033891](https://gitee.com/openharmony/kernel_liteos_a/commits/40338918d9132399ee0494d331930a05b7a13c67)), closes [#I4DEG5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DEG5)
|
|
||||||
* 修复shcmd.h需要用宏包起来的问题 ([6c4e4b1](https://gitee.com/openharmony/kernel_liteos_a/commits/6c4e4b16abe9c68fea43d40b2d39b4f0ed4bfc9c)), closes [#I4N50W](https://gitee.com/openharmony/kernel_liteos_a/issues/I4N50W)
|
|
||||||
* 修复xts权限用例压测异常问题 ([b0d31cb](https://gitee.com/openharmony/kernel_liteos_a/commits/b0d31cb43f5a8d1c3da574b2b957e3b0e98b3067)), closes [#I3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D)
|
|
||||||
* 修复硬随机不可用时,地址随机化不可用问题 ([665c152](https://gitee.com/openharmony/kernel_liteos_a/commits/665c152c27bb86395ddd0395279255f6cdaf7255)), closes [#I4D4TK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4D4TK)
|
|
||||||
* 修复进程用例导致门禁概率失败 ([1ed28b4](https://gitee.com/openharmony/kernel_liteos_a/commits/1ed28b4c80cfd222be08b0c2e71e6287e52bb276)), closes [#I4FO0N](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FO0N)
|
|
||||||
* 修复进程线程不稳定用例 ([f6ac03d](https://gitee.com/openharmony/kernel_liteos_a/commits/f6ac03d3e3c56236adc5734d4c059f1fbcc9e0c1)), closes [#I4F1XL](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F1XL)
|
|
||||||
* 修复重复执行内存用例导致系统卡死问题 ([6c2b163](https://gitee.com/openharmony/kernel_liteos_a/commits/6c2b163c7d7c696ef89b17a0275f3cddb3d7cefb)), closes [#I4F7PO](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F7PO)
|
|
||||||
* 修改MMU模块的注释错误 ([1a8e22d](https://gitee.com/openharmony/kernel_liteos_a/commits/1a8e22dcf15944153e013d004fd7bbf24557a8c7)), closes [#I4KMMJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KMMJ)
|
|
||||||
* 共享内存问题修复 ([9fdb80f](https://gitee.com/openharmony/kernel_liteos_a/commits/9fdb80f85f92d0167a0456455a94fc6f679797ce)), closes [#I47X2Z](https://gitee.com/openharmony/kernel_liteos_a/issues/I47X2Z)
|
|
||||||
* 内核ERR打印,无进程和线程信息,不方便问题定位。 ([cb423f8](https://gitee.com/openharmony/kernel_liteos_a/commits/cb423f845462b8cc474c3cba261dadf3943a08ef)), closes [#I4DAKM](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DAKM)
|
|
||||||
* 内核ERR级别及以上的打印输出当前进程和线程名 ([540b201](https://gitee.com/openharmony/kernel_liteos_a/commits/540b2017c5460e300365d2039a08abd5945cec6b))
|
|
||||||
* 内源检视测试用例问题修复 ([a6ac759](https://gitee.com/openharmony/kernel_liteos_a/commits/a6ac7597f85043ba6de3a1b395ca676d85c65ea7))
|
|
||||||
* 删除冗余的头文件 ([8e614bb](https://gitee.com/openharmony/kernel_liteos_a/commits/8e614bb1616b75bc89eee7ad7da49b7a9c285b47)), closes [#I4KN63](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KN63)
|
|
||||||
* 增加pselect SYSCALL函数及测试用例 ([f601c16](https://gitee.com/openharmony/kernel_liteos_a/commits/f601c16b9e67d531dda51fc18389a53db4360b7b)), closes [#I45SXU](https://gitee.com/openharmony/kernel_liteos_a/issues/I45SXU)
|
|
||||||
* 增加内核epoll系统调用 ([2251b8a](https://gitee.com/openharmony/kernel_liteos_a/commits/2251b8a2d1f649422dd67f8551b085a7e0c63ec7)), closes [#I4FXPT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FXPT)
|
|
||||||
* 实现了musl库net模块中的一些函数接口和相应的测试用例 ([3d00a7d](https://gitee.com/openharmony/kernel_liteos_a/commits/3d00a7d23a96f29c138cfc1672825b90b9e0c05e)), closes [#I4JQI1](https://gitee.com/openharmony/third_party_musl/issues/I4JQI1)
|
|
||||||
* 添加进程线程冒烟用例 ([2be5968](https://gitee.com/openharmony/kernel_liteos_a/commits/2be59680f2fb0801b43522cd38cc387c8ff38766)), closes [#I4EOGA](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EOGA)
|
|
||||||
* 用户态进程主线程退出时,其他子线程刚好进入异常处理流程会导致系统卡死 ([d955790](https://gitee.com/openharmony/kernel_liteos_a/commits/d955790a44a679421798ec1ac2900b4d75dd75a4)), closes [#I4KGBT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KGBT)
|
|
||||||
* 编码规范修改 ([d161a0b](https://gitee.com/openharmony/kernel_liteos_a/commits/d161a0b03de046c05fff45a2b625631b4e45a347))
|
|
||||||
* 编码规范问题修复 ([f60bc94](https://gitee.com/openharmony/kernel_liteos_a/commits/f60bc94cf231bc615ff6603ca0393b8fe33a8c47))
|
|
||||||
* 编译框架在做编译入口的统一 ([bdb9864](https://gitee.com/openharmony/kernel_liteos_a/commits/bdb9864436a6f128a4c3891bbd63e3c60352689f)), closes [#I4KRQN](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KRQN)
|
|
||||||
* 解决dmesg -s参数double lock问题 ([e151256](https://gitee.com/openharmony/kernel_liteos_a/commits/e1512566e322eb1fbc8f5d5997f9bfcd022feac7)), closes [#I4HIJK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HIJK)
|
|
||||||
* 进程退出前自己回收vmspace中的所有region ([298ccea](https://gitee.com/openharmony/kernel_liteos_a/commits/298ccea3fedaccc651b38973f0455fa1ce12e516)), closes [#I4CKQC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CKQC)
|
|
||||||
* 通过g_uart_fputc_en关闭打印后,shell进程不能正常启动 ([d21b05c](https://gitee.com/openharmony/kernel_liteos_a/commits/d21b05c0f69877130366ad37b852a0f30c11809d)), closes [#I4CTY2](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CTY2)
|
|
||||||
* 针对pr是否同步至release分支,增加原因说明规则 ([b37a7b7](https://gitee.com/openharmony/kernel_liteos_a/commits/b37a7b79292d93dae6c4914952b5f3bb509e8721))
|
|
||||||
* 非当前进程销毁时,销毁liteipc时错误的销毁了当前进程的liteipc资源 ([0f0e85b](https://gitee.com/openharmony/kernel_liteos_a/commits/0f0e85b7a6bf76d540925fbf661c483c8dba1cba)), closes [#I4FSA7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FSA7)
|
|
||||||
|
|
||||||
|
|
||||||
### Code Refactoring
|
|
||||||
|
|
||||||
* los_cir_buf.c中接口整合 ([0d325c5](https://gitee.com/openharmony/kernel_liteos_a/commits/0d325c56a1053043db05d53a6c8083f4d35f116b)), closes [#I4MC13](https://gitee.com/openharmony/kernel_liteos_a/issues/I4MC13)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
|
|
||||||
* add option SIOCGIFBRDADDR for ioctl ([4ecc473](https://gitee.com/openharmony/kernel_liteos_a/commits/4ecc473843207d259613d26b8ee176d75e7f00fd)), closes [#I4DNRF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DNRF)
|
|
||||||
* add sync() to vfs ([f67c4da](https://gitee.com/openharmony/kernel_liteos_a/commits/f67c4dae5141914df2e069dce0196b14780649d8)), closes [#I480HV](https://gitee.com/openharmony/kernel_liteos_a/issues/I480HV)
|
|
||||||
* **build:** support gcc toolchain ([6e886d4](https://gitee.com/openharmony/kernel_liteos_a/commits/6e886d4233dec3b82a27642f174b920e5f98f6aa))
|
|
||||||
* L0-L1 支持Perf ([6e0a3f1](https://gitee.com/openharmony/kernel_liteos_a/commits/6e0a3f10bbbfe29d110c050da927684b6d77b961)), closes [#I47I9A](https://gitee.com/openharmony/kernel_liteos_a/issues/I47I9A)
|
|
||||||
* L0~L1 支持Lms ([e748fdb](https://gitee.com/openharmony/kernel_liteos_a/commits/e748fdbe578a1ddd8eb10b2e207042676231ba26)), closes [#I4HYAV](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HYAV)
|
|
||||||
* liteipc 静态内存优化 ([5237924](https://gitee.com/openharmony/kernel_liteos_a/commits/52379242c109e0cf442784dbe811ff9d42d5f33a)), closes [#I4G4HP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4G4HP)
|
|
||||||
* page cache backed by vnode instead of filep ([38a6b80](https://gitee.com/openharmony/kernel_liteos_a/commits/38a6b804e9291d2fdbd189825ebd7d56165ec51c)), closes [#I44TBS](https://gitee.com/openharmony/kernel_liteos_a/issues/I44TBS)
|
|
||||||
* 提供低功耗默认处理框架 ([212d1bd](https://gitee.com/openharmony/kernel_liteos_a/commits/212d1bd1e806530fe7e7a16ea986cb2c6fb084ed)), closes [#I4KBG9](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KBG9)
|
|
||||||
* 支持AT_RANDOM以增强用户态栈保护能力 ([06ea037](https://gitee.com/openharmony/kernel_liteos_a/commits/06ea03715f0cfb8728fadd0d9c19a403dc8f6028)), closes [#I4CB8M](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CB8M)
|
|
||||||
* 支持L1 低功耗框架 ([64e49ab](https://gitee.com/openharmony/kernel_liteos_a/commits/64e49aba7c9c7d2280c5b3f29f04b17b63209855)), closes [#I4JSOT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4JSOT)
|
|
||||||
* 支持LOS_TaskJoin 和 LOS_TaskDetach ([37bc11f](https://gitee.com/openharmony/kernel_liteos_a/commits/37bc11fa8837a3019a0a56702f401ec1845f6547)), closes [#I4EENF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EENF)
|
|
||||||
* 新增解析异常和backtrace信息脚本 ([7019fdf](https://gitee.com/openharmony/kernel_liteos_a/commits/7019fdfcbb33c660e8aa9fd399d5fccbd7e23b49)), closes [#I47EVQ](https://gitee.com/openharmony/kernel_liteos_a/issues/I47EVQ)
|
|
||||||
* 调度tick响应时间计算优化 ([f47da44](https://gitee.com/openharmony/kernel_liteos_a/commits/f47da44b39be7fa3e9b5031d7b79b9bef1fd4fbc))
|
|
||||||
* 调度去进程化,优化进程线程依赖关系 ([dc479fb](https://gitee.com/openharmony/kernel_liteos_a/commits/dc479fb7bd9cb8441e4e47d44b42110ea07d76a2))
|
|
||||||
* 调度相关模块间依赖优化 ([0e3936c](https://gitee.com/openharmony/kernel_liteos_a/commits/0e3936c4f8b8bcfc48d283a6d53413e0fc0619b3)), closes [#I4RPRW](https://gitee.com/openharmony/kernel_liteos_a/issues/I4RPRW)
|
|
||||||
* 进程cpup占用率结构优化为动态分配 ([f06e090](https://gitee.com/openharmony/kernel_liteos_a/commits/f06e090a1085a654fd726fbc3c3a1c2bc703d663)), closes [#I4GLNT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4GLNT)
|
|
||||||
* 进程rlimit修改为动态分配,减少静态内存占用 ([cf8446c](https://gitee.com/openharmony/kernel_liteos_a/commits/cf8446c94112ed6993a2e6e71e793d83a72689d5)), closes [#I4EZY5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EZY5)
|
|
||||||
|
|
||||||
### BREAKING CHANGES
|
|
||||||
|
|
||||||
* 1. 删除 LOS_CirBufLock(),LOS_CirBufUnlock()内核对外接口
|
|
||||||
2. LOS_CirBufWrite(),LOS_CirBufRead()由原先内部不进行上/解锁操作,变为默认已包含上/解锁操作。
|
|
||||||
* 新增支持API:
|
|
||||||
|
|
||||||
LOS_LmsCheckPoolAdd使能检测指定内存池
|
|
||||||
LOS_LmsCheckPoolDel不检测指定内存池
|
|
||||||
LOS_LmsAddrProtect为指定内存段上锁,不允许访问
|
|
||||||
LOS_LmsAddrDisableProtect去能指定内存段的访问保护
|
|
||||||
* 1.新增一系列perf的对外API,位于los_perf.h中.
|
|
||||||
LOS_PerfInit配置采样数据缓冲区
|
|
||||||
LOS_PerfStart开启Perf采样
|
|
||||||
LOS_PerfStop停止Perf采样
|
|
||||||
LOS_PerfConfig配置Perf采样事件
|
|
||||||
LOS_PerfDataRead读取采样数据
|
|
||||||
LOS_PerfNotifyHookReg 注册采样数据缓冲区的钩子函数
|
|
||||||
LOS_PerfFlushHookReg 注册缓冲区刷cache的钩子
|
|
||||||
|
|
||||||
2. 用户态新增perf命令
|
|
||||||
【Usage】:
|
|
||||||
./perf [start] /[start id] Start perf.
|
|
||||||
./perf [stop] Stop perf.
|
|
||||||
./perf [read nBytes] Read nBytes raw data from perf buffer and print out.
|
|
||||||
./perf [list] List events to be used in -e.
|
|
||||||
./perf [stat] or [record] <option> <command>
|
|
||||||
-e, event selector. use './perf list' to list available events.
|
|
||||||
-p, event period.
|
|
||||||
-o, perf data output filename.
|
|
||||||
-t, taskId filter(whiltelist), if not set perf will sample all tasks.
|
|
||||||
-s, type of data to sample defined in PerfSampleType los_perf.h.
|
|
||||||
-P, processId filter(whiltelist), if not set perf will sample all processes.
|
|
||||||
-d, whether to prescaler (once every 64 counts), which only take effect on cpu cycle hardware event.
|
|
||||||
|
|
||||||
|
|
||||||
# (2021-09-30)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* A核代码告警清零 ([698756d](https://gitee.com/openharmony/kernel_liteos_a/commits/698756d1e6dfb11b9f874c02ce6a1496646f2c27)), closes [#I4378T](https://gitee.com/openharmony/kernel_liteos_a/issues/I4378T)
|
|
||||||
* A核告警消除 ([d16bfd0](https://gitee.com/openharmony/kernel_liteos_a/commits/d16bfd005a6dae78df2df3ad55cf21e0716dfae9)), closes [#I46KF6](https://gitee.com/openharmony/kernel_liteos_a/issues/I46KF6)
|
|
||||||
* 3518平台, 异常测试进程无法正常退出 ([23937a2](https://gitee.com/openharmony/kernel_liteos_a/commits/23937a239f50d1487e89f3184e4f4b933d6842c6)), closes [#I3V8R5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V8R5)
|
|
||||||
* add (void) to GetFileMappingList method ([56b8eca](https://gitee.com/openharmony/kernel_liteos_a/commits/56b8ecaf171671c0fe97f1dd1f191bebb7812a51)), closes [#I3XPXY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XPXY)
|
|
||||||
* add capability and amend smoke testcase ([c9d69e2](https://gitee.com/openharmony/kernel_liteos_a/commits/c9d69e2d1bde57c67068cc36f6a79327d5db5daf))
|
|
||||||
* add fchdir api ([e828cbd](https://gitee.com/openharmony/kernel_liteos_a/commits/e828cbdeac7d60bfd6ed98c75a9958ee8ec7b672))
|
|
||||||
* add fchmod api ([2f214bf](https://gitee.com/openharmony/kernel_liteos_a/commits/2f214bf4de6c31875c77e84b1763e96bc5ceb669))
|
|
||||||
* add fststfs api and unitest ([4c57aa2](https://gitee.com/openharmony/kernel_liteos_a/commits/4c57aa26ad3644ce2429effc8e8fe7fd3c52ebc2))
|
|
||||||
* add product_path parameter for driver build ([88fe4eb](https://gitee.com/openharmony/kernel_liteos_a/commits/88fe4eb3e1eafa6d1e32c7b96579a07f5a8c6e35)), closes [#I3PQ10](https://gitee.com/openharmony/drivers_adapter/issues/I3PQ10)
|
|
||||||
* add syscall for ppoll & add 2 testcases ([defedb6](https://gitee.com/openharmony/kernel_liteos_a/commits/defedb6fdf0806da4a39e22408544cdfb405f2ff))
|
|
||||||
* avoid compile warning ignored ([eca711b](https://gitee.com/openharmony/kernel_liteos_a/commits/eca711bb64a7c806ae34c8483cac73fe22b0104f)), closes [#I3VOAO](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VOAO)
|
|
||||||
* A核codex修改 ([ec977a1](https://gitee.com/openharmony/kernel_liteos_a/commits/ec977a1c7e9ba4ea6621ceb1d0d10e586148208d)), closes [#I40B1S](https://gitee.com/openharmony/kernel_liteos_a/issues/I40B1S)
|
|
||||||
* BBOX使用预留物理内存缓存故障日志 ([2ad176e](https://gitee.com/openharmony/kernel_liteos_a/commits/2ad176e587d5ed7106831a25d386a88e26192e2b)), closes [#I41YIZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I41YIZ)
|
|
||||||
* bootargs解析与rootfs挂载解耦,并支持自定义bootargs参数 ([80473f0](https://gitee.com/openharmony/kernel_liteos_a/commits/80473f0975fe6fd4c4eae3a8a473674ad2dd1293)), closes [#I41CL8](https://gitee.com/openharmony/kernel_liteos_a/issues/I41CL8)
|
|
||||||
* **build:** clang10.0.1支持lto,去掉冗余判断 ([73223ae](https://gitee.com/openharmony/kernel_liteos_a/commits/73223ae7e652b7cd9f1e1848c32b2b2573d07b2a))
|
|
||||||
* **build:** fix rootfsdir.sh target directory not exist ([21bf2b8](https://gitee.com/openharmony/kernel_liteos_a/commits/21bf2b889931787fb18ca7ea238291fd57e76d51)), closes [#I3NHQ0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NHQ0)
|
|
||||||
* **build:** 去除冗余单板相关的宏配置 ([471de36](https://gitee.com/openharmony/kernel_liteos_a/commits/471de3663ea8b63f7448162edc0293b8723dcefc))
|
|
||||||
* clang10 lld could not recognized Oz ([87a0006](https://gitee.com/openharmony/kernel_liteos_a/commits/87a0006d5e1976fdf5efe4be383921610eb04ec6))
|
|
||||||
* clang相关编译选项隔离 ([77dcef4](https://gitee.com/openharmony/kernel_liteos_a/commits/77dcef4bc0c92d0141f7a3be0addd4d5cb533b0b)), closes [#I444AV](https://gitee.com/openharmony/kernel_liteos_a/issues/I444AV)
|
|
||||||
* codex ([101a55d](https://gitee.com/openharmony/kernel_liteos_a/commits/101a55d1199530d621f809976f0024aa8295cce8))
|
|
||||||
* codex clean ([b5370af](https://gitee.com/openharmony/kernel_liteos_a/commits/b5370af822c8e81ed2248ac8aa3bb479a0db9dae)), closes [#I3UOFN](https://gitee.com/openharmony/kernel_liteos_a/issues/I3UOFN)
|
|
||||||
* compile error when fatfs disabled ([fd3f407](https://gitee.com/openharmony/kernel_liteos_a/commits/fd3f4072b5c3dff710013ccdaddf114b0e13f435))
|
|
||||||
* console compile bug fix ([f8441a0](https://gitee.com/openharmony/kernel_liteos_a/commits/f8441a0cdea301449416b0c0477dc48a05b6ab4e))
|
|
||||||
* correct spelling ([c66fe03](https://gitee.com/openharmony/kernel_liteos_a/commits/c66fe0313f76ba41992b4864c93cf82934378ad3))
|
|
||||||
* Correctly handle the return value of LOS_EventRead in QuickstartListen. ([0e0ab81](https://gitee.com/openharmony/kernel_liteos_a/commits/0e0ab81ff9474cffd5e60a8ee741840eac5d737b)), closes [#I3PSLZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PSLZ)
|
|
||||||
* Ctrl-C move out of LOS_MAGIC_KEY_ENABLE ([40f239a](https://gitee.com/openharmony/kernel_liteos_a/commits/40f239a7d4673dc740c853b1011b5072e48385b7))
|
|
||||||
* Delete useless 'exc interaction' macros and function declarations. ([d2f2679](https://gitee.com/openharmony/kernel_liteos_a/commits/d2f26790716c9f76589c4a7d6fa5518f9ccd743c)), closes [#I3SDKY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SDKY)
|
|
||||||
* dereference NULL point bug fix ([deaa564](https://gitee.com/openharmony/kernel_liteos_a/commits/deaa564a66b83c9fe19a37b8a061ec9064ece354))
|
|
||||||
* do not build toybox temporarily ([044f2c7](https://gitee.com/openharmony/kernel_liteos_a/commits/044f2c7c17c68e10aeccc3af0c222cfc722d194c))
|
|
||||||
* do not override existing libs ([8118408](https://gitee.com/openharmony/kernel_liteos_a/commits/8118408123e75f7f5a4ab9101e388be6bba0dcda))
|
|
||||||
* **doc:** 修复README_zh-HK.md的链接错误 ([f1b4c87](https://gitee.com/openharmony/kernel_liteos_a/commits/f1b4c87bc44650348504bc00b3f6f94491c341a0))
|
|
||||||
* fatfs memory leak ([fbfd71d](https://gitee.com/openharmony/kernel_liteos_a/commits/fbfd71dfe3b5555ef09e542d96a630dfba636daa))
|
|
||||||
* fix function name OsSchedSetIdleTaskSchedParam ([8f8c038](https://gitee.com/openharmony/kernel_liteos_a/commits/8f8c038b217d5ba2518413bfc1ba857587d47442))
|
|
||||||
* Fix kernel page fault exception handling causing system exception. ([a89fb57](https://gitee.com/openharmony/kernel_liteos_a/commits/a89fb57f5795236b93fd19ee2d7a059cae1b2b1b)), closes [#I3RAN4](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RAN4)
|
|
||||||
* fix length typo ([12d98b1](https://gitee.com/openharmony/kernel_liteos_a/commits/12d98b144b70e726d3fd31ddc9d17ed855d0ec1b))
|
|
||||||
* fix mq function by enable mq_notify api ([4427142](https://gitee.com/openharmony/kernel_liteos_a/commits/4427142d734df8f95f4599093392904abacc5c93))
|
|
||||||
* Fix quickstart codingstyle ([2e011b6](https://gitee.com/openharmony/kernel_liteos_a/commits/2e011b672f6b96ea7e0db066a07e3f9fb6ba5df3)), closes [#I3OPOM](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OPOM)
|
|
||||||
* fix stored typo ([d25560f](https://gitee.com/openharmony/kernel_liteos_a/commits/d25560f8ac3216670d198cbbb25891c394e0b3c2))
|
|
||||||
* fix syscall faccessat,fstatfs,fstatat & add 6 testcases ([aa1cd24](https://gitee.com/openharmony/kernel_liteos_a/commits/aa1cd245a5711e5b53c328b688da5ddc2e783d5f))
|
|
||||||
* fix the inappropriate errno in FatFs ([af61187](https://gitee.com/openharmony/kernel_liteos_a/commits/af61187587411dca38ff62e720451f08f19c1c82)), closes [#I3O8IF](https://gitee.com/openharmony/kernel_liteos_a/issues/I3O8IF)
|
|
||||||
* fix typo in quickstart ([3b2ff4b](https://gitee.com/openharmony/kernel_liteos_a/commits/3b2ff4b71fc5ae1dc74180c33fd66f69da0059d1)), closes [#I3M1S8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M1S8)
|
|
||||||
* Fix wrong judgment in los_trace.c to avoid null pointer access. ([4d863e9](https://gitee.com/openharmony/kernel_liteos_a/commits/4d863e985b6372f7895db57b602b662dba5cadd0)), closes [#I3RT9F](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RT9F)
|
|
||||||
* Identical condition 'ret<0', second condition is always false. :bug: ([1348809](https://gitee.com/openharmony/kernel_liteos_a/commits/1348809807548dd481286a55a6677a9169fcd705))
|
|
||||||
* init进程收到子进程退出信号后,调用fork重新拉起进程,会导致系统卡死 ([35a2f3a](https://gitee.com/openharmony/kernel_liteos_a/commits/35a2f3af33a5dba1e0ba36587efced8fead97223)), closes [#I41HOY](https://gitee.com/openharmony/kernel_liteos_a/issues/I41HOY)
|
|
||||||
* kernel crashed after rmdir the umounted folder ([ac0d083](https://gitee.com/openharmony/kernel_liteos_a/commits/ac0d083b1c89c4ad3fdaab0347d11f174d0185cb))
|
|
||||||
* kernel crashed when delete a umounted folder ([f305d1f](https://gitee.com/openharmony/kernel_liteos_a/commits/f305d1f702a770010125a0f4f0152ffefeeec5c4))
|
|
||||||
* kernel crashed when delete a umounted folder ([c6e9212](https://gitee.com/openharmony/kernel_liteos_a/commits/c6e921241b1cf26bcbfeea44e20f6b596512e259))
|
|
||||||
* **kernel_test:** 内核mem/shm冒烟用例重复运行失败 ([0676578](https://gitee.com/openharmony/kernel_liteos_a/commits/0676578aae09c101d79e7a276823e849df293e29)), closes [#I3TH4W](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TH4W)
|
|
||||||
* L1 toybox 命令功能实现 ([2ff44c4](https://gitee.com/openharmony/kernel_liteos_a/commits/2ff44c4938d2e66ce60e9497c505eb6e97efc8c2)), closes [#I41N2A](https://gitee.com/openharmony/third_party_toybox/issues/I41N2A)
|
|
||||||
* liteipc max data size too small ([4dc421e](https://gitee.com/openharmony/kernel_liteos_a/commits/4dc421e3decdaae60219d533c4a93dbc9334e35f))
|
|
||||||
* LiteOS_A BBOX Codex整改 ([6a5a032](https://gitee.com/openharmony/kernel_liteos_a/commits/6a5a0326d2b18ffacce5d38fb351530973c2f245)), closes [#I43RQU](https://gitee.com/openharmony/kernel_liteos_a/issues/I43RQU)
|
|
||||||
* Liteos-a创建的文件夹在Ubuntu中不可见 ([a9fc1e0](https://gitee.com/openharmony/kernel_liteos_a/commits/a9fc1e0e5d3e5eb8a34c568a8d147320a9afebe1)), closes [#I3XMY6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XMY6)
|
|
||||||
* lookup new vnode may cause parent vnode freeing ([902a11d](https://gitee.com/openharmony/kernel_liteos_a/commits/902a11de9a4b08e799820fb87942cb2171b9e095)), closes [#I3MYP4](https://gitee.com/openharmony/kernel_liteos_a/issues/I3MYP4)
|
|
||||||
* **mini:** fix compile error in mini liteos_a ([e13cb3b](https://gitee.com/openharmony/kernel_liteos_a/commits/e13cb3bcc4e74d4c49c31d290d686f99a4e81e3f))
|
|
||||||
* minimal compile ([ac8c2c6](https://gitee.com/openharmony/kernel_liteos_a/commits/ac8c2c6d5b9ede0e46b48212f0b3447605a613c4))
|
|
||||||
* misspell ([08980ea](https://gitee.com/openharmony/kernel_liteos_a/commits/08980eac3c249ec6a6717d8a04fb0be7716053a1))
|
|
||||||
* mkdir -p is more robust ([e38f9a9](https://gitee.com/openharmony/kernel_liteos_a/commits/e38f9a98c9d373db8381af707c5996d1fefef64e))
|
|
||||||
* mksh compile bug fix ([d8263b1](https://gitee.com/openharmony/kernel_liteos_a/commits/d8263b1e91d76706d52df321ef642c1c8297e8e4)), closes [#I3ZMR7](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZMR7)
|
|
||||||
* modify event API description ([937734b](https://gitee.com/openharmony/kernel_liteos_a/commits/937734b1e9f5fc52e0ac727549bd2e4b4c864e3c))
|
|
||||||
* move nuttx head file back ([4c8a86e](https://gitee.com/openharmony/kernel_liteos_a/commits/4c8a86ece7cafa8f74441bacc74c7788c0a1b780)), closes [#I4443Q](https://gitee.com/openharmony/kernel_liteos_a/issues/I4443Q)
|
|
||||||
* nanosleep 接口的rmtp参数被错误清零 ([9458de9](https://gitee.com/openharmony/kernel_liteos_a/commits/9458de9ac664cd75540c8b638b9a6caf82812fc8)), closes [#I41U0R](https://gitee.com/openharmony/kernel_liteos_a/issues/I41U0R)
|
|
||||||
* no exception information output, when the system is abnormal ([5bf4d1c](https://gitee.com/openharmony/kernel_liteos_a/commits/5bf4d1c7128e6718611bbec23cb4373bcb3bfe55))
|
|
||||||
* no exception information output, when the system is abnormal ([28aa777](https://gitee.com/openharmony/kernel_liteos_a/commits/28aa777191e7b41e4f1f346ab79f8688edc59c6d))
|
|
||||||
* no exception information output, when the system is abnormal after holding ([0ed8adf](https://gitee.com/openharmony/kernel_liteos_a/commits/0ed8adfe3ae59672e284331d40ef3b9e0bc8e094))
|
|
||||||
* Optimiz macro of quickstart cmd ([cb140a4](https://gitee.com/openharmony/kernel_liteos_a/commits/cb140a4442c02dd0b1925cc58deecbf4da36dcea)), closes [#I3OSYT](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OSYT)
|
|
||||||
* Optimize /dev/quickstart permissions. ([4e24b57](https://gitee.com/openharmony/kernel_liteos_a/commits/4e24b572897c33e1b2723122c0e13d3931096bae)), closes [#I3OYUQ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OYUQ)
|
|
||||||
* Optimize quickstart node implementation ([4abd2e0](https://gitee.com/openharmony/kernel_liteos_a/commits/4abd2e0247b14718bb21756fb446142140d30a88)), closes [#I3R8O8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3R8O8)
|
|
||||||
* OsGerCurrSchedTimeCycle 函数存在拼写错误 ([53ced1a](https://gitee.com/openharmony/kernel_liteos_a/commits/53ced1a85edc3d06230225ced3916772f432243f)), closes [#I446CX](https://gitee.com/openharmony/kernel_liteos_a/issues/I446CX)
|
|
||||||
* OsGetArgsAddr声明所在头文件不正确 ([14bd753](https://gitee.com/openharmony/kernel_liteos_a/commits/14bd753aa8beb49af887c8d0aedaefa446409760)), closes [#I41MWM](https://gitee.com/openharmony/kernel_liteos_a/issues/I41MWM)
|
|
||||||
* parent point of vnode found by VfsHashGet should be updated ([f32caa5](https://gitee.com/openharmony/kernel_liteos_a/commits/f32caa52c67eca20d58676be4e0439acbb4c5ac3)), closes [#I3NNFA](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NNFA)
|
|
||||||
* PathCacheFree try to free name field in struct PathCache ([9f47faf](https://gitee.com/openharmony/kernel_liteos_a/commits/9f47faff732609cf2249f104b94ed55f3ef133bb)), closes [#I3NTH9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NTH9)
|
|
||||||
* PathCacheMemoryDump miscalculate the RAM usage of PathCache ([87da7c7](https://gitee.com/openharmony/kernel_liteos_a/commits/87da7c794c9bc8e311ae5242820fbf8aefd8d558)), closes [#I3OBXY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OBXY)
|
|
||||||
* Provide a separate configuration macro for boot environment in RAM. ([e28e06b](https://gitee.com/openharmony/kernel_liteos_a/commits/e28e06b08f5b28091153e584cb9d93014a9f2b10))
|
|
||||||
* Provide a separate configuration macro for boot environment in RAM. ([bc67393](https://gitee.com/openharmony/kernel_liteos_a/commits/bc67393a67f714e0a8165b6103e53699c676341c))
|
|
||||||
* Provide a separate configuration macro for boot environment in RAM. ([f13b90e](https://gitee.com/openharmony/kernel_liteos_a/commits/f13b90e4308ba3d60683799b9ce62fb3705ac277)), closes [#I3OADR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OADR)
|
|
||||||
* race condition in liteipc ([7e2aef2](https://gitee.com/openharmony/kernel_liteos_a/commits/7e2aef2480b15f71ee0e089cef4443f578e03dbb)), closes [#I3PW5Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PW5Y)
|
|
||||||
* rebuild mksh depends on rebuild.sh script ([bef4ab9](https://gitee.com/openharmony/kernel_liteos_a/commits/bef4ab9835dec865898c74337dfb7154718b94aa))
|
|
||||||
* remove redundant headfile ([73a7777](https://gitee.com/openharmony/kernel_liteos_a/commits/73a777777e1b834192f6bb2c0e8bd03c69765c11)), closes [#I3RTNR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RTNR)
|
|
||||||
* Remove redundant invalid codes ([fe05df4](https://gitee.com/openharmony/kernel_liteos_a/commits/fe05df40ae710632adb1bd54fb04ad4a8e0c1429)), closes [#I3R70T](https://gitee.com/openharmony/kernel_liteos_a/issues/I3R70T)
|
|
||||||
* Show conflicting files for git apply or patch -p command ([35f7957](https://gitee.com/openharmony/kernel_liteos_a/commits/35f79579758644cbcac6005f894be21f34f42b99)), closes [#I3NNUS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NNUS)
|
|
||||||
* SIOCGIFCONF ioctl malloc size error in kernel ([bfd27e7](https://gitee.com/openharmony/kernel_liteos_a/commits/bfd27e78b259eedbd4c30548e80c9b4d789d26e1)), closes [#I3XEZ3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XEZ3)
|
|
||||||
* smp启动代码解耦及内存映射关系解耦 ([3bb3173](https://gitee.com/openharmony/kernel_liteos_a/commits/3bb3173604dc4dea09301f61da402974185dc112)), closes [#I41P8Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I41P8Y)
|
|
||||||
* some branch in format does not release the vnode mutex properly ([9b2b700](https://gitee.com/openharmony/kernel_liteos_a/commits/9b2b700fa0e3a8edadb38f09c917a3e3f013347f)), closes [#I3OFAY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OFAY)
|
|
||||||
* Sortlink, the response time to insert the node should be inserted into the back of the existing node. ([1323874](https://gitee.com/openharmony/kernel_liteos_a/commits/1323874389030c55fb053fead12ca1c6654d8851)), closes [#I3PSJ8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PSJ8)
|
|
||||||
* statfs can't get f_bfree and f_bavail of a FAT12/FAT16 partition ([9503c4a](https://gitee.com/openharmony/kernel_liteos_a/commits/9503c4a9fc30aaa8ea2031d4fb794436f3c98055)), closes [#I3Q0VS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Q0VS)
|
|
||||||
* SysOpenat返回值应该为进程fd,而非系统全局fd。 ([3457c0b](https://gitee.com/openharmony/kernel_liteos_a/commits/3457c0b11debb2cf5d4abe325c2510a750654512)), closes [#I3TNAK](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TNAK)
|
|
||||||
* the total used vnode number not increased after unlink a file under ([4f514a1](https://gitee.com/openharmony/kernel_liteos_a/commits/4f514a16af5a3f3b9c4ea182de774297afb17f66)), closes [#I3TS1Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TS1Y)
|
|
||||||
* tick 动态化计算优化,消除中断执行时间对系统总体时间的影响,保证软件定时器的响应精度。 ([8df3e8c](https://gitee.com/openharmony/kernel_liteos_a/commits/8df3e8c96515a1907455a9bbc61426f43c803c62)), closes [#I43UQJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I43UQJ)
|
|
||||||
* toybox update ([c3245b3](https://gitee.com/openharmony/kernel_liteos_a/commits/c3245b3ce317eb58c8dad58fdfc7f094b9b9794b))
|
|
||||||
* toybox命令升级 ([76f45b3](https://gitee.com/openharmony/kernel_liteos_a/commits/76f45b3fb2783d1cab45a6ba08787c29dfa2c948)), closes [#I41N2A](https://gitee.com/openharmony/third_party_toybox/issues/I41N2A)
|
|
||||||
* update LOS_DL_LIST_IS_END comment ([900269b](https://gitee.com/openharmony/kernel_liteos_a/commits/900269bd4645252d898f6d3b73de01d8548c960c))
|
|
||||||
* userfs分区的起始地址与大小改为通过bootargs配置 ([2e2b142](https://gitee.com/openharmony/kernel_liteos_a/commits/2e2b14205f4b81c7483ab42d62f144487097e9a4)), closes [#I3XNEY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XNEY)
|
|
||||||
* VnodeInUseIter and VnodeFreeAll used to be recursive ([5f6656c](https://gitee.com/openharmony/kernel_liteos_a/commits/5f6656cb36a2ffb0b290aeb53981aba7501e80b2)), closes [#I3NN3U](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NN3U)
|
|
||||||
* 以g_sysSchedStartTime是否为0判断时间轴是否生效存在极限场景导致调度时间不生效 ([67ac8c4](https://gitee.com/openharmony/kernel_liteos_a/commits/67ac8c4c586adc371ece56700fd42371ca7fc885)), closes [#I45HP5](https://gitee.com/openharmony/kernel_liteos_m/issues/I45HP5)
|
|
||||||
* 修复FATFS中不同内部接口不支持FAT12/FAT16 FAT表结束标志 ([33f5c70](https://gitee.com/openharmony/kernel_liteos_a/commits/33f5c70e6c8781758d2bfde0f60ca3d6ec7d543f)), closes [#I409R6](https://gitee.com/openharmony/kernel_liteos_a/issues/I409R6)
|
|
||||||
* 修复kill进程时,因liteipc阻塞的进程概率无法退出问题 ([7de43bb](https://gitee.com/openharmony/kernel_liteos_a/commits/7de43bb004a12f926550f0b36ca3c2fa610feb27)), closes [#I3XX7K](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XX7K)
|
|
||||||
* 修复MagicKey数组越界访问 ([071cd62](https://gitee.com/openharmony/kernel_liteos_a/commits/071cd6268aeaaef702387dacaf4ef1ffbb7618fc)), closes [#I3U4N9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3U4N9)
|
|
||||||
* 修复mprotect修改地址区间的权限后,相应的区间名丢失问题 ([e425187](https://gitee.com/openharmony/kernel_liteos_a/commits/e425187d176a5e09bc5253faefc9cfc8454da0a3)), closes [#I43R40](https://gitee.com/openharmony/kernel_liteos_a/issues/I43R40)
|
|
||||||
* 修复mq_close关闭后仍然占用文件描述符的问题 ([590c7b4](https://gitee.com/openharmony/kernel_liteos_a/commits/590c7b4e22662781d05ad035a785e985d573ec33)), closes [#I3ZQDA](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZQDA)
|
|
||||||
* 修复mqueue问题 ([26ee8b8](https://gitee.com/openharmony/kernel_liteos_a/commits/26ee8b836e346e641de4ecd72284f5d377bca6f8)), closes [#I43P4T](https://gitee.com/openharmony/kernel_liteos_a/issues/I43P4T)
|
|
||||||
* 修复sigwait等待到的信号值与获取的siginfo中的值不一致 ([ed7defb](https://gitee.com/openharmony/kernel_liteos_a/commits/ed7defbd439c345a07159d40eb04433afd530004)), closes [#I3M12H](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M12H)
|
|
||||||
* 修复了LOSCFG_FS_FAT_VIRTUAL_PARTITION宏开关错误作用域引起的功能错误 ([acda419](https://gitee.com/openharmony/kernel_liteos_a/commits/acda419a2d773ea890052a16ee66b4872f941fbb)), closes [#I3W1IW](https://gitee.com/openharmony/kernel_liteos_a/issues/I3W1IW)
|
|
||||||
* 修复了内核的VFAT测试用例 ([a8384b5](https://gitee.com/openharmony/kernel_liteos_a/commits/a8384b5db2274d50a350910d7cfd3fc36b4f4103)), closes [#I3XF3R](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XF3R)
|
|
||||||
* 修复内核access chmod chown接口 ([56a95b9](https://gitee.com/openharmony/kernel_liteos_a/commits/56a95b9ec903f815f9199ac65ca318e00a83b2ed)), closes [#I3Z5L6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z5L6)
|
|
||||||
* 修复内核c库的makefile中被优化函数替换的高频函数依然参与了编译的问题 ([6f6dc4f](https://gitee.com/openharmony/kernel_liteos_a/commits/6f6dc4f24c8ab05a6d42da46a9fa41d74a477bd7)), closes [#I3XGM8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XGM8)
|
|
||||||
* 修复内核堆完整性检查逻辑中访问非法指针导致系统异常问题。 ([30f5ab8](https://gitee.com/openharmony/kernel_liteos_a/commits/30f5ab89b72d45f596b15af82a8e8e01add7977d)), closes [#I3VJZT](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VJZT)
|
|
||||||
* 修复启动框架debug模式下-Werror=maybe-uninitialized告警以及符号链接不进镜像的隐患 ([4c02415](https://gitee.com/openharmony/kernel_liteos_a/commits/4c024159a9600745863e49ee955308470a5b657b)), closes [#I3T5HR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T5HR)
|
|
||||||
* 修复开机概率挂死 ([2e82c36](https://gitee.com/openharmony/kernel_liteos_a/commits/2e82c361f73b2119613c3571c48faae8ec41d4eb)), closes [#I3SWY2](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SWY2)
|
|
||||||
* 修复文档链接失效问题 ([42a3a6c](https://gitee.com/openharmony/kernel_liteos_a/commits/42a3a6c51bfca4ade8ce94084ea2f8eb1c86a137)), closes [#I45297](https://gitee.com/openharmony/kernel_liteos_a/issues/I45297)
|
|
||||||
* 修改/proc/mounts显示格式 ([6860246](https://gitee.com/openharmony/kernel_liteos_a/commits/6860246cfaac6f540665e79bbc4c3d54c419b092)), closes [#I3XGCS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XGCS)
|
|
||||||
* 修改clock_gettime接口适配posix标准测试用例011输入clk_id错误时返回值ESRCH为EINVAL. ([f8cf6e6](https://gitee.com/openharmony/kernel_liteos_a/commits/f8cf6e6439ee017fe8e0d4ecfc9949c28fa6775f)), closes [#I3OUHI](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OUHI)
|
|
||||||
* 修改DoNanoSleep 以纳秒为单位 ([6917e08](https://gitee.com/openharmony/kernel_liteos_a/commits/6917e08431689ccbd5a30e9a39b67016ffb64d0a)), closes [#I3Z9DP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z9DP)
|
|
||||||
* 修改某些平台保存bbox日志失败的问题 ([8f6a1dd](https://gitee.com/openharmony/kernel_liteos_a/commits/8f6a1dd33c59164070e8d2fb5abbd3e76ef8ac8e)), closes [#I41UTP](https://gitee.com/openharmony/kernel_liteos_a/issues/I41UTP)
|
|
||||||
* 修改默认窗口宽度到400 ([09c491c](https://gitee.com/openharmony/kernel_liteos_a/commits/09c491ca1fd6d3110eafb0d07e45b25bdc3bd5d0)), closes [#I40LQX](https://gitee.com/openharmony/kernel_liteos_a/issues/I40LQX)
|
|
||||||
* 关闭jffs和fat后,rootfs配置也被相应关闭,导致nand介质的rootfs不可用。 ([0ea476b](https://gitee.com/openharmony/kernel_liteos_a/commits/0ea476b9741fabd3c255c2770688f587920cf509)), closes [#I3SBYN](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SBYN)
|
|
||||||
* 内核态在console初始化完成后,使用printf无法正常打印 ([44ce696](https://gitee.com/openharmony/kernel_liteos_a/commits/44ce6969048c2e252f3f9d66fa485c77bdab8ae7)), closes [#I3UG00](https://gitee.com/openharmony/kernel_liteos_a/issues/I3UG00)
|
|
||||||
* 去掉冗余的strip操作 ([7819d15](https://gitee.com/openharmony/kernel_liteos_a/commits/7819d15b3619681ae37a1349a6bec2440c829ae9)), closes [#I43767](https://gitee.com/openharmony/kernel_liteos_a/issues/I43767)
|
|
||||||
* 合并进程栈两个地址连续的region ([42f374d](https://gitee.com/openharmony/kernel_liteos_a/commits/42f374dd7a353f1c8227e92fa92827c1c7b32424)), closes [#I43QYJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I43QYJ)
|
|
||||||
* 在内核提示No idle TCB时,增加打印当前系统任务信息,以方便问题定位。 ([11a9b00](https://gitee.com/openharmony/kernel_liteos_a/commits/11a9b00d43a6dbe9fba9f6eb07d78a9d226c28f8)), closes [#I434UC](https://gitee.com/openharmony/kernel_liteos_a/issues/I434UC)
|
|
||||||
* 增加表头,内容以制表符分栏。 ([e9ad6b7](https://gitee.com/openharmony/kernel_liteos_a/commits/e9ad6b71c3b1136414672cd21b339ded7a02dfb9)), closes [#I3W2M9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3W2M9)
|
|
||||||
* 将用户态内存调测解析脚本移至tools目录下 ([85b4cb7](https://gitee.com/openharmony/kernel_liteos_a/commits/85b4cb7a67b717984d3ebf68115c7139cc61d690)), closes [#I42T9A](https://gitee.com/openharmony/kernel_liteos_a/issues/I42T9A)
|
|
||||||
* 恢复了FATFS设置卷标的功能 ([9515d53](https://gitee.com/openharmony/kernel_liteos_a/commits/9515d53dccc9a6458bfbaf8e15143928f05cb660)), closes [#I3Y5G8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Y5G8)
|
|
||||||
* 解决kill进程时无法保证进程的已持有的内核资源合理释放. ([cf89f01](https://gitee.com/openharmony/kernel_liteos_a/commits/cf89f016e93f28f8d72e6f5de08640d08a155908)), closes [#I3S0N0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3S0N0)
|
|
||||||
* 解决不同环境下计算的rootfs的size偏小,导致mcopy造成的disk full错误 ([c54879b](https://gitee.com/openharmony/kernel_liteos_a/commits/c54879b54875abece53b1f64072cfacbd2e1970e)), closes [#I3IA06](https://gitee.com/openharmony/kernel_liteos_a/issues/I3IA06)
|
|
||||||
* 设置qemu默认userfs大小/修改qemu驱动目录 ([1d952a2](https://gitee.com/openharmony/kernel_liteos_a/commits/1d952a254a6e7ec2f70f7112eb27355cfd01ba4d)), closes [#I3XW96](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XW96)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* active mksh & toybox ([cacb4f0](https://gitee.com/openharmony/kernel_liteos_a/commits/cacb4f0103ecb2d1b7af54d84957f88d3e9443d2)), closes [#I3VEOG](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VEOG)
|
|
||||||
* Add /dev/quickstart to support synchronous communication between processes in user mode startup. ([46b63f7](https://gitee.com/openharmony/kernel_liteos_a/commits/46b63f71537789743ed2f3f337c1809ee4900d71)), closes [#I3OHO5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OHO5)
|
|
||||||
* add /proc/fd file to dump the pid/fd/path information ([600dded](https://gitee.com/openharmony/kernel_liteos_a/commits/600dded31e80df275ed08c326c0ce3d1857d8dd8)), closes [#I3WB5U](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WB5U)
|
|
||||||
* add /proc/fs_cache to display cache info ([231cb6b](https://gitee.com/openharmony/kernel_liteos_a/commits/231cb6be27380948bc48136ae2e02c28450f47a8)), closes [#I3WWBD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WWBD)
|
|
||||||
* add /proc/fs_cache to display cache info ([53c6d96](https://gitee.com/openharmony/kernel_liteos_a/commits/53c6d96c6f97cb006216769f8b73f50fba3bc325)), closes [#I3WESD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WESD)
|
|
||||||
* add and fix some syscall ([ce849f2](https://gitee.com/openharmony/kernel_liteos_a/commits/ce849f2145e1569517c5244c9ffcaebed53f3a66))
|
|
||||||
* add blackbox for liteos_a ([a195aac](https://gitee.com/openharmony/kernel_liteos_a/commits/a195aac9fb60b0163f9eebb29084287d226bd14c)), closes [#I406NP](https://gitee.com/openharmony/kernel_liteos_a/issues/I406NP)
|
|
||||||
* add blackbox for liteos_a ([425975e](https://gitee.com/openharmony/kernel_liteos_a/commits/425975e4811023e31a520979c20ea2562224d9d0))
|
|
||||||
* add clear cache cmd to /proc/fs_cache ([3d1cf68](https://gitee.com/openharmony/kernel_liteos_a/commits/3d1cf683f37a6f75e9db2ce1f11ec93159b77663)), closes [#I3XLPH](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XLPH)
|
|
||||||
* add liteos patch ability ([98ca844](https://gitee.com/openharmony/kernel_liteos_a/commits/98ca8441fe75ee1c3318a6a09376fd72f5a51350))
|
|
||||||
* add support for gn build system ([a8805a6](https://gitee.com/openharmony/kernel_liteos_a/commits/a8805a65aab9109b915364fccf36c8328f636e48))
|
|
||||||
* add uid/gid for ProcFs ([6780659](https://gitee.com/openharmony/kernel_liteos_a/commits/67806596a3c0df9a54893d8c74ebe9da98d7fb06)), closes [#I3WGVP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WGVP)
|
|
||||||
* A核proc文件系统在echo模式下新增write的功能 ([f10dd7c](https://gitee.com/openharmony/kernel_liteos_a/commits/f10dd7c135d37a5fb0d78610d5ece5807d01eb1f)), closes [#I3T6MZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T6MZ)
|
|
||||||
* build OHOS_Image from kernel ([abf4d8f](https://gitee.com/openharmony/kernel_liteos_a/commits/abf4d8fb252631aca9d46211762880a23be2a0b1))
|
|
||||||
* **build:** make liteos_config_file available as gn argument ([f9a9077](https://gitee.com/openharmony/kernel_liteos_a/commits/f9a907772f506ca7e2d84e96d4d17cffc7dae50f))
|
|
||||||
* **build:** 使用xts -notest选项时,内核用例不参与编译构建和用例编译配置方式调整 ([9bdf716](https://gitee.com/openharmony/kernel_liteos_a/commits/9bdf716407c125c9877b6f49c2133112c18cdabc))
|
|
||||||
* don't apply module_swith on configs of config ([f3beb4b](https://gitee.com/openharmony/kernel_liteos_a/commits/f3beb4b273c9a76fbfaffe57302f27d2a74cd2ba))
|
|
||||||
* enable gn build for toybox and mksh ([c54bfa1](https://gitee.com/openharmony/kernel_liteos_a/commits/c54bfa16e3907482c252e9738192df869c63326e))
|
|
||||||
* fatfs支持符号链接功能 ([e50cf0b](https://gitee.com/openharmony/kernel_liteos_a/commits/e50cf0be6f6d118022b6d79c5177aece574ba150)), closes [#I3V8D1](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V8D1)
|
|
||||||
* **file system:** add memory-based romfs ([c4595d2](https://gitee.com/openharmony/kernel_liteos_a/commits/c4595d25042b188570d991a815009764c37f3cb3)), closes [#I3S0CP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3S0CP)
|
|
||||||
* introduce mksh toybox to rootfs ([41c7689](https://gitee.com/openharmony/kernel_liteos_a/commits/41c7689dfa49c52fb15705ce15ef22a278fbf2ef))
|
|
||||||
* L0-L1 支持Trace ([dc9ec68](https://gitee.com/openharmony/kernel_liteos_a/commits/dc9ec6856fe14aa604f037f55f17a3ba2bafb098)), closes [#I46WA0](https://gitee.com/openharmony/kernel_liteos_a/issues/I46WA0)
|
|
||||||
* L1支持低功耗投票框架 ([21d8ac8](https://gitee.com/openharmony/kernel_liteos_a/commits/21d8ac8752469f6e0dc2d50d28b75421f665385a)), closes [#I3VS5N](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VS5N)
|
|
||||||
* **libc:** upgrade optimized-routines to v21.02 ([1ec8d5a](https://gitee.com/openharmony/kernel_liteos_a/commits/1ec8d5a454658e95c4acb821d0878f357f4e82ad))
|
|
||||||
* **make:** optimize makefiles and remove some unused files ([0e26094](https://gitee.com/openharmony/kernel_liteos_a/commits/0e260949c962158a263d4b0ad45fe9f6843d6e30))
|
|
||||||
* Open macro for ADC moudule ([c71ec9d](https://gitee.com/openharmony/kernel_liteos_a/commits/c71ec9d7e8574078a9dc2a8463f3141cca3d625a))
|
|
||||||
* **QEMU_ARM_VIRT_CA7:** 使能FAT文件系统编译选项 ([49856dc](https://gitee.com/openharmony/kernel_liteos_a/commits/49856dc1e0de1c5e92346c83eda641dfb1bb16be))
|
|
||||||
* support .mkshrc ([51a50c9](https://gitee.com/openharmony/kernel_liteos_a/commits/51a50c95b4cd47b6931523926b728d1c0ff8988b)), closes [#I3Y5KE](https://gitee.com/openharmony/third_party_mksh/issues/I3Y5KE)
|
|
||||||
* support link/symlink/readlink ([6eddc86](https://gitee.com/openharmony/kernel_liteos_a/commits/6eddc869d349be59860bfd84ff10b7579a9b00a9)), closes [#I3Q0OD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Q0OD)
|
|
||||||
* support toybox in qemu ([5618319](https://gitee.com/openharmony/kernel_liteos_a/commits/561831928bb1ad1871b2d60d2bba2d67488cea5f)), closes [#I3V17D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V17D)
|
|
||||||
* timer_create支持以SIGEV_THREAD方式创建定时器 ([e5f6bf0](https://gitee.com/openharmony/kernel_liteos_a/commits/e5f6bf05567c2d193f3746caca502199e7b81e92)), closes [#I3SRFI](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SRFI)
|
|
||||||
* using kconfiglib instead of kconfig ([8784694](https://gitee.com/openharmony/kernel_liteos_a/commits/878469468647a19f704e7ee2af696b0ba8ab775a))
|
|
||||||
* vfs support sdcard hotplug ([2db80ec](https://gitee.com/openharmony/kernel_liteos_a/commits/2db80ecb389176b53c77807567895470bb180a06)), closes [#I44WH1](https://gitee.com/openharmony/kernel_liteos_a/issues/I44WH1)
|
|
||||||
* **vfs:** vfs支持FD_CLOEXEC标记 ([27dca4d](https://gitee.com/openharmony/kernel_liteos_a/commits/27dca4d857ef8de6b4bb9302e0dd435be7e3284f)), closes [#I3U81W](https://gitee.com/openharmony/kernel_liteos_a/issues/I3U81W)
|
|
||||||
* 删除zpfs冗余代码 ([3393479](https://gitee.com/openharmony/kernel_liteos_a/commits/3393479c52f4a9dfe2394bb32beb4b98fca8e171))
|
|
||||||
* 基于汇编实现内核对用户态内存清零的功能 ([9db3407](https://gitee.com/openharmony/kernel_liteos_a/commits/9db3407589bb0b2d4a5772faac3130032bc0b8a9)), closes [#I3XXT0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XXT0)
|
|
||||||
* 增加mount的MS_RDONLY标志的支持 ([8729f6e](https://gitee.com/openharmony/kernel_liteos_a/commits/8729f6ee57ea57bc664d076ff112c8726fedded9)), closes [#I3Z1W6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z1W6)
|
|
||||||
* 支持killpg和waitid ([dc3cc09](https://gitee.com/openharmony/kernel_liteos_a/commits/dc3cc094a75c6da65d87522930afea06106d3933))
|
|
||||||
* 新增toybox reboot命令 ([e567a10](https://gitee.com/openharmony/kernel_liteos_a/commits/e567a10d021c3e0fe02d6911dbe8687255c67ffa)), closes [#I3YQ7S](https://gitee.com/openharmony/third_party_toybox/issues/I3YQ7S)
|
|
||||||
* 给开发者提供系统信息导出Hidumper工具。 ([cb17fa5](https://gitee.com/openharmony/kernel_liteos_a/commits/cb17fa50ed28e6e8f59b7d68ede13c759b983311))
|
|
||||||
* 自研shell命令回补 ([7bc68f4](https://gitee.com/openharmony/kernel_liteos_a/commits/7bc68f454ff5fbf415712c9b8479b8c832f68417)), closes [#I44U0H](https://gitee.com/openharmony/third_party_toybox/issues/I44U0H)
|
|
||||||
|
|
||||||
|
|
||||||
### Performance Improvements
|
|
||||||
|
|
||||||
* assign '-1' to uninitialized variable: ret ([e0a27ba](https://gitee.com/openharmony/kernel_liteos_a/commits/e0a27badde20868cf3a5b4a44305b90af00e4f3f))
|
|
||||||
|
|
||||||
|
|
||||||
### Reverts
|
|
||||||
|
|
||||||
* Revert "fix: 修改默认窗口宽度到400" ([1878849](https://gitee.com/openharmony/kernel_liteos_a/commits/187884937cd087e39a28c033c41033163d6b4766)), closes [#I42X9V](https://gitee.com/openharmony/kernel_liteos_a/issues/I42X9V)
|
|
||||||
|
|
||||||
|
|
||||||
### BREAKING CHANGES
|
|
||||||
|
|
||||||
* 1.新增一系列trace的对外API,位于los_trace.h中.
|
|
||||||
LOS_TRACE_EASY简易插桩
|
|
||||||
LOS_TRACE标准插桩
|
|
||||||
LOS_TraceInit配置Trace缓冲区的地址和大小
|
|
||||||
LOS_TraceStart开启事件记录
|
|
||||||
LOS_TraceStop停止事件记录
|
|
||||||
LOS_TraceRecordDump输出Trace缓冲区数据
|
|
||||||
LOS_TraceRecordGet获取Trace缓冲区的首地址
|
|
||||||
LOS_TraceReset清除Trace缓冲区中的事件
|
|
||||||
LOS_TraceEventMaskSet设置事件掩码,仅记录某些模块的事件
|
|
||||||
LOS_TraceHwiFilterHookReg注册过滤特定中断号事件的钩子函数
|
|
||||||
* **vfs:** 执行exec类函数后,进程拥有的文件描述符情况发生变化:修改前,默认关闭所有的进程文件描述符,0,1,2重新打开;修改后,除非文件描述符拥有FD_CLOEXEC标记,否则该描述符不会被关闭。
|
|
||||||
|
|
||||||
|
|
||||||
|
|
7
Kconfig
7
Kconfig
|
@ -235,12 +235,7 @@ config SCHED_DEBUG
|
||||||
depends on DEBUG_VERSION
|
depends on DEBUG_VERSION
|
||||||
help
|
help
|
||||||
If you wish to build LiteOS with support for sched debug.
|
If you wish to build LiteOS with support for sched debug.
|
||||||
config SCHED_EDF_DEBUG
|
|
||||||
bool "Enable sched EDF debug Feature"
|
|
||||||
default n
|
|
||||||
depends on SCHED_DEBUG
|
|
||||||
help
|
|
||||||
If you wish to build LiteOS with support for sched debug.
|
|
||||||
config USER_INIT_DEBUG
|
config USER_INIT_DEBUG
|
||||||
bool "Enable user init Debug"
|
bool "Enable user init Debug"
|
||||||
default n
|
default n
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -82,6 +82,9 @@ endif
|
||||||
ifeq ($(LOSCFG_STORAGE_SPINAND), y)
|
ifeq ($(LOSCFG_STORAGE_SPINAND), y)
|
||||||
FSTYPE = yaffs2
|
FSTYPE = yaffs2
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
||||||
|
FSTYPE = jffs2
|
||||||
|
endif
|
||||||
ROOTFS_DIR = $(OUT)/rootfs
|
ROOTFS_DIR = $(OUT)/rootfs
|
||||||
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
||||||
|
|
||||||
|
|
2
OAT.xml
2
OAT.xml
|
@ -65,8 +65,6 @@
|
||||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||||
</filefilter>
|
</filefilter>
|
||||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||||
<filteritem type="filepath" name="figures/architecture-of-the-openharmony-liteos-cortex-a-kernel.png" desc="architecture-of-the-openharmony-liteos-cortex-a-kernel"/>
|
|
||||||
<filteritem type="filepath" name="figures/OpenHarmony-LiteOS-A内核架构图.png" desc="LiteOS-A内核架构图"/>
|
|
||||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||||
|
|
31
README.md
31
README.md
|
@ -4,10 +4,10 @@
|
||||||
- [Directory Structure](#section161941989596)
|
- [Directory Structure](#section161941989596)
|
||||||
- [Constraints](#section119744591305)
|
- [Constraints](#section119744591305)
|
||||||
- [Usage](#section741617511812)
|
- [Usage](#section741617511812)
|
||||||
- [Preparations](#section1579912573329)
|
- [Preparations](#section1579912573329)
|
||||||
- [Source Code Acquisition](#section11443189655)
|
- [Source Code Acquisition](#section11443189655)
|
||||||
- [Compilation and Building](#section2081013992812)
|
- [Compilation and Building](#section2081013992812)
|
||||||
- [Contribution](#section1371123476304)
|
|
||||||
- [Repositories Involved](#section1371113476307)
|
- [Repositories Involved](#section1371113476307)
|
||||||
|
|
||||||
## Introduction<a name="section11660541593"></a>
|
## Introduction<a name="section11660541593"></a>
|
||||||
|
@ -67,33 +67,24 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
|
||||||
|
|
||||||
## Usage<a name="section741617511812"></a>
|
## Usage<a name="section741617511812"></a>
|
||||||
|
|
||||||
OpenHarmony LiteOS Cortex-A supports the [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-appendix-hi3516.md). You can develop and run your applications based on this development board.
|
OpenHarmony LiteOS Cortex-A supports the [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on this development board.
|
||||||
|
|
||||||
### Preparations<a name="section1579912573329"></a>
|
### Preparations<a name="section1579912573329"></a>
|
||||||
|
|
||||||
You need to set up the compilation environment on Ubuntu.
|
You need to set up the compilation environment on Linux.
|
||||||
|
|
||||||
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/Readme-EN.md)
|
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup.md)
|
||||||
|
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md).
|
||||||
|
|
||||||
### Source Code Acquisition<a name="section11443189655"></a>
|
### Source Code Acquisition<a name="section11443189655"></a>
|
||||||
|
|
||||||
Download and decompress a set of source code on a Ubuntu server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
|
Download and decompress a set of source code on a Linux server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
|
||||||
|
|
||||||
### Compilation and Building<a name="section2081013992812"></a>
|
### Compilation and Building<a name="section2081013992812"></a>
|
||||||
|
|
||||||
For details about how to develop the first application, see: [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)
|
For details about how to develop the first application, see:
|
||||||
|
|
||||||
For compilation, please refer to the [compilation instructions](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-pkg-3516-build.md).
|
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)
|
||||||
|
|
||||||
## Contribution<a name="section1371123476304"></a>
|
|
||||||
|
|
||||||
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution-guide.md)
|
|
||||||
|
|
||||||
[Commit message spec](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
|
|
||||||
|
|
||||||
[C&C++ Secure Coding Guide](https://gitee.com/openharmony/docs/blob/master/en/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
|
|
||||||
|
|
||||||
[LiteOS-A Kernel Coding Style Guide](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
|
|
||||||
|
|
||||||
## Repositories Involved<a name="section1371113476307"></a>
|
## Repositories Involved<a name="section1371113476307"></a>
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
- [目錄](#section161941989596)
|
- [目錄](#section161941989596)
|
||||||
- [約束](#section119744591305)
|
- [約束](#section119744591305)
|
||||||
- [使用說明](#section741617511812)
|
- [使用說明](#section741617511812)
|
||||||
- [準備](#section1579912573329)
|
- [準備](#section1579912573329)
|
||||||
- [獲取源碼](#section11443189655)
|
- [獲取源碼](#section11443189655)
|
||||||
- [編譯構建](#section2081013992812)
|
- [編譯構建](#section2081013992812)
|
||||||
- [貢獻](#section1371123476304)
|
|
||||||
- [相關倉](#section1371113476307)
|
- [相關倉](#section1371113476307)
|
||||||
|
|
||||||
## 簡介<a name="section11660541593"></a>
|
## 簡介<a name="section11660541593"></a>
|
||||||
|
@ -67,33 +67,24 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
|
||||||
|
|
||||||
## 使用說明<a name="section741617511812"></a>
|
## 使用說明<a name="section741617511812"></a>
|
||||||
|
|
||||||
OpenHarmony LiteOS-A內核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md)單板,開發者可基於此單板開發運行自己的應用程序。
|
OpenHarmony LiteOS-A內核支持Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md))單板,開發者可基於此單板開發運行自己的應用程序。
|
||||||
|
|
||||||
### 準備<a name="section1579912573329"></a>
|
### 準備<a name="section1579912573329"></a>
|
||||||
|
|
||||||
開發者需要在Ubuntu上搭建編譯環境:
|
開發者需要在Linux上搭建編譯環境:
|
||||||
|
|
||||||
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md);
|
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
|
||||||
|
- Hi3516DV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||||
|
|
||||||
### 獲取源碼<a name="section11443189655"></a>
|
### 獲取源碼<a name="section11443189655"></a>
|
||||||
|
|
||||||
在Ubuntu服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
在Linux服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
||||||
|
|
||||||
### 編譯構建<a name="section2081013992812"></a>
|
### 編譯構建<a name="section2081013992812"></a>
|
||||||
|
|
||||||
開發者開發第一個應用程序可參考:[helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)。
|
開發者開發第一個應用程序可參考:
|
||||||
|
|
||||||
編譯可以參考:[編譯指導](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md)
|
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||||
|
|
||||||
## 貢獻<a name="section1371123476304"></a>
|
|
||||||
|
|
||||||
[如何貢獻](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
|
|
||||||
|
|
||||||
[Commit message規範](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
|
|
||||||
|
|
||||||
[OpenHarmony C&C++ 安全編程指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
|
|
||||||
|
|
||||||
[LiteOS-A 內核編碼規範指南](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
|
|
||||||
|
|
||||||
## 相關倉<a name="section1371113476307"></a>
|
## 相關倉<a name="section1371113476307"></a>
|
||||||
|
|
||||||
|
|
33
README_zh.md
33
README_zh.md
|
@ -4,10 +4,10 @@
|
||||||
- [目录](#section161941989596)
|
- [目录](#section161941989596)
|
||||||
- [约束](#section119744591305)
|
- [约束](#section119744591305)
|
||||||
- [使用说明](#section741617511812)
|
- [使用说明](#section741617511812)
|
||||||
- [准备](#section1579912573329)
|
- [准备](#section1579912573329)
|
||||||
- [获取源码](#section11443189655)
|
- [获取源码](#section11443189655)
|
||||||
- [编译构建](#section2081013992812)
|
- [编译构建](#section2081013992812)
|
||||||
- [贡献](#section1371123476304)
|
|
||||||
- [相关仓](#section1371113476307)
|
- [相关仓](#section1371113476307)
|
||||||
|
|
||||||
## 简介<a name="section11660541593"></a>
|
## 简介<a name="section11660541593"></a>
|
||||||
|
@ -69,35 +69,24 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
|
||||||
|
|
||||||
## 使用说明<a name="section741617511812"></a>
|
## 使用说明<a name="section741617511812"></a>
|
||||||
|
|
||||||
OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md)单板。开发者可基于此单板开发运行自己的应用程序。
|
OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)单板。开发者可基于此单板开发运行自己的应用程序。
|
||||||
|
|
||||||
### 准备<a name="section1579912573329"></a>
|
### 准备<a name="section1579912573329"></a>
|
||||||
|
|
||||||
开发者需要在Ubuntu上搭建编译环境:
|
开发者需要在Linux上搭建编译环境:
|
||||||
|
|
||||||
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md);
|
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
|
||||||
|
- Hi3516DV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||||
|
|
||||||
### 获取源码<a name="section11443189655"></a>
|
### 获取源码<a name="section11443189655"></a>
|
||||||
|
|
||||||
在Ubuntu服务器源码获取方式参考: [源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
在Linux服务器上下载并解压一套源代码,源码获取方式参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
||||||
|
|
||||||
### 编译构建<a name="section2081013992812"></a>
|
### 编译构建<a name="section2081013992812"></a>
|
||||||
|
|
||||||
如果这是您的首次应用程序开发,可参考:[helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)。
|
如果这是您的首次应用程序开发,可参考:
|
||||||
|
|
||||||
编译可以参考:[编译指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md)
|
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||||
|
|
||||||
测试参考:[单元测试](testsuites/unittest/tools/README.md)
|
|
||||||
|
|
||||||
## 贡献<a name="section1371123476304"></a>
|
|
||||||
|
|
||||||
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
|
|
||||||
|
|
||||||
[Commit message规范](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
|
|
||||||
|
|
||||||
[OpenHarmony C&C++ 安全编程指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
|
|
||||||
|
|
||||||
[LiteOS-A 内核编码规范指南](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
|
|
||||||
|
|
||||||
## 相关仓<a name="section1371113476307"></a>
|
## 相关仓<a name="section1371113476307"></a>
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,6 @@ APP_SUBDIRS += mksh
|
||||||
APP_SUBDIRS += toybox
|
APP_SUBDIRS += toybox
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(LOSCFG_KERNEL_LMS), y)
|
|
||||||
APP_SUBDIRS += lms
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
||||||
APP_SUBDIRS += init
|
APP_SUBDIRS += init
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -73,5 +73,5 @@ executable("sample_usr_lms") {
|
||||||
"-Wl,--wrap=strcpy",
|
"-Wl,--wrap=strcpy",
|
||||||
"-Wl,--wrap=strcat",
|
"-Wl,--wrap=strcat",
|
||||||
]
|
]
|
||||||
deps = [ "$LITEOSTOPDIR/kernel/extended/lms/usr:usrlmslib" ]
|
deps = [ "//kernel/liteos_a/kernel/extended/lms/usr:usrlmslib" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,8 +180,7 @@ static void LmsStrcpyTest(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char *testStr = "bbbbbbbbbbbbbbbbb";
|
char *testStr = "bbbbbbbbbbbbbbbbb";
|
||||||
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n",
|
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1);
|
||||||
(int)strlen(testStr) + 1);
|
|
||||||
strcpy(buf, testStr);
|
strcpy(buf, testStr);
|
||||||
free(buf);
|
free(buf);
|
||||||
printf("\n-------- LmsStrcpyTest End --------\n");
|
printf("\n-------- LmsStrcpyTest End --------\n");
|
||||||
|
@ -231,7 +230,7 @@ int main(int argc, char * const *argv)
|
||||||
printf("\n############### Lms Test start ###############\n");
|
printf("\n############### Lms Test start ###############\n");
|
||||||
char *tmp = (char *)malloc(5000); /* 5000: test mem size */
|
char *tmp = (char *)malloc(5000); /* 5000: test mem size */
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
LmsMallocTest();
|
LmsMallocTest();
|
||||||
LmsReallocTest();
|
LmsReallocTest();
|
||||||
|
@ -246,5 +245,4 @@ int main(int argc, char * const *argv)
|
||||||
LmsFreeTest();
|
LmsFreeTest();
|
||||||
free(tmp);
|
free(tmp);
|
||||||
printf("\n############### Lms Test End ###############\n");
|
printf("\n############### Lms Test End ###############\n");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
import("//build/lite/config/component/lite_component.gni")
|
import("//build/lite/config/component/lite_component.gni")
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_MKSH_DIR/mksh.gni")
|
import("//third_party/mksh/mksh.gni")
|
||||||
|
|
||||||
group("mksh") {
|
group("mksh") {
|
||||||
deps = [ ":build_mksh" ]
|
deps = [ ":build_mksh" ]
|
||||||
|
@ -42,7 +42,7 @@ copy("copy_mksh_src") {
|
||||||
|
|
||||||
build_ext_component("build_mksh") {
|
build_ext_component("build_mksh") {
|
||||||
deps = [ ":copy_mksh_src" ]
|
deps = [ ":copy_mksh_src" ]
|
||||||
deps += [ "$THIRDPARTY_MUSL_DIR:sysroot_lite" ]
|
deps += [ "//third_party/musl:sysroot_lite" ]
|
||||||
exec_path = rebase_path("$target_out_dir/mksh_build")
|
exec_path = rebase_path("$target_out_dir/mksh_build")
|
||||||
|
|
||||||
cflags = [
|
cflags = [
|
||||||
|
|
|
@ -62,7 +62,7 @@ int main(int argc, char **argv)
|
||||||
PerfStop(fd);
|
PerfStop(fd);
|
||||||
} else if ((argc == THREE_ARGS) && strcmp(argv[1], "read") == 0) {
|
} else if ((argc == THREE_ARGS) && strcmp(argv[1], "read") == 0) {
|
||||||
size_t size = strtoul(argv[THREE_ARGS - 1], NULL, 0);
|
size_t size = strtoul(argv[THREE_ARGS - 1], NULL, 0);
|
||||||
if (size == 0) {
|
if (size <= 0) {
|
||||||
goto EXIT:
|
goto EXIT:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,12 +44,12 @@
|
||||||
|
|
||||||
ShellCB *g_shellCB = NULL;
|
ShellCB *g_shellCB = NULL;
|
||||||
|
|
||||||
ShellCB *OsGetShellCb(void)
|
ShellCB *OsGetShellCb()
|
||||||
{
|
{
|
||||||
return g_shellCB;
|
return g_shellCB;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShellDeinit(ShellCB *shellCB)
|
void ShellDeinit(ShellCB *shellCB)
|
||||||
{
|
{
|
||||||
(void)pthread_mutex_destroy(&shellCB->historyMutex);
|
(void)pthread_mutex_destroy(&shellCB->historyMutex);
|
||||||
(void)pthread_mutex_destroy(&shellCB->keyMutex);
|
(void)pthread_mutex_destroy(&shellCB->keyMutex);
|
||||||
|
@ -65,23 +65,27 @@ static int OsShellCreateTask(ShellCB *shellCB)
|
||||||
|
|
||||||
ret = sched_getparam(getpid(), ¶m);
|
ret = sched_getparam(getpid(), ¶m);
|
||||||
if (ret != SH_OK) {
|
if (ret != SH_OK) {
|
||||||
return ret;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
|
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
|
||||||
|
|
||||||
ret = sched_setparam(getpid(), ¶m);
|
ret = sched_setparam(getpid(), ¶m);
|
||||||
if (ret != SH_OK) {
|
if (ret != SH_OK) {
|
||||||
return ret;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ShellTaskInit(shellCB);
|
ret = ShellTaskInit(shellCB);
|
||||||
if (ret != SH_OK) {
|
if (ret != SH_OK) {
|
||||||
return ret;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
shellCB->shellEntryHandle = pthread_self();
|
shellCB->shellEntryHandle = pthread_self();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
OUT:
|
||||||
|
ShellDeinit(shellCB);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DoShellExec(char **argv)
|
static int DoShellExec(char **argv)
|
||||||
|
@ -144,7 +148,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
|
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
|
||||||
if (shellCB == NULL) {
|
if (shellCB == NULL) {
|
||||||
return SH_NOK;
|
goto ERR_OUT1;
|
||||||
}
|
}
|
||||||
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
|
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
|
||||||
if (ret != SH_OK) {
|
if (ret != SH_OK) {
|
||||||
|
@ -172,9 +176,7 @@ int main(int argc, char **argv)
|
||||||
g_shellCB = shellCB;
|
g_shellCB = shellCB;
|
||||||
ret = OsShellCreateTask(shellCB);
|
ret = OsShellCreateTask(shellCB);
|
||||||
if (ret != SH_OK) {
|
if (ret != SH_OK) {
|
||||||
ShellDeinit(shellCB);
|
goto ERR_OUT3;
|
||||||
g_shellCB = NULL;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShellEntry(shellCB);
|
ShellEntry(shellCB);
|
||||||
|
|
|
@ -1437,8 +1437,10 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
|
||||||
{
|
{
|
||||||
s32_t iSockNum = TFTP_NULL_INT32;
|
s32_t iSockNum = TFTP_NULL_INT32;
|
||||||
u32_t ulSrcStrLen;
|
u32_t ulSrcStrLen;
|
||||||
|
u32_t lDestStrLen;
|
||||||
u32_t ulSize;
|
u32_t ulSize;
|
||||||
u32_t ulRecvSize = TFTP_NULL_UINT32;
|
u32_t ulRecvSize = TFTP_NULL_UINT32;
|
||||||
|
s32_t iErrCode;
|
||||||
u32_t ulErrCode;
|
u32_t ulErrCode;
|
||||||
u16_t usReadReq;
|
u16_t usReadReq;
|
||||||
u16_t usTempServPort;
|
u16_t usTempServPort;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
import("//build/lite/config/component/lite_component.gni")
|
import("//build/lite/config/component/lite_component.gni")
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_TOYBOX_DIR/toybox.gni")
|
import("//third_party/toybox/toybox.gni")
|
||||||
|
|
||||||
group("toybox") {
|
group("toybox") {
|
||||||
deps = [ ":build_toybox" ]
|
deps = [ ":build_toybox" ]
|
||||||
|
@ -51,7 +51,7 @@ build_ext_component("build_toybox") {
|
||||||
":copy_toybox_config",
|
":copy_toybox_config",
|
||||||
":copy_toybox_src",
|
":copy_toybox_src",
|
||||||
]
|
]
|
||||||
deps += [ "$THIRDPARTY_MUSL_DIR:sysroot_lite" ]
|
deps += [ "//third_party/musl:sysroot_lite" ]
|
||||||
exec_path = rebase_path("$target_out_dir/toybox_build")
|
exec_path = rebase_path("$target_out_dir/toybox_build")
|
||||||
|
|
||||||
cflags = [
|
cflags = [
|
||||||
|
|
|
@ -70,7 +70,7 @@ static void TraceRead(int fd, size_t size)
|
||||||
{
|
{
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
if (size == 0) {
|
if (size <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -102,7 +102,7 @@ typedef struct {
|
||||||
* Return : pointer to the task context
|
* Return : pointer to the task context
|
||||||
*/
|
*/
|
||||||
extern VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag);
|
extern VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag);
|
||||||
extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfStask, UINT32 parentStackSize);
|
extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStask, UINT32 parentStackSize);
|
||||||
extern VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
|
extern VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
|
||||||
extern VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
|
extern VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
|
||||||
extern void arm_clean_cache_range(UINTPTR start, UINTPTR end);
|
extern void arm_clean_cache_range(UINTPTR start, UINTPTR end);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -103,7 +103,7 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
|
||||||
return (VOID *)taskContext;
|
return (VOID *)taskContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfStack, UINT32 parentStackSize)
|
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStack, UINT32 parentStackSize)
|
||||||
{
|
{
|
||||||
LosTaskCB *task = OsCurrTaskGet();
|
LosTaskCB *task = OsCurrTaskGet();
|
||||||
sig_cb *sigcb = &task->sig;
|
sig_cb *sigcb = &task->sig;
|
||||||
|
@ -117,10 +117,6 @@ VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfSta
|
||||||
|
|
||||||
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
|
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
|
||||||
((TaskContext *)childStack)->R0 = 0;
|
((TaskContext *)childStack)->R0 = 0;
|
||||||
if (sp != 0) {
|
|
||||||
((TaskContext *)childStack)->USP = TRUNCATE(sp, LOSCFG_STACK_POINT_ALIGN_SIZE);
|
|
||||||
((TaskContext *)childStack)->ULR = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)
|
LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)
|
||||||
|
|
|
@ -27,8 +27,11 @@
|
||||||
"component": {
|
"component": {
|
||||||
"name": "liteos_a",
|
"name": "liteos_a",
|
||||||
"subsystem": "kernel",
|
"subsystem": "kernel",
|
||||||
|
"syscap": [
|
||||||
|
"SystemCapability.Kernel.liteos-a"
|
||||||
|
],
|
||||||
"features": [],
|
"features": [],
|
||||||
"adapted_system_type": [
|
"adated_system_type": [
|
||||||
"small"
|
"small"
|
||||||
],
|
],
|
||||||
"rom": "1.5MB",
|
"rom": "1.5MB",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -74,10 +74,6 @@ extern "C" {
|
||||||
/* not support prio */
|
/* not support prio */
|
||||||
#define MQ_PRIO_MAX 1
|
#define MQ_PRIO_MAX 1
|
||||||
|
|
||||||
#ifndef MAX_MQ_FD
|
|
||||||
#define MAX_MQ_FD CONFIG_NQUEUE_DESCRIPTORS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef union send_receive_t {
|
typedef union send_receive_t {
|
||||||
unsigned oth : 3;
|
unsigned oth : 3;
|
||||||
unsigned grp : 6;
|
unsigned grp : 6;
|
||||||
|
@ -428,7 +424,6 @@ extern ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen,
|
||||||
|
|
||||||
extern void MqueueRefer(int sysFd);
|
extern void MqueueRefer(int sysFd);
|
||||||
extern int OsMqNotify(mqd_t personal, const struct sigevent *sigev);
|
extern int OsMqNotify(mqd_t personal, const struct sigevent *sigev);
|
||||||
extern VOID OsMqueueCBDestroy(struct mqarray *queueTable);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|
|
@ -53,27 +53,21 @@
|
||||||
|
|
||||||
int uname(struct utsname *name)
|
int uname(struct utsname *name)
|
||||||
{
|
{
|
||||||
|
INT32 ret;
|
||||||
|
const char *cpuInfo = NULL;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_UTS_CONTAINER
|
|
||||||
struct utsname *currentUtsName = OsGetCurrUtsName();
|
|
||||||
if (currentUtsName == NULL) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
(VOID)memcpy_s(name, sizeof(struct utsname), currentUtsName, sizeof(struct utsname));
|
|
||||||
#else
|
|
||||||
|
|
||||||
(VOID)strcpy_s(name->sysname, sizeof(name->sysname), KERNEL_NAME);
|
(VOID)strcpy_s(name->sysname, sizeof(name->sysname), KERNEL_NAME);
|
||||||
(VOID)strcpy_s(name->nodename, sizeof(name->nodename), KERNEL_NODE_NAME);
|
(VOID)strcpy_s(name->nodename, sizeof(name->nodename), "hisilicon");
|
||||||
INT32 ret = sprintf_s(name->version, sizeof(name->version), "%s %u.%u.%u.%u %s %s",
|
ret = sprintf_s(name->version, sizeof(name->version), "%s %u.%u.%u.%u %s %s",
|
||||||
KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, __DATE__, __TIME__);
|
KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, __DATE__, __TIME__);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *cpuInfo = LOS_CpuInfo();
|
cpuInfo = LOS_CpuInfo();
|
||||||
(VOID)strcpy_s(name->machine, sizeof(name->machine), cpuInfo);
|
(VOID)strcpy_s(name->machine, sizeof(name->machine), cpuInfo);
|
||||||
ret = sprintf_s(name->release, sizeof(name->release), "%u.%u.%u.%u",
|
ret = sprintf_s(name->release, sizeof(name->release), "%u.%u.%u.%u",
|
||||||
KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE);
|
KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE);
|
||||||
|
@ -82,7 +76,6 @@ int uname(struct utsname *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
name->domainname[0] = '\0';
|
name->domainname[0] = '\0';
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -44,19 +44,16 @@
|
||||||
|
|
||||||
#define FNONBLOCK O_NONBLOCK
|
#define FNONBLOCK O_NONBLOCK
|
||||||
|
|
||||||
#ifndef LOSCFG_IPC_CONTAINER
|
#ifndef MAX_MQ_FD
|
||||||
|
#define MAX_MQ_FD CONFIG_NQUEUE_DESCRIPTORS
|
||||||
|
#endif
|
||||||
|
|
||||||
/* GLOBALS */
|
/* GLOBALS */
|
||||||
STATIC fd_set g_queueFdSet;
|
STATIC fd_set g_queueFdSet;
|
||||||
STATIC struct mqarray g_queueTable[LOSCFG_BASE_IPC_QUEUE_LIMIT];
|
STATIC struct mqarray g_queueTable[LOSCFG_BASE_IPC_QUEUE_LIMIT];
|
||||||
STATIC pthread_mutex_t g_mqueueMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
STATIC pthread_mutex_t g_mqueueMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
||||||
STATIC struct mqpersonal *g_mqPrivBuf[MAX_MQ_FD];
|
STATIC struct mqpersonal *g_mqPrivBuf[MAX_MQ_FD];
|
||||||
|
|
||||||
#define IPC_QUEUE_FD_SET g_queueFdSet
|
|
||||||
#define IPC_QUEUE_TABLE g_queueTable
|
|
||||||
#define IPC_QUEUE_MUTEX g_mqueueMutex
|
|
||||||
#define IPC_QUEUE_MQ_PRIV_BUF g_mqPrivBuf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* LOCAL FUNCTIONS */
|
/* LOCAL FUNCTIONS */
|
||||||
STATIC INLINE INT32 MqNameCheck(const CHAR *mqName)
|
STATIC INLINE INT32 MqNameCheck(const CHAR *mqName)
|
||||||
{
|
{
|
||||||
|
@ -99,12 +96,12 @@ STATIC INLINE struct mqarray *GetMqueueCBByName(const CHAR *name)
|
||||||
UINT32 mylen = strlen(name);
|
UINT32 mylen = strlen(name);
|
||||||
|
|
||||||
for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {
|
for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {
|
||||||
if ((IPC_QUEUE_TABLE[index].mq_name == NULL) || (strlen(IPC_QUEUE_TABLE[index].mq_name) != mylen)) {
|
if ((g_queueTable[index].mq_name == NULL) || (strlen(g_queueTable[index].mq_name) != mylen)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(name, (const CHAR *)(IPC_QUEUE_TABLE[index].mq_name), mylen) == 0) {
|
if (strncmp(name, (const CHAR *)(g_queueTable[index].mq_name), mylen) == 0) {
|
||||||
return &(IPC_QUEUE_TABLE[index]);
|
return &(g_queueTable[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -113,9 +110,7 @@ STATIC INLINE struct mqarray *GetMqueueCBByName(const CHAR *name)
|
||||||
STATIC INT32 DoMqueueDelete(struct mqarray *mqueueCB)
|
STATIC INT32 DoMqueueDelete(struct mqarray *mqueueCB)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
|
||||||
OsIPCLimitMqFree();
|
|
||||||
#endif
|
|
||||||
if (mqueueCB->mq_name != NULL) {
|
if (mqueueCB->mq_name != NULL) {
|
||||||
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
|
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
|
||||||
mqueueCB->mq_name = NULL;
|
mqueueCB->mq_name = NULL;
|
||||||
|
@ -165,36 +160,18 @@ STATIC int SaveMqueueName(const CHAR *mqName, struct mqarray *mqueueCB)
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID MqueueCBInit(struct mqarray *mqueueCB, const struct mq_attr *attr, INT32 openFlag, UINT32 mode)
|
|
||||||
{
|
|
||||||
mqueueCB->unlinkflag = FALSE;
|
|
||||||
mqueueCB->unlink_ref = 0;
|
|
||||||
mqueueCB->mq_personal->mq_status = MQ_USE_MAGIC;
|
|
||||||
mqueueCB->mq_personal->mq_next = NULL;
|
|
||||||
mqueueCB->mq_personal->mq_posixdes = mqueueCB;
|
|
||||||
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
|
|
||||||
mqueueCB->mq_personal->mq_mode = mode;
|
|
||||||
mqueueCB->mq_personal->mq_refcount = 0;
|
|
||||||
mqueueCB->mq_notify.pid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR *mqName, INT32 openFlag, UINT32 mode)
|
STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR *mqName, INT32 openFlag, UINT32 mode)
|
||||||
{
|
{
|
||||||
struct mqarray *mqueueCB = NULL;
|
struct mqarray *mqueueCB = NULL;
|
||||||
UINT32 mqueueID;
|
UINT32 mqueueID;
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
|
||||||
if (OsIPCLimitMqAlloc() != LOS_OK) {
|
|
||||||
return (struct mqpersonal *)-1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
UINT32 err = LOS_QueueCreate(NULL, attr->mq_maxmsg, &mqueueID, 0, attr->mq_msgsize);
|
UINT32 err = LOS_QueueCreate(NULL, attr->mq_maxmsg, &mqueueID, 0, attr->mq_msgsize);
|
||||||
if (map_errno(err) != ENOERR) {
|
if (map_errno(err) != ENOERR) {
|
||||||
goto ERROUT;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IPC_QUEUE_TABLE[GET_QUEUE_INDEX(mqueueID)].mqcb == NULL) {
|
if (g_queueTable[GET_QUEUE_INDEX(mqueueID)].mqcb == NULL) {
|
||||||
mqueueCB = &(IPC_QUEUE_TABLE[GET_QUEUE_INDEX(mqueueID)]);
|
mqueueCB = &(g_queueTable[GET_QUEUE_INDEX(mqueueID)]);
|
||||||
mqueueCB->mq_id = mqueueID;
|
mqueueCB->mq_id = mqueueID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +198,15 @@ STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR
|
||||||
goto ERROUT;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
MqueueCBInit(mqueueCB, attr, openFlag, mode);
|
mqueueCB->unlinkflag = FALSE;
|
||||||
|
mqueueCB->unlink_ref = 0;
|
||||||
|
mqueueCB->mq_personal->mq_status = MQ_USE_MAGIC;
|
||||||
|
mqueueCB->mq_personal->mq_next = NULL;
|
||||||
|
mqueueCB->mq_personal->mq_posixdes = mqueueCB;
|
||||||
|
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
|
||||||
|
mqueueCB->mq_personal->mq_mode = mode;
|
||||||
|
mqueueCB->mq_personal->mq_refcount = 0;
|
||||||
|
mqueueCB->mq_notify.pid = 0;
|
||||||
|
|
||||||
return mqueueCB->mq_personal;
|
return mqueueCB->mq_personal;
|
||||||
ERROUT:
|
ERROUT:
|
||||||
|
@ -230,9 +215,6 @@ ERROUT:
|
||||||
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
|
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
|
||||||
mqueueCB->mq_name = NULL;
|
mqueueCB->mq_name = NULL;
|
||||||
}
|
}
|
||||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
|
||||||
OsIPCLimitMqFree();
|
|
||||||
#endif
|
|
||||||
return (struct mqpersonal *)-1;
|
return (struct mqpersonal *)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +252,6 @@ STATIC INT32 DoMqueueClose(struct mqpersonal *privateMqPersonal)
|
||||||
{
|
{
|
||||||
struct mqarray *mqueueCB = NULL;
|
struct mqarray *mqueueCB = NULL;
|
||||||
struct mqpersonal *tmp = NULL;
|
struct mqpersonal *tmp = NULL;
|
||||||
INT32 ret;
|
|
||||||
|
|
||||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||||
if (mqueueCB == NULL || mqueueCB->mq_personal == NULL) {
|
if (mqueueCB == NULL || mqueueCB->mq_personal == NULL) {
|
||||||
|
@ -278,12 +259,6 @@ STATIC INT32 DoMqueueClose(struct mqpersonal *privateMqPersonal)
|
||||||
return LOS_NOK;
|
return LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mqueueCB->unlinkflag == TRUE) && (privateMqPersonal->mq_next == NULL)) {
|
|
||||||
ret = DoMqueueDelete(mqueueCB);
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* find the personal and remove */
|
/* find the personal and remove */
|
||||||
if (mqueueCB->mq_personal == privateMqPersonal) {
|
if (mqueueCB->mq_personal == privateMqPersonal) {
|
||||||
mqueueCB->mq_personal = privateMqPersonal->mq_next;
|
mqueueCB->mq_personal = privateMqPersonal->mq_next;
|
||||||
|
@ -305,6 +280,9 @@ STATIC INT32 DoMqueueClose(struct mqpersonal *privateMqPersonal)
|
||||||
/* free the personal */
|
/* free the personal */
|
||||||
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
|
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
|
||||||
|
|
||||||
|
if ((mqueueCB->unlinkflag == TRUE) && (mqueueCB->mq_personal == NULL)) {
|
||||||
|
return DoMqueueDelete(mqueueCB);
|
||||||
|
}
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +297,7 @@ STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return IPC_QUEUE_MQ_PRIV_BUF[id];
|
return g_mqPrivBuf[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -333,13 +311,13 @@ STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
|
||||||
STATIC INT32 MqAllocSysFd(int maxfdp, struct mqpersonal *privateMqPersonal)
|
STATIC INT32 MqAllocSysFd(int maxfdp, struct mqpersonal *privateMqPersonal)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
fd_set *fdset = &IPC_QUEUE_FD_SET;
|
fd_set *fdset = &g_queueFdSet;
|
||||||
for (i = 0; i < maxfdp; i++) {
|
for (i = 0; i < maxfdp; i++) {
|
||||||
/* sysFd: used bit setting, and get the index of swtmrID buffer */
|
/* sysFd: used bit setting, and get the index of swtmrID buffer */
|
||||||
if (fdset && !(FD_ISSET(i + MQUEUE_FD_OFFSET, fdset))) {
|
if (fdset && !(FD_ISSET(i + MQUEUE_FD_OFFSET, fdset))) {
|
||||||
FD_SET(i + MQUEUE_FD_OFFSET, fdset);
|
FD_SET(i + MQUEUE_FD_OFFSET, fdset);
|
||||||
if (!IPC_QUEUE_MQ_PRIV_BUF[i]) {
|
if (!g_mqPrivBuf[i]) {
|
||||||
IPC_QUEUE_MQ_PRIV_BUF[i] = privateMqPersonal;
|
g_mqPrivBuf[i] = privateMqPersonal;
|
||||||
return i + MQUEUE_FD_OFFSET;
|
return i + MQUEUE_FD_OFFSET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,10 +328,10 @@ STATIC INT32 MqAllocSysFd(int maxfdp, struct mqpersonal *privateMqPersonal)
|
||||||
STATIC VOID MqFreeSysFd(mqd_t personal)
|
STATIC VOID MqFreeSysFd(mqd_t personal)
|
||||||
{
|
{
|
||||||
INT32 sysFd = (INT32)personal;
|
INT32 sysFd = (INT32)personal;
|
||||||
fd_set *fdset = &IPC_QUEUE_FD_SET;
|
fd_set *fdset = &g_queueFdSet;
|
||||||
if (fdset && FD_ISSET(sysFd, fdset)) {
|
if (fdset && FD_ISSET(sysFd, fdset)) {
|
||||||
FD_CLR(sysFd, fdset);
|
FD_CLR(sysFd, fdset);
|
||||||
IPC_QUEUE_MQ_PRIV_BUF[sysFd - MQUEUE_FD_OFFSET] = NULL;
|
g_mqPrivBuf[sysFd - MQUEUE_FD_OFFSET] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +341,7 @@ void MqueueRefer(int sysFd)
|
||||||
struct mqarray *mqueueCB = NULL;
|
struct mqarray *mqueueCB = NULL;
|
||||||
struct mqpersonal *privateMqPersonal = NULL;
|
struct mqpersonal *privateMqPersonal = NULL;
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
/* Get the personal sysFd and reset personal fd -1 */
|
/* Get the personal sysFd and reset personal fd -1 */
|
||||||
privateMqPersonal = MqGetPrivDataBuff((mqd_t)sysFd);
|
privateMqPersonal = MqGetPrivDataBuff((mqd_t)sysFd);
|
||||||
if (privateMqPersonal == NULL) {
|
if (privateMqPersonal == NULL) {
|
||||||
|
@ -376,7 +354,7 @@ void MqueueRefer(int sysFd)
|
||||||
|
|
||||||
privateMqPersonal->mq_refcount++;
|
privateMqPersonal->mq_refcount++;
|
||||||
OUT_UNLOCK:
|
OUT_UNLOCK:
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +498,7 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
|
||||||
return (mqd_t)-1;
|
return (mqd_t)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
mqueueCB = GetMqueueCBByName(mqName);
|
mqueueCB = GetMqueueCBByName(mqName);
|
||||||
if ((UINT32)openFlag & (UINT32)O_CREAT) {
|
if ((UINT32)openFlag & (UINT32)O_CREAT) {
|
||||||
if (mqueueCB != NULL) {
|
if (mqueueCB != NULL) {
|
||||||
|
@ -565,7 +543,7 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
|
||||||
mqFd = (mqd_t)sysFd;
|
mqFd = (mqd_t)sysFd;
|
||||||
}
|
}
|
||||||
OUT:
|
OUT:
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return mqFd;
|
return mqFd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,7 +552,7 @@ int mq_close(mqd_t personal)
|
||||||
INT32 ret = -1;
|
INT32 ret = -1;
|
||||||
struct mqpersonal *privateMqPersonal = NULL;
|
struct mqpersonal *privateMqPersonal = NULL;
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
|
|
||||||
/* Get the personal sysFd and reset personal fd -1 */
|
/* Get the personal sysFd and reset personal fd -1 */
|
||||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||||
|
@ -599,7 +577,7 @@ int mq_close(mqd_t personal)
|
||||||
MqFreeSysFd(personal);
|
MqFreeSysFd(personal);
|
||||||
|
|
||||||
OUT_UNLOCK:
|
OUT_UNLOCK:
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,22 +586,20 @@ int OsMqGetAttr(mqd_t personal, struct mq_attr *mqAttr)
|
||||||
struct mqarray *mqueueCB = NULL;
|
struct mqarray *mqueueCB = NULL;
|
||||||
struct mqpersonal *privateMqPersonal = NULL;
|
struct mqpersonal *privateMqPersonal = NULL;
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
|
||||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||||
if (privateMqPersonal == NULL) {
|
if (privateMqPersonal == NULL) {
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mqAttr == NULL) {
|
if (mqAttr == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,7 +608,7 @@ int OsMqGetAttr(mqd_t personal, struct mq_attr *mqAttr)
|
||||||
mqAttr->mq_msgsize = mqueueCB->mqcb->queueSize - sizeof(UINT32);
|
mqAttr->mq_msgsize = mqueueCB->mqcb->queueSize - sizeof(UINT32);
|
||||||
mqAttr->mq_curmsgs = mqueueCB->mqcb->readWriteableCnt[OS_QUEUE_READ];
|
mqAttr->mq_curmsgs = mqueueCB->mqcb->readWriteableCnt[OS_QUEUE_READ];
|
||||||
mqAttr->mq_flags = privateMqPersonal->mq_flags;
|
mqAttr->mq_flags = privateMqPersonal->mq_flags;
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,22 +616,20 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
|
||||||
{
|
{
|
||||||
struct mqpersonal *privateMqPersonal = NULL;
|
struct mqpersonal *privateMqPersonal = NULL;
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
|
||||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||||
if (privateMqPersonal == NULL) {
|
if (privateMqPersonal == NULL) {
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mqSetAttr == NULL) {
|
if (mqSetAttr == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +641,7 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
|
||||||
if (((UINT32)mqSetAttr->mq_flags & (UINT32)FNONBLOCK) == (UINT32)FNONBLOCK) {
|
if (((UINT32)mqSetAttr->mq_flags & (UINT32)FNONBLOCK) == (UINT32)FNONBLOCK) {
|
||||||
privateMqPersonal->mq_flags = (INT32)((UINT32)privateMqPersonal->mq_flags | (UINT32)FNONBLOCK);
|
privateMqPersonal->mq_flags = (INT32)((UINT32)privateMqPersonal->mq_flags | (UINT32)FNONBLOCK);
|
||||||
}
|
}
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,7 +662,7 @@ int mq_unlink(const char *mqName)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
mqueueCB = GetMqueueCBByName(mqName);
|
mqueueCB = GetMqueueCBByName(mqName);
|
||||||
if (mqueueCB == NULL) {
|
if (mqueueCB == NULL) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
|
@ -701,11 +675,11 @@ int mq_unlink(const char *mqName)
|
||||||
ret = DoMqueueDelete(mqueueCB);
|
ret = DoMqueueDelete(mqueueCB);
|
||||||
}
|
}
|
||||||
|
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ERROUT_UNLOCK:
|
ERROUT_UNLOCK:
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +767,7 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
|
||||||
OS_MQ_GOTO_ERROUT_IF(!MqParamCheck(personal, msg, msgLen), errno);
|
OS_MQ_GOTO_ERROUT_IF(!MqParamCheck(personal, msg, msgLen), errno);
|
||||||
OS_MQ_GOTO_ERROUT_IF(msgPrio > (MQ_PRIO_MAX - 1), EINVAL);
|
OS_MQ_GOTO_ERROUT_IF(msgPrio > (MQ_PRIO_MAX - 1), EINVAL);
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||||
|
|
||||||
OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF);
|
OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF);
|
||||||
|
@ -807,7 +781,7 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
|
||||||
|
|
||||||
OS_MQ_GOTO_ERROUT_UNLOCK_IF(ConvertTimeout(privateMqPersonal->mq_flags, absTimeout, &absTicks) == -1, errno);
|
OS_MQ_GOTO_ERROUT_UNLOCK_IF(ConvertTimeout(privateMqPersonal->mq_flags, absTimeout, &absTicks) == -1, errno);
|
||||||
mqueueID = mqueueCB->mq_id;
|
mqueueID = mqueueCB->mq_id;
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
|
|
||||||
if (LOS_ListEmpty(&mqueueCB->mqcb->readWriteList[OS_QUEUE_READ])) {
|
if (LOS_ListEmpty(&mqueueCB->mqcb->readWriteList[OS_QUEUE_READ])) {
|
||||||
MqSendNotify(mqueueCB);
|
MqSendNotify(mqueueCB);
|
||||||
|
@ -819,7 +793,7 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
ERROUT_UNLOCK:
|
ERROUT_UNLOCK:
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
ERROUT:
|
ERROUT:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -841,7 +815,7 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
|
||||||
*msgPrio = 0;
|
*msgPrio = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||||
if (privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
if (privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
|
@ -865,7 +839,7 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
|
||||||
|
|
||||||
receiveLen = msgLen;
|
receiveLen = msgLen;
|
||||||
mqueueID = mqueueCB->mq_id;
|
mqueueID = mqueueCB->mq_id;
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
|
|
||||||
err = LOS_QueueReadCopy(mqueueID, (VOID *)msg, &receiveLen, (UINT32)absTicks);
|
err = LOS_QueueReadCopy(mqueueID, (VOID *)msg, &receiveLen, (UINT32)absTicks);
|
||||||
if (map_errno(err) == ENOERR) {
|
if (map_errno(err) == ENOERR) {
|
||||||
|
@ -875,7 +849,7 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROUT_UNLOCK:
|
ERROUT_UNLOCK:
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
ERROUT:
|
ERROUT:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -924,7 +898,7 @@ int OsMqNotify(mqd_t personal, const struct sigevent *sigev)
|
||||||
goto ERROUT;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||||
if (privateMqPersonal == NULL) {
|
if (privateMqPersonal == NULL) {
|
||||||
goto OUT_UNLOCK;
|
goto OUT_UNLOCK;
|
||||||
|
@ -962,26 +936,11 @@ int OsMqNotify(mqd_t personal, const struct sigevent *sigev)
|
||||||
mqnotify->pid = LOS_GetCurrProcessID();
|
mqnotify->pid = LOS_GetCurrProcessID();
|
||||||
}
|
}
|
||||||
|
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
return 0;
|
return 0;
|
||||||
OUT_UNLOCK:
|
OUT_UNLOCK:
|
||||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||||
ERROUT:
|
ERROUT:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID OsMqueueCBDestroy(struct mqarray *queueTable)
|
|
||||||
{
|
|
||||||
if (queueTable == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (UINT32 index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {
|
|
||||||
struct mqarray *mqueueCB = &(queueTable[index]);
|
|
||||||
if (mqueueCB->mq_name == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
(VOID)DoMqueueClose(mqueueCB->mq_personal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -240,9 +240,9 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||||
taskInitParam.usTaskPrio = (UINT16)userAttr.schedparam.sched_priority;
|
taskInitParam.usTaskPrio = (UINT16)userAttr.schedparam.sched_priority;
|
||||||
taskInitParam.uwStackSize = userAttr.stacksize;
|
taskInitParam.uwStackSize = userAttr.stacksize;
|
||||||
if (OsProcessIsUserMode(OsCurrProcessGet())) {
|
if (OsProcessIsUserMode(OsCurrProcessGet())) {
|
||||||
taskInitParam.processID = (UINTPTR)OsGetKernelInitProcess();
|
taskInitParam.processID = OsGetKernelInitProcessID();
|
||||||
} else {
|
} else {
|
||||||
taskInitParam.processID = (UINTPTR)OsCurrProcessGet();
|
taskInitParam.processID = OsCurrProcessGet()->processID;
|
||||||
}
|
}
|
||||||
if (userAttr.detachstate == PTHREAD_CREATE_DETACHED) {
|
if (userAttr.detachstate == PTHREAD_CREATE_DETACHED) {
|
||||||
taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
|
taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -117,7 +117,7 @@ STATIC INLINE BOOL ValidTimerID(UINT16 swtmrID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check owner of this timer */
|
/* check owner of this timer */
|
||||||
if (OS_SWT_FROM_SID(swtmrID)->uwOwnerPid != (UINTPTR)OsCurrProcessGet()) {
|
if (OS_SWT_FROM_SID(swtmrID)->uwOwnerPid != LOS_GetCurrProcessID()) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
|
||||||
|
|
||||||
LosTaskCB *task = OsGetTaskCB(tid);
|
LosTaskCB *task = OsGetTaskCB(tid);
|
||||||
|
|
||||||
if (OsCurrTaskGet()->processCB != task->processCB) {
|
if (OsCurrTaskGet()->processID != task->processID) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,22 +599,13 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
|
||||||
|
|
||||||
switch (clockID) {
|
switch (clockID) {
|
||||||
case CLOCK_MONOTONIC_RAW:
|
case CLOCK_MONOTONIC_RAW:
|
||||||
#ifdef LOSCFG_TIME_CONTAINER
|
|
||||||
tmp = OsTimeSpecAdd(hwTime, CLOCK_MONOTONIC_TIME_BASE);
|
|
||||||
tp->tv_sec = tmp.tv_sec;
|
|
||||||
tp->tv_nsec = tmp.tv_nsec;
|
|
||||||
#else
|
|
||||||
tp->tv_sec = hwTime.tv_sec;
|
tp->tv_sec = hwTime.tv_sec;
|
||||||
tp->tv_nsec = hwTime.tv_nsec;
|
tp->tv_nsec = hwTime.tv_nsec;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case CLOCK_MONOTONIC:
|
case CLOCK_MONOTONIC:
|
||||||
LOS_SpinLockSave(&g_timeSpin, &intSave);
|
LOS_SpinLockSave(&g_timeSpin, &intSave);
|
||||||
tmp = OsTimeSpecAdd(hwTime, g_accDeltaFromAdj);
|
tmp = OsTimeSpecAdd(hwTime, g_accDeltaFromAdj);
|
||||||
LOS_SpinUnlockRestore(&g_timeSpin, intSave);
|
LOS_SpinUnlockRestore(&g_timeSpin, intSave);
|
||||||
#ifdef LOSCFG_TIME_CONTAINER
|
|
||||||
tmp = OsTimeSpecAdd(tmp, CLOCK_MONOTONIC_TIME_BASE);
|
|
||||||
#endif
|
|
||||||
tp->tv_sec = tmp.tv_sec;
|
tp->tv_sec = tmp.tv_sec;
|
||||||
tp->tv_nsec = tmp.tv_nsec;
|
tp->tv_nsec = tmp.tv_nsec;
|
||||||
break;
|
break;
|
||||||
|
@ -648,7 +639,7 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ERROUT:
|
ERROUT:
|
||||||
TIME_RETURN(EINVAL);
|
TIME_RETURN(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,7 +748,7 @@ static VOID SwtmrProc(UINTPTR tmrArg)
|
||||||
/* Make sure that the para is valid */
|
/* Make sure that the para is valid */
|
||||||
OS_GOTO_EXIT_IF(OS_TID_CHECK_INVALID(arg->tid), EINVAL);
|
OS_GOTO_EXIT_IF(OS_TID_CHECK_INVALID(arg->tid), EINVAL);
|
||||||
stcb = OsGetTaskCB(arg->tid);
|
stcb = OsGetTaskCB(arg->tid);
|
||||||
ret = OsUserProcessOperatePermissionsCheck(stcb, stcb->processCB);
|
ret = OsUserProcessOperatePermissionsCheck(stcb, stcb->processID);
|
||||||
OS_GOTO_EXIT_IF(ret != LOS_OK, -ret);
|
OS_GOTO_EXIT_IF(ret != LOS_OK, -ret);
|
||||||
|
|
||||||
/* Dispatch the signal to thread, bypassing normal task group thread
|
/* Dispatch the signal to thread, bypassing normal task group thread
|
||||||
|
@ -1096,7 +1087,8 @@ clock_t times(struct tms *buf)
|
||||||
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
|
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
LosProcessCB *processCB = OsCurrProcessGet();
|
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||||
|
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||||
timer_t timerID = 0;
|
timer_t timerID = 0;
|
||||||
struct itimerspec spec;
|
struct itimerspec spec;
|
||||||
struct itimerspec ospec;
|
struct itimerspec ospec;
|
||||||
|
@ -1149,7 +1141,8 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
|
||||||
|
|
||||||
int getitimer(int which, struct itimerval *value)
|
int getitimer(int which, struct itimerval *value)
|
||||||
{
|
{
|
||||||
LosProcessCB *processCB = OsCurrProcessGet();
|
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||||
|
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||||
struct itimerspec spec = {};
|
struct itimerspec spec = {};
|
||||||
|
|
||||||
int ret = LOS_OK;
|
int ret = LOS_OK;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
|
|
@ -1465,7 +1465,7 @@ INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops,
|
||||||
ret = VnodeLookup(diskName, &blkDriver, 0);
|
ret = VnodeLookup(diskName, &blkDriver, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
VnodeDrop();
|
VnodeDrop();
|
||||||
PRINT_ERR("disk_init : %s, failed to find the vnode, ERRNO=%d\n", diskName, ret);
|
ret = ENOENT;
|
||||||
goto DISK_FIND_ERROR;
|
goto DISK_FIND_ERROR;
|
||||||
}
|
}
|
||||||
struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops;
|
struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
import("//third_party/NuttX/NuttX.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_VFS_BLOCK_DEVICE)
|
module_switch = defined(LOSCFG_FS_VFS_BLOCK_DEVICE)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
|
|
|
@ -61,7 +61,7 @@ static ssize_t MemMap(struct file *filep, LosVmMapRegion *region)
|
||||||
VADDR_T vaddr = region->range.base;
|
VADDR_T vaddr = region->range.base;
|
||||||
LosVmSpace *space = LOS_SpaceGet(vaddr);
|
LosVmSpace *space = LOS_SpaceGet(vaddr);
|
||||||
|
|
||||||
if (((paddr + size) >= SYS_MEM_BASE) && (paddr < SYS_MEM_END)) {
|
if ((paddr >= SYS_MEM_BASE) && (paddr < SYS_MEM_END)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,5 +97,5 @@ static const struct file_operations_vfs g_memDevOps = {
|
||||||
|
|
||||||
int DevMemRegister(void)
|
int DevMemRegister(void)
|
||||||
{
|
{
|
||||||
return register_driver("/dev/mem", &g_memDevOps, 0644, 0); /* 0644: file mode */
|
return register_driver("/dev/mem", &g_memDevOps, 0666, 0); /* 0666: file mode */
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||||
return QuickstartNotify(arg);
|
return QuickstartNotify(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_GetCurrProcessID() != OS_USER_ROOT_PROCESS_ID) {
|
if (OsGetUserInitProcessID() != LOS_GetCurrProcessID()) {
|
||||||
PRINT_ERR("Permission denios!\n");
|
PRINT_ERR("Permission denios!\n");
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
import("//third_party/NuttX/NuttX.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_DRIVERS_VIDEO)
|
module_switch = defined(LOSCFG_DRIVERS_VIDEO)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
|
|
|
@ -39,6 +39,10 @@ kernel_module(module_name) {
|
||||||
|
|
||||||
include_dirs = [ "$LITEOSTOPDIR/fs/jffs2/include" ]
|
include_dirs = [ "$LITEOSTOPDIR/fs/jffs2/include" ]
|
||||||
|
|
||||||
|
if (defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)) {
|
||||||
|
include_dirs += [ "//device/qemu/drivers/cfiflash" ]
|
||||||
|
}
|
||||||
|
|
||||||
public_configs = [ ":public" ]
|
public_configs = [ ":public" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,10 @@ LOCAL_SRCS := $(wildcard src/*.c)
|
||||||
LOCAL_INCLUDE := \
|
LOCAL_INCLUDE := \
|
||||||
-I $(LITEOSTOPDIR)/fs/jffs2/include
|
-I $(LITEOSTOPDIR)/fs/jffs2/include
|
||||||
|
|
||||||
|
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
||||||
|
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/drivers/cfiflash
|
||||||
|
endif
|
||||||
|
|
||||||
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
||||||
|
|
||||||
include $(MODULE)
|
include $(MODULE)
|
||||||
|
|
|
@ -39,6 +39,11 @@
|
||||||
#include "fs/driver.h"
|
#include "fs/driver.h"
|
||||||
#include "mtd/mtd_legacy_lite.h"
|
#include "mtd/mtd_legacy_lite.h"
|
||||||
|
|
||||||
|
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||||
|
#include "cfiflash.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define DRIVER_NAME_ADD_SIZE 3
|
#define DRIVER_NAME_ADD_SIZE 3
|
||||||
pthread_mutex_t g_mtdPartitionLock = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t g_mtdPartitionLock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
@ -129,10 +134,17 @@ static VOID MtdNorParamAssign(partition_param *spinorParam, const struct MtdDev
|
||||||
* you can change the SPIBLK_NAME or SPICHR_NAME to NULL.
|
* you can change the SPIBLK_NAME or SPICHR_NAME to NULL.
|
||||||
*/
|
*/
|
||||||
spinorParam->flash_mtd = (struct MtdDev *)spinorMtd;
|
spinorParam->flash_mtd = (struct MtdDev *)spinorMtd;
|
||||||
|
#ifndef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||||
spinorParam->flash_ops = GetDevSpinorOps();
|
spinorParam->flash_ops = GetDevSpinorOps();
|
||||||
spinorParam->char_ops = GetMtdCharFops();
|
spinorParam->char_ops = GetMtdCharFops();
|
||||||
spinorParam->blockname = SPIBLK_NAME;
|
spinorParam->blockname = SPIBLK_NAME;
|
||||||
spinorParam->charname = SPICHR_NAME;
|
spinorParam->charname = SPICHR_NAME;
|
||||||
|
#else
|
||||||
|
spinorParam->flash_ops = GetCfiBlkOps();
|
||||||
|
spinorParam->char_ops = NULL;
|
||||||
|
spinorParam->blockname = CFI_DRIVER;
|
||||||
|
spinorParam->charname = NULL;
|
||||||
|
#endif
|
||||||
spinorParam->partition_head = g_spinorPartitionHead;
|
spinorParam->partition_head = g_spinorPartitionHead;
|
||||||
spinorParam->block_size = spinorMtd->eraseSize;
|
spinorParam->block_size = spinorMtd->eraseSize;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +158,11 @@ static VOID MtdDeinitSpinorParam(VOID)
|
||||||
|
|
||||||
static partition_param *MtdInitSpinorParam(partition_param *spinorParam)
|
static partition_param *MtdInitSpinorParam(partition_param *spinorParam)
|
||||||
{
|
{
|
||||||
|
#ifndef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||||
struct MtdDev *spinorMtd = GetMtd("spinor");
|
struct MtdDev *spinorMtd = GetMtd("spinor");
|
||||||
|
#else
|
||||||
|
struct MtdDev *spinorMtd = GetCfiMtdDev();
|
||||||
|
#endif
|
||||||
if (spinorMtd == NULL) {
|
if (spinorMtd == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 30 KiB |
Binary file not shown.
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 24 KiB |
|
@ -28,7 +28,7 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_FATFS_DIR/FatFs.gni")
|
import("//third_party/FatFs/FatFs.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_FAT)
|
module_switch = defined(LOSCFG_FS_FAT)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -1409,7 +1409,7 @@ DWORD fattime_format(time_t time)
|
||||||
ftime |= ((DWORD)((st.tm_year > YEAR_OFFSET) ? (st.tm_year - YEAR_OFFSET) : 0)) << FTIME_YEAR_OFFSET;
|
ftime |= ((DWORD)((st.tm_year > YEAR_OFFSET) ? (st.tm_year - YEAR_OFFSET) : 0)) << FTIME_YEAR_OFFSET;
|
||||||
ftime <<= FTIME_DATE_OFFSET;
|
ftime <<= FTIME_DATE_OFFSET;
|
||||||
|
|
||||||
ftime |= (DWORD)st.tm_sec / SEC_MULTIPLIER;
|
ftime = (DWORD)st.tm_sec / SEC_MULTIPLIER;
|
||||||
ftime |= ((DWORD)st.tm_min) << FTIME_MIN_OFFSET;
|
ftime |= ((DWORD)st.tm_min) << FTIME_MIN_OFFSET;
|
||||||
ftime |= ((DWORD)st.tm_hour) << FTIME_HR_OFFSET;
|
ftime |= ((DWORD)st.tm_hour) << FTIME_HR_OFFSET;
|
||||||
|
|
||||||
|
@ -2167,7 +2167,7 @@ int fatfs_symlink(struct Vnode *parentVnode, struct Vnode **newVnode, const char
|
||||||
ssize_t fatfs_readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
|
ssize_t fatfs_readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
FRESULT res;
|
FRESULT res = FR_OK;
|
||||||
DWORD clust;
|
DWORD clust;
|
||||||
QWORD sect;
|
QWORD sect;
|
||||||
DIR_FILE *dfp = (DIR_FILE *)(vnode->data);
|
DIR_FILE *dfp = (DIR_FILE *)(vnode->data);
|
||||||
|
|
|
@ -59,9 +59,6 @@ struct files_struct {
|
||||||
spinlock_t workdir_lock;
|
spinlock_t workdir_lock;
|
||||||
char workdir[PATH_MAX];
|
char workdir[PATH_MAX];
|
||||||
#endif
|
#endif
|
||||||
#ifdef LOSCFG_CHROOT
|
|
||||||
struct Vnode *rootVnode;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ProcessCB LosProcessCB;
|
typedef struct ProcessCB LosProcessCB;
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#define MS_NOSYNC 2
|
#define MS_NOSYNC 2
|
||||||
|
|
||||||
struct MountOps;
|
struct MountOps;
|
||||||
struct fsmap_t;
|
|
||||||
|
|
||||||
struct Mount {
|
struct Mount {
|
||||||
LIST_ENTRY mountList; /* mount list */
|
LIST_ENTRY mountList; /* mount list */
|
||||||
|
@ -70,11 +69,8 @@ typedef int (*foreach_mountpoint_t)(const char *devpoint,
|
||||||
struct statfs *statbuf,
|
struct statfs *statbuf,
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
struct Mount *MountAlloc(struct Vnode *vnode, struct MountOps *mop);
|
struct Mount* MountAlloc(struct Vnode* vnode, struct MountOps* mop);
|
||||||
LIST_HEAD *GetMountList(void);
|
LIST_HEAD* GetMountList(void);
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
LIST_HEAD *GetMountCache(void);
|
|
||||||
#endif
|
|
||||||
int foreach_mountpoint(foreach_mountpoint_t handler, void *arg);
|
int foreach_mountpoint(foreach_mountpoint_t handler, void *arg);
|
||||||
int ForceUmountDev(struct Vnode *dev);
|
int ForceUmountDev(struct Vnode *dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,7 @@ import("//kernel/liteos_a/liteos.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_JFFS)
|
module_switch = defined(LOSCFG_FS_JFFS)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
linux_path = rebase_path("$KERNEL_LINUX_DIR")
|
linux_path = rebase_path("//kernel/linux/linux-5.10")
|
||||||
out_path = rebase_path(target_out_dir)
|
out_path = rebase_path(target_out_dir)
|
||||||
|
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
|
|
|
@ -2311,7 +2311,7 @@ diff -Nupr old/fs/jffs2/erase.c new/fs/jffs2/erase.c
|
||||||
diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
--- old/fs/jffs2/file.c 2022-05-09 17:22:53.000000000 +0800
|
--- old/fs/jffs2/file.c 2022-05-09 17:22:53.000000000 +0800
|
||||||
+++ new/fs/jffs2/file.c 2022-05-10 09:43:14.250000000 +0800
|
+++ new/fs/jffs2/file.c 2022-05-10 09:43:14.250000000 +0800
|
||||||
@@ -9,334 +9,31 @@
|
@@ -9,325 +9,34 @@
|
||||||
* For licensing information, see the file 'LICENCE' in this directory.
|
* For licensing information, see the file 'LICENCE' in this directory.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -2336,37 +2336,32 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
- loff_t pos, unsigned len, unsigned flags,
|
- loff_t pos, unsigned len, unsigned flags,
|
||||||
- struct page **pagep, void **fsdata);
|
- struct page **pagep, void **fsdata);
|
||||||
-static int jffs2_readpage (struct file *filp, struct page *pg);
|
-static int jffs2_readpage (struct file *filp, struct page *pg);
|
||||||
|
-
|
||||||
|
-int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
|
||||||
|
-{
|
||||||
|
- struct inode *inode = filp->f_mapping->host;
|
||||||
|
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- ret = file_write_and_wait_range(filp, start, end);
|
||||||
|
- if (ret)
|
||||||
|
- return ret;
|
||||||
|
|
||||||
|
- inode_lock(inode);
|
||||||
|
- /* Trigger GC to flush any pending writes for this inode */
|
||||||
|
- jffs2_flush_wbuf_gc(c, inode->i_ino);
|
||||||
|
- inode_unlock(inode);
|
||||||
+static unsigned char gc_buffer[PAGE_SIZE]; //avoids malloc when user may be under memory pressure
|
+static unsigned char gc_buffer[PAGE_SIZE]; //avoids malloc when user may be under memory pressure
|
||||||
|
|
||||||
-int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
|
- return 0;
|
||||||
|
-}
|
||||||
|
|
||||||
|
-const struct file_operations jffs2_file_operations =
|
||||||
+unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
|
+unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
|
||||||
+ struct jffs2_inode_info *f,
|
+ struct jffs2_inode_info *f,
|
||||||
+ unsigned long offset,
|
+ unsigned long offset,
|
||||||
+ unsigned long *priv)
|
+ unsigned long *priv)
|
||||||
{
|
{
|
||||||
- struct inode *inode = filp->f_mapping->host;
|
|
||||||
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
|
||||||
+ /* FIXME: This works only with one file system mounted at a time */
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
- ret = file_write_and_wait_range(filp, start, end);
|
|
||||||
+ ret = jffs2_read_inode_range(c, f, gc_buffer,
|
|
||||||
+ offset & ~(PAGE_SIZE-1), PAGE_SIZE);
|
|
||||||
if (ret)
|
|
||||||
- return ret;
|
|
||||||
-
|
|
||||||
- inode_lock(inode);
|
|
||||||
- /* Trigger GC to flush any pending writes for this inode */
|
|
||||||
- jffs2_flush_wbuf_gc(c, inode->i_ino);
|
|
||||||
- inode_unlock(inode);
|
|
||||||
-
|
|
||||||
- return 0;
|
|
||||||
+ return ERR_PTR(ret);
|
|
||||||
+ return gc_buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
-const struct file_operations jffs2_file_operations =
|
|
||||||
-{
|
|
||||||
- .llseek = generic_file_llseek,
|
- .llseek = generic_file_llseek,
|
||||||
- .open = generic_file_open,
|
- .open = generic_file_open,
|
||||||
- .read_iter = generic_file_read_iter,
|
- .read_iter = generic_file_read_iter,
|
||||||
|
@ -2389,10 +2384,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
-};
|
-};
|
||||||
-
|
-
|
||||||
-const struct address_space_operations jffs2_file_address_operations =
|
-const struct address_space_operations jffs2_file_address_operations =
|
||||||
+void jffs2_gc_release_page(struct jffs2_sb_info *c,
|
-{
|
||||||
+ unsigned char *ptr,
|
|
||||||
+ unsigned long *priv)
|
|
||||||
{
|
|
||||||
- .readpage = jffs2_readpage,
|
- .readpage = jffs2_readpage,
|
||||||
- .write_begin = jffs2_write_begin,
|
- .write_begin = jffs2_write_begin,
|
||||||
- .write_end = jffs2_write_end,
|
- .write_end = jffs2_write_end,
|
||||||
|
@ -2403,8 +2395,9 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
||||||
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
||||||
- unsigned char *pg_buf;
|
- unsigned char *pg_buf;
|
||||||
- int ret;
|
+ /* FIXME: This works only with one file system mounted at a time */
|
||||||
-
|
int ret;
|
||||||
|
|
||||||
- jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n",
|
- jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n",
|
||||||
- __func__, inode->i_ino, pg->index << PAGE_SHIFT);
|
- __func__, inode->i_ino, pg->index << PAGE_SHIFT);
|
||||||
-
|
-
|
||||||
|
@ -2443,39 +2436,53 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
-{
|
-{
|
||||||
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host);
|
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host);
|
||||||
- int ret;
|
- int ret;
|
||||||
-
|
+ ret = jffs2_read_inode_range(c, f, gc_buffer,
|
||||||
|
+ offset & ~(PAGE_SIZE-1), PAGE_SIZE);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ERR_PTR(ret);
|
||||||
|
|
||||||
- mutex_lock(&f->sem);
|
- mutex_lock(&f->sem);
|
||||||
- ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);
|
- ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);
|
||||||
- mutex_unlock(&f->sem);
|
- mutex_unlock(&f->sem);
|
||||||
- return ret;
|
- return ret;
|
||||||
-}
|
+ return gc_buffer;
|
||||||
|
}
|
||||||
-
|
-
|
||||||
-static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
|
-static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
|
||||||
- loff_t pos, unsigned len, unsigned flags,
|
- loff_t pos, unsigned len, unsigned flags,
|
||||||
- struct page **pagep, void **fsdata)
|
- struct page **pagep, void **fsdata)
|
||||||
-{
|
+void jffs2_gc_release_page(struct jffs2_sb_info *c,
|
||||||
|
+ unsigned char *ptr,
|
||||||
|
+ unsigned long *priv)
|
||||||
|
{
|
||||||
- struct page *pg;
|
- struct page *pg;
|
||||||
- struct inode *inode = mapping->host;
|
- struct inode *inode = mapping->host;
|
||||||
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
||||||
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
|
||||||
- pgoff_t index = pos >> PAGE_SHIFT;
|
- pgoff_t index = pos >> PAGE_SHIFT;
|
||||||
|
- uint32_t pageofs = index << PAGE_SHIFT;
|
||||||
- int ret = 0;
|
- int ret = 0;
|
||||||
-
|
-
|
||||||
|
- pg = grab_cache_page_write_begin(mapping, index, flags);
|
||||||
|
- if (!pg)
|
||||||
|
- return -ENOMEM;
|
||||||
|
- *pagep = pg;
|
||||||
|
-
|
||||||
- jffs2_dbg(1, "%s()\n", __func__);
|
- jffs2_dbg(1, "%s()\n", __func__);
|
||||||
-
|
-
|
||||||
- if (pos > inode->i_size) {
|
- if (pageofs > inode->i_size) {
|
||||||
- /* Make new hole frag from old EOF to new position */
|
- /* Make new hole frag from old EOF to new page */
|
||||||
|
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
||||||
- struct jffs2_raw_inode ri;
|
- struct jffs2_raw_inode ri;
|
||||||
- struct jffs2_full_dnode *fn;
|
- struct jffs2_full_dnode *fn;
|
||||||
- uint32_t alloc_len;
|
- uint32_t alloc_len;
|
||||||
-
|
-
|
||||||
- jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new position\n",
|
- jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
|
||||||
- (unsigned int)inode->i_size, (uint32_t)pos);
|
- (unsigned int)inode->i_size, pageofs);
|
||||||
-
|
-
|
||||||
- ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
|
- ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
|
||||||
- ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
|
- ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
|
||||||
- if (ret)
|
- if (ret)
|
||||||
- goto out_err;
|
- goto out_page;
|
||||||
-
|
-
|
||||||
- mutex_lock(&f->sem);
|
- mutex_lock(&f->sem);
|
||||||
- memset(&ri, 0, sizeof(ri));
|
- memset(&ri, 0, sizeof(ri));
|
||||||
|
@ -2490,10 +2497,10 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
- ri.mode = cpu_to_jemode(inode->i_mode);
|
- ri.mode = cpu_to_jemode(inode->i_mode);
|
||||||
- ri.uid = cpu_to_je16(i_uid_read(inode));
|
- ri.uid = cpu_to_je16(i_uid_read(inode));
|
||||||
- ri.gid = cpu_to_je16(i_gid_read(inode));
|
- ri.gid = cpu_to_je16(i_gid_read(inode));
|
||||||
- ri.isize = cpu_to_je32((uint32_t)pos);
|
- ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
|
||||||
- ri.atime = ri.ctime = ri.mtime = cpu_to_je32(JFFS2_NOW());
|
- ri.atime = ri.ctime = ri.mtime = cpu_to_je32(JFFS2_NOW());
|
||||||
- ri.offset = cpu_to_je32(inode->i_size);
|
- ri.offset = cpu_to_je32(inode->i_size);
|
||||||
- ri.dsize = cpu_to_je32((uint32_t)pos - inode->i_size);
|
- ri.dsize = cpu_to_je32(pageofs - inode->i_size);
|
||||||
- ri.csize = cpu_to_je32(0);
|
- ri.csize = cpu_to_je32(0);
|
||||||
- ri.compr = JFFS2_COMPR_ZERO;
|
- ri.compr = JFFS2_COMPR_ZERO;
|
||||||
- ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
|
- ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
|
||||||
|
@ -2505,7 +2512,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
- ret = PTR_ERR(fn);
|
- ret = PTR_ERR(fn);
|
||||||
- jffs2_complete_reservation(c);
|
- jffs2_complete_reservation(c);
|
||||||
- mutex_unlock(&f->sem);
|
- mutex_unlock(&f->sem);
|
||||||
- goto out_err;
|
- goto out_page;
|
||||||
- }
|
- }
|
||||||
- ret = jffs2_add_full_dnode_to_inode(c, f, fn);
|
- ret = jffs2_add_full_dnode_to_inode(c, f, fn);
|
||||||
- if (f->metadata) {
|
- if (f->metadata) {
|
||||||
|
@ -2520,27 +2527,14 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
- jffs2_free_full_dnode(fn);
|
- jffs2_free_full_dnode(fn);
|
||||||
- jffs2_complete_reservation(c);
|
- jffs2_complete_reservation(c);
|
||||||
- mutex_unlock(&f->sem);
|
- mutex_unlock(&f->sem);
|
||||||
- goto out_err;
|
- goto out_page;
|
||||||
- }
|
- }
|
||||||
- jffs2_complete_reservation(c);
|
- jffs2_complete_reservation(c);
|
||||||
- inode->i_size = pos;
|
- inode->i_size = pageofs;
|
||||||
- mutex_unlock(&f->sem);
|
- mutex_unlock(&f->sem);
|
||||||
- }
|
- }
|
||||||
-
|
-
|
||||||
- /*
|
- /*
|
||||||
- * While getting a page and reading data in, lock c->alloc_sem until
|
|
||||||
- * the page is Uptodate. Otherwise GC task may attempt to read the same
|
|
||||||
- * page in read_cache_page(), which causes a deadlock.
|
|
||||||
- */
|
|
||||||
- mutex_lock(&c->alloc_sem);
|
|
||||||
- pg = grab_cache_page_write_begin(mapping, index, flags);
|
|
||||||
- if (!pg) {
|
|
||||||
- ret = -ENOMEM;
|
|
||||||
- goto release_sem;
|
|
||||||
- }
|
|
||||||
- *pagep = pg;
|
|
||||||
-
|
|
||||||
- /*
|
|
||||||
- * Read in the page if it wasn't already present. Cannot optimize away
|
- * Read in the page if it wasn't already present. Cannot optimize away
|
||||||
- * the whole page write case until jffs2_write_end can handle the
|
- * the whole page write case until jffs2_write_end can handle the
|
||||||
- * case of a short-copy.
|
- * case of a short-copy.
|
||||||
|
@ -2549,20 +2543,19 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
- mutex_lock(&f->sem);
|
- mutex_lock(&f->sem);
|
||||||
- ret = jffs2_do_readpage_nolock(inode, pg);
|
- ret = jffs2_do_readpage_nolock(inode, pg);
|
||||||
- mutex_unlock(&f->sem);
|
- mutex_unlock(&f->sem);
|
||||||
- if (ret) {
|
- if (ret)
|
||||||
- unlock_page(pg);
|
- goto out_page;
|
||||||
- put_page(pg);
|
|
||||||
- goto release_sem;
|
|
||||||
- }
|
|
||||||
- }
|
- }
|
||||||
- jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
|
- jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
|
||||||
-
|
|
||||||
-release_sem:
|
|
||||||
- mutex_unlock(&c->alloc_sem);
|
|
||||||
-out_err:
|
|
||||||
- return ret;
|
- return ret;
|
||||||
-}
|
|
||||||
-
|
-
|
||||||
|
-out_page:
|
||||||
|
- unlock_page(pg);
|
||||||
|
- put_page(pg);
|
||||||
|
- return ret;
|
||||||
|
+ /* Do nothing */
|
||||||
|
}
|
||||||
|
|
||||||
-static int jffs2_write_end(struct file *filp, struct address_space *mapping,
|
-static int jffs2_write_end(struct file *filp, struct address_space *mapping,
|
||||||
- loff_t pos, unsigned len, unsigned copied,
|
- loff_t pos, unsigned len, unsigned copied,
|
||||||
- struct page *pg, void *fsdata)
|
- struct page *pg, void *fsdata)
|
||||||
|
@ -2660,8 +2653,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||||
- unlock_page(pg);
|
- unlock_page(pg);
|
||||||
- put_page(pg);
|
- put_page(pg);
|
||||||
- return writtenlen > 0 ? writtenlen : ret;
|
- return writtenlen > 0 ? writtenlen : ret;
|
||||||
+ /* Do nothing */
|
-}
|
||||||
}
|
|
||||||
diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
--- old/fs/jffs2/fs.c 2022-05-09 17:22:53.000000000 +0800
|
--- old/fs/jffs2/fs.c 2022-05-09 17:22:53.000000000 +0800
|
||||||
+++ new/fs/jffs2/fs.c 2022-05-10 16:13:37.830000000 +0800
|
+++ new/fs/jffs2/fs.c 2022-05-10 16:13:37.830000000 +0800
|
||||||
|
@ -2777,11 +2769,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
ri->version = cpu_to_je32(++f->highest_version);
|
ri->version = cpu_to_je32(++f->highest_version);
|
||||||
+ ri->uid = cpu_to_je16(inode->i_uid);
|
+ ri->uid = cpu_to_je16(inode->i_uid);
|
||||||
+ ri->gid = cpu_to_je16(inode->i_gid);
|
+ ri->gid = cpu_to_je16(inode->i_gid);
|
||||||
|
+
|
||||||
- ri->uid = cpu_to_je16((ivalid & ATTR_UID)?
|
|
||||||
- from_kuid(&init_user_ns, iattr->ia_uid):i_uid_read(inode));
|
|
||||||
- ri->gid = cpu_to_je16((ivalid & ATTR_GID)?
|
|
||||||
- from_kgid(&init_user_ns, iattr->ia_gid):i_gid_read(inode));
|
|
||||||
+ if (ivalid & CHG_UID) {
|
+ if (ivalid & CHG_UID) {
|
||||||
+ if (((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) && (!IsCapPermit(CAP_CHOWN))) {
|
+ if (((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) && (!IsCapPermit(CAP_CHOWN))) {
|
||||||
+ jffs2_complete_reservation(c);
|
+ jffs2_complete_reservation(c);
|
||||||
|
@ -2803,7 +2791,16 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
+ ri->gid = cpu_to_je16(attr->attr_chg_gid);
|
+ ri->gid = cpu_to_je16(attr->attr_chg_gid);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
|
- ri->uid = cpu_to_je16((ivalid & ATTR_UID)?
|
||||||
|
- from_kuid(&init_user_ns, iattr->ia_uid):i_uid_read(inode));
|
||||||
|
- ri->gid = cpu_to_je16((ivalid & ATTR_GID)?
|
||||||
|
- from_kgid(&init_user_ns, iattr->ia_gid):i_gid_read(inode));
|
||||||
|
-
|
||||||
|
- if (ivalid & ATTR_MODE)
|
||||||
|
- ri->mode = cpu_to_jemode(iattr->ia_mode);
|
||||||
|
- else
|
||||||
|
- ri->mode = cpu_to_jemode(inode->i_mode);
|
||||||
+ if (ivalid & CHG_MODE) {
|
+ if (ivalid & CHG_MODE) {
|
||||||
+ if (!IsCapPermit(CAP_FOWNER) && (c_uid != inode->i_uid)) {
|
+ if (!IsCapPermit(CAP_FOWNER) && (c_uid != inode->i_uid)) {
|
||||||
+ jffs2_complete_reservation(c);
|
+ jffs2_complete_reservation(c);
|
||||||
|
@ -2817,10 +2814,6 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
- if (ivalid & ATTR_MODE)
|
|
||||||
- ri->mode = cpu_to_jemode(iattr->ia_mode);
|
|
||||||
- else
|
|
||||||
- ri->mode = cpu_to_jemode(inode->i_mode);
|
|
||||||
+ if (ivalid & CHG_ATIME) {
|
+ if (ivalid & CHG_ATIME) {
|
||||||
+ if ((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) {
|
+ if ((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) {
|
||||||
+ return -EPERM;
|
+ return -EPERM;
|
||||||
|
@ -2830,7 +2823,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
+ } else {
|
+ } else {
|
||||||
+ ri->atime = cpu_to_je32(inode->i_atime);
|
+ ri->atime = cpu_to_je32(inode->i_atime);
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ if (ivalid & CHG_MTIME) {
|
+ if (ivalid & CHG_MTIME) {
|
||||||
+ if ((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) {
|
+ if ((c_uid != inode->i_uid) || (attr->attr_chg_uid != inode->i_uid)) {
|
||||||
+ return -EPERM;
|
+ return -EPERM;
|
||||||
|
@ -2882,7 +2875,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
if (IS_ERR(new_metadata)) {
|
if (IS_ERR(new_metadata)) {
|
||||||
jffs2_complete_reservation(c);
|
jffs2_complete_reservation(c);
|
||||||
jffs2_free_raw_inode(ri);
|
jffs2_free_raw_inode(ri);
|
||||||
@@ -147,23 +140,20 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
|
@@ -147,23 +140,20 @@ int jffs2_do_setattr (struct inode *inod
|
||||||
return PTR_ERR(new_metadata);
|
return PTR_ERR(new_metadata);
|
||||||
}
|
}
|
||||||
/* It worked. Update the inode */
|
/* It worked. Update the inode */
|
||||||
|
@ -2915,7 +2908,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
f->metadata = NULL;
|
f->metadata = NULL;
|
||||||
} else {
|
} else {
|
||||||
f->metadata = new_metadata;
|
f->metadata = new_metadata;
|
||||||
@@ -182,315 +172,201 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
|
@@ -182,315 +172,201 @@ int jffs2_do_setattr (struct inode *inod
|
||||||
We are protected from a simultaneous write() extending i_size
|
We are protected from a simultaneous write() extending i_size
|
||||||
back past iattr->ia_size, because do_truncate() holds the
|
back past iattr->ia_size, because do_truncate() holds the
|
||||||
generic inode semaphore. */
|
generic inode semaphore. */
|
||||||
|
@ -2934,43 +2927,31 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
{
|
{
|
||||||
- struct inode *inode = d_inode(dentry);
|
- struct inode *inode = d_inode(dentry);
|
||||||
- int rc;
|
- int rc;
|
||||||
|
-
|
||||||
|
- rc = setattr_prepare(dentry, iattr);
|
||||||
|
- if (rc)
|
||||||
|
- return rc;
|
||||||
|
-
|
||||||
|
- rc = jffs2_do_setattr(inode, iattr);
|
||||||
|
- if (!rc && (iattr->ia_valid & ATTR_MODE))
|
||||||
|
- rc = posix_acl_chmod(inode, inode->i_mode);
|
||||||
+ /* We can forget about this inode for now - drop all
|
+ /* We can forget about this inode for now - drop all
|
||||||
+ * the nodelists associated with it, etc.
|
+ * the nodelists associated with it, etc.
|
||||||
+ */
|
+ */
|
||||||
+ struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
+ struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
||||||
+ struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
+ struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
||||||
+
|
|
||||||
+ jffs2_do_clear_inode(c, f);
|
|
||||||
+}
|
|
||||||
|
|
||||||
- rc = setattr_prepare(dentry, iattr);
|
|
||||||
- if (rc)
|
|
||||||
- return rc;
|
|
||||||
+static struct jffs2_inode *ilookup(struct super_block *sb, uint32_t ino)
|
|
||||||
+{
|
|
||||||
+ struct jffs2_inode *node = NULL;
|
|
||||||
|
|
||||||
- rc = jffs2_do_setattr(inode, iattr);
|
|
||||||
- if (!rc && (iattr->ia_valid & ATTR_MODE))
|
|
||||||
- rc = posix_acl_chmod(inode, inode->i_mode);
|
|
||||||
+ if (sb->s_root == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- return rc;
|
- return rc;
|
||||||
+ // Check for this inode in the cache
|
+ jffs2_do_clear_inode(c, f);
|
||||||
+ Jffs2NodeLock();
|
|
||||||
+ (void)Jffs2HashGet(&sb->s_node_hash_lock, &sb->s_node_hash[0], sb, ino, &node);
|
|
||||||
+ Jffs2NodeUnlock();
|
|
||||||
+ return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-int jffs2_statfs(struct dentry *dentry, struct kstatfs *buf)
|
-int jffs2_statfs(struct dentry *dentry, struct kstatfs *buf)
|
||||||
+struct jffs2_inode *new_inode(struct super_block *sb)
|
+static struct jffs2_inode *ilookup(struct super_block *sb, uint32_t ino)
|
||||||
{
|
{
|
||||||
- struct jffs2_sb_info *c = JFFS2_SB_INFO(dentry->d_sb);
|
- struct jffs2_sb_info *c = JFFS2_SB_INFO(dentry->d_sb);
|
||||||
- unsigned long avail;
|
- unsigned long avail;
|
||||||
-
|
+ struct jffs2_inode *node = NULL;
|
||||||
|
|
||||||
- buf->f_type = JFFS2_SUPER_MAGIC;
|
- buf->f_type = JFFS2_SUPER_MAGIC;
|
||||||
- buf->f_bsize = 1 << PAGE_SHIFT;
|
- buf->f_bsize = 1 << PAGE_SHIFT;
|
||||||
- buf->f_blocks = c->flash_size >> PAGE_SHIFT;
|
- buf->f_blocks = c->flash_size >> PAGE_SHIFT;
|
||||||
|
@ -2989,35 +2970,47 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
- spin_unlock(&c->erase_completion_lock);
|
- spin_unlock(&c->erase_completion_lock);
|
||||||
-
|
-
|
||||||
- buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT;
|
- buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT;
|
||||||
+ struct jffs2_inode *inode = NULL;
|
+ if (sb->s_root == NULL) {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
|
||||||
- return 0;
|
- return 0;
|
||||||
-}
|
+ // Check for this inode in the cache
|
||||||
+ inode = zalloc(sizeof (struct jffs2_inode));
|
+ Jffs2NodeLock();
|
||||||
+ if (inode == NULL)
|
+ (void)Jffs2HashGet(&sb->s_node_hash_lock, &sb->s_node_hash[0], sb, ino, &node);
|
||||||
+ return 0;
|
+ Jffs2NodeUnlock();
|
||||||
|
+ return node;
|
||||||
+ D2(PRINTK("malloc new_inode %x ####################################\n",
|
}
|
||||||
+ inode));
|
|
||||||
|
|
||||||
|
-
|
||||||
-void jffs2_evict_inode (struct inode *inode)
|
-void jffs2_evict_inode (struct inode *inode)
|
||||||
-{
|
+struct jffs2_inode *new_inode(struct super_block *sb)
|
||||||
|
{
|
||||||
- /* We can forget about this inode for now - drop all
|
- /* We can forget about this inode for now - drop all
|
||||||
- * the nodelists associated with it, etc.
|
- * the nodelists associated with it, etc.
|
||||||
- */
|
- */
|
||||||
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
||||||
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
||||||
+ inode->i_sb = sb;
|
+ struct jffs2_inode *inode = NULL;
|
||||||
+ inode->i_ino = 1;
|
|
||||||
+ inode->i_nlink = 1; // Let JFFS2 manage the link count
|
|
||||||
+ inode->i_size = 0;
|
|
||||||
+ LOS_ListInit((&(inode->i_hashlist)));
|
|
||||||
|
|
||||||
- jffs2_dbg(1, "%s(): ino #%lu mode %o\n",
|
- jffs2_dbg(1, "%s(): ino #%lu mode %o\n",
|
||||||
- __func__, inode->i_ino, inode->i_mode);
|
- __func__, inode->i_ino, inode->i_mode);
|
||||||
- truncate_inode_pages_final(&inode->i_data);
|
- truncate_inode_pages_final(&inode->i_data);
|
||||||
- clear_inode(inode);
|
- clear_inode(inode);
|
||||||
- jffs2_do_clear_inode(c, f);
|
- jffs2_do_clear_inode(c, f);
|
||||||
|
+ inode = zalloc(sizeof (struct jffs2_inode));
|
||||||
|
+ if (inode == NULL)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ D2(PRINTK("malloc new_inode %x ####################################\n",
|
||||||
|
+ inode));
|
||||||
|
+
|
||||||
|
+ inode->i_sb = sb;
|
||||||
|
+ inode->i_ino = 1;
|
||||||
|
+ inode->i_nlink = 1; // Let JFFS2 manage the link count
|
||||||
|
+ inode->i_size = 0;
|
||||||
|
+ LOS_ListInit((&(inode->i_hashlist)));
|
||||||
|
+
|
||||||
+ return inode;
|
+ return inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3082,16 +3075,16 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
- inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
|
- inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
|
||||||
-
|
-
|
||||||
- set_nlink(inode, f->inocache->pino_nlink);
|
- set_nlink(inode, f->inocache->pino_nlink);
|
||||||
-
|
|
||||||
- inode->i_blocks = (inode->i_size + 511) >> 9;
|
|
||||||
+ inode->i_atime = je32_to_cpu(latest_node.atime);
|
+ inode->i_atime = je32_to_cpu(latest_node.atime);
|
||||||
+ inode->i_mtime = je32_to_cpu(latest_node.mtime);
|
+ inode->i_mtime = je32_to_cpu(latest_node.mtime);
|
||||||
+ inode->i_ctime = je32_to_cpu(latest_node.ctime);
|
+ inode->i_ctime = je32_to_cpu(latest_node.ctime);
|
||||||
+ inode->i_nlink = f->inocache->pino_nlink;
|
+ inode->i_nlink = f->inocache->pino_nlink;
|
||||||
|
|
||||||
- switch (inode->i_mode & S_IFMT) {
|
- inode->i_blocks = (inode->i_size + 511) >> 9;
|
||||||
+ (void)mutex_unlock(&f->sem);
|
+ (void)mutex_unlock(&f->sem);
|
||||||
|
|
||||||
|
- switch (inode->i_mode & S_IFMT) {
|
||||||
|
-
|
||||||
- case S_IFLNK:
|
- case S_IFLNK:
|
||||||
- inode->i_op = &jffs2_symlink_inode_operations;
|
- inode->i_op = &jffs2_symlink_inode_operations;
|
||||||
- inode->i_link = f->target;
|
- inode->i_link = f->target;
|
||||||
|
@ -3161,21 +3154,20 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
jffs2_dbg(1, "jffs2_read_inode() returning\n");
|
jffs2_dbg(1, "jffs2_read_inode() returning\n");
|
||||||
- unlock_new_inode(inode);
|
- unlock_new_inode(inode);
|
||||||
- return inode;
|
- return inode;
|
||||||
+ Jffs2NodeUnlock();
|
-
|
||||||
|
|
||||||
-error_io:
|
-error_io:
|
||||||
- ret = -EIO;
|
- ret = -EIO;
|
||||||
-error:
|
-error:
|
||||||
- mutex_unlock(&f->sem);
|
- mutex_unlock(&f->sem);
|
||||||
- iget_failed(inode);
|
- iget_failed(inode);
|
||||||
- return ERR_PTR(ret);
|
- return ERR_PTR(ret);
|
||||||
+ return inode;
|
-}
|
||||||
}
|
+ Jffs2NodeUnlock();
|
||||||
|
|
||||||
-void jffs2_dirty_inode(struct inode *inode, int flags)
|
-void jffs2_dirty_inode(struct inode *inode, int flags)
|
||||||
-{
|
-{
|
||||||
- struct iattr iattr;
|
- struct iattr iattr;
|
||||||
|
-
|
||||||
- if (!(inode->i_state & I_DIRTY_DATASYNC)) {
|
- if (!(inode->i_state & I_DIRTY_DATASYNC)) {
|
||||||
- jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n",
|
- jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n",
|
||||||
- __func__, inode->i_ino);
|
- __func__, inode->i_ino);
|
||||||
|
@ -3194,19 +3186,16 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
- iattr.ia_ctime = inode->i_ctime;
|
- iattr.ia_ctime = inode->i_ctime;
|
||||||
-
|
-
|
||||||
- jffs2_do_setattr(inode, &iattr);
|
- jffs2_do_setattr(inode, &iattr);
|
||||||
-}
|
+ return inode;
|
||||||
+// -------------------------------------------------------------------------
|
}
|
||||||
+// Decrement the reference count on an inode. If this makes the ref count
|
|
||||||
+// zero, then this inode can be freed.
|
|
||||||
|
|
||||||
-int jffs2_do_remount_fs(struct super_block *sb, struct fs_context *fc)
|
-int jffs2_do_remount_fs(struct super_block *sb, struct fs_context *fc)
|
||||||
+int jffs2_iput(struct jffs2_inode *i)
|
-{
|
||||||
{
|
|
||||||
- struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
|
- struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
|
||||||
-
|
-
|
||||||
- if (c->flags & JFFS2_SB_FLAG_RO && !sb_rdonly(sb))
|
- if (c->flags & JFFS2_SB_FLAG_RO && !sb_rdonly(sb))
|
||||||
- return -EROFS;
|
- return -EROFS;
|
||||||
-
|
|
||||||
- /* We stop if it was running, then restart if it needs to.
|
- /* We stop if it was running, then restart if it needs to.
|
||||||
- This also catches the case where it was stopped and this
|
- This also catches the case where it was stopped and this
|
||||||
- is just a remount to restart it.
|
- is just a remount to restart it.
|
||||||
|
@ -3217,9 +3206,12 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
- jffs2_flush_wbuf_pad(c);
|
- jffs2_flush_wbuf_pad(c);
|
||||||
- mutex_unlock(&c->alloc_sem);
|
- mutex_unlock(&c->alloc_sem);
|
||||||
- }
|
- }
|
||||||
-
|
+// -------------------------------------------------------------------------
|
||||||
- if (!(fc->sb_flags & SB_RDONLY))
|
+// Decrement the reference count on an inode. If this makes the ref count
|
||||||
- jffs2_start_garbage_collect_thread(c);
|
+// zero, then this inode can be freed.
|
||||||
|
+
|
||||||
|
+int jffs2_iput(struct jffs2_inode *i)
|
||||||
|
+{
|
||||||
+ // Called in jffs2_find
|
+ // Called in jffs2_find
|
||||||
+ // (and jffs2_open and jffs2_ops_mkdir?)
|
+ // (and jffs2_open and jffs2_ops_mkdir?)
|
||||||
+ // super.c jffs2_fill_super,
|
+ // super.c jffs2_fill_super,
|
||||||
|
@ -3241,6 +3233,9 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
+ free(i);
|
+ free(i);
|
||||||
+ Jffs2NodeUnlock();
|
+ Jffs2NodeUnlock();
|
||||||
|
|
||||||
|
- if (!(fc->sb_flags & SB_RDONLY))
|
||||||
|
- jffs2_start_garbage_collect_thread(c);
|
||||||
|
-
|
||||||
- fc->sb_flags |= SB_NOATIME;
|
- fc->sb_flags |= SB_NOATIME;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3347,7 +3342,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Pick a inocache hash size based on the size of the medium.
|
* Pick a inocache hash size based on the size of the medium.
|
||||||
@@ -510,118 +386,17 @@ static int calculate_inocache_hashsize(uint32_t flash_size)
|
@@ -510,117 +386,17 @@ static int calculate_inocache_hashsize(u
|
||||||
return hashsize;
|
return hashsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3443,9 +3438,8 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
- jffs2_free_ino_caches(c);
|
- jffs2_free_ino_caches(c);
|
||||||
- jffs2_free_raw_node_refs(c);
|
- jffs2_free_raw_node_refs(c);
|
||||||
- kvfree(c->blocks);
|
- kvfree(c->blocks);
|
||||||
- jffs2_clear_xattr_subsystem(c);
|
|
||||||
- jffs2_sum_exit(c);
|
|
||||||
- out_inohash:
|
- out_inohash:
|
||||||
|
- jffs2_clear_xattr_subsystem(c);
|
||||||
- kfree(c->inocache_list);
|
- kfree(c->inocache_list);
|
||||||
- out_wbuf:
|
- out_wbuf:
|
||||||
- jffs2_flash_cleanup(c);
|
- jffs2_flash_cleanup(c);
|
||||||
|
@ -3454,7 +3448,8 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
-}
|
-}
|
||||||
-
|
-
|
||||||
void jffs2_gc_release_inode(struct jffs2_sb_info *c,
|
void jffs2_gc_release_inode(struct jffs2_sb_info *c,
|
||||||
struct jffs2_inode_info *f)
|
- struct jffs2_inode_info *f)
|
||||||
|
+ struct jffs2_inode_info *f)
|
||||||
{
|
{
|
||||||
- iput(OFNI_EDONI_2SFFJ(f));
|
- iput(OFNI_EDONI_2SFFJ(f));
|
||||||
+ struct jffs2_inode *node = OFNI_EDONI_2SFFJ(f);
|
+ struct jffs2_inode *node = OFNI_EDONI_2SFFJ(f);
|
||||||
|
@ -3469,7 +3464,7 @@ diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
|
||||||
struct jffs2_inode_cache *ic;
|
struct jffs2_inode_cache *ic;
|
||||||
|
|
||||||
if (unlinked) {
|
if (unlinked) {
|
||||||
@@ -669,72 +444,9 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c,
|
@@ -668,72 +444,9 @@ struct jffs2_inode_info *jffs2_gc_fetch_
|
||||||
Just iget() it, and if read_inode() is necessary that's OK.
|
Just iget() it, and if read_inode() is necessary that's OK.
|
||||||
*/
|
*/
|
||||||
inode = jffs2_iget(OFNI_BS_2SFFJ(c), inum);
|
inode = jffs2_iget(OFNI_BS_2SFFJ(c), inum);
|
||||||
|
@ -5561,7 +5556,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
|
||||||
|
|
||||||
#define DEFAULT_EMPTY_SCAN_SIZE 256
|
#define DEFAULT_EMPTY_SCAN_SIZE 256
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ static int file_dirty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
|
@@ -74,7 +73,7 @@ static int file_dirty(struct jffs2_sb_in
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size)))
|
if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size)))
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -5570,13 +5565,15 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
|
||||||
think it's recoverable now. */
|
think it's recoverable now. */
|
||||||
jeb->dirty_size += jeb->wasted_size;
|
jeb->dirty_size += jeb->wasted_size;
|
||||||
c->dirty_size += jeb->wasted_size;
|
c->dirty_size += jeb->wasted_size;
|
||||||
@@ -95,40 +94,26 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
|
@@ -95,40 +94,26 @@ int jffs2_scan_medium(struct jffs2_sb_in
|
||||||
unsigned char *flashbuf = NULL;
|
unsigned char *flashbuf = NULL;
|
||||||
uint32_t buf_size = 0;
|
uint32_t buf_size = 0;
|
||||||
struct jffs2_summary *s = NULL; /* summary info collected by the scan process */
|
struct jffs2_summary *s = NULL; /* summary info collected by the scan process */
|
||||||
-#ifndef __ECOS
|
-#ifndef __ECOS
|
||||||
- size_t pointlen, try_size;
|
- size_t pointlen, try_size;
|
||||||
-
|
+ struct super_block *sb = NULL;
|
||||||
|
+ struct MtdNorDev *device = NULL;
|
||||||
|
|
||||||
- ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen,
|
- ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen,
|
||||||
- (void **)&flashbuf, NULL);
|
- (void **)&flashbuf, NULL);
|
||||||
- if (!ret && pointlen < c->mtd->size) {
|
- if (!ret && pointlen < c->mtd->size) {
|
||||||
|
@ -5589,9 +5586,6 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
|
||||||
- if (ret && ret != -EOPNOTSUPP)
|
- if (ret && ret != -EOPNOTSUPP)
|
||||||
- jffs2_dbg(1, "MTD point failed %d\n", ret);
|
- jffs2_dbg(1, "MTD point failed %d\n", ret);
|
||||||
-#endif
|
-#endif
|
||||||
+ struct super_block *sb = NULL;
|
|
||||||
+ struct MtdNorDev *device = NULL;
|
|
||||||
+
|
|
||||||
if (!flashbuf) {
|
if (!flashbuf) {
|
||||||
/* For NAND it's quicker to read a whole eraseblock at a time,
|
/* For NAND it's quicker to read a whole eraseblock at a time,
|
||||||
apparently */
|
apparently */
|
||||||
|
@ -5619,7 +5613,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jffs2_sum_active()) {
|
if (jffs2_sum_active()) {
|
||||||
@@ -140,7 +125,9 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
|
@@ -140,7 +125,9 @@ int jffs2_scan_medium(struct jffs2_sb_in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5630,7 +5624,7 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
|
||||||
struct jffs2_eraseblock *jeb = &c->blocks[i];
|
struct jffs2_eraseblock *jeb = &c->blocks[i];
|
||||||
|
|
||||||
cond_resched();
|
cond_resched();
|
||||||
@@ -269,14 +256,10 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
|
@@ -269,19 +256,12 @@ int jffs2_scan_medium(struct jffs2_sb_in
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -5640,254 +5634,20 @@ diff -Nupr old/fs/jffs2/scan.c new/fs/jffs2/scan.c
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
- jffs2_sum_reset_collected(s);
|
- if (buf_size)
|
||||||
- kfree(s);
|
- kfree(flashbuf);
|
||||||
+ kfree(flashbuf);
|
|
||||||
out_buf:
|
|
||||||
if (buf_size)
|
|
||||||
kfree(flashbuf);
|
|
||||||
@@ -413,7 +396,7 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
|
|
||||||
if (!ref)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
- /* BEFORE jffs2_build_xattr_subsystem() called,
|
|
||||||
+ /* BEFORE jffs2_build_xattr_subsystem() called,
|
|
||||||
* and AFTER xattr_ref is marked as a dead xref,
|
|
||||||
* ref->xid is used to store 32bit xid, xd is not used
|
|
||||||
* ref->ino is used to store 32bit inode-number, ic is not used
|
|
||||||
@@ -486,10 +469,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
struct jffs2_sum_marker *sm;
|
|
||||||
void *sumptr = NULL;
|
|
||||||
uint32_t sumlen;
|
|
||||||
-
|
|
||||||
+
|
|
||||||
if (!buf_size) {
|
|
||||||
/* XIP case. Just look, point at the summary if it's there */
|
|
||||||
- sm = (void *)buf + c->sector_size - sizeof(*sm);
|
|
||||||
+ sm = (struct jffs2_sum_marker *)((uint8_t *)buf + c->sector_size - sizeof(*sm));
|
|
||||||
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
|
|
||||||
sumptr = buf + je32_to_cpu(sm->offset);
|
|
||||||
sumlen = c->sector_size - je32_to_cpu(sm->offset);
|
|
||||||
@@ -502,13 +485,13 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
buf_len = sizeof(*sm);
|
|
||||||
|
|
||||||
/* Read as much as we want into the _end_ of the preallocated buffer */
|
|
||||||
- err = jffs2_fill_scan_buf(c, buf + buf_size - buf_len,
|
|
||||||
+ err = jffs2_fill_scan_buf(c, buf + buf_size - buf_len,
|
|
||||||
jeb->offset + c->sector_size - buf_len,
|
|
||||||
- buf_len);
|
|
||||||
+ buf_len);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
- sm = (void *)buf + buf_size - sizeof(*sm);
|
|
||||||
+ sm = (struct jffs2_sum_marker *)((uint8_t *)buf + buf_size - sizeof(*sm));
|
|
||||||
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
|
|
||||||
sumlen = c->sector_size - je32_to_cpu(sm->offset);
|
|
||||||
sumptr = buf + buf_size - sumlen;
|
|
||||||
@@ -523,18 +506,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
sumptr = kmalloc(sumlen, GFP_KERNEL);
|
|
||||||
if (!sumptr)
|
|
||||||
return -ENOMEM;
|
|
||||||
- memcpy(sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len);
|
|
||||||
+ memcpy((uint8_t *)sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len);
|
|
||||||
}
|
|
||||||
if (buf_len < sumlen) {
|
|
||||||
/* Need to read more so that the entire summary node is present */
|
|
||||||
- err = jffs2_fill_scan_buf(c, sumptr,
|
|
||||||
+ err = jffs2_fill_scan_buf(c, sumptr,
|
|
||||||
jeb->offset + c->sector_size - sumlen,
|
|
||||||
- sumlen - buf_len);
|
|
||||||
- if (err) {
|
|
||||||
- if (sumlen > buf_size)
|
|
||||||
- kfree(sumptr);
|
|
||||||
+ sumlen - buf_len);
|
|
||||||
+ if (err)
|
|
||||||
return err;
|
|
||||||
- }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -545,7 +525,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
|
|
||||||
if (buf_size && sumlen > buf_size)
|
|
||||||
kfree(sumptr);
|
|
||||||
- /* If it returns with a real error, bail.
|
|
||||||
+ /* If it returns with a real error, bail.
|
|
||||||
If it returns positive, that's a block classification
|
|
||||||
(i.e. BLK_STATE_xxx) so return that too.
|
|
||||||
If it returns zero, fall through to full scan. */
|
|
||||||
@@ -607,7 +587,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
/* Now ofs is a complete physical flash offset as it always was... */
|
|
||||||
ofs += jeb->offset;
|
|
||||||
|
|
||||||
- noise = 10;
|
|
||||||
+ noise = 1;
|
|
||||||
|
|
||||||
dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset);
|
|
||||||
|
|
||||||
@@ -700,7 +680,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
scan_end = buf_len;
|
|
||||||
goto more_empty;
|
|
||||||
}
|
|
||||||
-
|
|
||||||
+
|
|
||||||
/* See how much more there is to read in this eraseblock... */
|
|
||||||
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
|
|
||||||
if (!buf_len) {
|
|
||||||
@@ -950,7 +930,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n",
|
|
||||||
jeb->offset, jeb->free_size, jeb->dirty_size,
|
|
||||||
jeb->unchecked_size, jeb->used_size, jeb->wasted_size);
|
|
||||||
-
|
|
||||||
+
|
|
||||||
/* mark_node_obsolete can add to wasted !! */
|
|
||||||
if (jeb->wasted_size) {
|
|
||||||
jeb->dirty_size += jeb->wasted_size;
|
|
||||||
@@ -978,7 +958,6 @@ struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uin
|
|
||||||
pr_notice("%s(): allocation of inode cache failed\n", __func__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
- memset(ic, 0, sizeof(*ic));
|
|
||||||
|
|
||||||
ic->ino = ino;
|
|
||||||
ic->nodes = (void *)ic;
|
|
||||||
@@ -1069,7 +1048,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
pseudo_random += je32_to_cpu(rd->version);
|
|
||||||
|
|
||||||
/* Should never happen. Did. (OLPC trac #4184)*/
|
|
||||||
- checkedlen = strnlen(rd->name, rd->nsize);
|
|
||||||
+ checkedlen = strnlen((const char *)rd->name, rd->nsize);
|
|
||||||
if (checkedlen < rd->nsize) {
|
|
||||||
pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n",
|
|
||||||
ofs, checkedlen);
|
|
||||||
@@ -1081,7 +1060,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
memcpy(&fd->name, rd->name, checkedlen);
|
|
||||||
fd->name[checkedlen] = 0;
|
|
||||||
|
|
||||||
- crc = crc32(0, fd->name, checkedlen);
|
|
||||||
+ crc = crc32(0, fd->name, rd->nsize);
|
|
||||||
if (crc != je32_to_cpu(rd->name_crc)) {
|
|
||||||
pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
|
|
||||||
__func__, ofs, je32_to_cpu(rd->name_crc), crc);
|
|
||||||
@@ -1106,7 +1085,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
|
|
||||||
fd->next = NULL;
|
|
||||||
fd->version = je32_to_cpu(rd->version);
|
|
||||||
fd->ino = je32_to_cpu(rd->ino);
|
|
||||||
- fd->nhash = full_name_hash(NULL, fd->name, checkedlen);
|
|
||||||
+ fd->nhash = full_name_hash(fd->name, checkedlen);
|
|
||||||
fd->type = rd->type;
|
|
||||||
jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
|
|
||||||
|
|
||||||
diff
|
|
||||||
@@ -9,18 +9,17 @@
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
||||||
-
|
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/sched.h>
|
|
||||||
#include <linux/slab.h>
|
|
||||||
-#include <linux/mtd/mtd.h>
|
|
||||||
#include <linux/pagemap.h>
|
|
||||||
-#include <linux/crc32.h>
|
|
||||||
#include <linux/compiler.h>
|
|
||||||
#include "nodelist.h"
|
|
||||||
#include "summary.h"
|
|
||||||
#include "debug.h"
|
|
||||||
+#include "mtd_dev.h"
|
|
||||||
+#include "los_typedef.h"
|
|
||||||
+#include "los_crc32.h"
|
|
||||||
|
|
||||||
#define DEFAULT_EMPTY_SCAN_SIZE 256
|
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ static int file_dirty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
|
|
||||||
return ret;
|
|
||||||
if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size)))
|
|
||||||
return ret;
|
|
||||||
- /* Turned wasted size into dirty, since we apparently
|
|
||||||
+ /* Turned wasted size into dirty, since we apparently
|
|
||||||
think it's recoverable now. */
|
|
||||||
jeb->dirty_size += jeb->wasted_size;
|
|
||||||
c->dirty_size += jeb->wasted_size;
|
|
||||||
@@ -95,40 +94,26 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
|
|
||||||
unsigned char *flashbuf = NULL;
|
|
||||||
uint32_t buf_size = 0;
|
|
||||||
struct jffs2_summary *s = NULL; /* summary info collected by the scan process */
|
|
||||||
-#ifndef __ECOS
|
-#ifndef __ECOS
|
||||||
- size_t pointlen, try_size;
|
- else
|
||||||
-
|
- mtd_unpoint(c->mtd, 0, c->mtd->size);
|
||||||
- ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen,
|
|
||||||
- (void **)&flashbuf, NULL);
|
|
||||||
- if (!ret && pointlen < c->mtd->size) {
|
|
||||||
- /* Don't muck about if it won't let us point to the whole flash */
|
|
||||||
- jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n",
|
|
||||||
- pointlen);
|
|
||||||
- mtd_unpoint(c->mtd, 0, pointlen);
|
|
||||||
- flashbuf = NULL;
|
|
||||||
- }
|
|
||||||
- if (ret && ret != -EOPNOTSUPP)
|
|
||||||
- jffs2_dbg(1, "MTD point failed %d\n", ret);
|
|
||||||
-#endif
|
-#endif
|
||||||
+ struct super_block *sb = NULL;
|
|
||||||
+ struct MtdNorDev *device = NULL;
|
|
||||||
+
|
|
||||||
if (!flashbuf) {
|
|
||||||
/* For NAND it's quicker to read a whole eraseblock at a time,
|
|
||||||
apparently */
|
|
||||||
if (jffs2_cleanmarker_oob(c))
|
|
||||||
- try_size = c->sector_size;
|
|
||||||
+ buf_size = c->sector_size;
|
|
||||||
else
|
|
||||||
- try_size = PAGE_SIZE;
|
|
||||||
+ buf_size = PAGE_SIZE;
|
|
||||||
|
|
||||||
jffs2_dbg(1, "Trying to allocate readbuf of %zu "
|
|
||||||
- "bytes\n", try_size);
|
|
||||||
+ "bytes\n", buf_size);
|
|
||||||
|
|
||||||
- flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size);
|
|
||||||
+ flashbuf = kmalloc(buf_size, GFP_KERNEL);
|
|
||||||
if (!flashbuf)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
jffs2_dbg(1, "Allocated readbuf of %zu bytes\n",
|
|
||||||
- try_size);
|
|
||||||
-
|
|
||||||
- buf_size = (uint32_t)try_size;
|
|
||||||
+ buf_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jffs2_sum_active()) {
|
|
||||||
@@ -140,7 +125,9 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- for (i=0; i<c->nr_blocks; i++) {
|
|
||||||
+ sb = OFNI_BS_2SFFJ(c);
|
|
||||||
+ device = (struct MtdNorDev*)(sb->s_dev);
|
|
||||||
+ for (i=device->blockStart; i<c->nr_blocks + device->blockStart; i++) {
|
|
||||||
struct jffs2_eraseblock *jeb = &c->blocks[i];
|
|
||||||
|
|
||||||
cond_resched();
|
|
||||||
@@ -269,14 +256,10 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
|
|
||||||
ret = -EIO;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
- spin_lock(&c->erase_completion_lock);
|
|
||||||
- jffs2_garbage_collect_trigger(c);
|
|
||||||
- spin_unlock(&c->erase_completion_lock);
|
|
||||||
}
|
|
||||||
ret = 0;
|
|
||||||
out:
|
|
||||||
- jffs2_sum_reset_collected(s);
|
|
||||||
- kfree(s);
|
- kfree(s);
|
||||||
|
+
|
||||||
+ kfree(flashbuf);
|
+ kfree(flashbuf);
|
||||||
out_buf:
|
+
|
||||||
if (buf_size)
|
return ret;
|
||||||
kfree(flashbuf);
|
}
|
||||||
@@ -413,7 +396,7 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
|
|
||||||
|
@@ -411,7 +391,7 @@ static int jffs2_scan_xref_node(struct j
|
||||||
if (!ref)
|
if (!ref)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -5896,7 +5656,7 @@ diff
|
||||||
* and AFTER xattr_ref is marked as a dead xref,
|
* and AFTER xattr_ref is marked as a dead xref,
|
||||||
* ref->xid is used to store 32bit xid, xd is not used
|
* ref->xid is used to store 32bit xid, xd is not used
|
||||||
* ref->ino is used to store 32bit inode-number, ic is not used
|
* ref->ino is used to store 32bit inode-number, ic is not used
|
||||||
@@ -486,10 +469,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -484,10 +464,10 @@ static int jffs2_scan_eraseblock (struct
|
||||||
struct jffs2_sum_marker *sm;
|
struct jffs2_sum_marker *sm;
|
||||||
void *sumptr = NULL;
|
void *sumptr = NULL;
|
||||||
uint32_t sumlen;
|
uint32_t sumlen;
|
||||||
|
@ -5909,7 +5669,7 @@ diff
|
||||||
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
|
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
|
||||||
sumptr = buf + je32_to_cpu(sm->offset);
|
sumptr = buf + je32_to_cpu(sm->offset);
|
||||||
sumlen = c->sector_size - je32_to_cpu(sm->offset);
|
sumlen = c->sector_size - je32_to_cpu(sm->offset);
|
||||||
@@ -502,13 +485,13 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -500,13 +480,13 @@ static int jffs2_scan_eraseblock (struct
|
||||||
buf_len = sizeof(*sm);
|
buf_len = sizeof(*sm);
|
||||||
|
|
||||||
/* Read as much as we want into the _end_ of the preallocated buffer */
|
/* Read as much as we want into the _end_ of the preallocated buffer */
|
||||||
|
@ -5926,7 +5686,7 @@ diff
|
||||||
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
|
if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC) {
|
||||||
sumlen = c->sector_size - je32_to_cpu(sm->offset);
|
sumlen = c->sector_size - je32_to_cpu(sm->offset);
|
||||||
sumptr = buf + buf_size - sumlen;
|
sumptr = buf + buf_size - sumlen;
|
||||||
@@ -523,18 +506,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -521,18 +501,15 @@ static int jffs2_scan_eraseblock (struct
|
||||||
sumptr = kmalloc(sumlen, GFP_KERNEL);
|
sumptr = kmalloc(sumlen, GFP_KERNEL);
|
||||||
if (!sumptr)
|
if (!sumptr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -5949,7 +5709,7 @@ diff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +525,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -543,7 +520,7 @@ static int jffs2_scan_eraseblock (struct
|
||||||
|
|
||||||
if (buf_size && sumlen > buf_size)
|
if (buf_size && sumlen > buf_size)
|
||||||
kfree(sumptr);
|
kfree(sumptr);
|
||||||
|
@ -5958,7 +5718,7 @@ diff
|
||||||
If it returns positive, that's a block classification
|
If it returns positive, that's a block classification
|
||||||
(i.e. BLK_STATE_xxx) so return that too.
|
(i.e. BLK_STATE_xxx) so return that too.
|
||||||
If it returns zero, fall through to full scan. */
|
If it returns zero, fall through to full scan. */
|
||||||
@@ -607,7 +587,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -605,7 +582,7 @@ full_scan:
|
||||||
/* Now ofs is a complete physical flash offset as it always was... */
|
/* Now ofs is a complete physical flash offset as it always was... */
|
||||||
ofs += jeb->offset;
|
ofs += jeb->offset;
|
||||||
|
|
||||||
|
@ -5967,7 +5727,7 @@ diff
|
||||||
|
|
||||||
dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset);
|
dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset);
|
||||||
|
|
||||||
@@ -700,7 +680,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -698,7 +675,7 @@ scan_more:
|
||||||
scan_end = buf_len;
|
scan_end = buf_len;
|
||||||
goto more_empty;
|
goto more_empty;
|
||||||
}
|
}
|
||||||
|
@ -5976,7 +5736,7 @@ diff
|
||||||
/* See how much more there is to read in this eraseblock... */
|
/* See how much more there is to read in this eraseblock... */
|
||||||
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
|
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
|
||||||
if (!buf_len) {
|
if (!buf_len) {
|
||||||
@@ -950,7 +930,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -948,7 +925,7 @@ scan_more:
|
||||||
jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n",
|
jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n",
|
||||||
jeb->offset, jeb->free_size, jeb->dirty_size,
|
jeb->offset, jeb->free_size, jeb->dirty_size,
|
||||||
jeb->unchecked_size, jeb->used_size, jeb->wasted_size);
|
jeb->unchecked_size, jeb->used_size, jeb->wasted_size);
|
||||||
|
@ -5985,7 +5745,7 @@ diff
|
||||||
/* mark_node_obsolete can add to wasted !! */
|
/* mark_node_obsolete can add to wasted !! */
|
||||||
if (jeb->wasted_size) {
|
if (jeb->wasted_size) {
|
||||||
jeb->dirty_size += jeb->wasted_size;
|
jeb->dirty_size += jeb->wasted_size;
|
||||||
@@ -978,7 +958,6 @@ struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uin
|
@@ -976,7 +953,6 @@ struct jffs2_inode_cache *jffs2_scan_mak
|
||||||
pr_notice("%s(): allocation of inode cache failed\n", __func__);
|
pr_notice("%s(): allocation of inode cache failed\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -5993,7 +5753,7 @@ diff
|
||||||
|
|
||||||
ic->ino = ino;
|
ic->ino = ino;
|
||||||
ic->nodes = (void *)ic;
|
ic->nodes = (void *)ic;
|
||||||
@@ -1069,7 +1048,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -1067,7 +1043,7 @@ static int jffs2_scan_dirent_node(struct
|
||||||
pseudo_random += je32_to_cpu(rd->version);
|
pseudo_random += je32_to_cpu(rd->version);
|
||||||
|
|
||||||
/* Should never happen. Did. (OLPC trac #4184)*/
|
/* Should never happen. Did. (OLPC trac #4184)*/
|
||||||
|
@ -6002,7 +5762,7 @@ diff
|
||||||
if (checkedlen < rd->nsize) {
|
if (checkedlen < rd->nsize) {
|
||||||
pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n",
|
pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n",
|
||||||
ofs, checkedlen);
|
ofs, checkedlen);
|
||||||
@@ -1081,7 +1060,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -1079,7 +1055,7 @@ static int jffs2_scan_dirent_node(struct
|
||||||
memcpy(&fd->name, rd->name, checkedlen);
|
memcpy(&fd->name, rd->name, checkedlen);
|
||||||
fd->name[checkedlen] = 0;
|
fd->name[checkedlen] = 0;
|
||||||
|
|
||||||
|
@ -6011,7 +5771,7 @@ diff
|
||||||
if (crc != je32_to_cpu(rd->name_crc)) {
|
if (crc != je32_to_cpu(rd->name_crc)) {
|
||||||
pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
|
pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
|
||||||
__func__, ofs, je32_to_cpu(rd->name_crc), crc);
|
__func__, ofs, je32_to_cpu(rd->name_crc), crc);
|
||||||
@@ -1106,7 +1085,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
|
@@ -1104,7 +1080,7 @@ static int jffs2_scan_dirent_node(struct
|
||||||
fd->next = NULL;
|
fd->next = NULL;
|
||||||
fd->version = je32_to_cpu(rd->version);
|
fd->version = je32_to_cpu(rd->version);
|
||||||
fd->ino = je32_to_cpu(rd->ino);
|
fd->ino = je32_to_cpu(rd->ino);
|
||||||
|
@ -6340,7 +6100,7 @@ diff -Nupr old/fs/jffs2/summary.h new/fs/jffs2/summary.h
|
||||||
diff -Nupr old/fs/jffs2/super.c new/fs/jffs2/super.c
|
diff -Nupr old/fs/jffs2/super.c new/fs/jffs2/super.c
|
||||||
--- old/fs/jffs2/super.c 2022-05-09 17:22:53.000000000 +0800
|
--- old/fs/jffs2/super.c 2022-05-09 17:22:53.000000000 +0800
|
||||||
+++ new/fs/jffs2/super.c 2022-05-09 20:09:32.170000000 +0800
|
+++ new/fs/jffs2/super.c 2022-05-09 20:09:32.170000000 +0800
|
||||||
@@ -9,434 +9,188 @@
|
@@ -9,433 +9,188 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -6418,7 +6178,6 @@ diff -Nupr old/fs/jffs2/super.c new/fs/jffs2/super.c
|
||||||
+ c->cleanmarker_size = sizeof(struct jffs2_unknown_node);
|
+ c->cleanmarker_size = sizeof(struct jffs2_unknown_node);
|
||||||
|
|
||||||
- mutex_init(&f->sem);
|
- mutex_init(&f->sem);
|
||||||
- f->target = NULL;
|
|
||||||
- inode_init_once(&f->vfs_inode);
|
- inode_init_once(&f->vfs_inode);
|
||||||
-}
|
-}
|
||||||
+ ret = jffs2_do_mount_fs(c);
|
+ ret = jffs2_do_mount_fs(c);
|
||||||
|
@ -8668,7 +8427,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
|
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
|
--- 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
|
+++ new/fs/jffs2/xattr.c 1970-01-01 08:00:00.000000000 +0800
|
||||||
@@ -1,1352 +0,0 @@
|
@@ -1,1347 +0,0 @@
|
||||||
-/*
|
-/*
|
||||||
- * JFFS2 -- Journalling Flash File System, Version 2.
|
- * JFFS2 -- Journalling Flash File System, Version 2.
|
||||||
- *
|
- *
|
||||||
|
@ -9443,10 +9202,10 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
|
||||||
-}
|
-}
|
||||||
-
|
-
|
||||||
-#define XREF_TMPHASH_SIZE (128)
|
-#define XREF_TMPHASH_SIZE (128)
|
||||||
-int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c)
|
-void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c)
|
||||||
-{
|
-{
|
||||||
- struct jffs2_xattr_ref *ref, *_ref;
|
- struct jffs2_xattr_ref *ref, *_ref;
|
||||||
- struct jffs2_xattr_ref **xref_tmphash;
|
- struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE];
|
||||||
- struct jffs2_xattr_datum *xd, *_xd;
|
- struct jffs2_xattr_datum *xd, *_xd;
|
||||||
- struct jffs2_inode_cache *ic;
|
- struct jffs2_inode_cache *ic;
|
||||||
- struct jffs2_raw_node_ref *raw;
|
- struct jffs2_raw_node_ref *raw;
|
||||||
|
@ -9455,12 +9214,9 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
|
||||||
-
|
-
|
||||||
- BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING));
|
- 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 */
|
- /* 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) {
|
- for (ref=c->xref_temp; ref; ref=_ref) {
|
||||||
- struct jffs2_xattr_ref *tmp;
|
- struct jffs2_xattr_ref *tmp;
|
||||||
-
|
-
|
||||||
|
@ -9558,8 +9314,6 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
|
||||||
- "%u of xref (%u dead, %u orphan) found.\n",
|
- "%u of xref (%u dead, %u orphan) found.\n",
|
||||||
- xdatum_count, xdatum_unchecked_count, xdatum_orphan_count,
|
- xdatum_count, xdatum_unchecked_count, xdatum_orphan_count,
|
||||||
- xref_count, xref_dead_count, xref_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,
|
-struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
|
||||||
|
|
|
@ -490,14 +490,14 @@ off_t VfsJffs2Seek(struct file *filep, off_t offset, int whence)
|
||||||
filePos = filep->f_pos;
|
filePos = filep->f_pos;
|
||||||
|
|
||||||
switch (whence) {
|
switch (whence) {
|
||||||
case SEEK_CUR:
|
|
||||||
filePos += offset;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
filePos = offset;
|
filePos = offset;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SEEK_CUR:
|
||||||
|
filePos += offset;
|
||||||
|
break;
|
||||||
|
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
filePos = node->i_size + offset;
|
filePos = node->i_size + offset;
|
||||||
break;
|
break;
|
||||||
|
@ -780,6 +780,7 @@ ssize_t VfsJffs2Readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
|
||||||
|
|
||||||
cnt = (bufLen - 1) < targetLen ? (bufLen - 1) : targetLen;
|
cnt = (bufLen - 1) < targetLen ? (bufLen - 1) : targetLen;
|
||||||
if (LOS_CopyFromKernel(buffer, bufLen, (const char *)f->target, cnt) != 0) {
|
if (LOS_CopyFromKernel(buffer, bufLen, (const char *)f->target, cnt) != 0) {
|
||||||
|
cnt = 0;
|
||||||
LOS_MuxUnlock(&g_jffs2FsLock);
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
import("//third_party/NuttX/NuttX.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_NFS)
|
module_switch = defined(LOSCFG_FS_NFS)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
|
|
|
@ -34,16 +34,12 @@ module_name = get_path_info(rebase_path("."), "name")
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [
|
sources = [
|
||||||
"os_adapt/fd_proc.c",
|
"os_adapt/fd_proc.c",
|
||||||
"os_adapt/file_sys.c",
|
|
||||||
"os_adapt/fs_cache_proc.c",
|
"os_adapt/fs_cache_proc.c",
|
||||||
"os_adapt/mem_info.c",
|
|
||||||
"os_adapt/mounts_proc.c",
|
"os_adapt/mounts_proc.c",
|
||||||
"os_adapt/plimits_proc.c",
|
|
||||||
"os_adapt/power_proc.c",
|
"os_adapt/power_proc.c",
|
||||||
"os_adapt/proc_init.c",
|
"os_adapt/proc_init.c",
|
||||||
"os_adapt/proc_vfs.c",
|
"os_adapt/proc_vfs.c",
|
||||||
"os_adapt/process_proc.c",
|
"os_adapt/process_proc.c",
|
||||||
"os_adapt/sys_user.c",
|
|
||||||
"os_adapt/uptime_proc.c",
|
"os_adapt/uptime_proc.c",
|
||||||
"os_adapt/vmm_proc.c",
|
"os_adapt/vmm_proc.c",
|
||||||
"src/proc_file.c",
|
"src/proc_file.c",
|
||||||
|
|
|
@ -4,8 +4,3 @@ config FS_PROC
|
||||||
depends on FS_VFS
|
depends on FS_VFS
|
||||||
help
|
help
|
||||||
Answer Y to enable LiteOS support proc filesystem.
|
Answer Y to enable LiteOS support proc filesystem.
|
||||||
|
|
||||||
config PROC_PROCESS_DIR
|
|
||||||
bool "Enable Process mount directory"
|
|
||||||
default n
|
|
||||||
depends on FS_PROC
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -45,26 +45,6 @@ extern "C" {
|
||||||
extern spinlock_t procfsLock;
|
extern spinlock_t procfsLock;
|
||||||
extern bool procfsInit;
|
extern bool procfsInit;
|
||||||
|
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
int ProcCreateProcessDir(UINT32 pid, uintptr_t process);
|
|
||||||
|
|
||||||
void ProcFreeProcessDir(struct ProcDirEntry *processDir);
|
|
||||||
|
|
||||||
void ProcSysMemInfoInit(void);
|
|
||||||
|
|
||||||
void ProcFileSysInit(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
void ProcLimitsInit(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ProcEntryClearVnode(struct ProcDirEntry *entry);
|
|
||||||
|
|
||||||
void ProcDetachNode(struct ProcDirEntry *pn);
|
|
||||||
|
|
||||||
void RemoveProcEntryTravalsal(struct ProcDirEntry *pn);
|
|
||||||
|
|
||||||
void ProcPmInit(void);
|
void ProcPmInit(void);
|
||||||
|
|
||||||
void ProcVmmInit(void);
|
void ProcVmmInit(void);
|
||||||
|
@ -77,20 +57,15 @@ struct ProcDirEntry *ProcFindEntry(const char *path);
|
||||||
|
|
||||||
void ProcFreeEntry(struct ProcDirEntry *pde);
|
void ProcFreeEntry(struct ProcDirEntry *pde);
|
||||||
|
|
||||||
int ProcStat(const char *file, struct ProcStat *buf);
|
extern int ProcStat(const char *file, struct ProcStat *buf);
|
||||||
|
|
||||||
void ProcMountsInit(void);
|
extern void ProcMountsInit(void);
|
||||||
|
|
||||||
void ProcUptimeInit(void);
|
extern void ProcUptimeInit(void);
|
||||||
|
|
||||||
void ProcFsCacheInit(void);
|
extern void ProcFsCacheInit(void);
|
||||||
|
|
||||||
void ProcFdInit(void);
|
extern void ProcFdInit(void);
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
void *ProcfsContainerGet(int fd, unsigned int *containerType);
|
|
||||||
void ProcSysUserInit(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -82,7 +82,6 @@ typedef unsigned short fmode_t;
|
||||||
#define FMODE_READ ((fmode_t)0x1)
|
#define FMODE_READ ((fmode_t)0x1)
|
||||||
|
|
||||||
struct ProcFile;
|
struct ProcFile;
|
||||||
struct ProcDirEntry;
|
|
||||||
|
|
||||||
struct ProcFileOperations {
|
struct ProcFileOperations {
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -90,18 +89,8 @@ struct ProcFileOperations {
|
||||||
int (*open)(struct Vnode *vnode, struct ProcFile *pf);
|
int (*open)(struct Vnode *vnode, struct ProcFile *pf);
|
||||||
int (*release)(struct Vnode *vnode, struct ProcFile *pf);
|
int (*release)(struct Vnode *vnode, struct ProcFile *pf);
|
||||||
int (*read)(struct SeqBuf *m, void *v);
|
int (*read)(struct SeqBuf *m, void *v);
|
||||||
ssize_t (*readLink)(struct ProcDirEntry *pde, char *buf, size_t bufLen);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
struct ProcDirOperations {
|
|
||||||
int (*rmdir)(struct ProcDirEntry *parent, struct ProcDirEntry *pde, const char *name);
|
|
||||||
int (*mkdir)(struct ProcDirEntry *parent, const char *dirName, mode_t mode, struct ProcDirEntry **pde);
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PROC_DATA_STATIC 0
|
|
||||||
#define PROC_DATA_FREE 1
|
|
||||||
struct ProcDirEntry {
|
struct ProcDirEntry {
|
||||||
uint uid;
|
uint uid;
|
||||||
uint gid;
|
uint gid;
|
||||||
|
@ -110,10 +99,6 @@ struct ProcDirEntry {
|
||||||
const struct ProcFileOperations *procFileOps;
|
const struct ProcFileOperations *procFileOps;
|
||||||
struct ProcFile *pf;
|
struct ProcFile *pf;
|
||||||
struct ProcDirEntry *next, *parent, *subdir;
|
struct ProcDirEntry *next, *parent, *subdir;
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
const struct ProcDirOperations *procDirOps;
|
|
||||||
#endif
|
|
||||||
int dataType;
|
|
||||||
void *data;
|
void *data;
|
||||||
atomic_t count; /* open file count */
|
atomic_t count; /* open file count */
|
||||||
spinlock_t pdeUnloadLock;
|
spinlock_t pdeUnloadLock;
|
||||||
|
@ -124,11 +109,6 @@ struct ProcDirEntry {
|
||||||
enum VnodeType type;
|
enum VnodeType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ProcDataParm {
|
|
||||||
void *data;
|
|
||||||
int dataType;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ProcFile {
|
struct ProcFile {
|
||||||
fmode_t fMode;
|
fmode_t fMode;
|
||||||
spinlock_t fLock;
|
spinlock_t fLock;
|
||||||
|
@ -264,35 +244,6 @@ extern struct ProcDirEntry *ProcMkdir(const char *name, struct ProcDirEntry *par
|
||||||
extern struct ProcDirEntry *ProcCreate(const char *name, mode_t mode,
|
extern struct ProcDirEntry *ProcCreate(const char *name, mode_t mode,
|
||||||
struct ProcDirEntry *parent, const struct ProcFileOperations *procFops);
|
struct ProcDirEntry *parent, const struct ProcFileOperations *procFops);
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup procfs
|
|
||||||
* @brief create a proc node
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to create the node by 'name' and parent vnode,
|
|
||||||
* And assignment operation function
|
|
||||||
*
|
|
||||||
* @attention
|
|
||||||
* <ul>
|
|
||||||
* <li>This interface should be called after system initialization.</li>
|
|
||||||
* <li>The parameter name should be a valid string.</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @param name [IN] Type #const char * The name of the node to be created.
|
|
||||||
* @param mode [IN] Type #mode_t the mode of create's node.
|
|
||||||
* @param parent [IN] Type #struct ProcDirEntry * the parent node of the node to be created.
|
|
||||||
* @param procFops [IN] Type #const struct ProcFileOperations * operation function of the node.
|
|
||||||
* @param data [IN] Type #void * data of the node.
|
|
||||||
*
|
|
||||||
* @retval #NULL Create failed.
|
|
||||||
* @retval #ProcDirEntry* Create successfully.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>proc_fs.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
extern struct ProcDirEntry *ProcCreateData(const char *name, mode_t mode, struct ProcDirEntry *parent,
|
|
||||||
const struct ProcFileOperations *procFileOps, struct ProcDataParm *param);
|
|
||||||
/**
|
/**
|
||||||
* @ingroup procfs
|
* @ingroup procfs
|
||||||
* @brief init proc fs
|
* @brief init proc fs
|
||||||
|
@ -315,7 +266,6 @@ extern struct ProcDirEntry *ProcCreateData(const char *name, mode_t mode, struct
|
||||||
*/
|
*/
|
||||||
extern void ProcFsInit(void);
|
extern void ProcFsInit(void);
|
||||||
|
|
||||||
extern struct ProcDirEntry *VnodeToEntry(struct Vnode *node);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "fs/fs.h"
|
|
||||||
#include "proc_fs.h"
|
|
||||||
#include "proc_file.h"
|
|
||||||
#include "errno.h"
|
|
||||||
#include "sys/mount.h"
|
|
||||||
|
|
||||||
extern struct fsmap_t g_fsmap[];
|
|
||||||
extern struct fsmap_t g_fsmap_end;
|
|
||||||
|
|
||||||
static int FsFileSysProcRead(struct SeqBuf *seqBuf, void *buf)
|
|
||||||
{
|
|
||||||
(void)buf;
|
|
||||||
|
|
||||||
struct fsmap_t *m = NULL;
|
|
||||||
for (m = &g_fsmap[0]; m != &g_fsmap_end; ++m) {
|
|
||||||
if (m->fs_filesystemtype) {
|
|
||||||
if (m->is_bdfs == true) {
|
|
||||||
(void)LosBufPrintf(seqBuf, "\n %s\n", m->fs_filesystemtype);
|
|
||||||
} else {
|
|
||||||
(void)LosBufPrintf(seqBuf, "%s %s\n", "nodev", m->fs_filesystemtype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct ProcFileOperations FILESYS_PROC_FOPS = {
|
|
||||||
.read = FsFileSysProcRead,
|
|
||||||
};
|
|
||||||
|
|
||||||
void ProcFileSysInit(void)
|
|
||||||
{
|
|
||||||
struct ProcDirEntry *pde = CreateProcEntry("filesystems", 0, NULL);
|
|
||||||
if (pde == NULL) {
|
|
||||||
PRINT_ERR("creat /proc/filesystems error!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pde->procFileOps = &FILESYS_PROC_FOPS;
|
|
||||||
}
|
|
|
@ -207,7 +207,7 @@ static const struct ProcFileOperations FS_CACHE_PROC_FOPS = {
|
||||||
|
|
||||||
void ProcFsCacheInit(void)
|
void ProcFsCacheInit(void)
|
||||||
{
|
{
|
||||||
struct ProcDirEntry *pde = CreateProcEntry("fs_cache", 0400, NULL);
|
struct ProcDirEntry *pde = CreateProcEntry("fs_cache", 0, NULL);
|
||||||
if (pde == NULL) {
|
if (pde == NULL) {
|
||||||
PRINT_ERR("create fs_cache error!\n");
|
PRINT_ERR("create fs_cache error!\n");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "internal.h"
|
|
||||||
#include "proc_fs.h"
|
|
||||||
#include "vnode.h"
|
|
||||||
#include "los_memory.h"
|
|
||||||
#include "los_vm_filemap.h"
|
|
||||||
#include "los_memory_pri.h"
|
|
||||||
|
|
||||||
static int SysMemInfoFill(struct SeqBuf *seqBuf, void *arg)
|
|
||||||
{
|
|
||||||
(void)arg;
|
|
||||||
LOS_MEM_POOL_STATUS mem = {0};
|
|
||||||
if (LOS_MemInfoGet(m_aucSysMem0, &mem) == LOS_NOK) {
|
|
||||||
return -EBADF;
|
|
||||||
}
|
|
||||||
(void)LosBufPrintf(seqBuf, "\nUsedSize: %u byte\n", mem.totalUsedSize);
|
|
||||||
(void)LosBufPrintf(seqBuf, "FreeSize: %u byte\n", mem.totalFreeSize);
|
|
||||||
(void)LosBufPrintf(seqBuf, "MaxFreeNodeSize: %u byte\n", mem.maxFreeNodeSize);
|
|
||||||
(void)LosBufPrintf(seqBuf, "UsedNodeNum: %u\n", mem.usedNodeNum);
|
|
||||||
(void)LosBufPrintf(seqBuf, "FreeNodeNum: %u\n", mem.freeNodeNum);
|
|
||||||
#ifdef LOSCFG_MEM_WATERLINE
|
|
||||||
(void)LosBufPrintf(seqBuf, "UsageWaterLine: %u byte\n", mem.usageWaterLine);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct ProcFileOperations SYS_MEMINFO_PROC_FOPS = {
|
|
||||||
.read = SysMemInfoFill,
|
|
||||||
};
|
|
||||||
|
|
||||||
void ProcSysMemInfoInit(void)
|
|
||||||
{
|
|
||||||
struct ProcDirEntry *pde = CreateProcEntry("meminfo", 0, NULL);
|
|
||||||
if (pde == NULL) {
|
|
||||||
PRINT_ERR("create mem_info error!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pde->procFileOps = &SYS_MEMINFO_PROC_FOPS;
|
|
||||||
}
|
|
|
@ -1,905 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/statfs.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include "los_printf.h"
|
|
||||||
#include "los_base.h"
|
|
||||||
#include "los_seq_buf.h"
|
|
||||||
#include "internal.h"
|
|
||||||
#include "proc_fs.h"
|
|
||||||
#include "los_task_pri.h"
|
|
||||||
#include "los_process_pri.h"
|
|
||||||
#include "los_process.h"
|
|
||||||
#include "show.h"
|
|
||||||
#include "vnode.h"
|
|
||||||
#include "proc_file.h"
|
|
||||||
#include "user_copy.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
#include "los_plimits.h"
|
|
||||||
|
|
||||||
#define PLIMITS_ENTRY_NAME_MAX 64
|
|
||||||
#define PLIMITERSET_DELETE_ALLOC 4
|
|
||||||
#define UNITPTR_NULL ((uintptr_t)(0xFFFFFFFF))
|
|
||||||
#define PLIMIT_FILE_MODE_READ_WRITE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
|
|
||||||
#define PLIMIT_FILE_MODE_READ_ONLY (S_IRUSR | S_IRGRP | S_IROTH)
|
|
||||||
#define PLIMIT_FILE_MODE_WRITE_ONLY (S_IWUSR)
|
|
||||||
#define PLIMIT_FILE_MODE_MASK_WRITE (~((mode_t)(S_IWUSR)))
|
|
||||||
#define PLIMIT_FILE_MODE_MASK_NONE (~((mode_t)(0)))
|
|
||||||
#define LOS_MAX_CACHE (UINT64)(0xFFFFFFFFFFFFFFFF)
|
|
||||||
#define PLIMIT_CAT_BUF_SIZE 512
|
|
||||||
#define MAX_PROTECTED_PROCESS_ID 14
|
|
||||||
#define UNITPTR_NULL ((uintptr_t)(0xFFFFFFFF))
|
|
||||||
|
|
||||||
static int ShowPids(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static ssize_t PidMigrateFromProcLimiterSet(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t PidLimitReadPidLimit(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static ssize_t PidLimitReadPriorityLimit(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static ssize_t PriorityLimitVariableWrite(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t PidsMaxVariableWrite(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t ProcLimitsShowLimiters(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static int ProcfsPlimitsMkdir(struct ProcDirEntry *parent, const char *dirName, mode_t mode, struct ProcDirEntry **pde);
|
|
||||||
static int ProcfsPlimitsRmdir(struct ProcDirEntry *parent, struct ProcDirEntry *pde, const char *name);
|
|
||||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
|
||||||
static ssize_t MemLimitReadLimit(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static ssize_t MemLimitWriteLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t MemLimitStatShow(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
|
||||||
static ssize_t IPCLimitReadMqLimit(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static ssize_t IPCLimitWriteMqLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t IPCLimitReadShmLimit(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static ssize_t IPCLimitWriteShmLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t IPCLimitShowStat(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
|
||||||
static ssize_t DevLimitWriteAllow(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t DevLimitWriteDeny(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t DevLimitShow(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
|
||||||
static ssize_t SchedLimitReadPeriod(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static ssize_t SchedLimitWritePeriod(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t SchedLimitReadQuota(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
static ssize_t SchedLimitWriteQuota(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
|
||||||
static ssize_t SchedLimitShow(struct SeqBuf *seqBuf, VOID *data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct PLimitsEntryOpt {
|
|
||||||
int id;
|
|
||||||
char name[PLIMITS_ENTRY_NAME_MAX];
|
|
||||||
mode_t mode;
|
|
||||||
uintptr_t offset;
|
|
||||||
struct ProcFileOperations ops;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct ProcDirOperations g_procDirOperations = {
|
|
||||||
.mkdir = ProcfsPlimitsMkdir,
|
|
||||||
.rmdir = ProcfsPlimitsRmdir,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct PLimitsEntryOpt g_plimitsEntryOpts[] = {
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_COUNT,
|
|
||||||
.name = "plimits.limiters",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
|
||||||
.offset = UNITPTR_NULL,
|
|
||||||
.ops = {
|
|
||||||
.read = ProcLimitsShowLimiters,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_COUNT,
|
|
||||||
.name = "plimits.procs",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
|
||||||
.offset = UNITPTR_NULL,
|
|
||||||
.ops = {
|
|
||||||
.read = ShowPids,
|
|
||||||
.write = PidMigrateFromProcLimiterSet,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_PIDS,
|
|
||||||
.name = "pids.max",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
|
||||||
.offset = 0,
|
|
||||||
.ops = {
|
|
||||||
.read = PidLimitReadPidLimit,
|
|
||||||
.write = PidsMaxVariableWrite,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_PIDS,
|
|
||||||
.name = "pids.priority",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
|
||||||
.offset = 0,
|
|
||||||
.ops = {
|
|
||||||
.read = PidLimitReadPriorityLimit,
|
|
||||||
.write = PriorityLimitVariableWrite,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_MEM,
|
|
||||||
.name = "memory.limit",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
|
||||||
.offset = 0,
|
|
||||||
.ops = {
|
|
||||||
.read = MemLimitReadLimit,
|
|
||||||
.write = MemLimitWriteLimit,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_MEM,
|
|
||||||
.name = "memory.stat",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
|
||||||
.offset = UNITPTR_NULL,
|
|
||||||
.ops = {
|
|
||||||
.read = MemLimitStatShow,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_IPC,
|
|
||||||
.name = "ipc.mq_limit",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
|
||||||
.offset = 0,
|
|
||||||
.ops = {
|
|
||||||
.read = IPCLimitReadMqLimit,
|
|
||||||
.write = IPCLimitWriteMqLimit,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_IPC,
|
|
||||||
.name = "ipc.shm_limit",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
|
||||||
.offset = 0,
|
|
||||||
.ops = {
|
|
||||||
.read = IPCLimitReadShmLimit,
|
|
||||||
.write = IPCLimitWriteShmLimit,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_IPC,
|
|
||||||
.name = "ipc.stat",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
|
||||||
.offset = UNITPTR_NULL,
|
|
||||||
.ops = {
|
|
||||||
.read = IPCLimitShowStat,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_DEV,
|
|
||||||
.name = "devices.allow",
|
|
||||||
.mode = PLIMIT_FILE_MODE_WRITE_ONLY,
|
|
||||||
.offset = UNITPTR_NULL,
|
|
||||||
.ops = {
|
|
||||||
.write = DevLimitWriteAllow,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_DEV,
|
|
||||||
.name = "devices.deny",
|
|
||||||
.mode = PLIMIT_FILE_MODE_WRITE_ONLY,
|
|
||||||
.offset = UNITPTR_NULL,
|
|
||||||
.ops = {
|
|
||||||
.write = DevLimitWriteDeny,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_DEV,
|
|
||||||
.name = "devices.list",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
|
||||||
.offset = 0,
|
|
||||||
.ops = {
|
|
||||||
.read = DevLimitShow,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_SCHED,
|
|
||||||
.name = "sched.period",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
|
||||||
.offset = 0,
|
|
||||||
.ops = {
|
|
||||||
.read = SchedLimitReadPeriod,
|
|
||||||
.write = SchedLimitWritePeriod,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_SCHED,
|
|
||||||
.name = "sched.quota",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
|
||||||
.offset = 0,
|
|
||||||
.ops = {
|
|
||||||
.read = SchedLimitReadQuota,
|
|
||||||
.write = SchedLimitWriteQuota,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = PROCESS_LIMITER_ID_SCHED,
|
|
||||||
.name = "sched.stat",
|
|
||||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
|
||||||
.offset = UNITPTR_NULL,
|
|
||||||
.ops = {
|
|
||||||
.read = SchedLimitShow,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned int MemUserCopy(const char *src, size_t len, char **kbuf)
|
|
||||||
{
|
|
||||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)src, len)) {
|
|
||||||
char *kernelBuf = LOS_MemAlloc(m_aucSysMem1, len + 1);
|
|
||||||
if (kernelBuf == NULL) {
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOS_ArchCopyFromUser(kernelBuf, src, len) != 0) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, kernelBuf);
|
|
||||||
return EFAULT;
|
|
||||||
}
|
|
||||||
kernelBuf[len] = '\0';
|
|
||||||
*kbuf = kernelBuf;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct ProcDirEntry *GetCurrDirectory(struct ProcDirEntry *dirEntry)
|
|
||||||
{
|
|
||||||
return ((dirEntry == NULL) || S_ISDIR(dirEntry->mode)) ? dirEntry : dirEntry->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline ProcLimiterSet *GetProcLimiterSetFromDirEntry(struct ProcDirEntry *dirEntry)
|
|
||||||
{
|
|
||||||
struct ProcDirEntry *currDirectory = GetCurrDirectory(dirEntry);
|
|
||||||
return (currDirectory == NULL) || (currDirectory->data == NULL) ? NULL : (ProcLimiterSet *)currDirectory->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct ProcDirEntry *ProcCreateLimiterFiles(struct ProcDirEntry *parentEntry,
|
|
||||||
struct PLimitsEntryOpt *entryOpt,
|
|
||||||
mode_t mode, void *data)
|
|
||||||
{
|
|
||||||
struct ProcDataParm dataParm = {
|
|
||||||
.data = data,
|
|
||||||
.dataType = PROC_DATA_STATIC,
|
|
||||||
};
|
|
||||||
struct ProcDirEntry *plimitFile = ProcCreateData(entryOpt->name, entryOpt->mode & mode, parentEntry,
|
|
||||||
&entryOpt->ops, &dataParm);
|
|
||||||
if (plimitFile == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return plimitFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ProcLimiterDirEntryInit(struct ProcDirEntry *dirEntry, unsigned mask, mode_t mode)
|
|
||||||
{
|
|
||||||
struct ProcDirEntry *currDir = GetCurrDirectory(dirEntry);
|
|
||||||
if (currDir == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcLimiterSet *plimiterData = (ProcLimiterSet *)currDir->data;
|
|
||||||
if (plimiterData == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < (sizeof(g_plimitsEntryOpts) / sizeof(struct PLimitsEntryOpt)); index++) {
|
|
||||||
struct PLimitsEntryOpt *entryOpt = &g_plimitsEntryOpts[index];
|
|
||||||
enum ProcLimiterID plimiterType = entryOpt->id;
|
|
||||||
if (!(BIT(plimiterType) & mask)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *head = (entryOpt->offset == UNITPTR_NULL) ?
|
|
||||||
plimiterData : (void *)plimiterData->limitsList[plimiterType];
|
|
||||||
struct ProcDirEntry *entry = ProcCreateLimiterFiles(currDir, entryOpt, mode, head);
|
|
||||||
if (entry == NULL) {
|
|
||||||
RemoveProcEntry(currDir->name, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t PLimitsCopyLimits(struct ProcDirEntry *dirEntry)
|
|
||||||
{
|
|
||||||
struct ProcDirEntry *parentPde = dirEntry->parent;
|
|
||||||
ProcLimiterSet *parentPLimits = (ProcLimiterSet *)parentPde->data;
|
|
||||||
if (parentPLimits == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcLimiterSet *newPLimits = OsPLimitsCreate(parentPLimits);
|
|
||||||
if (newPLimits == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
dirEntry->data = (VOID *)newPLimits;
|
|
||||||
dirEntry->dataType = PROC_DATA_STATIC;
|
|
||||||
dirEntry->procDirOps = parentPde->procDirOps;
|
|
||||||
ProcLimiterDirEntryInit(dirEntry, newPLimits->mask, PLIMIT_FILE_MODE_MASK_NONE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ProcfsPlimitsMkdir(struct ProcDirEntry *parent, const char *dirName, mode_t mode, struct ProcDirEntry **pde)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
if (strcmp(parent->name, "plimits") != 0) {
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcDirEntry *plimitDir = ProcCreateData(dirName, S_IFDIR | mode, parent, NULL, NULL);
|
|
||||||
if (plimitDir == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = PLimitsCopyLimits(plimitDir);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
ProcFreeEntry(plimitDir);
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
*pde = plimitDir;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ProcfsPlimitsRmdir(struct ProcDirEntry *parent, struct ProcDirEntry *pde, const char *name)
|
|
||||||
{
|
|
||||||
if (pde == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcLimiterSet *plimits = GetProcLimiterSetFromDirEntry(pde);
|
|
||||||
pde->data = NULL;
|
|
||||||
|
|
||||||
unsigned ret = OsPLimitsFree(plimits);
|
|
||||||
if (ret != 0) {
|
|
||||||
pde->data = plimits;
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock(&procfsLock);
|
|
||||||
ProcDetachNode(pde);
|
|
||||||
spin_unlock(&procfsLock);
|
|
||||||
|
|
||||||
RemoveProcEntryTravalsal(pde->subdir);
|
|
||||||
|
|
||||||
ProcFreeEntry(pde);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t ProcLimitsShowLimiters(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcLimiterSet *plimits = (ProcLimiterSet *)data;
|
|
||||||
UINT32 mask;
|
|
||||||
if (plimits == NULL) {
|
|
||||||
return -LOS_NOK;
|
|
||||||
}
|
|
||||||
mask = plimits->mask;
|
|
||||||
|
|
||||||
if (mask & BIT(PROCESS_LIMITER_ID_PIDS)) {
|
|
||||||
LosBufPrintf(seqBuf, "%s ", "pids");
|
|
||||||
}
|
|
||||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
|
||||||
if (mask & BIT(PROCESS_LIMITER_ID_MEM)) {
|
|
||||||
LosBufPrintf(seqBuf, "%s ", "memory");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
|
||||||
if (mask & BIT(PROCESS_LIMITER_ID_IPC)) {
|
|
||||||
LosBufPrintf(seqBuf, "%s ", "ipc");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
|
||||||
if (mask & BIT(PROCESS_LIMITER_ID_DEV)) {
|
|
||||||
LosBufPrintf(seqBuf, "%s ", "devices");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
|
||||||
if (mask & BIT(PROCESS_LIMITER_ID_SCHED)) {
|
|
||||||
LosBufPrintf(seqBuf, "%s ", "sched");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return LOS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PLIMITS_PID_STR_LENGTH 4
|
|
||||||
static int ShowPids(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
unsigned int size, pidMax;
|
|
||||||
if (data == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ProcLimiterSet *plimits = (const ProcLimiterSet *)data;
|
|
||||||
pidMax = LOS_GetSystemProcessMaximum();
|
|
||||||
size = pidMax * sizeof(unsigned int);
|
|
||||||
unsigned int *pids = (unsigned int *)LOS_MemAlloc(m_aucSysMem1, size);
|
|
||||||
if (pids == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
(void)memset_s(pids, size, 0, size);
|
|
||||||
|
|
||||||
unsigned int ret = OsPLimitsPidsGet(plimits, pids, size);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, pids);
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "\n");
|
|
||||||
for (unsigned int index = 0; index < pidMax; index++) {
|
|
||||||
if (pids[index] == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
(void)LosBufPrintf(seqBuf, "%u ", index);
|
|
||||||
}
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, pids);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static long long int GetPidLimitValue(struct ProcFile *pf, const CHAR *buf, size_t count)
|
|
||||||
{
|
|
||||||
long long int value;
|
|
||||||
char *kbuf = NULL;
|
|
||||||
|
|
||||||
if ((pf == NULL) || (pf->pPDE == NULL) || (buf == NULL) || (count <= 0)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned ret = MemUserCopy(buf, count, &kbuf);
|
|
||||||
if (ret != 0) {
|
|
||||||
return -ret;
|
|
||||||
} else if ((ret == 0) && (kbuf != NULL)) {
|
|
||||||
buf = (const char *)kbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strspn(buf, "0123456789") != count) {
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
value = strtoll(buf, NULL, 10); /* 10: decimal */
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t PidMigrateFromProcLimiterSet(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(VOID)ppos;
|
|
||||||
unsigned ret;
|
|
||||||
|
|
||||||
long long int pid = GetPidLimitValue(pf, buf, count);
|
|
||||||
if (pid < 0) {
|
|
||||||
return pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcLimiterSet *plimits = GetCurrDirectory(pf->pPDE)->data;
|
|
||||||
ret = OsPLimitsAddPid(plimits, (unsigned int)pid);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t PidLimitReadPidLimit(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
PidLimit *pidLimit = (PidLimit *)data;
|
|
||||||
if ((seqBuf == NULL) || (pidLimit == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "%u\n", pidLimit->pidLimit);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t PidLimitReadPriorityLimit(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
PidLimit *pidLimit = (PidLimit *)data;
|
|
||||||
if ((seqBuf == NULL) || (pidLimit == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "%u\n", pidLimit->priorityLimit);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t PriorityLimitVariableWrite(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
long long int value = GetPidLimitValue(pf, buf, count);
|
|
||||||
if (value < 0) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
PidLimit *pidLimit = (PidLimit *)pf->pPDE->data;
|
|
||||||
unsigned ret = PidLimitSetPriorityLimit(pidLimit, (unsigned)value);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t PidsMaxVariableWrite(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
long long int value = GetPidLimitValue(pf, buf, count);
|
|
||||||
if (value < 0) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
PidLimit *pidLimit = (PidLimit *)pf->pPDE->data;
|
|
||||||
unsigned ret = PidLimitSetPidLimit(pidLimit, (unsigned)value);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
|
||||||
static ssize_t MemLimitReadLimit(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)data;
|
|
||||||
if ((seqBuf == NULL) || (memLimit == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "%llu\n", memLimit->limit);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t MemLimitWriteLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
long long int value = GetPidLimitValue(pf, buf, count);
|
|
||||||
if ((value < 0) || (value > (long long int)OS_NULL_INT)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)pf->pPDE->data;
|
|
||||||
unsigned ret = OsMemLimitSetMemLimit(memLimit, (unsigned long long)value);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t MemLimitStatShow(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcLimiterSet *plimits = (ProcLimiterSet *)data;
|
|
||||||
if ((seqBuf == NULL) || (plimits == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT32 pidMax = LOS_GetSystemProcessMaximum();
|
|
||||||
UINT32 size = sizeof(ProcMemLimiter) + pidMax * sizeof(unsigned long long);
|
|
||||||
unsigned long long *usage = (unsigned long long *)LOS_MemAlloc(m_aucSysMem1, size);
|
|
||||||
if (usage == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
(void)memset_s(usage, size, 0, size);
|
|
||||||
|
|
||||||
unsigned int ret = OsPLimitsMemUsageGet(plimits, usage, size);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, usage);
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)usage;
|
|
||||||
unsigned long long *memUsage = (unsigned long long *)((uintptr_t)usage + sizeof(ProcMemLimiter));
|
|
||||||
(void)LosBufPrintf(seqBuf, "\nMem used: %llu\n", memLimit->usage);
|
|
||||||
(void)LosBufPrintf(seqBuf, "Mem peak: %llu\n", memLimit->peak);
|
|
||||||
(void)LosBufPrintf(seqBuf, "Mem failed count: %u\n", memLimit->failcnt);
|
|
||||||
|
|
||||||
for (unsigned int index = 0; index < pidMax; index++) {
|
|
||||||
if (memUsage[index] == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
(void)LosBufPrintf(seqBuf, "PID: %u mem used: %llu \n", index, memUsage[index]);
|
|
||||||
}
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, usage);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
|
||||||
static ssize_t IPCLimitReadMqLimit(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)data;
|
|
||||||
if ((seqBuf == NULL) || (ipcLimit == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "%u\n", ipcLimit->mqCountLimit);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t IPCLimitWriteMqLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
long long int value = GetPidLimitValue(pf, buf, count);
|
|
||||||
if (value < 0) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)pf->pPDE->data;
|
|
||||||
unsigned ret = OsIPCLimitSetMqLimit(ipcLimit, (unsigned long long)value);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t IPCLimitReadShmLimit(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)data;
|
|
||||||
if ((seqBuf == NULL) || (ipcLimit == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "%u\n", ipcLimit->shmSizeLimit);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t IPCLimitWriteShmLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
long long int value = GetPidLimitValue(pf, buf, count);
|
|
||||||
if ((value < 0) || (value > (long long int)OS_NULL_INT)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)pf->pPDE->data;
|
|
||||||
unsigned ret = OsIPCLimitSetShmLimit(ipcLimit, (unsigned long long)value);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t IPCLimitShowStat(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcLimiterSet *plimits = (ProcLimiterSet *)data;
|
|
||||||
if ((seqBuf == NULL) || (plimits == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int size = sizeof(ProcIPCLimit);
|
|
||||||
ProcIPCLimit *newIPCLimit = (ProcIPCLimit *)LOS_MemAlloc(m_aucSysMem1, size);
|
|
||||||
if (newIPCLimit == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
(void)memset_s(newIPCLimit, size, 0, size);
|
|
||||||
|
|
||||||
unsigned int ret = OsPLimitsIPCStatGet(plimits, newIPCLimit, size);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, newIPCLimit);
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "mq count: %u\n", newIPCLimit->mqCount);
|
|
||||||
(void)LosBufPrintf(seqBuf, "mq failed count: %u\n", newIPCLimit->mqFailedCount);
|
|
||||||
(void)LosBufPrintf(seqBuf, "shm size: %u\n", newIPCLimit->shmSize);
|
|
||||||
(void)LosBufPrintf(seqBuf, "shm failed count: %u\n", newIPCLimit->shmFailedCount);
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, newIPCLimit);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
|
||||||
static ssize_t DevLimitWriteAllow(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
char *kbuf = NULL;
|
|
||||||
|
|
||||||
if ((pf == NULL) || (pf->pPDE == NULL) || (buf == NULL) || (count <= 0)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned ret = MemUserCopy(buf, count, &kbuf);
|
|
||||||
if (ret != 0) {
|
|
||||||
return -ret;
|
|
||||||
} else if ((ret == 0) && (kbuf != NULL)) {
|
|
||||||
buf = (const char *)kbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcLimiterSet *plimit = (ProcLimiterSet *)pf->pPDE->data;
|
|
||||||
ret = OsDevLimitWriteAllow(plimit, buf, count);
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t DevLimitWriteDeny(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
char *kbuf = NULL;
|
|
||||||
|
|
||||||
if ((pf == NULL) || (pf->pPDE == NULL) || (buf == NULL) || (count <= 0)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned ret = MemUserCopy(buf, count, &kbuf);
|
|
||||||
if (ret != 0) {
|
|
||||||
return -ret;
|
|
||||||
} else if ((ret == 0) && (kbuf != NULL)) {
|
|
||||||
buf = (const char *)kbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcLimiterSet *plimit = (ProcLimiterSet *)pf->pPDE->data;
|
|
||||||
ret = OsDevLimitWriteDeny(plimit, buf, count);
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t DevLimitShow(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcDevLimit *devLimit = (ProcDevLimit *)data;
|
|
||||||
if ((seqBuf == NULL) || (devLimit == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned ret = OsDevLimitShow(devLimit, seqBuf);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
|
||||||
static ssize_t SchedLimitReadPeriod(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)data;
|
|
||||||
if ((seqBuf == NULL) || (schedLimit == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "%lld\n", schedLimit->period);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t SchedLimitWritePeriod(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
long long int value = GetPidLimitValue(pf, buf, count);
|
|
||||||
if (value < 0) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)pf->pPDE->data;
|
|
||||||
unsigned ret = OsSchedLimitSetPeriod(schedLimit, (unsigned long long)value);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t SchedLimitReadQuota(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)data;
|
|
||||||
if ((seqBuf == NULL) || (schedLimit == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "%lld\n", schedLimit->quota);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t SchedLimitWriteQuota(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
long long int value = GetPidLimitValue(pf, buf, count);
|
|
||||||
if (value < 0) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)pf->pPDE->data;
|
|
||||||
unsigned ret = OsSchedLimitSetQuota(schedLimit, (unsigned long long)value);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TIME_CYCLE_TO_US(time) ((((UINT64)time) * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US)
|
|
||||||
#define SCHED_DEFAULT_VALUE (0x101010101010101)
|
|
||||||
|
|
||||||
static ssize_t SchedLimitShow(struct SeqBuf *seqBuf, VOID *data)
|
|
||||||
{
|
|
||||||
ProcLimiterSet *plimits = (ProcLimiterSet *)data;
|
|
||||||
if ((seqBuf == NULL) || (plimits == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT32 pidMax = LOS_GetSystemProcessMaximum();
|
|
||||||
UINT32 size = pidMax * sizeof(unsigned long long);
|
|
||||||
unsigned long long *usage = (unsigned long long *)LOS_MemAlloc(m_aucSysMem1, size);
|
|
||||||
if (usage == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
(void)memset_s(usage, size, 1, size);
|
|
||||||
|
|
||||||
unsigned int ret = OsPLimitsSchedUsageGet(plimits, usage, size);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, usage);
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int index = 0; index < pidMax; index++) {
|
|
||||||
if (usage[index] == SCHED_DEFAULT_VALUE) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
(void)LosBufPrintf(seqBuf, "PID: %u runTime: %llu us\n", index, TIME_CYCLE_TO_US(usage[index]));
|
|
||||||
}
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, usage);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PROC_PLIMITS_MODE (S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
|
||||||
void ProcLimitsInit(void)
|
|
||||||
{
|
|
||||||
struct ProcDirEntry *parentPDE = CreateProcEntry("plimits", PROC_PLIMITS_MODE, NULL);
|
|
||||||
if (parentPDE == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProcLimiterSet *plimits = OsRootPLimitsGet();
|
|
||||||
parentPDE->procDirOps = &g_procDirOperations;
|
|
||||||
parentPDE->data = (VOID *)plimits;
|
|
||||||
parentPDE->dataType = PROC_DATA_STATIC;
|
|
||||||
plimits->mask = BIT(PROCESS_LIMITER_ID_PIDS) | BIT(PROCESS_LIMITER_COUNT);
|
|
||||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
|
||||||
plimits->mask |= BIT(PROCESS_LIMITER_ID_MEM);
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
|
||||||
plimits->mask |= BIT(PROCESS_LIMITER_ID_IPC);
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
|
||||||
plimits->mask |= BIT(PROCESS_LIMITER_ID_DEV);
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
|
||||||
plimits->mask |= BIT(PROCESS_LIMITER_ID_SCHED);
|
|
||||||
#endif
|
|
||||||
ProcLimiterDirEntryInit(parentPDE, plimits->mask, PLIMIT_FILE_MODE_MASK_WRITE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -68,16 +68,6 @@ void ProcFsInit(void)
|
||||||
#ifdef LOSCFG_KERNEL_PM
|
#ifdef LOSCFG_KERNEL_PM
|
||||||
ProcPmInit();
|
ProcPmInit();
|
||||||
#endif
|
#endif
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
ProcSysMemInfoInit();
|
|
||||||
ProcFileSysInit();
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
ProcLimitsInit();
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
ProcSysUserInit();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_MODULE_INIT(ProcFsInit, LOS_INIT_LEVEL_KMOD_EXTENDED);
|
LOS_MODULE_INIT(ProcFsInit, LOS_INIT_LEVEL_KMOD_EXTENDED);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
static struct VnodeOps g_procfsVops;
|
static struct VnodeOps g_procfsVops;
|
||||||
static struct file_operations_vfs g_procfsFops;
|
static struct file_operations_vfs g_procfsFops;
|
||||||
|
|
||||||
struct ProcDirEntry *VnodeToEntry(struct Vnode *node)
|
static struct ProcDirEntry *VnodeToEntry(struct Vnode *node)
|
||||||
{
|
{
|
||||||
return (struct ProcDirEntry *)(node->data);
|
return (struct ProcDirEntry *)(node->data);
|
||||||
}
|
}
|
||||||
|
@ -125,16 +125,10 @@ int VfsProcfsRead(struct file *filep, char *buffer, size_t buflen)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VnodeHold();
|
|
||||||
entry = VnodeToEntry(filep->f_vnode);
|
entry = VnodeToEntry(filep->f_vnode);
|
||||||
if (entry == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = (ssize_t)ReadProcFile(entry, (void *)buffer, buflen);
|
size = (ssize_t)ReadProcFile(entry, (void *)buffer, buflen);
|
||||||
filep->f_pos = entry->pf->fPos;
|
filep->f_pos = entry->pf->fPos;
|
||||||
VnodeDrop();
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,16 +140,10 @@ int VfsProcfsWrite(struct file *filep, const char *buffer, size_t buflen)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VnodeHold();
|
|
||||||
entry = VnodeToEntry(filep->f_vnode);
|
entry = VnodeToEntry(filep->f_vnode);
|
||||||
if (entry == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = (ssize_t)WriteProcFile(entry, (void *)buffer, buflen);
|
size = (ssize_t)WriteProcFile(entry, (void *)buffer, buflen);
|
||||||
filep->f_pos = entry->pf->fPos;
|
filep->f_pos = entry->pf->fPos;
|
||||||
VnodeDrop();
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +156,6 @@ int VfsProcfsLookup(struct Vnode *parent, const char *name, int len, struct Vnod
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = entry->subdir;
|
entry = entry->subdir;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
|
@ -227,70 +214,21 @@ int VfsProcfsUnmount(void *handle, struct Vnode **blkdriver)
|
||||||
|
|
||||||
int VfsProcfsStat(struct Vnode *node, struct stat *buf)
|
int VfsProcfsStat(struct Vnode *node, struct stat *buf)
|
||||||
{
|
{
|
||||||
VnodeHold();
|
|
||||||
struct ProcDirEntry *entry = VnodeToEntry(node);
|
struct ProcDirEntry *entry = VnodeToEntry(node);
|
||||||
if (entry == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
(void)memset_s(buf, sizeof(struct stat), 0, sizeof(struct stat));
|
(void)memset_s(buf, sizeof(struct stat), 0, sizeof(struct stat));
|
||||||
buf->st_mode = entry->mode;
|
buf->st_mode = entry->mode;
|
||||||
VnodeDrop();
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
int VfsProcfsMkdir(struct Vnode *parent, const char *dirName, mode_t mode, struct Vnode **vnode)
|
|
||||||
{
|
|
||||||
struct ProcDirEntry *parentEntry = VnodeToEntry(parent);
|
|
||||||
struct ProcDirEntry *pde = NULL;
|
|
||||||
if ((parentEntry->procDirOps == NULL) || (parentEntry->procDirOps->mkdir == NULL)) {
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = parentEntry->procDirOps->mkdir(parentEntry, dirName, mode, &pde);
|
|
||||||
if ((ret < 0) || (pde == NULL)) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
*vnode = EntryToVnode(pde);
|
|
||||||
(*vnode)->vop = parent->vop;
|
|
||||||
(*vnode)->parent = parent;
|
|
||||||
(*vnode)->originMount = parent->originMount;
|
|
||||||
if ((*vnode)->type == VNODE_TYPE_DIR) {
|
|
||||||
(*vnode)->mode = S_IFDIR | PROCFS_DEFAULT_MODE;
|
|
||||||
} else {
|
|
||||||
(*vnode)->mode = S_IFREG | PROCFS_DEFAULT_MODE;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int VfsProcfsRmdir(struct Vnode *parent, struct Vnode *vnode, const char *dirName)
|
|
||||||
{
|
|
||||||
if (parent == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcDirEntry *parentEntry = VnodeToEntry(parent);
|
|
||||||
if ((parentEntry->procDirOps == NULL) || (parentEntry->procDirOps->rmdir == NULL)) {
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcDirEntry *dirEntry = VnodeToEntry(vnode);
|
|
||||||
int ret = parentEntry->procDirOps->rmdir(parentEntry, dirEntry, dirName);
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
vnode->data = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
|
int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
unsigned int minSize, dstNameSize;
|
int buflen = NAME_MAX;
|
||||||
|
unsigned int min_size;
|
||||||
|
unsigned int dst_name_size;
|
||||||
struct ProcDirEntry *pde = NULL;
|
struct ProcDirEntry *pde = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -300,35 +238,28 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
|
||||||
if (node->type != VNODE_TYPE_DIR) {
|
if (node->type != VNODE_TYPE_DIR) {
|
||||||
return -ENOTDIR;
|
return -ENOTDIR;
|
||||||
}
|
}
|
||||||
VnodeHold();
|
|
||||||
pde = VnodeToEntry(node);
|
pde = VnodeToEntry(node);
|
||||||
if (pde == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (i < dir->read_cnt) {
|
while (i < dir->read_cnt) {
|
||||||
buffer = (char *)zalloc(sizeof(char) * NAME_MAX);
|
buffer = (char *)zalloc(sizeof(char) * NAME_MAX);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
VnodeDrop();
|
|
||||||
PRINT_ERR("malloc failed\n");
|
PRINT_ERR("malloc failed\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ReadProcFile(pde, (void *)buffer, NAME_MAX);
|
result = ReadProcFile(pde, (void *)buffer, buflen);
|
||||||
if (result != ENOERR) {
|
if (result != ENOERR) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dstNameSize = sizeof(dir->fd_dir[i].d_name);
|
dst_name_size = sizeof(dir->fd_dir[i].d_name);
|
||||||
minSize = (dstNameSize < NAME_MAX) ? dstNameSize : NAME_MAX;
|
min_size = (dst_name_size < NAME_MAX) ? dst_name_size : NAME_MAX;
|
||||||
result = strncpy_s(dir->fd_dir[i].d_name, dstNameSize, buffer, minSize);
|
result = strncpy_s(dir->fd_dir[i].d_name, dst_name_size, buffer, min_size);
|
||||||
if (result != EOK) {
|
if (result != EOK) {
|
||||||
VnodeDrop();
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return -ENAMETOOLONG;
|
return -ENAMETOOLONG;
|
||||||
}
|
}
|
||||||
dir->fd_dir[i].d_name[dstNameSize - 1] = '\0';
|
dir->fd_dir[i].d_name[dst_name_size - 1] = '\0';
|
||||||
dir->fd_position++;
|
dir->fd_position++;
|
||||||
dir->fd_dir[i].d_off = dir->fd_position;
|
dir->fd_dir[i].d_off = dir->fd_position;
|
||||||
dir->fd_dir[i].d_reclen = (uint16_t)sizeof(struct dirent);
|
dir->fd_dir[i].d_reclen = (uint16_t)sizeof(struct dirent);
|
||||||
|
@ -336,26 +267,19 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
|
||||||
i++;
|
i++;
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
VnodeDrop();
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VfsProcfsOpendir(struct Vnode *node, struct fs_dirent_s *dir)
|
int VfsProcfsOpendir(struct Vnode *node, struct fs_dirent_s *dir)
|
||||||
{
|
{
|
||||||
VnodeHold();
|
|
||||||
struct ProcDirEntry *pde = VnodeToEntry(node);
|
struct ProcDirEntry *pde = VnodeToEntry(node);
|
||||||
if (pde == NULL) {
|
if (pde == NULL) {
|
||||||
VnodeDrop();
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pde->pdirCurrent = pde->subdir;
|
pde->pdirCurrent = pde->subdir;
|
||||||
if (pde->pf == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
pde->pf->fPos = 0;
|
pde->pf->fPos = 0;
|
||||||
VnodeDrop();
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,14 +288,8 @@ int VfsProcfsOpen(struct file *filep)
|
||||||
if (filep == NULL) {
|
if (filep == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
VnodeHold();
|
|
||||||
struct Vnode *node = filep->f_vnode;
|
struct Vnode *node = filep->f_vnode;
|
||||||
struct ProcDirEntry *pde = VnodeToEntry(node);
|
struct ProcDirEntry *pde = VnodeToEntry(node);
|
||||||
if (pde == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ProcOpen(pde->pf) != OK) {
|
if (ProcOpen(pde->pf) != OK) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +301,6 @@ int VfsProcfsOpen(struct file *filep)
|
||||||
pde->pf->fPos = 0;
|
pde->pf->fPos = 0;
|
||||||
}
|
}
|
||||||
filep->f_priv = (void *)pde;
|
filep->f_priv = (void *)pde;
|
||||||
VnodeDrop();
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,22 +310,15 @@ int VfsProcfsClose(struct file *filep)
|
||||||
if (filep == NULL) {
|
if (filep == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VnodeHold();
|
|
||||||
struct Vnode *node = filep->f_vnode;
|
struct Vnode *node = filep->f_vnode;
|
||||||
struct ProcDirEntry *pde = VnodeToEntry(node);
|
struct ProcDirEntry *pde = VnodeToEntry(node);
|
||||||
if ((pde == NULL) || (pde->pf == NULL)) {
|
|
||||||
VnodeDrop();
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
pde->pf->fPos = 0;
|
pde->pf->fPos = 0;
|
||||||
if ((pde->procFileOps != NULL) && (pde->procFileOps->release != NULL)) {
|
if ((pde->procFileOps != NULL) && (pde->procFileOps->release != NULL)) {
|
||||||
result = pde->procFileOps->release((struct Vnode *)pde, pde->pf);
|
result = pde->procFileOps->release((struct Vnode *)pde, pde->pf);
|
||||||
}
|
}
|
||||||
LosBufRelease(pde->pf->sbuf);
|
LosBufRelease(pde->pf->sbuf);
|
||||||
pde->pf->sbuf = NULL;
|
pde->pf->sbuf = NULL;
|
||||||
VnodeDrop();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,24 +335,6 @@ int VfsProcfsClosedir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t VfsProcfsReadlink(struct Vnode *vnode, char *buffer, size_t bufLen)
|
|
||||||
{
|
|
||||||
int result = -EINVAL;
|
|
||||||
if (vnode == NULL) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcDirEntry *pde = VnodeToEntry(vnode);
|
|
||||||
if (pde == NULL) {
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pde->procFileOps != NULL) && (pde->procFileOps->readLink != NULL)) {
|
|
||||||
result = pde->procFileOps->readLink(pde, buffer, bufLen);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct MountOps procfs_operations = {
|
const struct MountOps procfs_operations = {
|
||||||
.Mount = VfsProcfsMount,
|
.Mount = VfsProcfsMount,
|
||||||
.Unmount = NULL,
|
.Unmount = NULL,
|
||||||
|
@ -455,12 +347,7 @@ static struct VnodeOps g_procfsVops = {
|
||||||
.Readdir = VfsProcfsReaddir,
|
.Readdir = VfsProcfsReaddir,
|
||||||
.Opendir = VfsProcfsOpendir,
|
.Opendir = VfsProcfsOpendir,
|
||||||
.Closedir = VfsProcfsClosedir,
|
.Closedir = VfsProcfsClosedir,
|
||||||
.Truncate = VfsProcfsTruncate,
|
.Truncate = VfsProcfsTruncate
|
||||||
.Readlink = VfsProcfsReadlink,
|
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
.Mkdir = VfsProcfsMkdir,
|
|
||||||
.Rmdir = VfsProcfsRmdir,
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct file_operations_vfs g_procfsFops = {
|
static struct file_operations_vfs g_procfsFops = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -32,666 +32,7 @@
|
||||||
#include <sys/statfs.h>
|
#include <sys/statfs.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include "proc_fs.h"
|
#include "proc_fs.h"
|
||||||
#include "internal.h"
|
|
||||||
#include "los_process_pri.h"
|
#include "los_process_pri.h"
|
||||||
#include "user_copy.h"
|
|
||||||
#include "los_memory.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
#include "los_vm_dump.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PROC_PID,
|
|
||||||
PROC_PID_MEM,
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
|
||||||
PROC_PID_CPUP,
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_USER_CONTAINER
|
|
||||||
PROC_UID_MAP,
|
|
||||||
PROC_GID_MAP,
|
|
||||||
#endif
|
|
||||||
PROC_P_TYPE_MAX,
|
|
||||||
} ProcessDataType;
|
|
||||||
|
|
||||||
struct ProcProcess {
|
|
||||||
char *name;
|
|
||||||
mode_t mode;
|
|
||||||
int type;
|
|
||||||
const struct ProcFileOperations *fileOps;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ProcessData {
|
|
||||||
uintptr_t process;
|
|
||||||
unsigned int type;
|
|
||||||
};
|
|
||||||
|
|
||||||
static LosProcessCB *ProcGetProcessCB(struct ProcessData *data)
|
|
||||||
{
|
|
||||||
if (data->process != 0) {
|
|
||||||
return (LosProcessCB *)data->process;
|
|
||||||
}
|
|
||||||
return OsCurrProcessGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PROC_PID_PRIVILEGE 7
|
|
||||||
#define PROC_PID_DIR_LEN 100
|
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
static ssize_t ProcessContainerLink(unsigned int containerID, ContainerType type, char *buffer, size_t bufLen)
|
|
||||||
{
|
|
||||||
ssize_t count = -1;
|
|
||||||
if ((type == PID_CONTAINER) || (type == PID_CHILD_CONTAINER)) {
|
|
||||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'pid:[%u]'", containerID);
|
|
||||||
} else if (type == UTS_CONTAINER) {
|
|
||||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'uts:[%u]'", containerID);
|
|
||||||
} else if (type == MNT_CONTAINER) {
|
|
||||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'mnt:[%u]'", containerID);
|
|
||||||
} else if (type == IPC_CONTAINER) {
|
|
||||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'ipc:[%u]'", containerID);
|
|
||||||
} else if ((type == TIME_CONTAINER) || (type == TIME_CHILD_CONTAINER)) {
|
|
||||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'time:[%u]'", containerID);
|
|
||||||
} else if (type == USER_CONTAINER) {
|
|
||||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'user:[%u]'", containerID);
|
|
||||||
} else if (type == NET_CONTAINER) {
|
|
||||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'net:[%u]'", containerID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count < 0) {
|
|
||||||
return -EBADF;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t ProcessContainerReadLink(struct ProcDirEntry *entry, char *buffer, size_t bufLen)
|
|
||||||
{
|
|
||||||
char *freeBuf = NULL;
|
|
||||||
char *buf = buffer;
|
|
||||||
ssize_t count;
|
|
||||||
unsigned int intSave;
|
|
||||||
if (entry == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
struct ProcessData *data = (struct ProcessData *)entry->data;
|
|
||||||
if (data == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)buffer, bufLen)) {
|
|
||||||
buf = LOS_MemAlloc(m_aucSysMem1, bufLen);
|
|
||||||
if (buf == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
(void)memset_s(buf, bufLen, 0, bufLen);
|
|
||||||
freeBuf = buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
LosProcessCB *processCB = ProcGetProcessCB(data);
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
UINT32 containerID = OsGetContainerID(processCB, (ContainerType)data->type);
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
if (containerID != OS_INVALID_VALUE) {
|
|
||||||
count = ProcessContainerLink(containerID, (ContainerType)data->type, buf, bufLen);
|
|
||||||
} else {
|
|
||||||
count = strlen("(unknown)");
|
|
||||||
if (memcpy_s(buf, bufLen, "(unknown)", count + 1) != EOK) {
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, freeBuf);
|
|
||||||
return -EBADF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (count < 0) {
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, freeBuf);
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)buffer, bufLen)) {
|
|
||||||
if (LOS_ArchCopyToUser(buffer, buf, bufLen) != 0) {
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, freeBuf);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, freeBuf);
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct ProcFileOperations PID_CONTAINER_FOPS = {
|
|
||||||
.readLink = ProcessContainerReadLink,
|
|
||||||
};
|
|
||||||
|
|
||||||
void *ProcfsContainerGet(int fd, unsigned int *containerType)
|
|
||||||
{
|
|
||||||
if ((fd <= 0) || (containerType == NULL)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
VnodeHold();
|
|
||||||
struct Vnode *vnode = VnodeFind(fd);
|
|
||||||
if (vnode == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcDirEntry *entry = VnodeToEntry(vnode);
|
|
||||||
if (entry == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcessData *data = (struct ProcessData *)entry->data;
|
|
||||||
if (data == NULL) {
|
|
||||||
VnodeDrop();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *processCB = (void *)ProcGetProcessCB(data);
|
|
||||||
*containerType = data->type;
|
|
||||||
VnodeDrop();
|
|
||||||
return processCB;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* LOSCFG_KERNEL_CONTAINER */
|
|
||||||
|
|
||||||
static int ProcessMemInfoRead(struct SeqBuf *seqBuf, LosProcessCB *pcb)
|
|
||||||
{
|
|
||||||
unsigned int intSave;
|
|
||||||
unsigned int size = sizeof(LosVmSpace) + sizeof(LosVmMapRegion);
|
|
||||||
LosVmSpace *vmSpace = (LosVmSpace *)LOS_MemAlloc(m_aucSysMem1, size);
|
|
||||||
if (vmSpace == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
(void)memset_s(vmSpace, size, 0, size);
|
|
||||||
LosVmMapRegion *heap = (LosVmMapRegion *)((char *)vmSpace + sizeof(LosVmSpace));
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
if (OsProcessIsInactive(pcb)) {
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, vmSpace);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
(void)memcpy_s(vmSpace, sizeof(LosVmSpace), pcb->vmSpace, sizeof(LosVmSpace));
|
|
||||||
(void)memcpy_s(heap, sizeof(LosVmMapRegion), pcb->vmSpace->heap, sizeof(LosVmMapRegion));
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "\nVMSpaceSize: %u byte\n", vmSpace->size);
|
|
||||||
(void)LosBufPrintf(seqBuf, "VMSpaceMapSize: %u byte\n", vmSpace->mapSize);
|
|
||||||
(void)LosBufPrintf(seqBuf, "VM TLB Asid: %u\n", vmSpace->archMmu.asid);
|
|
||||||
(void)LosBufPrintf(seqBuf, "VMHeapSize: %u byte\n", heap->range.size);
|
|
||||||
(void)LosBufPrintf(seqBuf, "VMHeapRegionName: %s\n", OsGetRegionNameOrFilePath(heap));
|
|
||||||
(void)LosBufPrintf(seqBuf, "VMHeapRegionType: 0x%x\n", heap->regionType);
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, vmSpace);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
|
||||||
#define TIME_CYCLE_TO_US(time) ((((UINT64)time) * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US)
|
|
||||||
static int ProcessCpupRead(struct SeqBuf *seqBuf, LosProcessCB *pcb)
|
|
||||||
{
|
|
||||||
unsigned int intSave;
|
|
||||||
OsCpupBase *processCpup = (OsCpupBase *)LOS_MemAlloc(m_aucSysMem1, sizeof(OsCpupBase));
|
|
||||||
if (processCpup == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
(void)memset_s(processCpup, sizeof(OsCpupBase), 0, sizeof(OsCpupBase));
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
if (OsProcessIsInactive(pcb)) {
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, processCpup);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
(void)memcpy_s(processCpup, sizeof(OsCpupBase), pcb->processCpup, sizeof(OsCpupBase));
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
|
|
||||||
(void)LosBufPrintf(seqBuf, "\nTotalRunningTime: %lu us\n", TIME_CYCLE_TO_US(processCpup->allTime));
|
|
||||||
(void)LosBufPrintf(seqBuf, "HistoricalRunningTime:(us) ");
|
|
||||||
for (UINT32 i = 0; i < OS_CPUP_HISTORY_RECORD_NUM + 1; i++) {
|
|
||||||
(void)LosBufPrintf(seqBuf, "%lu ", TIME_CYCLE_TO_US(processCpup->historyTime[i]));
|
|
||||||
}
|
|
||||||
(void)LosBufPrintf(seqBuf, "\n");
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, processCpup);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LOSCFG_TIME_CONTAINER
|
|
||||||
static const CHAR *g_monotonic = "monotonic";
|
|
||||||
#define DECIMAL_BASE 10
|
|
||||||
|
|
||||||
static int ProcTimeContainerRead(struct SeqBuf *m, void *v)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
unsigned int intSave;
|
|
||||||
struct timespec64 offsets = {0};
|
|
||||||
|
|
||||||
if ((m == NULL) || (v == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcessData *data = (struct ProcessData *)v;
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
LosProcessCB *processCB = ProcGetProcessCB(data);
|
|
||||||
ret = OsGetTimeContainerMonotonic(processCB, &offsets);
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
LosBufPrintf(m, "monotonic %lld %ld\n", offsets.tv_sec, offsets.tv_nsec);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ProcSetTimensOffset(const char *buf, LosProcessCB *processCB)
|
|
||||||
{
|
|
||||||
unsigned int intSave;
|
|
||||||
struct timespec64 offsets;
|
|
||||||
char *endptr = NULL;
|
|
||||||
|
|
||||||
offsets.tv_sec = strtoll(buf, &endptr, DECIMAL_BASE);
|
|
||||||
offsets.tv_nsec = strtoll(endptr, NULL, DECIMAL_BASE);
|
|
||||||
if (offsets.tv_nsec >= OS_SYS_NS_PER_SECOND) {
|
|
||||||
return -EACCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
unsigned int ret = OsSetTimeContainerMonotonic(processCB, &offsets);
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ProcTimeContainerWrite(struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
char *kbuf = NULL;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if ((pf == NULL) || (count <= 0)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcDirEntry *entry = pf->pPDE;
|
|
||||||
if (entry == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcessData *data = (struct ProcessData *)entry->data;
|
|
||||||
if (data == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)buf, count)) {
|
|
||||||
kbuf = LOS_MemAlloc(m_aucSysMem1, count + 1);
|
|
||||||
if (kbuf == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOS_ArchCopyFromUser(kbuf, buf, count) != 0) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
kbuf[count] = '\0';
|
|
||||||
buf = kbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = strncmp(buf, g_monotonic, strlen(g_monotonic));
|
|
||||||
if (ret != 0) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf += strlen(g_monotonic);
|
|
||||||
ret = ProcSetTimensOffset(buf, ProcGetProcessCB(data));
|
|
||||||
if (ret < 0) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct ProcFileOperations TIME_CONTAINER_FOPS = {
|
|
||||||
.read = ProcTimeContainerRead,
|
|
||||||
.write = ProcTimeContainerWrite,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LOSCFG_USER_CONTAINER
|
|
||||||
|
|
||||||
static void *MemdupUserNul(const void *src, size_t len)
|
|
||||||
{
|
|
||||||
char *des = NULL;
|
|
||||||
if (len <= 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
des = LOS_MemAlloc(OS_SYS_MEM_ADDR, len + 1);
|
|
||||||
if (des == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOS_ArchCopyFromUser(des, src, len) != 0) {
|
|
||||||
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, des);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
des[len] = '\0';
|
|
||||||
return des;
|
|
||||||
}
|
|
||||||
|
|
||||||
static LosProcessCB *ProcUidGidMapWriteCheck(struct ProcFile *pf, const char *buf, size_t size,
|
|
||||||
char **kbuf, ProcessDataType *type)
|
|
||||||
{
|
|
||||||
if ((pf == NULL) || (size <= 0) || (size >= PAGE_SIZE)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcDirEntry *entry = pf->pPDE;
|
|
||||||
if (entry == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProcessData *data = (struct ProcessData *)entry->data;
|
|
||||||
if (data == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*kbuf = MemdupUserNul(buf, size);
|
|
||||||
if (*kbuf == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*type = (ProcessDataType)data->type;
|
|
||||||
return ProcGetProcessCB(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t ProcIDMapWrite(struct ProcFile *file, const char *buf, size_t size, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
char *kbuf = NULL;
|
|
||||||
int ret;
|
|
||||||
unsigned int intSave;
|
|
||||||
ProcessDataType type = PROC_P_TYPE_MAX;
|
|
||||||
LosProcessCB *processCB = ProcUidGidMapWriteCheck(file, buf, size, &kbuf, &type);
|
|
||||||
if (processCB == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
if ((processCB->credentials == NULL) || (processCB->credentials->userContainer == NULL)) {
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
UserContainer *userContainer = processCB->credentials->userContainer;
|
|
||||||
if (userContainer->parent == NULL) {
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
if (type == PROC_UID_MAP) {
|
|
||||||
ret = OsUserContainerMapWrite(file, kbuf, size, CAP_SETUID,
|
|
||||||
&userContainer->uidMap, &userContainer->parent->uidMap);
|
|
||||||
} else {
|
|
||||||
ret = OsUserContainerMapWrite(file, kbuf, size, CAP_SETGID,
|
|
||||||
&userContainer->gidMap, &userContainer->parent->gidMap);
|
|
||||||
}
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ProcIDMapRead(struct SeqBuf *seqBuf, void *v)
|
|
||||||
{
|
|
||||||
unsigned int intSave;
|
|
||||||
if ((seqBuf == NULL) || (v == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
struct ProcessData *data = (struct ProcessData *)v;
|
|
||||||
LosProcessCB *processCB = ProcGetProcessCB(data);
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
if ((processCB->credentials == NULL) || (processCB->credentials->userContainer == NULL)) {
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
UserContainer *userContainer = processCB->credentials->userContainer;
|
|
||||||
if ((userContainer != NULL) && (userContainer->parent == NULL)) {
|
|
||||||
UidGidExtent uidGidExtent = userContainer->uidMap.extent[0];
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
(void)LosBufPrintf(seqBuf, "%d %d %u\n", uidGidExtent.first, uidGidExtent.lowerFirst,
|
|
||||||
uidGidExtent.count);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct ProcFileOperations UID_GID_MAP_FOPS = {
|
|
||||||
.read = ProcIDMapRead,
|
|
||||||
.write = ProcIDMapWrite,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int ProcProcessRead(struct SeqBuf *m, void *v)
|
|
||||||
{
|
|
||||||
if ((m == NULL) || (v == NULL)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
struct ProcessData *data = (struct ProcessData *)v;
|
|
||||||
switch (data->type) {
|
|
||||||
case PROC_PID_MEM:
|
|
||||||
return ProcessMemInfoRead(m, ProcGetProcessCB(data));
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
|
||||||
case PROC_PID_CPUP:
|
|
||||||
return ProcessCpupRead(m, ProcGetProcessCB(data));
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct ProcFileOperations PID_FOPS = {
|
|
||||||
.read = ProcProcessRead,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct ProcProcess g_procProcess[] = {
|
|
||||||
{
|
|
||||||
.name = NULL,
|
|
||||||
.mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IROTH,
|
|
||||||
.type = PROC_PID,
|
|
||||||
.fileOps = &PID_FOPS
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.name = "meminfo",
|
|
||||||
.mode = 0,
|
|
||||||
.type = PROC_PID_MEM,
|
|
||||||
.fileOps = &PID_FOPS
|
|
||||||
},
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
|
||||||
{
|
|
||||||
.name = "cpup",
|
|
||||||
.mode = 0,
|
|
||||||
.type = PROC_PID_CPUP,
|
|
||||||
.fileOps = &PID_FOPS
|
|
||||||
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "container",
|
|
||||||
.mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH,
|
|
||||||
.type = CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
|
|
||||||
},
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "container/pid",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = PID_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.name = "container/pid_for_children",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = PID_CHILD_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_UTS_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "container/uts",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = UTS_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "container/mnt",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = MNT_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "container/ipc",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = IPC_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_TIME_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "container/time",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = TIME_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.name = "container/time_for_children",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = TIME_CHILD_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.name = "time_offsets",
|
|
||||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
|
||||||
.type = TIME_CONTAINER,
|
|
||||||
.fileOps = &TIME_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "container/user",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = USER_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.name = "uid_map",
|
|
||||||
.mode = 0,
|
|
||||||
.type = PROC_UID_MAP,
|
|
||||||
.fileOps = &UID_GID_MAP_FOPS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.name = "gid_map",
|
|
||||||
.mode = 0,
|
|
||||||
.type = PROC_GID_MAP,
|
|
||||||
.fileOps = &UID_GID_MAP_FOPS
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "container/net",
|
|
||||||
.mode = S_IFLNK,
|
|
||||||
.type = NET_CONTAINER,
|
|
||||||
.fileOps = &PID_CONTAINER_FOPS
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
void ProcFreeProcessDir(struct ProcDirEntry *processDir)
|
|
||||||
{
|
|
||||||
if (processDir == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RemoveProcEntry(processDir->name, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct ProcDirEntry *ProcCreatePorcess(UINT32 pid, struct ProcProcess *porcess, uintptr_t processCB)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct ProcDataParm dataParm;
|
|
||||||
char pidName[PROC_PID_DIR_LEN] = {0};
|
|
||||||
struct ProcessData *data = (struct ProcessData *)malloc(sizeof(struct ProcessData));
|
|
||||||
if (data == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (pid != OS_INVALID_VALUE) {
|
|
||||||
if (porcess->name != NULL) {
|
|
||||||
ret = snprintf_s(pidName, PROC_PID_DIR_LEN, PROC_PID_DIR_LEN - 1, "%u/%s", pid, porcess->name);
|
|
||||||
} else {
|
|
||||||
ret = snprintf_s(pidName, PROC_PID_DIR_LEN, PROC_PID_DIR_LEN - 1, "%u", pid);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (porcess->name != NULL) {
|
|
||||||
ret = snprintf_s(pidName, PROC_PID_DIR_LEN, PROC_PID_DIR_LEN - 1, "%s/%s", "self", porcess->name);
|
|
||||||
} else {
|
|
||||||
ret = snprintf_s(pidName, PROC_PID_DIR_LEN, PROC_PID_DIR_LEN - 1, "%s", "self");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret < 0) {
|
|
||||||
free(data);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->process = processCB;
|
|
||||||
data->type = porcess->type;
|
|
||||||
dataParm.data = data;
|
|
||||||
dataParm.dataType = PROC_DATA_FREE;
|
|
||||||
struct ProcDirEntry *container = ProcCreateData(pidName, porcess->mode, NULL, porcess->fileOps, &dataParm);
|
|
||||||
if (container == NULL) {
|
|
||||||
free(data);
|
|
||||||
PRINT_ERR("create /proc/%s error!\n", pidName);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProcCreateProcessDir(UINT32 pid, uintptr_t process)
|
|
||||||
{
|
|
||||||
unsigned int intSave;
|
|
||||||
struct ProcDirEntry *pidDir = NULL;
|
|
||||||
for (int index = 0; index < (sizeof(g_procProcess) / sizeof(struct ProcProcess)); index++) {
|
|
||||||
struct ProcProcess *procProcess = &g_procProcess[index];
|
|
||||||
struct ProcDirEntry *dir = ProcCreatePorcess(pid, procProcess, process);
|
|
||||||
if (dir == NULL) {
|
|
||||||
PRINT_ERR("create /proc/%s error!\n", procProcess->name);
|
|
||||||
goto CREATE_ERROR;
|
|
||||||
}
|
|
||||||
if (index == 0) {
|
|
||||||
pidDir = dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process != 0) {
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
((LosProcessCB *)process)->procDir = pidDir;
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
CREATE_ERROR:
|
|
||||||
if (pidDir != NULL) {
|
|
||||||
RemoveProcEntry(pidDir->name, NULL);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif /* LOSCFG_PROC_PROCESS_DIR */
|
|
||||||
|
|
||||||
static int ProcessProcFill(struct SeqBuf *m, void *v)
|
static int ProcessProcFill(struct SeqBuf *m, void *v)
|
||||||
{
|
{
|
||||||
|
@ -711,18 +52,7 @@ void ProcProcessInit(void)
|
||||||
PRINT_ERR("create /proc/process error!\n");
|
PRINT_ERR("create /proc/process error!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pde->procFileOps = &PROCESS_PROC_FOPS;
|
pde->procFileOps = &PROCESS_PROC_FOPS;
|
||||||
|
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
int ret = ProcCreateProcessDir(OS_INVALID_VALUE, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
PRINT_ERR("Create proc process self dir failed!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ProcCreateProcessDir(OS_USER_ROOT_PROCESS_ID, (uintptr_t)OsGetUserInitProcess());
|
|
||||||
if (ret < 0) {
|
|
||||||
PRINT_ERR("Create proc process %d dir failed!\n", OS_USER_ROOT_PROCESS_ID);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,228 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/statfs.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include "proc_fs.h"
|
|
||||||
#include "internal.h"
|
|
||||||
#include "los_process_pri.h"
|
|
||||||
#include "user_copy.h"
|
|
||||||
#include "los_memory.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
struct ProcSysUser {
|
|
||||||
char *name;
|
|
||||||
mode_t mode;
|
|
||||||
int type;
|
|
||||||
const struct ProcFileOperations *fileOps;
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned int MemUserCopy(const char *src, size_t len, char **kbuf)
|
|
||||||
{
|
|
||||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)src, len)) {
|
|
||||||
char *kernelBuf = LOS_MemAlloc(m_aucSysMem1, len + 1);
|
|
||||||
if (kernelBuf == NULL) {
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOS_ArchCopyFromUser(kernelBuf, src, len) != 0) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, kernelBuf);
|
|
||||||
return EFAULT;
|
|
||||||
}
|
|
||||||
kernelBuf[len] = '\0';
|
|
||||||
*kbuf = kernelBuf;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetContainerLimitValue(struct ProcFile *pf, const CHAR *buf, size_t count)
|
|
||||||
{
|
|
||||||
int value;
|
|
||||||
char *kbuf = NULL;
|
|
||||||
|
|
||||||
if ((pf == NULL) || (pf->pPDE == NULL) || (buf == NULL) || (count <= 0)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned ret = MemUserCopy(buf, count, &kbuf);
|
|
||||||
if (ret != 0) {
|
|
||||||
return -ret;
|
|
||||||
} else if ((ret == 0) && (kbuf != NULL)) {
|
|
||||||
buf = (const char *)kbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strspn(buf, "0123456789") != count) {
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
value = atoi(buf);
|
|
||||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t ProcSysUserWrite(struct ProcFile *pf, const char *buf, size_t size, loff_t *ppos)
|
|
||||||
{
|
|
||||||
(void)ppos;
|
|
||||||
unsigned ret;
|
|
||||||
int value = GetContainerLimitValue(pf, buf, size);
|
|
||||||
if (value < 0) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContainerType type = (ContainerType)(uintptr_t)pf->pPDE->data;
|
|
||||||
ret = OsSetContainerLimit(type, value);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ProcSysUserRead(struct SeqBuf *seqBuf, void *v)
|
|
||||||
{
|
|
||||||
unsigned ret;
|
|
||||||
if ((seqBuf == NULL) || (v == NULL)) {
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContainerType type = (ContainerType)(uintptr_t)v;
|
|
||||||
ret = OsGetContainerLimit(type);
|
|
||||||
if (ret == OS_INVALID_VALUE) {
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
(void)LosBufPrintf(seqBuf, "\nlimit: %u\n", ret);
|
|
||||||
(void)LosBufPrintf(seqBuf, "count: %u\n", OsGetContainerCount(type));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct ProcFileOperations SYS_USER_OPT = {
|
|
||||||
.read = ProcSysUserRead,
|
|
||||||
.write = ProcSysUserWrite,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct ProcSysUser g_sysUser[] = {
|
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "max_mnt_container",
|
|
||||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
|
||||||
.type = MNT_CONTAINER,
|
|
||||||
.fileOps = &SYS_USER_OPT
|
|
||||||
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "max_pid_container",
|
|
||||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
|
||||||
.type = PID_CONTAINER,
|
|
||||||
.fileOps = &SYS_USER_OPT
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_USER_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "max_user_container",
|
|
||||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
|
||||||
.type = USER_CONTAINER,
|
|
||||||
.fileOps = &SYS_USER_OPT
|
|
||||||
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_UTS_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "max_uts_container",
|
|
||||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
|
||||||
.type = UTS_CONTAINER,
|
|
||||||
.fileOps = &SYS_USER_OPT
|
|
||||||
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_UTS_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "max_time_container",
|
|
||||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
|
||||||
.type = UTS_CONTAINER,
|
|
||||||
.fileOps = &SYS_USER_OPT
|
|
||||||
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "max_ipc_container",
|
|
||||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
|
||||||
.type = IPC_CONTAINER,
|
|
||||||
.fileOps = &SYS_USER_OPT
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_NET_CONTAINER
|
|
||||||
{
|
|
||||||
.name = "max_net_container",
|
|
||||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
|
||||||
.type = NET_CONTAINER,
|
|
||||||
.fileOps = &SYS_USER_OPT
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
static int ProcCreateSysUser(struct ProcDirEntry *parent)
|
|
||||||
{
|
|
||||||
struct ProcDataParm parm;
|
|
||||||
for (int index = 0; index < (sizeof(g_sysUser) / sizeof(struct ProcSysUser)); index++) {
|
|
||||||
struct ProcSysUser *sysUser = &g_sysUser[index];
|
|
||||||
parm.data = (void *)(uintptr_t)sysUser->type;
|
|
||||||
parm.dataType = PROC_DATA_STATIC;
|
|
||||||
struct ProcDirEntry *userFile = ProcCreateData(sysUser->name, sysUser->mode, parent, sysUser->fileOps, &parm);
|
|
||||||
if (userFile == NULL) {
|
|
||||||
PRINT_ERR("create /proc/%s/%s error!\n", parent->name, sysUser->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PROC_SYS_USER_MODE (S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
|
||||||
void ProcSysUserInit(void)
|
|
||||||
{
|
|
||||||
struct ProcDirEntry *parentPDE = CreateProcEntry("sys", PROC_SYS_USER_MODE, NULL);
|
|
||||||
if (parentPDE == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
struct ProcDirEntry *pde = CreateProcEntry("user", PROC_SYS_USER_MODE, parentPDE);
|
|
||||||
if (pde == NULL) {
|
|
||||||
PRINT_ERR("create /proc/process error!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = ProcCreateSysUser(pde);
|
|
||||||
if (ret < 0) {
|
|
||||||
PRINT_ERR("Create proc sys user failed!\n");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -62,9 +62,8 @@ static struct ProcDirEntry g_procRootDirEntry = {
|
||||||
|
|
||||||
int ProcMatch(unsigned int len, const char *name, struct ProcDirEntry *pn)
|
int ProcMatch(unsigned int len, const char *name, struct ProcDirEntry *pn)
|
||||||
{
|
{
|
||||||
if (len != pn->nameLen) {
|
if (len != pn->nameLen)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
return !strncmp(name, pn->name, len);
|
return !strncmp(name, pn->name, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +295,7 @@ static int ProcAddNode(struct ProcDirEntry *parent, struct ProcDirEntry *pn)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcDetachNode(struct ProcDirEntry *pn)
|
static void ProcDetachNode(struct ProcDirEntry *pn)
|
||||||
{
|
{
|
||||||
struct ProcDirEntry *parent = pn->parent;
|
struct ProcDirEntry *parent = pn->parent;
|
||||||
struct ProcDirEntry **iter = NULL;
|
struct ProcDirEntry **iter = NULL;
|
||||||
|
@ -352,11 +351,6 @@ static struct ProcDirEntry *ProcCreateFile(struct ProcDirEntry *parent, const ch
|
||||||
|
|
||||||
pn->procFileOps = procFileOps;
|
pn->procFileOps = procFileOps;
|
||||||
pn->type = VNODE_TYPE_REG;
|
pn->type = VNODE_TYPE_REG;
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
if (S_ISLNK(mode)) {
|
|
||||||
pn->type = VNODE_TYPE_VIR_LNK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ret = ProcAddNode(parent, pn);
|
ret = ProcAddNode(parent, pn);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
free(pn->pf);
|
free(pn->pf);
|
||||||
|
@ -379,50 +373,25 @@ struct ProcDirEntry *CreateProcEntry(const char *name, mode_t mode, struct ProcD
|
||||||
return pde;
|
return pde;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcEntryClearVnode(struct ProcDirEntry *entry)
|
|
||||||
{
|
|
||||||
struct Vnode *item = NULL;
|
|
||||||
struct Vnode *nextItem = NULL;
|
|
||||||
|
|
||||||
VnodeHold();
|
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, GetVnodeActiveList(), struct Vnode, actFreeEntry) {
|
|
||||||
if ((struct ProcDirEntry *)item->data != entry) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VnodeFree(item) != LOS_OK) {
|
|
||||||
PRINT_ERR("ProcEntryClearVnode free failed, entry: %s\n", entry->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VnodeDrop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void FreeProcEntry(struct ProcDirEntry *entry)
|
static void FreeProcEntry(struct ProcDirEntry *entry)
|
||||||
{
|
{
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->pf != NULL) {
|
if (entry->pf != NULL) {
|
||||||
free(entry->pf);
|
free(entry->pf);
|
||||||
entry->pf = NULL;
|
entry->pf = NULL;
|
||||||
}
|
}
|
||||||
if ((entry->dataType == PROC_DATA_FREE) && (entry->data != NULL)) {
|
|
||||||
free(entry->data);
|
|
||||||
}
|
|
||||||
entry->data = NULL;
|
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcFreeEntry(struct ProcDirEntry *pn)
|
void ProcFreeEntry(struct ProcDirEntry *pn)
|
||||||
{
|
{
|
||||||
if (atomic_dec_and_test(&pn->count)) {
|
if (atomic_dec_and_test(&pn->count))
|
||||||
FreeProcEntry(pn);
|
FreeProcEntry(pn);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)
|
static void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)
|
||||||
{
|
{
|
||||||
if (pn == NULL) {
|
if (pn == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -430,8 +399,6 @@ void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)
|
||||||
RemoveProcEntryTravalsal(pn->next);
|
RemoveProcEntryTravalsal(pn->next);
|
||||||
RemoveProcEntryTravalsal(pn->subdir);
|
RemoveProcEntryTravalsal(pn->subdir);
|
||||||
|
|
||||||
ProcEntryClearVnode(pn);
|
|
||||||
|
|
||||||
ProcFreeEntry(pn);
|
ProcFreeEntry(pn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,9 +428,6 @@ void RemoveProcEntry(const char *name, struct ProcDirEntry *parent)
|
||||||
spin_unlock(&procfsLock);
|
spin_unlock(&procfsLock);
|
||||||
|
|
||||||
RemoveProcEntryTravalsal(pn->subdir);
|
RemoveProcEntryTravalsal(pn->subdir);
|
||||||
|
|
||||||
ProcEntryClearVnode(pn);
|
|
||||||
|
|
||||||
ProcFreeEntry(pn);
|
ProcFreeEntry(pn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,17 +442,14 @@ struct ProcDirEntry *ProcMkdir(const char *name, struct ProcDirEntry *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ProcDirEntry *ProcCreateData(const char *name, mode_t mode, struct ProcDirEntry *parent,
|
struct ProcDirEntry *ProcCreateData(const char *name, mode_t mode, struct ProcDirEntry *parent,
|
||||||
const struct ProcFileOperations *procFileOps, struct ProcDataParm *param)
|
const struct ProcFileOperations *procFileOps, void *data)
|
||||||
{
|
{
|
||||||
struct ProcDirEntry *pde = CreateProcEntry(name, mode, parent);
|
struct ProcDirEntry *pde = CreateProcEntry(name, mode, parent);
|
||||||
if (pde != NULL) {
|
if (pde != NULL) {
|
||||||
if (procFileOps != NULL) {
|
if (procFileOps != NULL) {
|
||||||
pde->procFileOps = procFileOps;
|
pde->procFileOps = procFileOps;
|
||||||
}
|
}
|
||||||
if (param != NULL) {
|
pde->data = data;
|
||||||
pde->data = param->data;
|
|
||||||
pde->dataType = param->dataType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return pde;
|
return pde;
|
||||||
}
|
}
|
||||||
|
@ -566,7 +527,7 @@ static int ProcRead(struct ProcDirEntry *pde, char *buf, size_t len)
|
||||||
|
|
||||||
if (sb->buf == NULL) {
|
if (sb->buf == NULL) {
|
||||||
// only read once to build the storage buffer
|
// only read once to build the storage buffer
|
||||||
if (pde->procFileOps->read(sb, pde->data) != 0) {
|
if (pde->procFileOps->read(sb, NULL) != 0) {
|
||||||
return PROC_ERROR;
|
return PROC_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,17 +552,21 @@ static int ProcRead(struct ProcDirEntry *pde, char *buf, size_t len)
|
||||||
|
|
||||||
struct ProcDirEntry *OpenProcFile(const char *fileName, int flags, ...)
|
struct ProcDirEntry *OpenProcFile(const char *fileName, int flags, ...)
|
||||||
{
|
{
|
||||||
|
unsigned int intSave;
|
||||||
struct ProcDirEntry *pn = ProcFindEntry(fileName);
|
struct ProcDirEntry *pn = ProcFindEntry(fileName);
|
||||||
if (pn == NULL) {
|
if (pn == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCHEDULER_LOCK(intSave);
|
||||||
if (S_ISREG(pn->mode) && (pn->count != 1)) {
|
if (S_ISREG(pn->mode) && (pn->count != 1)) {
|
||||||
|
SCHEDULER_UNLOCK(intSave);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pn->flags = (unsigned int)(pn->flags) | (unsigned int)flags;
|
pn->flags = (unsigned int)(pn->flags) | (unsigned int)flags;
|
||||||
atomic_set(&pn->count, PROC_INUSE);
|
atomic_set(&pn->count, PROC_INUSE);
|
||||||
|
SCHEDULER_UNLOCK(intSave);
|
||||||
if (ProcOpen(pn->pf) != OK) {
|
if (ProcOpen(pn->pf) != OK) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -650,6 +615,7 @@ int WriteProcFile(struct ProcDirEntry *pde, const void *buf, size_t len)
|
||||||
result = pde->procFileOps->write(pde->pf, (const char *)buf, len, &(pde->pf->fPos));
|
result = pde->procFileOps->write(pde->pf, (const char *)buf, len, &(pde->pf->fPos));
|
||||||
}
|
}
|
||||||
spin_unlock(&procfsLock);
|
spin_unlock(&procfsLock);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
import("//third_party/NuttX/NuttX.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_RAMFS)
|
module_switch = defined(LOSCFG_FS_RAMFS)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
import("//third_party/NuttX/NuttX.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_ROMFS)
|
module_switch = defined(LOSCFG_FS_ROMFS)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
|
|
|
@ -33,6 +33,10 @@ MODULE_NAME := rootfs
|
||||||
|
|
||||||
LOCAL_SRCS := $(wildcard los_rootfs.c los_bootargs.c)
|
LOCAL_SRCS := $(wildcard los_rootfs.c los_bootargs.c)
|
||||||
|
|
||||||
|
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
||||||
|
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/drivers/cfiflash
|
||||||
|
endif
|
||||||
|
|
||||||
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
||||||
|
|
||||||
include $(MODULE)
|
include $(MODULE)
|
||||||
|
|
|
@ -32,10 +32,14 @@
|
||||||
#include "los_base.h"
|
#include "los_base.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND)
|
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)
|
||||||
#include "mtd_list.h"
|
#include "mtd_list.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||||
|
#include "cfiflash.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LOSCFG_STORAGE_EMMC
|
#ifdef LOSCFG_STORAGE_EMMC
|
||||||
#include "disk.h"
|
#include "disk.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -94,6 +98,19 @@ INT32 LOS_GetCmdLine(VOID)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||||
|
struct MtdDev *mtd = GetCfiMtdDev();
|
||||||
|
if (mtd == NULL) {
|
||||||
|
PRINT_ERR("Get CFI mtd failed!\n");
|
||||||
|
goto ERROUT;
|
||||||
|
}
|
||||||
|
g_alignSize = mtd->eraseSize;
|
||||||
|
ret = mtd->read(mtd, CFIFLASH_BOOTARGS_ADDR, COMMAND_LINE_SIZE, g_cmdLine);
|
||||||
|
if (ret == COMMAND_LINE_SIZE) {
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
PRINT_ERR("Read cmdline error!\n");
|
PRINT_ERR("Read cmdline error!\n");
|
||||||
ERROUT:
|
ERROUT:
|
||||||
free(g_cmdLine);
|
free(g_cmdLine);
|
||||||
|
|
|
@ -37,11 +37,15 @@
|
||||||
#include "sys/stat.h"
|
#include "sys/stat.h"
|
||||||
#include "sys/types.h"
|
#include "sys/types.h"
|
||||||
|
|
||||||
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND)
|
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)
|
||||||
#include "mtd_list.h"
|
#include "mtd_list.h"
|
||||||
#include "mtd_partition.h"
|
#include "mtd_partition.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||||
|
#include "cfiflash.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LOSCFG_STORAGE_EMMC
|
#ifdef LOSCFG_STORAGE_EMMC
|
||||||
#include "disk.h"
|
#include "disk.h"
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
|
@ -124,7 +128,14 @@ STATIC INT32 AddEmmcParts(INT32 rootAddr, INT32 rootSize, INT32 userAddr, INT32
|
||||||
|
|
||||||
STATIC INT32 AddPartitions(CHAR *dev, UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr, UINT64 userSize)
|
STATIC INT32 AddPartitions(CHAR *dev, UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr, UINT64 userSize)
|
||||||
{
|
{
|
||||||
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND)
|
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||||
|
if ((strcmp(dev, "cfi-flash") == 0) && (rootAddr != CFIFLASH_ROOT_ADDR)) {
|
||||||
|
PRINT_ERR("Error rootAddr, must be %#0x!\n", CFIFLASH_ROOT_ADDR);
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)
|
||||||
INT32 ret;
|
INT32 ret;
|
||||||
INT32 blk0 = 0;
|
INT32 blk0 = 0;
|
||||||
INT32 blk2 = 2;
|
INT32 blk2 = 2;
|
||||||
|
|
|
@ -59,6 +59,12 @@
|
||||||
#define ROOTFS_ADDR 0x600000
|
#define ROOTFS_ADDR 0x600000
|
||||||
#define ROOTFS_SIZE 0x800000
|
#define ROOTFS_SIZE 0x800000
|
||||||
#define USERFS_SIZE 0x80000
|
#define USERFS_SIZE 0x80000
|
||||||
|
#elif defined (LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)
|
||||||
|
#define ROOT_DEV_NAME "/dev/cfiflash0"
|
||||||
|
#define USER_DEV_NAME "/dev/cfiflash2"
|
||||||
|
#define ROOTFS_ADDR CFIFLASH_ROOT_ADDR
|
||||||
|
#define ROOTFS_SIZE 0x1B00000
|
||||||
|
#define USERFS_SIZE (CFIFLASH_CAPACITY - ROOTFS_ADDR - ROOTFS_SIZE)
|
||||||
#elif defined (LOSCFG_STORAGE_EMMC)
|
#elif defined (LOSCFG_STORAGE_EMMC)
|
||||||
#define ROOT_DEV_NAME "/dev/mmcblk0p0"
|
#define ROOT_DEV_NAME "/dev/mmcblk0p0"
|
||||||
#ifdef LOSCFG_PLATFORM_PATCHFS
|
#ifdef LOSCFG_PLATFORM_PATCHFS
|
||||||
|
|
|
@ -28,14 +28,17 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_a/liteos.gni")
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
import("//third_party/NuttX/NuttX.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_VFS)
|
module_switch = defined(LOSCFG_FS_VFS)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [
|
sources = [
|
||||||
"epoll/fs_epoll.c",
|
"$LITEOSTOPDIR/fs/vfs/epoll/fs_epoll.c",
|
||||||
"mount.c",
|
"$LITEOSTOPDIR/fs/vfs/mount.c",
|
||||||
|
"$LITEOSTOPDIR/fs/vfs/path_cache.c",
|
||||||
|
"$LITEOSTOPDIR/fs/vfs/vnode.c",
|
||||||
|
"$LITEOSTOPDIR/fs/vfs/vnode_hash.c",
|
||||||
"operation/fullpath.c",
|
"operation/fullpath.c",
|
||||||
"operation/vfs_chattr.c",
|
"operation/vfs_chattr.c",
|
||||||
"operation/vfs_check.c",
|
"operation/vfs_check.c",
|
||||||
|
@ -52,10 +55,7 @@ kernel_module(module_name) {
|
||||||
"operation/vfs_readv.c",
|
"operation/vfs_readv.c",
|
||||||
"operation/vfs_utime.c",
|
"operation/vfs_utime.c",
|
||||||
"operation/vfs_writev.c",
|
"operation/vfs_writev.c",
|
||||||
"path_cache.c",
|
|
||||||
"vfs_cmd/vfs_shellcmd.c",
|
"vfs_cmd/vfs_shellcmd.c",
|
||||||
"vnode.c",
|
|
||||||
"vnode_hash.c",
|
|
||||||
]
|
]
|
||||||
sources += NUTTX_FS_DIRENT_SRC_FILES
|
sources += NUTTX_FS_DIRENT_SRC_FILES
|
||||||
sources += NUTTX_FS_DRIVER_SRC_FILES
|
sources += NUTTX_FS_DRIVER_SRC_FILES
|
||||||
|
|
|
@ -581,8 +581,8 @@ static OsBcacheBlock *AllocNewBlock(OsBcache *bc, BOOL read, UINT64 num)
|
||||||
DelBlock(bc, prefer);
|
DelBlock(bc, prefer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefer->used) { /* do not combine with next check */
|
if (prefer->used) {
|
||||||
MergeSyncBlocks(bc, prefer); /* prefer->used may be changed here */
|
MergeSyncBlocks(bc, prefer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefer->used) {
|
if (prefer->used) {
|
||||||
|
|
|
@ -220,18 +220,14 @@ int epoll_close(int epfd)
|
||||||
{
|
{
|
||||||
struct epoll_head *epHead = NULL;
|
struct epoll_head *epHead = NULL;
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&g_epollMutex);
|
|
||||||
epHead = EpollGetDataBuff(epfd);
|
epHead = EpollGetDataBuff(epfd);
|
||||||
if (epHead == NULL) {
|
if (epHead == NULL) {
|
||||||
(VOID)pthread_mutex_unlock(&g_epollMutex);
|
|
||||||
set_errno(EBADF);
|
set_errno(EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoEpollClose(epHead);
|
DoEpollClose(epHead);
|
||||||
int ret = EpollFreeSysFd(epfd);
|
return EpollFreeSysFd(epfd);
|
||||||
(VOID)pthread_mutex_unlock(&g_epollMutex);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev)
|
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev)
|
||||||
|
@ -240,16 +236,15 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev)
|
||||||
int i;
|
int i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
(VOID)pthread_mutex_lock(&g_epollMutex);
|
|
||||||
epHead = EpollGetDataBuff(epfd);
|
epHead = EpollGetDataBuff(epfd);
|
||||||
if (epHead == NULL) {
|
if (epHead == NULL) {
|
||||||
set_errno(EBADF);
|
set_errno(EBADF);
|
||||||
goto OUT_RELEASE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev == NULL) {
|
if (ev == NULL) {
|
||||||
set_errno(EINVAL);
|
set_errno(EINVAL);
|
||||||
goto OUT_RELEASE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -257,19 +252,18 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev)
|
||||||
ret = CheckFdExist(epHead, fd);
|
ret = CheckFdExist(epHead, fd);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
set_errno(EEXIST);
|
set_errno(EEXIST);
|
||||||
goto OUT_RELEASE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (epHead->nodeCount == EPOLL_DEFAULT_SIZE) {
|
if (epHead->nodeCount == EPOLL_DEFAULT_SIZE) {
|
||||||
set_errno(ENOMEM);
|
set_errno(ENOMEM);
|
||||||
goto OUT_RELEASE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
epHead->evs[epHead->nodeCount].events = ev->events | POLLERR | POLLHUP;
|
epHead->evs[epHead->nodeCount].events = ev->events | POLLERR | POLLHUP;
|
||||||
epHead->evs[epHead->nodeCount].data.fd = fd;
|
epHead->evs[epHead->nodeCount].data.fd = fd;
|
||||||
epHead->nodeCount++;
|
epHead->nodeCount++;
|
||||||
ret = 0;
|
return 0;
|
||||||
break;
|
|
||||||
case EPOLL_CTL_DEL:
|
case EPOLL_CTL_DEL:
|
||||||
for (i = 0; i < epHead->nodeCount; i++) {
|
for (i = 0; i < epHead->nodeCount; i++) {
|
||||||
if (epHead->evs[i].data.fd != fd) {
|
if (epHead->evs[i].data.fd != fd) {
|
||||||
|
@ -281,29 +275,23 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev)
|
||||||
epHead->nodeCount - i);
|
epHead->nodeCount - i);
|
||||||
}
|
}
|
||||||
epHead->nodeCount--;
|
epHead->nodeCount--;
|
||||||
ret = 0;
|
return 0;
|
||||||
goto OUT_RELEASE;
|
|
||||||
}
|
}
|
||||||
set_errno(ENOENT);
|
set_errno(ENOENT);
|
||||||
break;
|
return -1;
|
||||||
case EPOLL_CTL_MOD:
|
case EPOLL_CTL_MOD:
|
||||||
for (i = 0; i < epHead->nodeCount; i++) {
|
for (i = 0; i < epHead->nodeCount; i++) {
|
||||||
if (epHead->evs[i].data.fd == fd) {
|
if (epHead->evs[i].data.fd == fd) {
|
||||||
epHead->evs[i].events = ev->events | POLLERR | POLLHUP;
|
epHead->evs[i].events = ev->events | POLLERR | POLLHUP;
|
||||||
ret = 0;
|
return 0;
|
||||||
goto OUT_RELEASE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_errno(ENOENT);
|
set_errno(ENOENT);
|
||||||
break;
|
return -1;
|
||||||
default:
|
default:
|
||||||
set_errno(EINVAL);
|
set_errno(EINVAL);
|
||||||
break;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_RELEASE:
|
|
||||||
(VOID)pthread_mutex_unlock(&g_epollMutex);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout)
|
int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout)
|
||||||
|
@ -338,7 +326,7 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < pollSize; i++) {
|
for (i = 0; i < epHead->nodeCount; i++) {
|
||||||
pFd[i].fd = epHead->evs[i].data.fd;
|
pFd[i].fd = epHead->evs[i].data.fd;
|
||||||
pFd[i].events = (short)epHead->evs[i].events;
|
pFd[i].events = (short)epHead->evs[i].events;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,9 +101,6 @@ enum VnodeType {
|
||||||
VNODE_TYPE_BCHR, /* block char mix device */
|
VNODE_TYPE_BCHR, /* block char mix device */
|
||||||
VNODE_TYPE_FIFO, /* pipe */
|
VNODE_TYPE_FIFO, /* pipe */
|
||||||
VNODE_TYPE_LNK, /* link */
|
VNODE_TYPE_LNK, /* link */
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
VNODE_TYPE_VIR_LNK, /* virtual link */
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fs_dirent_s;
|
struct fs_dirent_s;
|
||||||
|
@ -130,9 +127,6 @@ struct Vnode {
|
||||||
struct Mount *newMount; /* fs info about who mount on this vnode */
|
struct Mount *newMount; /* fs info about who mount on this vnode */
|
||||||
char *filePath; /* file path of the vnode */
|
char *filePath; /* file path of the vnode */
|
||||||
struct page_mapping mapping; /* page mapping of the vnode */
|
struct page_mapping mapping; /* page mapping of the vnode */
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
int mntCount; /* ref count of mounts */
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VnodeOps {
|
struct VnodeOps {
|
||||||
|
@ -166,7 +160,7 @@ typedef int VfsHashCmp(struct Vnode *vnode, void *arg);
|
||||||
|
|
||||||
int VnodesInit(void);
|
int VnodesInit(void);
|
||||||
int VnodeDevInit(void);
|
int VnodeDevInit(void);
|
||||||
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode);
|
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **vnode);
|
||||||
int VnodeFree(struct Vnode *vnode);
|
int VnodeFree(struct Vnode *vnode);
|
||||||
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags);
|
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags);
|
||||||
int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags);
|
int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags);
|
||||||
|
@ -191,8 +185,5 @@ LIST_HEAD* GetVnodeFreeList(void);
|
||||||
LIST_HEAD* GetVnodeActiveList(void);
|
LIST_HEAD* GetVnodeActiveList(void);
|
||||||
LIST_HEAD* GetVnodeVirtualList(void);
|
LIST_HEAD* GetVnodeVirtualList(void);
|
||||||
int VnodeClearCache(void);
|
int VnodeClearCache(void);
|
||||||
struct Vnode *GetCurrRootVnode(void);
|
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
struct Vnode *VnodeFind(int fd);
|
|
||||||
#endif
|
|
||||||
#endif /* !_VNODE_H_ */
|
#endif /* !_VNODE_H_ */
|
||||||
|
|
|
@ -37,16 +37,11 @@
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
#include "los_mnt_container_pri.h"
|
|
||||||
static LIST_HEAD *g_mountCache = NULL;
|
|
||||||
#else
|
|
||||||
static LIST_HEAD *g_mountList = NULL;
|
static LIST_HEAD *g_mountList = NULL;
|
||||||
#endif
|
|
||||||
|
|
||||||
struct Mount *MountAlloc(struct Vnode *vnodeBeCovered, struct MountOps *fsop)
|
struct Mount* MountAlloc(struct Vnode* vnodeBeCovered, struct MountOps* fsop)
|
||||||
{
|
{
|
||||||
struct Mount *mnt = (struct Mount *)zalloc(sizeof(struct Mount));
|
struct Mount* mnt = (struct Mount*)zalloc(sizeof(struct Mount));
|
||||||
if (mnt == NULL) {
|
if (mnt == NULL) {
|
||||||
PRINT_ERR("MountAlloc failed no memory!\n");
|
PRINT_ERR("MountAlloc failed no memory!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -67,26 +62,7 @@ struct Mount *MountAlloc(struct Vnode *vnodeBeCovered, struct MountOps *fsop)
|
||||||
return mnt;
|
return mnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
LIST_HEAD* GetMountList()
|
||||||
LIST_HEAD *GetMountList(void)
|
|
||||||
{
|
|
||||||
return GetContainerMntList();
|
|
||||||
}
|
|
||||||
|
|
||||||
LIST_HEAD *GetMountCache(void)
|
|
||||||
{
|
|
||||||
if (g_mountCache == NULL) {
|
|
||||||
g_mountCache = zalloc(sizeof(LIST_HEAD));
|
|
||||||
if (g_mountCache == NULL) {
|
|
||||||
PRINT_ERR("init cache mount list failed, no memory.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
LOS_ListInit(g_mountCache);
|
|
||||||
}
|
|
||||||
return g_mountCache;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
LIST_HEAD* GetMountList(void)
|
|
||||||
{
|
{
|
||||||
if (g_mountList == NULL) {
|
if (g_mountList == NULL) {
|
||||||
g_mountList = zalloc(sizeof(LIST_HEAD));
|
g_mountList = zalloc(sizeof(LIST_HEAD));
|
||||||
|
@ -98,4 +74,3 @@ LIST_HEAD* GetMountList(void)
|
||||||
}
|
}
|
||||||
return g_mountList;
|
return g_mountList;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
|
|
@ -353,7 +353,7 @@ static struct file_operations_vfs g_errorFileOps = {
|
||||||
.unlink = ErrorFopUnlink,
|
.unlink = ErrorFopUnlink,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct Mount* GetDevMountPoint(const struct Vnode *dev)
|
static struct Mount* GetDevMountPoint(struct Vnode *dev)
|
||||||
{
|
{
|
||||||
struct Mount *mnt = NULL;
|
struct Mount *mnt = NULL;
|
||||||
LIST_HEAD *mntList = GetMountList();
|
LIST_HEAD *mntList = GetMountList();
|
||||||
|
@ -394,7 +394,7 @@ static void FilePreClose(struct file *filep, const struct file_operations_vfs *o
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FileDisableAndClean(const struct Mount *mnt)
|
static void FileDisableAndClean(struct Mount *mnt)
|
||||||
{
|
{
|
||||||
struct filelist *flist = &tg_filelist;
|
struct filelist *flist = &tg_filelist;
|
||||||
struct file *filep = NULL;
|
struct file *filep = NULL;
|
||||||
|
@ -435,7 +435,7 @@ static void VnodeTryFree(struct Vnode *vnode)
|
||||||
vnode->fop = &g_errorFileOps;
|
vnode->fop = &g_errorFileOps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VnodeTryFreeAll(const struct Mount *mount)
|
static void VnodeTryFreeAll(struct Mount *mount)
|
||||||
{
|
{
|
||||||
struct Vnode *vnode = NULL;
|
struct Vnode *vnode = NULL;
|
||||||
struct Vnode *nextVnode = NULL;
|
struct Vnode *nextVnode = NULL;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -482,7 +482,7 @@ exit_with_nomem:
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintFileInfo64(const struct stat64 *stat64Info, const char *name, const char *linkName)
|
static void PrintFileInfo64(const struct stat64 *stat64Info, const char *name)
|
||||||
{
|
{
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
char str[UGO_NUMS][UGO_NUMS + 1] = {0};
|
char str[UGO_NUMS][UGO_NUMS + 1] = {0};
|
||||||
|
@ -504,18 +504,11 @@ static void PrintFileInfo64(const struct stat64 *stat64Info, const char *name, c
|
||||||
dirFlag = '-';
|
dirFlag = '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISLNK(stat64Info->st_mode)) {
|
PRINTK("%c%s%s%s %-8lld u:%-5d g:%-5d %-10s\n", dirFlag,
|
||||||
PRINTK("%c%s%s%s %-8lld u:%-5d g:%-5d %-10s -> %s\n", dirFlag,
|
str[0], str[1], str[UGO_NUMS - 1], stat64Info->st_size, stat64Info->st_uid, stat64Info->st_gid, name);
|
||||||
str[0], str[1], str[UGO_NUMS - 1], stat64Info->st_size,
|
|
||||||
stat64Info->st_uid, stat64Info->st_gid, name, linkName);
|
|
||||||
} else {
|
|
||||||
PRINTK("%c%s%s%s %-8lld u:%-5d g:%-5d %-10s\n", dirFlag,
|
|
||||||
str[0], str[1], str[UGO_NUMS - 1], stat64Info->st_size,
|
|
||||||
stat64Info->st_uid, stat64Info->st_gid, name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintFileInfo(const struct stat *statInfo, const char *name, const char *linkName)
|
static void PrintFileInfo(const struct stat *statInfo, const char *name)
|
||||||
{
|
{
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
char str[UGO_NUMS][UGO_NUMS + 1] = {0};
|
char str[UGO_NUMS][UGO_NUMS + 1] = {0};
|
||||||
|
@ -537,33 +530,19 @@ static void PrintFileInfo(const struct stat *statInfo, const char *name, const c
|
||||||
dirFlag = '-';
|
dirFlag = '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISLNK(statInfo->st_mode)) {
|
PRINTK("%c%s%s%s %-8lld u:%-5d g:%-5d %-10s\n", dirFlag,
|
||||||
PRINTK("%c%s%s%s %-8lld u:%-5d g:%-5d %-10s -> %s\n", dirFlag,
|
str[0], str[1], str[UGO_NUMS - 1], statInfo->st_size, statInfo->st_uid, statInfo->st_gid, name);
|
||||||
str[0], str[1], str[UGO_NUMS - 1], statInfo->st_size,
|
|
||||||
statInfo->st_uid, statInfo->st_gid, name, linkName);
|
|
||||||
} else {
|
|
||||||
PRINTK("%c%s%s%s %-8lld u:%-5d g:%-5d %-10s\n", dirFlag,
|
|
||||||
str[0], str[1], str[UGO_NUMS - 1], statInfo->st_size,
|
|
||||||
statInfo->st_uid, statInfo->st_gid, name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LsFile(const char *path)
|
int LsFile(const char *path)
|
||||||
{
|
{
|
||||||
struct stat64 stat64Info;
|
struct stat64 stat64Info;
|
||||||
struct stat statInfo;
|
struct stat statInfo;
|
||||||
char linkName[NAME_MAX] = { 0 };
|
|
||||||
|
|
||||||
if (stat64(path, &stat64Info) == 0) {
|
if (stat64(path, &stat64Info) == 0) {
|
||||||
if (S_ISLNK(stat64Info.st_mode)) {
|
PrintFileInfo64(&stat64Info, path);
|
||||||
readlink(path, linkName, NAME_MAX);
|
|
||||||
}
|
|
||||||
PrintFileInfo64(&stat64Info, path, (const char *)linkName);
|
|
||||||
} else if (stat(path, &statInfo) == 0) {
|
} else if (stat(path, &statInfo) == 0) {
|
||||||
if (S_ISLNK(statInfo.st_mode)) {
|
PrintFileInfo(&statInfo, path);
|
||||||
readlink(path, linkName, NAME_MAX);
|
|
||||||
}
|
|
||||||
PrintFileInfo(&statInfo, path, (const char *)linkName);
|
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -575,7 +554,6 @@ int LsDir(const char *path)
|
||||||
{
|
{
|
||||||
struct stat statInfo = { 0 };
|
struct stat statInfo = { 0 };
|
||||||
struct stat64 stat64Info = { 0 };
|
struct stat64 stat64Info = { 0 };
|
||||||
char linkName[NAME_MAX] = { 0 };
|
|
||||||
DIR *d = NULL;
|
DIR *d = NULL;
|
||||||
char *fullpath = NULL;
|
char *fullpath = NULL;
|
||||||
char *fullpath_bak = NULL;
|
char *fullpath_bak = NULL;
|
||||||
|
@ -591,34 +569,28 @@ int LsDir(const char *path)
|
||||||
pdirent = readdir(d);
|
pdirent = readdir(d);
|
||||||
if (pdirent == NULL) {
|
if (pdirent == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
if (!strcmp(pdirent->d_name, ".") || !strcmp(pdirent->d_name, "..")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
(void)memset_s(&statInfo, sizeof(struct stat), 0, sizeof(struct stat));
|
|
||||||
(void)memset_s(&stat64Info, sizeof(struct stat), 0, sizeof(struct stat));
|
|
||||||
(void)memset_s(&linkName, sizeof(linkName), 0, sizeof(linkName));
|
|
||||||
fullpath = ls_get_fullpath(path, pdirent);
|
|
||||||
if (fullpath == NULL) {
|
|
||||||
(void)closedir(d);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fullpath_bak = fullpath;
|
|
||||||
if (stat64(fullpath, &stat64Info) == 0) {
|
|
||||||
if (S_ISLNK(stat64Info.st_mode)) {
|
|
||||||
readlink(fullpath, linkName, NAME_MAX);
|
|
||||||
}
|
|
||||||
PrintFileInfo64(&stat64Info, pdirent->d_name, linkName);
|
|
||||||
} else if (stat(fullpath, &statInfo) == 0) {
|
|
||||||
if (S_ISLNK(statInfo.st_mode)) {
|
|
||||||
readlink(fullpath, linkName, NAME_MAX);
|
|
||||||
}
|
|
||||||
PrintFileInfo(&statInfo, pdirent->d_name, linkName);
|
|
||||||
} else {
|
} else {
|
||||||
PRINTK("BAD file: %s\n", pdirent->d_name);
|
if (!strcmp(pdirent->d_name, ".") || !strcmp(pdirent->d_name, "..")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(void)memset_s(&statInfo, sizeof(struct stat), 0, sizeof(struct stat));
|
||||||
|
(void)memset_s(&stat64Info, sizeof(struct stat), 0, sizeof(struct stat));
|
||||||
|
fullpath = ls_get_fullpath(path, pdirent);
|
||||||
|
if (fullpath == NULL) {
|
||||||
|
(void)closedir(d);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fullpath_bak = fullpath;
|
||||||
|
if (stat64(fullpath, &stat64Info) == 0) {
|
||||||
|
PrintFileInfo64(&stat64Info, pdirent->d_name);
|
||||||
|
} else if (stat(fullpath, &statInfo) == 0) {
|
||||||
|
PrintFileInfo(&statInfo, pdirent->d_name);
|
||||||
|
} else {
|
||||||
|
PRINTK("BAD file: %s\n", pdirent->d_name);
|
||||||
|
}
|
||||||
|
free(fullpath_bak);
|
||||||
}
|
}
|
||||||
free(fullpath_bak);
|
|
||||||
} while (1);
|
} while (1);
|
||||||
(void)closedir(d);
|
(void)closedir(d);
|
||||||
|
|
||||||
|
@ -758,45 +730,3 @@ mode_t SysUmask(mode_t mask)
|
||||||
return oldUmask;
|
return oldUmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_CHROOT
|
|
||||||
int chroot(const char *path)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct Vnode *vnode = NULL;
|
|
||||||
|
|
||||||
if (!path) {
|
|
||||||
set_errno(EFAULT);
|
|
||||||
return VFS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strlen(path)) {
|
|
||||||
set_errno(ENOENT);
|
|
||||||
return VFS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen(path) > PATH_MAX) {
|
|
||||||
set_errno(ENAMETOOLONG);
|
|
||||||
return VFS_ERROR;
|
|
||||||
}
|
|
||||||
VnodeHold();
|
|
||||||
ret = VnodeLookup(path, &vnode, 0);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
VnodeDrop();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
LosProcessCB *curr = OsCurrProcessGet();
|
|
||||||
if ((curr->files == NULL) || (curr->files->rootVnode == NULL)) {
|
|
||||||
VnodeDrop();
|
|
||||||
return VFS_ERROR;
|
|
||||||
}
|
|
||||||
if (curr->files->rootVnode->useCount > 0) {
|
|
||||||
curr->files->rootVnode->useCount--;
|
|
||||||
}
|
|
||||||
vnode->useCount++;
|
|
||||||
curr->files->rootVnode = vnode;
|
|
||||||
|
|
||||||
VnodeDrop();
|
|
||||||
return LOS_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
|
|
@ -66,6 +66,7 @@ static int iov_trans_to_buf(char *buf, ssize_t totallen, const struct iovec *iov
|
||||||
} else {
|
} else {
|
||||||
writepart = bytestowrite - ret;
|
writepart = bytestowrite - ret;
|
||||||
curbuf += writepart;
|
curbuf += writepart;
|
||||||
|
totallen -= writepart;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -259,6 +259,7 @@ int osShellCmdCat(int argc, const char **argv)
|
||||||
init_param.uwStackSize = CAT_TASK_STACK_SIZE;
|
init_param.uwStackSize = CAT_TASK_STACK_SIZE;
|
||||||
init_param.pcName = "shellcmd_cat";
|
init_param.pcName = "shellcmd_cat";
|
||||||
init_param.uwResved = LOS_TASK_STATUS_DETACHED | OS_TASK_FLAG_SPECIFIES_PROCESS;
|
init_param.uwResved = LOS_TASK_STATUS_DETACHED | OS_TASK_FLAG_SPECIFIES_PROCESS;
|
||||||
|
init_param.processID = 2; /* 2: kProcess */
|
||||||
|
|
||||||
ret = (int)LOS_TaskCreate(&ca_task, &init_param);
|
ret = (int)LOS_TaskCreate(&ca_task, &init_param);
|
||||||
if (ret != LOS_OK) {
|
if (ret != LOS_OK) {
|
||||||
|
@ -343,7 +344,7 @@ int osShellCmdMount(int argc, const char **argv)
|
||||||
|
|
||||||
filessystemtype = (argc >= 4) ? (char *)argv[3] : NULL; /* 4: specify fs type, 3: fs type */
|
filessystemtype = (argc >= 4) ? (char *)argv[3] : NULL; /* 4: specify fs type, 3: fs type */
|
||||||
mountfalgs = (argc >= 5) ? get_mountflags((const char *)argv[4]) : 0; /* 4: usr option */
|
mountfalgs = (argc >= 5) ? get_mountflags((const char *)argv[4]) : 0; /* 4: usr option */
|
||||||
data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data, 6: six args needed for data */
|
data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data */
|
||||||
|
|
||||||
if (strcmp(argv[1], "0") == 0) {
|
if (strcmp(argv[1], "0") == 0) {
|
||||||
ret = mount((const char *)NULL, fullpath, filessystemtype, mountfalgs, data);
|
ret = mount((const char *)NULL, fullpath, filessystemtype, mountfalgs, data);
|
||||||
|
@ -383,7 +384,7 @@ int osShellCmdMount(int argc, const char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
mountfalgs = (argc >= 4) ? get_mountflags((const char *)argv[3]) : 0; /* 3: usr option */
|
mountfalgs = (argc >= 4) ? get_mountflags((const char *)argv[3]) : 0; /* 3: usr option */
|
||||||
data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data, 5: number of args needed for data */
|
data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data */
|
||||||
|
|
||||||
if (strcmp(argv[0], "0") == 0) {
|
if (strcmp(argv[0], "0") == 0) {
|
||||||
ret = mount((const char *)NULL, fullpath, argv[2], mountfalgs, data);
|
ret = mount((const char *)NULL, fullpath, argv[2], mountfalgs, data);
|
||||||
|
@ -760,6 +761,11 @@ static int os_shell_cmd_do_rmdir(const char *pathname)
|
||||||
}
|
}
|
||||||
if (strcmp(dirent->d_name, "..") && strcmp(dirent->d_name, ".")) {
|
if (strcmp(dirent->d_name, "..") && strcmp(dirent->d_name, ".")) {
|
||||||
size_t fullpath_buf_size = strlen(pathname) + strlen(dirent->d_name) + SEPARATOR_EOF_LEN;
|
size_t fullpath_buf_size = strlen(pathname) + strlen(dirent->d_name) + SEPARATOR_EOF_LEN;
|
||||||
|
if (fullpath_buf_size <= 0) {
|
||||||
|
PRINTK("buffer size is invalid!\n");
|
||||||
|
(void)closedir(d);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
fullpath = (char *)malloc(fullpath_buf_size);
|
fullpath = (char *)malloc(fullpath_buf_size);
|
||||||
if (fullpath == NULL) {
|
if (fullpath == NULL) {
|
||||||
PRINTK("malloc failure!\n");
|
PRINTK("malloc failure!\n");
|
||||||
|
|
|
@ -29,11 +29,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_mux.h"
|
#include "los_mux.h"
|
||||||
|
#include "vnode.h"
|
||||||
#include "fs/dirent_fs.h"
|
#include "fs/dirent_fs.h"
|
||||||
#include "path_cache.h"
|
#include "path_cache.h"
|
||||||
#include "vnode.h"
|
|
||||||
#include "los_process.h"
|
|
||||||
#include "los_process_pri.h"
|
|
||||||
|
|
||||||
LIST_HEAD g_vnodeFreeList; /* free vnodes list */
|
LIST_HEAD g_vnodeFreeList; /* free vnodes list */
|
||||||
LIST_HEAD g_vnodeVirtualList; /* dev vnodes list */
|
LIST_HEAD g_vnodeVirtualList; /* dev vnodes list */
|
||||||
|
@ -69,13 +67,6 @@ int VnodesInit(void)
|
||||||
g_rootVnode->type = VNODE_TYPE_DIR;
|
g_rootVnode->type = VNODE_TYPE_DIR;
|
||||||
g_rootVnode->filePath = "/";
|
g_rootVnode->filePath = "/";
|
||||||
|
|
||||||
#ifdef LOSCFG_CHROOT
|
|
||||||
LosProcessCB *processCB = OsGetKernelInitProcess();
|
|
||||||
if (processCB->files != NULL) {
|
|
||||||
g_rootVnode->useCount++;
|
|
||||||
processCB->files->rootVnode = g_rootVnode;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +129,7 @@ int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode)
|
||||||
VnodeHold();
|
VnodeHold();
|
||||||
vnode = GetFromFreeList();
|
vnode = GetFromFreeList();
|
||||||
if ((vnode == NULL) && g_totalVnodeSize < LOSCFG_MAX_VNODE_SIZE) {
|
if ((vnode == NULL) && g_totalVnodeSize < LOSCFG_MAX_VNODE_SIZE) {
|
||||||
vnode = (struct Vnode *)zalloc(sizeof(struct Vnode));
|
vnode = (struct Vnode*)zalloc(sizeof(struct Vnode));
|
||||||
g_totalVnodeSize++;
|
g_totalVnodeSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +281,7 @@ static int PreProcess(const char *originPath, struct Vnode **startVnode, char **
|
||||||
|
|
||||||
ret = vfs_normalize_path(NULL, originPath, &absolutePath);
|
ret = vfs_normalize_path(NULL, originPath, &absolutePath);
|
||||||
if (ret == LOS_OK) {
|
if (ret == LOS_OK) {
|
||||||
*startVnode = GetCurrRootVnode();
|
*startVnode = g_rootVnode;
|
||||||
*path = absolutePath;
|
*path = absolutePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,21 +293,7 @@ static struct Vnode *ConvertVnodeIfMounted(struct Vnode *vnode)
|
||||||
if ((vnode == NULL) || !(vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) {
|
if ((vnode == NULL) || !(vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) {
|
||||||
return vnode;
|
return vnode;
|
||||||
}
|
}
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
LIST_HEAD *mntList = GetMountList();
|
|
||||||
struct Mount *mnt = NULL;
|
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY(mnt, mntList, struct Mount, mountList) {
|
|
||||||
if ((mnt != NULL) && (mnt->vnodeBeCovered == vnode)) {
|
|
||||||
return mnt->vnodeCovered;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strcmp(vnode->filePath, "/dev") == 0) {
|
|
||||||
return vnode->newMount->vnodeCovered;
|
|
||||||
}
|
|
||||||
return vnode;
|
|
||||||
#else
|
|
||||||
return vnode->newMount->vnodeCovered;
|
return vnode->newMount->vnodeCovered;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RefreshLRU(struct Vnode *vnode)
|
static void RefreshLRU(struct Vnode *vnode)
|
||||||
|
@ -417,7 +394,7 @@ int VnodeLookupAt(const char *path, struct Vnode **result, uint32_t flags, struc
|
||||||
}
|
}
|
||||||
|
|
||||||
if (normalizedPath[1] == '\0' && normalizedPath[0] == '/') {
|
if (normalizedPath[1] == '\0' && normalizedPath[0] == '/') {
|
||||||
*result = GetCurrRootVnode();
|
*result = g_rootVnode;
|
||||||
free(normalizedPath);
|
free(normalizedPath);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
@ -477,7 +454,7 @@ int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags)
|
||||||
|
|
||||||
int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags)
|
int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags)
|
||||||
{
|
{
|
||||||
return VnodeLookupAt(fullpath, vnode, flags, GetCurrRootVnode());
|
return VnodeLookupAt(fullpath, vnode, flags, g_rootVnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChangeRootInternal(struct Vnode *rootOld, char *dirname)
|
static void ChangeRootInternal(struct Vnode *rootOld, char *dirname)
|
||||||
|
@ -519,17 +496,6 @@ void ChangeRoot(struct Vnode *rootNew)
|
||||||
{
|
{
|
||||||
struct Vnode *rootOld = g_rootVnode;
|
struct Vnode *rootOld = g_rootVnode;
|
||||||
g_rootVnode = rootNew;
|
g_rootVnode = rootNew;
|
||||||
#ifdef LOSCFG_CHROOT
|
|
||||||
LosProcessCB *curr = OsCurrProcessGet();
|
|
||||||
if ((curr->files != NULL) &&
|
|
||||||
(curr->files->rootVnode != NULL) &&
|
|
||||||
(curr->files->rootVnode->useCount > 0)) {
|
|
||||||
curr->files->rootVnode->useCount--;
|
|
||||||
}
|
|
||||||
rootNew->useCount++;
|
|
||||||
curr->files->rootVnode = rootNew;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ChangeRootInternal(rootOld, "proc");
|
ChangeRootInternal(rootOld, "proc");
|
||||||
ChangeRootInternal(rootOld, "dev");
|
ChangeRootInternal(rootOld, "dev");
|
||||||
}
|
}
|
||||||
|
@ -716,27 +682,6 @@ void VnodeMemoryDump(void)
|
||||||
PRINTK("Vnode memory size = %d(B)\n", vnodeCount * sizeof(struct Vnode));
|
PRINTK("Vnode memory size = %d(B)\n", vnodeCount * sizeof(struct Vnode));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
struct Vnode *VnodeFind(int fd)
|
|
||||||
{
|
|
||||||
INT32 sysFd;
|
|
||||||
|
|
||||||
if (fd < 0) {
|
|
||||||
PRINT_ERR("Error. fd is invalid as %d\n", fd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process fd convert to system global fd */
|
|
||||||
sysFd = GetAssociatedSystemFd(fd);
|
|
||||||
if (sysFd < 0) {
|
|
||||||
PRINT_ERR("Error. sysFd is invalid as %d\n", sysFd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return files_get_openfile((int)sysFd);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LIST_HEAD* GetVnodeFreeList()
|
LIST_HEAD* GetVnodeFreeList()
|
||||||
{
|
{
|
||||||
return &g_vnodeFreeList;
|
return &g_vnodeFreeList;
|
||||||
|
@ -774,13 +719,3 @@ int VnodeClearCache(void)
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Vnode *GetCurrRootVnode(void)
|
|
||||||
{
|
|
||||||
#ifdef LOSCFG_CHROOT
|
|
||||||
LosProcessCB *curr = OsCurrProcessGet();
|
|
||||||
return curr->files->rootVnode;
|
|
||||||
#else
|
|
||||||
return g_rootVnode;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -67,14 +67,13 @@ config PAGE_TABLE_FINE_LOCK
|
||||||
help
|
help
|
||||||
This option will enable fine lock for page table.
|
This option will enable fine lock for page table.
|
||||||
|
|
||||||
|
|
||||||
######################### config options of extended #####################
|
|
||||||
source "kernel/extended/Kconfig"
|
|
||||||
|
|
||||||
config ENABLE_KERNEL_TEST
|
config ENABLE_KERNEL_TEST
|
||||||
bool "Enable kernel test"
|
bool "Enable kernel test"
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
This option will enable kernel test.
|
This option will enable kernel test.
|
||||||
|
|
||||||
|
######################### config options of extended #####################
|
||||||
|
source "kernel/extended/Kconfig"
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
# Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
|
@ -33,7 +33,6 @@ module_name = get_path_info(rebase_path("."), "name")
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [
|
sources = [
|
||||||
"core/los_bitmap.c",
|
"core/los_bitmap.c",
|
||||||
"core/los_info.c",
|
|
||||||
"core/los_process.c",
|
"core/los_process.c",
|
||||||
"core/los_smp.c",
|
"core/los_smp.c",
|
||||||
"core/los_swtmr.c",
|
"core/los_swtmr.c",
|
||||||
|
@ -67,7 +66,6 @@ kernel_module(module_name) {
|
||||||
"mp/los_percpu.c",
|
"mp/los_percpu.c",
|
||||||
"mp/los_spinlock.c",
|
"mp/los_spinlock.c",
|
||||||
"om/los_err.c",
|
"om/los_err.c",
|
||||||
"sched/los_deadline.c",
|
|
||||||
"sched/los_idle.c",
|
"sched/los_idle.c",
|
||||||
"sched/los_priority.c",
|
"sched/los_priority.c",
|
||||||
"sched/los_sched.c",
|
"sched/los_sched.c",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
# Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
|
@ -38,8 +38,7 @@ LOCAL_SRCS := $(wildcard ipc/*.c) $(wildcard core/*.c) $(wildcard mem/membox/*.
|
||||||
$(wildcard mem/tlsf/*.c) \
|
$(wildcard mem/tlsf/*.c) \
|
||||||
$(wildcard mp/*.c) \
|
$(wildcard mp/*.c) \
|
||||||
$(wildcard sched/*.c) \
|
$(wildcard sched/*.c) \
|
||||||
$(wildcard vm/*.c) \
|
$(wildcard vm/*.c)
|
||||||
|
|
||||||
|
|
||||||
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) -Wno-frame-address
|
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) -Wno-frame-address
|
||||||
|
|
||||||
|
|
|
@ -1,256 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "los_info_pri.h"
|
|
||||||
#include "los_task_pri.h"
|
|
||||||
#include "los_vm_dump.h"
|
|
||||||
|
|
||||||
STATIC UINT32 GetCurrParentPid(UINT32 pid, const LosProcessCB *processCB)
|
|
||||||
{
|
|
||||||
if (processCB->parentProcess == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
if (pid == OS_USER_ROOT_PROCESS_ID) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OS_PROCESS_CONTAINER_CHECK(processCB->parentProcess, OsCurrProcessGet())) {
|
|
||||||
return OsGetVpidFromCurrContainer(processCB->parentProcess);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return processCB->parentProcess->processID;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE UINT32 GetCurrTid(const LosTaskCB *taskCB)
|
|
||||||
{
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
if (taskCB->pidContainer != OsCurrTaskGet()->pidContainer) {
|
|
||||||
return OsGetVtidFromCurrContainer(taskCB);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return taskCB->taskID;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC UINT16 GetProcessStatus(LosProcessCB *processCB)
|
|
||||||
{
|
|
||||||
UINT16 status;
|
|
||||||
LosTaskCB *taskCB = NULL;
|
|
||||||
|
|
||||||
if (LOS_ListEmpty(&processCB->threadSiblingList)) {
|
|
||||||
return processCB->processStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = processCB->processStatus;
|
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY(taskCB, &processCB->threadSiblingList, LosTaskCB, threadList) {
|
|
||||||
status |= (taskCB->taskStatus & 0x00FF);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC VOID GetProcessInfo(ProcessInfo *pcbInfo, const LosProcessCB *processCB)
|
|
||||||
{
|
|
||||||
SchedParam param = {0};
|
|
||||||
pcbInfo->pid = OsGetPid(processCB);
|
|
||||||
pcbInfo->ppid = GetCurrParentPid(pcbInfo->pid, processCB);
|
|
||||||
pcbInfo->status = GetProcessStatus((LosProcessCB *)processCB);
|
|
||||||
pcbInfo->mode = processCB->processMode;
|
|
||||||
if (processCB->pgroup != NULL) {
|
|
||||||
pcbInfo->pgroupID = OsGetPid(OS_GET_PGROUP_LEADER(processCB->pgroup));
|
|
||||||
} else {
|
|
||||||
pcbInfo->pgroupID = -1;
|
|
||||||
}
|
|
||||||
#ifdef LOSCFG_SECURITY_CAPABILITY
|
|
||||||
if (processCB->user != NULL) {
|
|
||||||
pcbInfo->userID = processCB->user->userID;
|
|
||||||
} else {
|
|
||||||
pcbInfo->userID = -1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
pcbInfo->userID = 0;
|
|
||||||
#endif
|
|
||||||
LosTaskCB *taskCB = processCB->threadGroup;
|
|
||||||
pcbInfo->threadGroupID = taskCB->taskID;
|
|
||||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
|
||||||
pcbInfo->policy = LOS_SCHED_RR;
|
|
||||||
pcbInfo->basePrio = param.basePrio;
|
|
||||||
pcbInfo->threadNumber = processCB->threadNumber;
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
|
||||||
(VOID)OsGetProcessAllCpuUsageUnsafe(processCB->processCpup, pcbInfo);
|
|
||||||
#endif
|
|
||||||
(VOID)memcpy_s(pcbInfo->name, OS_PCB_NAME_LEN, processCB->processName, OS_PCB_NAME_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
STATIC VOID GetProcessMemInfo(ProcessInfo *pcbInfo, const LosProcessCB *processCB, LosVmSpace *vmSpace)
|
|
||||||
{
|
|
||||||
/* Process memory usage statistics, idle task defaults to 0 */
|
|
||||||
if (processCB == &g_processCBArray[0]) {
|
|
||||||
pcbInfo->virtualMem = 0;
|
|
||||||
pcbInfo->shareMem = 0;
|
|
||||||
pcbInfo->physicalMem = 0;
|
|
||||||
} else if (vmSpace == LOS_GetKVmSpace()) {
|
|
||||||
(VOID)OsShellCmdProcessPmUsage(vmSpace, &pcbInfo->shareMem, &pcbInfo->physicalMem);
|
|
||||||
pcbInfo->virtualMem = pcbInfo->physicalMem;
|
|
||||||
} else {
|
|
||||||
pcbInfo->virtualMem = OsShellCmdProcessVmUsage(vmSpace);
|
|
||||||
if (pcbInfo->virtualMem == 0) {
|
|
||||||
pcbInfo->status = OS_PROCESS_FLAG_UNUSED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (OsShellCmdProcessPmUsage(vmSpace, &pcbInfo->shareMem, &pcbInfo->physicalMem) == 0) {
|
|
||||||
pcbInfo->status = OS_PROCESS_FLAG_UNUSED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
STATIC VOID GetThreadInfo(ProcessThreadInfo *threadInfo, LosProcessCB *processCB)
|
|
||||||
{
|
|
||||||
SchedParam param = {0};
|
|
||||||
LosTaskCB *taskCB = NULL;
|
|
||||||
if (LOS_ListEmpty(&processCB->threadSiblingList)) {
|
|
||||||
threadInfo->threadCount = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
threadInfo->threadCount = 0;
|
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY(taskCB, &processCB->threadSiblingList, LosTaskCB, threadList) {
|
|
||||||
TaskInfo *taskInfo = &threadInfo->taskInfo[threadInfo->threadCount];
|
|
||||||
taskInfo->tid = GetCurrTid(taskCB);
|
|
||||||
taskInfo->pid = OsGetPid(processCB);
|
|
||||||
taskInfo->status = taskCB->taskStatus;
|
|
||||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
|
||||||
taskInfo->policy = param.policy;
|
|
||||||
taskInfo->priority = param.priority;
|
|
||||||
#ifdef LOSCFG_KERNEL_SMP
|
|
||||||
taskInfo->currCpu = taskCB->currCpu;
|
|
||||||
taskInfo->cpuAffiMask = taskCB->cpuAffiMask;
|
|
||||||
#endif
|
|
||||||
taskInfo->stackPoint = (UINTPTR)taskCB->stackPointer;
|
|
||||||
taskInfo->topOfStack = taskCB->topOfStack;
|
|
||||||
taskInfo->stackSize = taskCB->stackSize;
|
|
||||||
taskInfo->waitFlag = taskCB->waitFlag;
|
|
||||||
taskInfo->waitID = taskCB->waitID;
|
|
||||||
taskInfo->taskMux = taskCB->taskMux;
|
|
||||||
(VOID)OsStackWaterLineGet((const UINTPTR *)(taskCB->topOfStack + taskCB->stackSize),
|
|
||||||
(const UINTPTR *)taskCB->topOfStack, &taskInfo->waterLine);
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
|
||||||
(VOID)OsGetTaskAllCpuUsageUnsafe(&taskCB->taskCpup, taskInfo);
|
|
||||||
#endif
|
|
||||||
(VOID)memcpy_s(taskInfo->name, OS_TCB_NAME_LEN, taskCB->taskName, OS_TCB_NAME_LEN);
|
|
||||||
threadInfo->threadCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT32 OsGetProcessThreadInfo(UINT32 pid, ProcessThreadInfo *threadInfo)
|
|
||||||
{
|
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
if (OS_PID_CHECK_INVALID(pid) || (pid == 0) || (threadInfo == NULL)) {
|
|
||||||
return LOS_NOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
|
|
||||||
if (OsProcessIsUnused(processCB)) {
|
|
||||||
return LOS_NOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
GetProcessMemInfo(&threadInfo->processInfo, processCB, processCB->vmSpace);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
GetProcessInfo(&threadInfo->processInfo, processCB);
|
|
||||||
GetThreadInfo(threadInfo, processCB);
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
return LOS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC VOID ProcessMemUsageGet(ProcessInfo *pcbArray)
|
|
||||||
{
|
|
||||||
UINT32 intSave;
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
PidContainer *pidContainer = OsCurrTaskGet()->pidContainer;
|
|
||||||
for (UINT32 pid = 0; pid < g_processMaxNum; ++pid) {
|
|
||||||
ProcessVid *processVid = &pidContainer->pidArray[pid];
|
|
||||||
const LosProcessCB *processCB = (LosProcessCB *)processVid->cb;
|
|
||||||
#else
|
|
||||||
for (UINT32 pid = 0; pid < g_processMaxNum; ++pid) {
|
|
||||||
const LosProcessCB *processCB = OS_PCB_FROM_RPID(pid);
|
|
||||||
#endif
|
|
||||||
ProcessInfo *pcbInfo = pcbArray + pid;
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
if (OsProcessIsUnused(processCB)) {
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
pcbInfo->status = OS_PROCESS_FLAG_UNUSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
LosVmSpace *vmSpace = processCB->vmSpace;
|
|
||||||
#endif
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
GetProcessMemInfo(pcbInfo, processCB, vmSpace);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT32 OsGetAllProcessInfo(ProcessInfo *pcbArray)
|
|
||||||
{
|
|
||||||
UINT32 intSave;
|
|
||||||
if (pcbArray == NULL) {
|
|
||||||
return LOS_NOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcessMemUsageGet(pcbArray);
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
PidContainer *pidContainer = OsCurrTaskGet()->pidContainer;
|
|
||||||
for (UINT32 index = 0; index < LOSCFG_BASE_CORE_PROCESS_LIMIT; index++) {
|
|
||||||
ProcessVid *processVid = &pidContainer->pidArray[index];
|
|
||||||
LosProcessCB *processCB = (LosProcessCB *)processVid->cb;
|
|
||||||
#else
|
|
||||||
for (UINT32 index = 0; index < LOSCFG_BASE_CORE_PROCESS_LIMIT; index++) {
|
|
||||||
LosProcessCB *processCB = OS_PCB_FROM_RPID(index);
|
|
||||||
#endif
|
|
||||||
ProcessInfo *pcbInfo = pcbArray + index;
|
|
||||||
if (OsProcessIsUnused(processCB)) {
|
|
||||||
pcbInfo->status = OS_PROCESS_FLAG_UNUSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
GetProcessInfo(pcbInfo, processCB);
|
|
||||||
}
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
return LOS_OK;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -45,13 +45,11 @@ STATIC VOID OsSmpSecondaryInit(VOID *arg)
|
||||||
{
|
{
|
||||||
UNUSED(arg);
|
UNUSED(arg);
|
||||||
|
|
||||||
OsCurrTaskSet(OsGetMainTask());
|
|
||||||
|
|
||||||
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
||||||
OsSwtmrInit();
|
OsSwtmrInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OsIdleTaskCreate((UINTPTR)OsGetIdleProcess());
|
OsIdleTaskCreate();
|
||||||
OsInitCall(LOS_INIT_LEVEL_KMOD_TASK);
|
OsInitCall(LOS_INIT_LEVEL_KMOD_TASK);
|
||||||
|
|
||||||
OsSchedStart();
|
OsSchedStart();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -320,10 +320,10 @@ BOOL OsIsSwtmrTask(const LosTaskCB *taskCB)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT VOID OsSwtmrRecycle(UINTPTR ownerID)
|
LITE_OS_SEC_TEXT_INIT VOID OsSwtmrRecycle(UINT32 processID)
|
||||||
{
|
{
|
||||||
for (UINT16 index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++) {
|
for (UINT16 index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++) {
|
||||||
if (g_swtmrCBArray[index].uwOwnerPid == ownerID) {
|
if (g_swtmrCBArray[index].uwOwnerPid == processID) {
|
||||||
LOS_SwtmrDelete(index);
|
LOS_SwtmrDelete(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ STATIC INLINE VOID SwtmrDelete(SWTMR_CTRL_S *swtmr)
|
||||||
/* insert to free list */
|
/* insert to free list */
|
||||||
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
|
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
|
||||||
swtmr->ucState = OS_SWTMR_STATUS_UNUSED;
|
swtmr->ucState = OS_SWTMR_STATUS_UNUSED;
|
||||||
swtmr->uwOwnerPid = OS_INVALID_VALUE;
|
swtmr->uwOwnerPid = 0;
|
||||||
|
|
||||||
SwtmrDebugDataClear(swtmr->usTimerID);
|
SwtmrDebugDataClear(swtmr->usTimerID);
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ STATIC INLINE BOOL SwtmrRunqueueFind(SortLinkAttribute *swtmrSortLink, SCHED_TL_
|
||||||
STATIC BOOL SwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
|
STATIC BOOL SwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
|
||||||
{
|
{
|
||||||
for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
|
for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
|
||||||
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[cpuid].swtmrSortLink;
|
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[ArchCurrCpuid()].swtmrSortLink;
|
||||||
if (SwtmrRunqueueFind(swtmrSortLink, checkFunc, arg)) {
|
if (SwtmrRunqueueFind(swtmrSortLink, checkFunc, arg)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate(UINT32 interval,
|
||||||
LOS_ListDelete(LOS_DL_LIST_FIRST(&g_swtmrFreeList));
|
LOS_ListDelete(LOS_DL_LIST_FIRST(&g_swtmrFreeList));
|
||||||
SWTMR_UNLOCK(intSave);
|
SWTMR_UNLOCK(intSave);
|
||||||
|
|
||||||
swtmr->uwOwnerPid = (UINTPTR)OsCurrProcessGet();
|
swtmr->uwOwnerPid = OsCurrProcessGet()->processID;
|
||||||
swtmr->pfnHandler = handler;
|
swtmr->pfnHandler = handler;
|
||||||
swtmr->ucMode = mode;
|
swtmr->ucMode = mode;
|
||||||
swtmr->uwOverrun = 0;
|
swtmr->uwOverrun = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -61,9 +61,6 @@
|
||||||
#ifdef LOSCFG_ENABLE_OOM_LOOP_TASK
|
#ifdef LOSCFG_ENABLE_OOM_LOOP_TASK
|
||||||
#include "los_oom.h"
|
#include "los_oom.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
#include "los_container_pri.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (LOSCFG_BASE_CORE_TSK_LIMIT <= 0)
|
#if (LOSCFG_BASE_CORE_TSK_LIMIT <= 0)
|
||||||
#error "task maxnum cannot be zero"
|
#error "task maxnum cannot be zero"
|
||||||
|
@ -84,12 +81,12 @@ STATIC VOID OsConsoleIDSetHook(UINT32 param1,
|
||||||
/* temp task blocks for booting procedure */
|
/* temp task blocks for booting procedure */
|
||||||
LITE_OS_SEC_BSS STATIC LosTaskCB g_mainTask[LOSCFG_KERNEL_CORE_NUM];
|
LITE_OS_SEC_BSS STATIC LosTaskCB g_mainTask[LOSCFG_KERNEL_CORE_NUM];
|
||||||
|
|
||||||
LosTaskCB *OsGetMainTask(VOID)
|
LosTaskCB *OsGetMainTask()
|
||||||
{
|
{
|
||||||
return (LosTaskCB *)(g_mainTask + ArchCurrCpuid());
|
return (LosTaskCB *)(g_mainTask + ArchCurrCpuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID OsSetMainTask(VOID)
|
VOID OsSetMainTask()
|
||||||
{
|
{
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
CHAR *name = "osMain";
|
CHAR *name = "osMain";
|
||||||
|
@ -102,7 +99,7 @@ VOID OsSetMainTask(VOID)
|
||||||
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
||||||
g_mainTask[i].taskStatus = OS_TASK_STATUS_UNUSED;
|
g_mainTask[i].taskStatus = OS_TASK_STATUS_UNUSED;
|
||||||
g_mainTask[i].taskID = LOSCFG_BASE_CORE_TSK_LIMIT;
|
g_mainTask[i].taskID = LOSCFG_BASE_CORE_TSK_LIMIT;
|
||||||
g_mainTask[i].processCB = OS_KERNEL_PROCESS_GROUP;
|
g_mainTask[i].processID = OS_KERNEL_PROCESS_GROUP;
|
||||||
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
|
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
|
||||||
g_mainTask[i].lockDep.lockDepth = 0;
|
g_mainTask[i].lockDep.lockDepth = 0;
|
||||||
g_mainTask[i].lockDep.waitLock = NULL;
|
g_mainTask[i].lockDep.waitLock = NULL;
|
||||||
|
@ -113,16 +110,6 @@ VOID OsSetMainTask(VOID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID OsSetMainTaskProcess(UINTPTR processCB)
|
|
||||||
{
|
|
||||||
for (UINT32 i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
|
||||||
g_mainTask[i].processCB = processCB;
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
g_mainTask[i].pidContainer = OS_PID_CONTAINER_FROM_PCB((LosProcessCB *)processCB);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT WEAK VOID OsIdleTask(VOID)
|
LITE_OS_SEC_TEXT WEAK VOID OsIdleTask(VOID)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -181,7 +168,7 @@ LITE_OS_SEC_TEXT UINT32 OsTaskSetDetachUnsafe(LosTaskCB *taskCB)
|
||||||
return LOS_EINVAL;
|
return LOS_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(UINTPTR processCB)
|
LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
|
||||||
{
|
{
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
UINT32 size;
|
UINT32 size;
|
||||||
|
@ -205,14 +192,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(UINTPTR processCB)
|
||||||
for (index = 0; index < g_taskMaxNum; index++) {
|
for (index = 0; index < g_taskMaxNum; index++) {
|
||||||
g_taskCBArray[index].taskStatus = OS_TASK_STATUS_UNUSED;
|
g_taskCBArray[index].taskStatus = OS_TASK_STATUS_UNUSED;
|
||||||
g_taskCBArray[index].taskID = index;
|
g_taskCBArray[index].taskID = index;
|
||||||
g_taskCBArray[index].processCB = processCB;
|
|
||||||
LOS_ListTailInsert(&g_losFreeTask, &g_taskCBArray[index].pendList);
|
LOS_ListTailInsert(&g_losFreeTask, &g_taskCBArray[index].pendList);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_taskCBArray[index].taskStatus = OS_TASK_STATUS_UNUSED;
|
|
||||||
g_taskCBArray[index].taskID = index;
|
|
||||||
g_taskCBArray[index].processCB = processCB;
|
|
||||||
|
|
||||||
ret = OsSchedInit();
|
ret = OsSchedInit();
|
||||||
|
|
||||||
EXIT:
|
EXIT:
|
||||||
|
@ -224,10 +206,10 @@ EXIT:
|
||||||
|
|
||||||
UINT32 OsGetIdleTaskId(VOID)
|
UINT32 OsGetIdleTaskId(VOID)
|
||||||
{
|
{
|
||||||
return OsSchedRunqueueIdleGet()->taskID;
|
return OsSchedRunqueueIdleGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(UINTPTR processID)
|
LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
TSK_INIT_PARAM_S taskInitParam;
|
TSK_INIT_PARAM_S taskInitParam;
|
||||||
|
@ -239,7 +221,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(UINTPTR processID)
|
||||||
taskInitParam.pcName = "Idle";
|
taskInitParam.pcName = "Idle";
|
||||||
taskInitParam.policy = LOS_SCHED_IDLE;
|
taskInitParam.policy = LOS_SCHED_IDLE;
|
||||||
taskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
|
taskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
|
||||||
taskInitParam.processID = processID;
|
taskInitParam.processID = OsGetIdleProcessID();
|
||||||
#ifdef LOSCFG_KERNEL_SMP
|
#ifdef LOSCFG_KERNEL_SMP
|
||||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||||
#endif
|
#endif
|
||||||
|
@ -249,7 +231,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(UINTPTR processID)
|
||||||
}
|
}
|
||||||
LosTaskCB *idleTask = OS_TCB_FROM_TID(idleTaskID);
|
LosTaskCB *idleTask = OS_TCB_FROM_TID(idleTaskID);
|
||||||
idleTask->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;
|
idleTask->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;
|
||||||
OsSchedRunqueueIdleInit(idleTask);
|
OsSchedRunqueueIdleInit(idleTaskID);
|
||||||
|
|
||||||
return LOS_TaskResume(idleTaskID);
|
return LOS_TaskResume(idleTaskID);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +250,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_CurTaskIDGet(VOID)
|
||||||
return runTask->taskID;
|
return runTask->taskID;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE UINT32 TaskSyncCreate(LosTaskCB *taskCB)
|
STATIC INLINE UINT32 OsTaskSyncCreate(LosTaskCB *taskCB)
|
||||||
{
|
{
|
||||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
||||||
UINT32 ret = LOS_SemCreate(0, &taskCB->syncSignal);
|
UINT32 ret = LOS_SemCreate(0, &taskCB->syncSignal);
|
||||||
|
@ -328,14 +310,11 @@ STATIC INLINE VOID OsTaskSyncWake(const LosTaskCB *taskCB)
|
||||||
|
|
||||||
STATIC INLINE VOID OsInsertTCBToFreeList(LosTaskCB *taskCB)
|
STATIC INLINE VOID OsInsertTCBToFreeList(LosTaskCB *taskCB)
|
||||||
{
|
{
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
OsFreeVtid(taskCB);
|
|
||||||
#endif
|
|
||||||
UINT32 taskID = taskCB->taskID;
|
UINT32 taskID = taskCB->taskID;
|
||||||
(VOID)memset_s(taskCB, sizeof(LosTaskCB), 0, sizeof(LosTaskCB));
|
(VOID)memset_s(taskCB, sizeof(LosTaskCB), 0, sizeof(LosTaskCB));
|
||||||
taskCB->taskID = taskID;
|
taskCB->taskID = taskID;
|
||||||
taskCB->processCB = (UINTPTR)OsGetDefaultProcessCB();
|
|
||||||
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
|
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
|
||||||
|
taskCB->processID = OS_INVALID_VALUE;
|
||||||
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
|
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,12 +340,12 @@ STATIC VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
||||||
taskCB->userArea = 0;
|
taskCB->userArea = 0;
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
|
||||||
LosProcessCB *processCB = OS_PCB_FROM_TCB(taskCB);
|
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||||
LOS_ASSERT(!(OsProcessVmSpaceGet(processCB) == NULL));
|
LOS_ASSERT(!(OsProcessVmSpaceGet(processCB) == NULL));
|
||||||
UINT32 ret = OsUnMMap(OsProcessVmSpaceGet(processCB), (UINTPTR)mapBase, mapSize);
|
UINT32 ret = OsUnMMap(OsProcessVmSpaceGet(processCB), (UINTPTR)mapBase, mapSize);
|
||||||
if ((ret != LOS_OK) && (mapBase != 0) && !OsProcessIsInit(processCB)) {
|
if ((ret != LOS_OK) && (mapBase != 0) && !OsProcessIsInit(processCB)) {
|
||||||
PRINT_ERR("process(%u) unmmap user task(%u) stack failed! mapbase: 0x%x size :0x%x, error: %d\n",
|
PRINT_ERR("process(%u) unmmap user task(%u) stack failed! mapbase: 0x%x size :0x%x, error: %d\n",
|
||||||
processCB->processID, taskCB->taskID, mapBase, mapSize, ret);
|
taskCB->processID, taskCB->taskID, mapBase, mapSize, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||||
|
@ -394,7 +373,7 @@ STATIC VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree(void)
|
LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree()
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
|
@ -437,9 +416,11 @@ LITE_OS_SEC_TEXT_INIT VOID OsTaskEntry(UINT32 taskID)
|
||||||
OsRunningTaskToExit(taskCB, 0);
|
OsRunningTaskToExit(taskCB, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 TaskCreateParamCheck(const UINT32 *taskID, TSK_INIT_PARAM_S *initParam)
|
LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsTaskCreateParamCheck(const UINT32 *taskID,
|
||||||
|
TSK_INIT_PARAM_S *initParam, VOID **pool)
|
||||||
{
|
{
|
||||||
UINT32 poolSize = OS_SYS_MEM_SIZE;
|
UINT32 poolSize = OS_SYS_MEM_SIZE;
|
||||||
|
*pool = (VOID *)m_aucSysMem1;
|
||||||
|
|
||||||
if (taskID == NULL) {
|
if (taskID == NULL) {
|
||||||
return LOS_ERRNO_TSK_ID_INVALID;
|
return LOS_ERRNO_TSK_ID_INVALID;
|
||||||
|
@ -449,7 +430,8 @@ STATIC UINT32 TaskCreateParamCheck(const UINT32 *taskID, TSK_INIT_PARAM_S *initP
|
||||||
return LOS_ERRNO_TSK_PTR_NULL;
|
return LOS_ERRNO_TSK_PTR_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OsProcessIsUserMode((LosProcessCB *)initParam->processID)) {
|
LosProcessCB *process = OS_PCB_FROM_PID(initParam->processID);
|
||||||
|
if (!OsProcessIsUserMode(process)) {
|
||||||
if (initParam->pcName == NULL) {
|
if (initParam->pcName == NULL) {
|
||||||
return LOS_ERRNO_TSK_NAME_EMPTY;
|
return LOS_ERRNO_TSK_NAME_EMPTY;
|
||||||
}
|
}
|
||||||
|
@ -479,47 +461,24 @@ STATIC UINT32 TaskCreateParamCheck(const UINT32 *taskID, TSK_INIT_PARAM_S *initP
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID TaskCBDeInit(LosTaskCB *taskCB)
|
LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskStackAlloc(VOID **topStack, UINT32 stackSize, VOID *pool)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
*topStack = (VOID *)LOS_MemAllocAlign(pool, stackSize, LOSCFG_STACK_POINT_ALIGN_SIZE);
|
||||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
|
||||||
if (taskCB->syncSignal != OS_INVALID_VALUE) {
|
|
||||||
OsTaskSyncDestroy(taskCB->syncSignal);
|
|
||||||
taskCB->syncSignal = OS_INVALID_VALUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (taskCB->topOfStack != (UINTPTR)NULL) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, (VOID *)taskCB->topOfStack);
|
|
||||||
taskCB->topOfStack = (UINTPTR)NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
|
||||||
LosProcessCB *processCB = OS_PCB_FROM_TCB(taskCB);
|
|
||||||
if (processCB != OsGetDefaultProcessCB()) {
|
|
||||||
LOS_ListDelete(&taskCB->threadList);
|
|
||||||
processCB->threadNumber--;
|
|
||||||
processCB->threadCount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
OsInsertTCBToFreeList(taskCB);
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID TaskCBBaseInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam)
|
STATIC VOID TaskCBBaseInit(LosTaskCB *taskCB, const VOID *stackPtr, const VOID *topStack,
|
||||||
|
const TSK_INIT_PARAM_S *initParam)
|
||||||
{
|
{
|
||||||
taskCB->stackPointer = NULL;
|
taskCB->stackPointer = (VOID *)stackPtr;
|
||||||
taskCB->args[0] = initParam->auwArgs[0]; /* 0~3: just for args array index */
|
taskCB->args[0] = initParam->auwArgs[0]; /* 0~3: just for args array index */
|
||||||
taskCB->args[1] = initParam->auwArgs[1];
|
taskCB->args[1] = initParam->auwArgs[1];
|
||||||
taskCB->args[2] = initParam->auwArgs[2];
|
taskCB->args[2] = initParam->auwArgs[2];
|
||||||
taskCB->args[3] = initParam->auwArgs[3];
|
taskCB->args[3] = initParam->auwArgs[3];
|
||||||
taskCB->topOfStack = (UINTPTR)NULL;
|
taskCB->topOfStack = (UINTPTR)topStack;
|
||||||
taskCB->stackSize = initParam->uwStackSize;
|
taskCB->stackSize = initParam->uwStackSize;
|
||||||
taskCB->taskEntry = initParam->pfnTaskEntry;
|
taskCB->taskEntry = initParam->pfnTaskEntry;
|
||||||
taskCB->signal = SIGNAL_NONE;
|
taskCB->signal = SIGNAL_NONE;
|
||||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
|
||||||
taskCB->syncSignal = OS_INVALID_VALUE;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_SMP
|
#ifdef LOSCFG_KERNEL_SMP
|
||||||
taskCB->currCpu = OS_TASK_INVALID_CPUID;
|
taskCB->currCpu = OS_TASK_INVALID_CPUID;
|
||||||
taskCB->cpuAffiMask = (initParam->usCpuAffiMask) ?
|
taskCB->cpuAffiMask = (initParam->usCpuAffiMask) ?
|
||||||
|
@ -533,35 +492,31 @@ STATIC VOID TaskCBBaseInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam)
|
||||||
|
|
||||||
LOS_ListInit(&taskCB->lockList);
|
LOS_ListInit(&taskCB->lockList);
|
||||||
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
|
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
taskCB->futex.index = OS_INVALID_VALUE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 TaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam)
|
STATIC UINT32 OsTaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam,
|
||||||
|
const VOID *stackPtr, const VOID *topStack)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
UINT32 numCount;
|
UINT32 numCount;
|
||||||
SchedParam schedParam = { 0 };
|
SchedParam schedParam = { 0 };
|
||||||
LosSchedParam initSchedParam = {0};
|
|
||||||
UINT16 policy = (initParam->policy == LOS_SCHED_NORMAL) ? LOS_SCHED_RR : initParam->policy;
|
UINT16 policy = (initParam->policy == LOS_SCHED_NORMAL) ? LOS_SCHED_RR : initParam->policy;
|
||||||
|
|
||||||
TaskCBBaseInit(taskCB, initParam);
|
TaskCBBaseInit(taskCB, stackPtr, topStack, initParam);
|
||||||
|
|
||||||
schedParam.policy = policy;
|
schedParam.policy = policy;
|
||||||
ret = OsProcessAddNewTask(initParam->processID, taskCB, &schedParam, &numCount);
|
numCount = OsProcessAddNewTask(initParam->processID, taskCB, &schedParam);
|
||||||
if (ret != LOS_OK) {
|
#ifdef LOSCFG_KERNEL_VM
|
||||||
return ret;
|
taskCB->futex.index = OS_INVALID_VALUE;
|
||||||
|
if (taskCB->taskStatus & OS_TASK_FLAG_USER_MODE) {
|
||||||
|
taskCB->userArea = initParam->userParam.userArea;
|
||||||
|
taskCB->userMapBase = initParam->userParam.userMapBase;
|
||||||
|
taskCB->userMapSize = initParam->userParam.userMapSize;
|
||||||
|
OsUserTaskStackInit(taskCB->stackPointer, (UINTPTR)taskCB->taskEntry, initParam->userParam.userSP);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (policy == LOS_SCHED_DEADLINE) {
|
ret = OsSchedParamInit(taskCB, policy, &schedParam, initParam);
|
||||||
initSchedParam.runTimeUs = initParam->runTimeUs;
|
|
||||||
initSchedParam.deadlineUs = initParam->deadlineUs;
|
|
||||||
initSchedParam.periodUs = initParam->periodUs;
|
|
||||||
} else {
|
|
||||||
initSchedParam.priority = initParam->usTaskPrio;
|
|
||||||
}
|
|
||||||
ret = OsSchedParamInit(taskCB, policy, &schedParam, &initSchedParam);
|
|
||||||
if (ret != LOS_OK) {
|
if (ret != LOS_OK) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -579,27 +534,7 @@ STATIC UINT32 TaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam)
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 TaskStackInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam)
|
LITE_OS_SEC_TEXT LosTaskCB *OsGetFreeTaskCB(VOID)
|
||||||
{
|
|
||||||
VOID *topStack = (VOID *)LOS_MemAllocAlign(m_aucSysMem1, initParam->uwStackSize, LOSCFG_STACK_POINT_ALIGN_SIZE);
|
|
||||||
if (topStack == NULL) {
|
|
||||||
return LOS_ERRNO_TSK_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
taskCB->topOfStack = (UINTPTR)topStack;
|
|
||||||
taskCB->stackPointer = OsTaskStackInit(taskCB->taskID, initParam->uwStackSize, topStack, TRUE);
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
if (taskCB->taskStatus & OS_TASK_FLAG_USER_MODE) {
|
|
||||||
taskCB->userArea = initParam->userParam.userArea;
|
|
||||||
taskCB->userMapBase = initParam->userParam.userMapBase;
|
|
||||||
taskCB->userMapSize = initParam->userParam.userMapSize;
|
|
||||||
OsUserTaskStackInit(taskCB->stackPointer, (UINTPTR)taskCB->taskEntry, initParam->userParam.userSP);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return LOS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC LosTaskCB *GetFreeTaskCB(VOID)
|
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
|
@ -619,31 +554,37 @@ STATIC LosTaskCB *GetFreeTaskCB(VOID)
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S *initParam)
|
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S *initParam)
|
||||||
{
|
{
|
||||||
UINT32 errRet = TaskCreateParamCheck(taskID, initParam);
|
UINT32 intSave, errRet;
|
||||||
|
VOID *topStack = NULL;
|
||||||
|
VOID *pool = NULL;
|
||||||
|
|
||||||
|
errRet = OsTaskCreateParamCheck(taskID, initParam, &pool);
|
||||||
if (errRet != LOS_OK) {
|
if (errRet != LOS_OK) {
|
||||||
return errRet;
|
return errRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
LosTaskCB *taskCB = GetFreeTaskCB();
|
LosTaskCB *taskCB = OsGetFreeTaskCB();
|
||||||
if (taskCB == NULL) {
|
if (taskCB == NULL) {
|
||||||
return LOS_ERRNO_TSK_TCB_UNAVAILABLE;
|
errRet = LOS_ERRNO_TSK_TCB_UNAVAILABLE;
|
||||||
|
goto LOS_ERREND;
|
||||||
}
|
}
|
||||||
|
|
||||||
errRet = TaskCBInit(taskCB, initParam);
|
errRet = OsTaskSyncCreate(taskCB);
|
||||||
if (errRet != LOS_OK) {
|
if (errRet != LOS_OK) {
|
||||||
goto DEINIT_TCB;
|
goto LOS_ERREND_REWIND_TCB;
|
||||||
}
|
}
|
||||||
|
|
||||||
errRet = TaskSyncCreate(taskCB);
|
OsTaskStackAlloc(&topStack, initParam->uwStackSize, pool);
|
||||||
|
if (topStack == NULL) {
|
||||||
|
errRet = LOS_ERRNO_TSK_NO_MEMORY;
|
||||||
|
goto LOS_ERREND_REWIND_SYNC;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID *stackPtr = OsTaskStackInit(taskCB->taskID, initParam->uwStackSize, topStack, TRUE);
|
||||||
|
errRet = OsTaskCBInit(taskCB, initParam, stackPtr, topStack);
|
||||||
if (errRet != LOS_OK) {
|
if (errRet != LOS_OK) {
|
||||||
goto DEINIT_TCB;
|
goto LOS_ERREND_TCB_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
errRet = TaskStackInit(taskCB, initParam);
|
|
||||||
if (errRet != LOS_OK) {
|
|
||||||
goto DEINIT_TCB;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OsConsoleIDSetHook != NULL) {
|
if (OsConsoleIDSetHook != NULL) {
|
||||||
OsConsoleIDSetHook(taskCB->taskID, OsCurrTaskGet()->taskID);
|
OsConsoleIDSetHook(taskCB->taskID, OsCurrTaskGet()->taskID);
|
||||||
}
|
}
|
||||||
|
@ -652,8 +593,17 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S
|
||||||
OsHookCall(LOS_HOOK_TYPE_TASK_CREATE, taskCB);
|
OsHookCall(LOS_HOOK_TYPE_TASK_CREATE, taskCB);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
||||||
DEINIT_TCB:
|
LOS_ERREND_TCB_INIT:
|
||||||
TaskCBDeInit(taskCB);
|
(VOID)LOS_MemFree(pool, topStack);
|
||||||
|
LOS_ERREND_REWIND_SYNC:
|
||||||
|
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
||||||
|
OsTaskSyncDestroy(taskCB->syncSignal);
|
||||||
|
#endif
|
||||||
|
LOS_ERREND_REWIND_TCB:
|
||||||
|
SCHEDULER_LOCK(intSave);
|
||||||
|
OsInsertTCBToFreeList(taskCB);
|
||||||
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
LOS_ERREND:
|
||||||
return errRet;
|
return errRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,9 +621,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *in
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OsProcessIsUserMode(OsCurrProcessGet())) {
|
if (OsProcessIsUserMode(OsCurrProcessGet())) {
|
||||||
initParam->processID = (UINTPTR)OsGetKernelInitProcess();
|
initParam->processID = OsGetKernelInitProcessID();
|
||||||
} else {
|
} else {
|
||||||
initParam->processID = (UINTPTR)OsCurrProcessGet();
|
initParam->processID = OsCurrProcessGet()->processID;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = LOS_TaskCreateOnly(taskID, initParam);
|
ret = LOS_TaskCreateOnly(taskID, initParam);
|
||||||
|
@ -851,7 +801,7 @@ LITE_OS_SEC_TEXT VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (OsIsProcessThreadGroup(runTask)) {
|
if (OsProcessThreadGroupIDGet(runTask) == runTask->taskID) {
|
||||||
OsProcessThreadGroupDestroy();
|
OsProcessThreadGroupDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,11 +812,11 @@ LITE_OS_SEC_TEXT VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status)
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
|
||||||
OsTaskResourcesToFree(runTask);
|
OsTaskResourcesToFree(runTask);
|
||||||
OsProcessResourcesToFree(OS_PCB_FROM_TCB(runTask));
|
OsProcessResourcesToFree(OS_PCB_FROM_PID(runTask->processID));
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
|
|
||||||
OsProcessNaturalExit(OS_PCB_FROM_TCB(runTask), status);
|
OsProcessNaturalExit(OS_PCB_FROM_PID(runTask->processID), status);
|
||||||
OsTaskReleaseHoldLock(runTask);
|
OsTaskReleaseHoldLock(runTask);
|
||||||
OsTaskStatusUnusedSet(runTask);
|
OsTaskStatusUnusedSet(runTask);
|
||||||
} else if (runTask->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
|
} else if (runTask->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
|
||||||
|
@ -931,8 +881,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
|
||||||
}
|
}
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
if (OsTaskIsNotDelete(taskCB)) {
|
if (taskCB->taskStatus & (OS_TASK_STATUS_UNUSED | OS_TASK_FLAG_SYSTEM_TASK | OS_TASK_FLAG_NO_DELETE)) {
|
||||||
if (OsTaskIsUnused(taskCB)) {
|
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||||
ret = LOS_ERRNO_TSK_NOT_CREATED;
|
ret = LOS_ERRNO_TSK_NOT_CREATED;
|
||||||
} else {
|
} else {
|
||||||
ret = LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
|
ret = LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
|
||||||
|
@ -1302,8 +1252,8 @@ LITE_OS_SEC_TEXT INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL s
|
||||||
|
|
||||||
err = LOS_OK;
|
err = LOS_OK;
|
||||||
/* if thread is main thread, then set processName as taskName */
|
/* if thread is main thread, then set processName as taskName */
|
||||||
if (OsIsProcessThreadGroup(taskCB) && (setPName == TRUE)) {
|
if ((taskCB->taskID == OsProcessThreadGroupIDGet(taskCB)) && (setPName == TRUE)) {
|
||||||
err = (INT32)OsSetProcessName(OS_PCB_FROM_TCB(taskCB), (const CHAR *)taskCB->taskName);
|
err = (INT32)OsSetProcessName(OS_PCB_FROM_PID(taskCB->processID), (const CHAR *)taskCB->taskName);
|
||||||
if (err != LOS_OK) {
|
if (err != LOS_OK) {
|
||||||
err = EINVAL;
|
err = EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -1316,16 +1266,16 @@ EXIT:
|
||||||
|
|
||||||
INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB)
|
INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB)
|
||||||
{
|
{
|
||||||
return OsUserProcessOperatePermissionsCheck(taskCB, (UINTPTR)OsCurrProcessGet());
|
return OsUserProcessOperatePermissionsCheck(taskCB, OsCurrProcessGet()->processID);
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINTPTR processCB)
|
INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINT32 processID)
|
||||||
{
|
{
|
||||||
if (taskCB == NULL) {
|
if (taskCB == NULL) {
|
||||||
return LOS_EINVAL;
|
return LOS_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processCB == (UINTPTR)OsGetDefaultProcessCB()) {
|
if (processID == OS_INVALID_VALUE) {
|
||||||
return LOS_EINVAL;
|
return LOS_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1333,7 +1283,7 @@ INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINTPTR proc
|
||||||
return LOS_EINVAL;
|
return LOS_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processCB != taskCB->processCB) {
|
if (processID != taskCB->processID) {
|
||||||
return LOS_EPERM;
|
return LOS_EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,13 +1318,11 @@ LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsCreateUserTaskParamCheck(UINT32 processID,
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 OsCreateUserTask(UINTPTR processID, TSK_INIT_PARAM_S *initParam)
|
LITE_OS_SEC_TEXT_INIT UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S *initParam)
|
||||||
{
|
{
|
||||||
UINT32 taskID;
|
UINT32 taskID;
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
INT32 policy;
|
|
||||||
SchedParam param;
|
|
||||||
|
|
||||||
ret = OsCreateUserTaskParamCheck(processID, initParam);
|
ret = OsCreateUserTaskParamCheck(processID, initParam);
|
||||||
if (ret != LOS_OK) {
|
if (ret != LOS_OK) {
|
||||||
|
@ -1383,25 +1331,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCreateUserTask(UINTPTR processID, TSK_INIT_PARAM_
|
||||||
|
|
||||||
initParam->uwStackSize = OS_USER_TASK_SYSCALL_STACK_SIZE;
|
initParam->uwStackSize = OS_USER_TASK_SYSCALL_STACK_SIZE;
|
||||||
initParam->usTaskPrio = OS_TASK_PRIORITY_LOWEST;
|
initParam->usTaskPrio = OS_TASK_PRIORITY_LOWEST;
|
||||||
|
initParam->policy = LOS_SCHED_RR;
|
||||||
if (processID == OS_INVALID_VALUE) {
|
if (processID == OS_INVALID_VALUE) {
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
LosProcessCB *processCB = OsCurrProcessGet();
|
LosProcessCB *processCB = OsCurrProcessGet();
|
||||||
initParam->processID = (UINTPTR)processCB;
|
initParam->processID = processCB->processID;
|
||||||
initParam->consoleID = processCB->consoleID;
|
initParam->consoleID = processCB->consoleID;
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
ret = LOS_GetProcessScheduler(processCB->processID, &policy, NULL);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return OS_INVALID_VALUE;
|
|
||||||
}
|
|
||||||
initParam->policy = policy;
|
|
||||||
if (policy == LOS_SCHED_DEADLINE) {
|
|
||||||
OsSchedProcessDefaultSchedParamGet((UINT16)policy, ¶m);
|
|
||||||
initParam->runTimeUs = param.runTimeUs;
|
|
||||||
initParam->deadlineUs = param.deadlineUs;
|
|
||||||
initParam->periodUs = param.periodUs;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
initParam->policy = LOS_SCHED_RR;
|
|
||||||
initParam->processID = processID;
|
initParam->processID = processID;
|
||||||
initParam->consoleID = 0;
|
initParam->consoleID = 0;
|
||||||
}
|
}
|
||||||
|
@ -1525,7 +1462,7 @@ UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval)
|
||||||
return LOS_EINVAL;
|
return LOS_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runTask->processCB != taskCB->processCB) {
|
if (runTask->processID != taskCB->processID) {
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
return LOS_EPERM;
|
return LOS_EPERM;
|
||||||
}
|
}
|
||||||
|
@ -1568,7 +1505,7 @@ UINT32 LOS_TaskDetach(UINT32 taskID)
|
||||||
return LOS_EINVAL;
|
return LOS_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runTask->processCB != taskCB->processCB) {
|
if (runTask->processID != taskCB->processID) {
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
return LOS_EPERM;
|
return LOS_EPERM;
|
||||||
}
|
}
|
||||||
|
@ -1588,11 +1525,6 @@ LITE_OS_SEC_TEXT UINT32 LOS_GetSystemTaskMaximum(VOID)
|
||||||
return g_taskMaxNum;
|
return g_taskMaxNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
LosTaskCB *OsGetDefaultTaskCB(VOID)
|
|
||||||
{
|
|
||||||
return &g_taskCBArray[g_taskMaxNum];
|
|
||||||
}
|
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT VOID OsWriteResourceEvent(UINT32 events)
|
LITE_OS_SEC_TEXT VOID OsWriteResourceEvent(UINT32 events)
|
||||||
{
|
{
|
||||||
(VOID)LOS_EventWrite(&g_resourceEvent, events);
|
(VOID)LOS_EventWrite(&g_resourceEvent, events);
|
||||||
|
|
|
@ -1,148 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LOS_CONTAINER_PRI_H
|
|
||||||
#define _LOS_CONTAINER_PRI_H
|
|
||||||
|
|
||||||
#include "los_atomic.h"
|
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
#include "los_pid_container_pri.h"
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_UTS_CONTAINER
|
|
||||||
#include "los_uts_container_pri.h"
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
#include "los_mnt_container_pri.h"
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
#include "los_ipc_container_pri.h"
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_USER_CONTAINER
|
|
||||||
#include "los_user_container_pri.h"
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_TIME_CONTAINER
|
|
||||||
#include "los_time_container_pri.h"
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_NET_CONTAINER
|
|
||||||
#include "los_net_container_pri.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
CONTAINER = 0,
|
|
||||||
PID_CONTAINER,
|
|
||||||
PID_CHILD_CONTAINER,
|
|
||||||
UTS_CONTAINER,
|
|
||||||
MNT_CONTAINER,
|
|
||||||
IPC_CONTAINER,
|
|
||||||
USER_CONTAINER,
|
|
||||||
TIME_CONTAINER,
|
|
||||||
TIME_CHILD_CONTAINER,
|
|
||||||
NET_CONTAINER,
|
|
||||||
CONTAINER_MAX,
|
|
||||||
} ContainerType;
|
|
||||||
|
|
||||||
typedef struct Container {
|
|
||||||
Atomic rc;
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
struct PidContainer *pidContainer;
|
|
||||||
struct PidContainer *pidForChildContainer;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_UTS_CONTAINER
|
|
||||||
struct UtsContainer *utsContainer;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
struct MntContainer *mntContainer;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
struct IpcContainer *ipcContainer;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_TIME_CONTAINER
|
|
||||||
struct TimeContainer *timeContainer;
|
|
||||||
struct TimeContainer *timeForChildContainer;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_NET_CONTAINER
|
|
||||||
struct NetContainer *netContainer;
|
|
||||||
#endif
|
|
||||||
} Container;
|
|
||||||
|
|
||||||
typedef struct TagContainerLimit {
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
UINT32 pidLimit;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_UTS_CONTAINER
|
|
||||||
UINT32 utsLimit;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
UINT32 mntLimit;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
UINT32 ipcLimit;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_TIME_CONTAINER
|
|
||||||
UINT32 timeLimit;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_USER_CONTAINER
|
|
||||||
UINT32 userLimit;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_NET_CONTAINER
|
|
||||||
UINT32 netLimit;
|
|
||||||
#endif
|
|
||||||
} ContainerLimit;
|
|
||||||
|
|
||||||
VOID OsContainerInitSystemProcess(LosProcessCB *processCB);
|
|
||||||
|
|
||||||
VOID OsInitRootContainer(VOID);
|
|
||||||
|
|
||||||
UINT32 OsCopyContainers(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent, UINT32 *processID);
|
|
||||||
|
|
||||||
VOID OsOsContainersDestroyEarly(LosProcessCB *processCB);
|
|
||||||
|
|
||||||
VOID OsContainersDestroy(LosProcessCB *processCB);
|
|
||||||
|
|
||||||
VOID OsContainerFree(LosProcessCB *processCB);
|
|
||||||
|
|
||||||
UINT32 OsAllocContainerID(VOID);
|
|
||||||
|
|
||||||
UINT32 OsGetContainerID(LosProcessCB *processCB, ContainerType type);
|
|
||||||
|
|
||||||
INT32 OsUnshare(UINT32 flags);
|
|
||||||
|
|
||||||
INT32 OsSetNs(INT32 fd, INT32 type);
|
|
||||||
|
|
||||||
UINT32 OsGetContainerLimit(ContainerType type);
|
|
||||||
|
|
||||||
UINT32 OsContainerLimitCheck(ContainerType type, UINT32 *containerCount);
|
|
||||||
|
|
||||||
UINT32 OsSetContainerLimit(ContainerType type, UINT32 value);
|
|
||||||
|
|
||||||
UINT32 OsGetContainerCount(ContainerType type);
|
|
||||||
#endif
|
|
||||||
#endif /* _LOS_CONTAINER_PRI_H */
|
|
|
@ -1,73 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LOS_CREDENTIALS_PRI_H
|
|
||||||
#define _LOS_CREDENTIALS_PRI_H
|
|
||||||
|
|
||||||
#include "los_atomic.h"
|
|
||||||
#include "los_list.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_USER_CONTAINER
|
|
||||||
struct Container;
|
|
||||||
struct UserContainer;
|
|
||||||
typedef struct ProcessCB LosProcessCB;
|
|
||||||
|
|
||||||
typedef struct Credentials {
|
|
||||||
Atomic rc;
|
|
||||||
UINT32 uid;
|
|
||||||
UINT32 gid;
|
|
||||||
UINT32 euid;
|
|
||||||
UINT32 egid;
|
|
||||||
struct UserContainer *userContainer;
|
|
||||||
} Credentials;
|
|
||||||
|
|
||||||
UINT32 OsCopyCredentials(unsigned long flags, LosProcessCB *child, LosProcessCB *parent);
|
|
||||||
|
|
||||||
UINT32 OsInitRootUserCredentials(Credentials **credentials);
|
|
||||||
|
|
||||||
UINT32 OsUnshareUserCredentials(UINTPTR flags, LosProcessCB *curr);
|
|
||||||
|
|
||||||
UINT32 OsSetNsUserContainer(struct UserContainer *targetContainer, LosProcessCB *runProcess);
|
|
||||||
|
|
||||||
VOID FreeCredential(Credentials *credentials);
|
|
||||||
|
|
||||||
VOID OsUserContainerDestroy(LosProcessCB *curr);
|
|
||||||
|
|
||||||
UINT32 OsGetUserContainerID(Credentials *credentials);
|
|
||||||
|
|
||||||
Credentials *PrepareCredential(LosProcessCB *runProcessCB);
|
|
||||||
|
|
||||||
INT32 CommitCredentials(Credentials *newCredentials);
|
|
||||||
|
|
||||||
Credentials *CurrentCredentials(VOID);
|
|
||||||
|
|
||||||
struct UserContainer *OsCurrentUserContainer(VOID);
|
|
||||||
#endif
|
|
||||||
#endif /* _LOS_CREDENTIALS_PRI_H */
|
|
|
@ -1,108 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LOS_INFO_PRI_H
|
|
||||||
#define _LOS_INFO_PRI_H
|
|
||||||
|
|
||||||
#include "los_process_pri.h"
|
|
||||||
#include "los_sched_pri.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#if __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
typedef struct TagTaskInfo {
|
|
||||||
UINT32 tid;
|
|
||||||
UINT32 pid;
|
|
||||||
UINT16 status;
|
|
||||||
UINT16 policy;
|
|
||||||
UINT16 priority;
|
|
||||||
#ifdef LOSCFG_KERNEL_SMP
|
|
||||||
UINT16 currCpu;
|
|
||||||
UINT16 cpuAffiMask;
|
|
||||||
#endif
|
|
||||||
UINT32 stackSize;
|
|
||||||
UINTPTR stackPoint;
|
|
||||||
UINTPTR topOfStack;
|
|
||||||
UINT32 waitFlag;
|
|
||||||
UINT32 waitID;
|
|
||||||
VOID *taskMux;
|
|
||||||
UINT32 waterLine;
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
|
||||||
UINT32 cpup1sUsage;
|
|
||||||
UINT32 cpup10sUsage;
|
|
||||||
UINT32 cpupAllsUsage;
|
|
||||||
#endif
|
|
||||||
CHAR name[OS_TCB_NAME_LEN];
|
|
||||||
} TaskInfo;
|
|
||||||
|
|
||||||
typedef struct TagProcessInfo {
|
|
||||||
UINT32 pid;
|
|
||||||
UINT32 ppid;
|
|
||||||
UINT16 status;
|
|
||||||
UINT16 mode;
|
|
||||||
UINT32 pgroupID;
|
|
||||||
UINT32 userID;
|
|
||||||
UINT16 policy;
|
|
||||||
UINT32 basePrio;
|
|
||||||
UINT32 threadGroupID;
|
|
||||||
UINT32 threadNumber;
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
UINT32 virtualMem;
|
|
||||||
UINT32 shareMem;
|
|
||||||
UINT32 physicalMem;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
|
||||||
UINT32 cpup1sUsage;
|
|
||||||
UINT32 cpup10sUsage;
|
|
||||||
UINT32 cpupAllsUsage;
|
|
||||||
#endif
|
|
||||||
CHAR name[OS_PCB_NAME_LEN];
|
|
||||||
} ProcessInfo;
|
|
||||||
|
|
||||||
typedef struct TagProcessThreadInfo {
|
|
||||||
ProcessInfo processInfo;
|
|
||||||
UINT32 threadCount;
|
|
||||||
TaskInfo taskInfo[LOSCFG_BASE_CORE_TSK_LIMIT];
|
|
||||||
} ProcessThreadInfo;
|
|
||||||
|
|
||||||
UINT32 OsGetAllProcessInfo(ProcessInfo *pcbArray);
|
|
||||||
|
|
||||||
UINT32 OsGetProcessThreadInfo(UINT32 pid, ProcessThreadInfo *threadInfo);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#if __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* _LOS_INFO_PRI_H */
|
|
|
@ -1,98 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
#ifndef _LOS_IPC_CONTAINER_PRI_H
|
|
||||||
#define _LOS_IPC_CONTAINER_PRI_H
|
|
||||||
|
|
||||||
#include "los_atomic.h"
|
|
||||||
#include "los_list.h"
|
|
||||||
#include "mqueue.h"
|
|
||||||
#include "fs/file.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
struct shmIDSource;
|
|
||||||
struct Container;
|
|
||||||
typedef struct TagQueueCB LosQueueCB;
|
|
||||||
typedef struct OsMux LosMux;
|
|
||||||
typedef LosMux pthread_mutex_t;
|
|
||||||
typedef struct ProcessCB LosProcessCB;
|
|
||||||
|
|
||||||
typedef struct IpcContainer {
|
|
||||||
Atomic rc;
|
|
||||||
LosQueueCB *allQueue;
|
|
||||||
LOS_DL_LIST freeQueueList;
|
|
||||||
fd_set queueFdSet;
|
|
||||||
struct mqarray queueTable[LOSCFG_BASE_IPC_QUEUE_LIMIT];
|
|
||||||
pthread_mutex_t mqueueMutex;
|
|
||||||
struct mqpersonal *mqPrivBuf[MAX_MQ_FD];
|
|
||||||
struct shminfo shmInfo;
|
|
||||||
LosMux sysvShmMux;
|
|
||||||
struct shmIDSource *shmSegs;
|
|
||||||
UINT32 shmUsedPageCount;
|
|
||||||
UINT32 containerID;
|
|
||||||
} IpcContainer;
|
|
||||||
|
|
||||||
UINT32 OsInitRootIpcContainer(IpcContainer **ipcContainer);
|
|
||||||
|
|
||||||
UINT32 OsCopyIpcContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent);
|
|
||||||
|
|
||||||
UINT32 OsUnshareIpcContainer(UINTPTR flags, LosProcessCB *curr, struct Container *newContainer);
|
|
||||||
|
|
||||||
UINT32 OsSetNsIpcContainer(UINT32 flags, struct Container *container, struct Container *newContainer);
|
|
||||||
|
|
||||||
VOID OsIpcContainerDestroy(struct Container *container);
|
|
||||||
|
|
||||||
UINT32 OsGetIpcContainerID(IpcContainer *ipcContainer);
|
|
||||||
|
|
||||||
IpcContainer *OsGetCurrIpcContainer(VOID);
|
|
||||||
|
|
||||||
UINT32 OsGetIpcContainerCount(VOID);
|
|
||||||
|
|
||||||
#define IPC_ALL_QUEUE (OsGetCurrIpcContainer()->allQueue)
|
|
||||||
|
|
||||||
#define FREE_QUEUE_LIST (OsGetCurrIpcContainer()->freeQueueList)
|
|
||||||
|
|
||||||
#define IPC_QUEUE_FD_SET (OsGetCurrIpcContainer()->queueFdSet)
|
|
||||||
|
|
||||||
#define IPC_QUEUE_TABLE (OsGetCurrIpcContainer()->queueTable)
|
|
||||||
|
|
||||||
#define IPC_QUEUE_MUTEX (OsGetCurrIpcContainer()->mqueueMutex)
|
|
||||||
|
|
||||||
#define IPC_QUEUE_MQ_PRIV_BUF (OsGetCurrIpcContainer()->mqPrivBuf)
|
|
||||||
|
|
||||||
#define IPC_SHM_INFO (OsGetCurrIpcContainer()->shmInfo)
|
|
||||||
|
|
||||||
#define IPC_SHM_SYS_VSHM_MUTEX (OsGetCurrIpcContainer()->sysvShmMux)
|
|
||||||
|
|
||||||
#define IPC_SHM_SEGS (OsGetCurrIpcContainer()->shmSegs)
|
|
||||||
|
|
||||||
#define IPC_SHM_USED_PAGE_COUNT (OsGetCurrIpcContainer()->shmUsedPageCount)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif /* _LOS_IPC_CONTAINER_PRI_H */
|
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LOS_MNT_CONTAINER_PRI_H
|
|
||||||
#define _LOS_MNT_CONTAINER_PRI_H
|
|
||||||
|
|
||||||
#include "fs/mount.h"
|
|
||||||
#include "sched.h"
|
|
||||||
#include "los_atomic.h"
|
|
||||||
#include "vnode.h"
|
|
||||||
#include "stdlib.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_MNT_CONTAINER
|
|
||||||
typedef struct ProcessCB LosProcessCB;
|
|
||||||
struct Container;
|
|
||||||
|
|
||||||
typedef struct MntContainer {
|
|
||||||
Atomic rc;
|
|
||||||
UINT32 containerID;
|
|
||||||
LIST_HEAD mountList;
|
|
||||||
} MntContainer;
|
|
||||||
|
|
||||||
LIST_HEAD *GetContainerMntList(VOID);
|
|
||||||
|
|
||||||
UINT32 OsInitRootMntContainer(MntContainer **mntContainer);
|
|
||||||
|
|
||||||
UINT32 OsCopyMntContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent);
|
|
||||||
|
|
||||||
UINT32 OsUnshareMntContainer(UINTPTR flags, LosProcessCB *curr, struct Container *newContainer);
|
|
||||||
|
|
||||||
UINT32 OsSetNsMntContainer(UINT32 flags, struct Container *container, struct Container *newContainer);
|
|
||||||
|
|
||||||
VOID OsMntContainerDestroy(struct Container *container);
|
|
||||||
|
|
||||||
UINT32 OsGetMntContainerID(MntContainer *mntContainer);
|
|
||||||
|
|
||||||
UINT32 OsGetMntContainerCount(VOID);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LOS_NET_CONTAINER_PRI_H
|
|
||||||
#define _LOS_NET_CONTAINER_PRI_H
|
|
||||||
#include <lwip/net_group.h>
|
|
||||||
#include <lwip/netif.h>
|
|
||||||
#include <lwip/ip.h>
|
|
||||||
#include "los_atomic.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_NET_CONTAINER
|
|
||||||
typedef struct ProcessCB LosProcessCB;
|
|
||||||
struct Container;
|
|
||||||
|
|
||||||
typedef struct NetContainer {
|
|
||||||
Atomic rc;
|
|
||||||
struct net_group *group;
|
|
||||||
UINT32 containerID;
|
|
||||||
} NetContainer;
|
|
||||||
|
|
||||||
UINT32 OsInitRootNetContainer(NetContainer **ipcContainer);
|
|
||||||
|
|
||||||
UINT32 OsCopyNetContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent);
|
|
||||||
|
|
||||||
UINT32 OsUnshareNetContainer(UINTPTR flags, LosProcessCB *curr, struct Container *newContainer);
|
|
||||||
|
|
||||||
UINT32 OsSetNsNetContainer(UINT32 flags, struct Container *container, struct Container *newContainer);
|
|
||||||
|
|
||||||
VOID OsNetContainerDestroy(struct Container *container);
|
|
||||||
|
|
||||||
UINT32 OsGetNetContainerID(NetContainer *ipcContainer);
|
|
||||||
|
|
||||||
UINT32 OsGetNetContainerCount(VOID);
|
|
||||||
#endif
|
|
||||||
#endif /* _LOS_NET_CONTAINER_PRI_H */
|
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LOS_PID_CONTAINER_PRI_H
|
|
||||||
#define _LOS_PID_CONTAINER_PRI_H
|
|
||||||
#include "los_config.h"
|
|
||||||
#include "los_atomic.h"
|
|
||||||
#include "los_list.h"
|
|
||||||
|
|
||||||
typedef struct TagTaskCB LosTaskCB;
|
|
||||||
typedef struct ProcessCB LosProcessCB;
|
|
||||||
struct ProcessGroup;
|
|
||||||
struct Container;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT32 vid; /* Virtual ID */
|
|
||||||
UINT32 vpid; /* Virtual parent ID */
|
|
||||||
UINTPTR cb; /* Control block */
|
|
||||||
LosProcessCB *realParent; /* process real parent */
|
|
||||||
LOS_DL_LIST node;
|
|
||||||
} ProcessVid;
|
|
||||||
|
|
||||||
#define PID_CONTAINER_LEVEL_LIMIT 3
|
|
||||||
|
|
||||||
typedef struct PidContainer {
|
|
||||||
Atomic rc;
|
|
||||||
Atomic level;
|
|
||||||
Atomic lock;
|
|
||||||
BOOL referenced;
|
|
||||||
UINT32 containerID;
|
|
||||||
struct PidContainer *parent;
|
|
||||||
struct ProcessGroup *rootPGroup;
|
|
||||||
LOS_DL_LIST tidFreeList;
|
|
||||||
ProcessVid tidArray[LOSCFG_BASE_CORE_TSK_LIMIT];
|
|
||||||
LOS_DL_LIST pidFreeList;
|
|
||||||
ProcessVid pidArray[LOSCFG_BASE_CORE_PROCESS_LIMIT];
|
|
||||||
} PidContainer;
|
|
||||||
|
|
||||||
#define OS_PID_CONTAINER_FROM_PCB(processCB) ((processCB)->container->pidContainer)
|
|
||||||
|
|
||||||
#define OS_ROOT_PGRP(processCB) (OS_PID_CONTAINER_FROM_PCB(processCB)->rootPGroup)
|
|
||||||
|
|
||||||
#define OS_PROCESS_CONTAINER_CHECK(processCB, currProcessCB) \
|
|
||||||
((processCB)->container->pidContainer != (currProcessCB)->container->pidContainer)
|
|
||||||
|
|
||||||
#define OS_PROCESS_PID_FOR_CONTAINER_CHECK(processCB) \
|
|
||||||
(((processCB)->container->pidContainer != (processCB)->container->pidForChildContainer) && \
|
|
||||||
((processCB)->container->pidForChildContainer->referenced == FALSE))
|
|
||||||
|
|
||||||
UINT32 OsAllocSpecifiedVpidUnsafe(UINT32 vpid, PidContainer *pidContainer,
|
|
||||||
LosProcessCB *processCB, LosProcessCB *parent);
|
|
||||||
|
|
||||||
VOID OsPidContainerDestroyAllProcess(LosProcessCB *processCB);
|
|
||||||
|
|
||||||
VOID OsPidContainerDestroy(struct Container *container, LosProcessCB *processCB);
|
|
||||||
|
|
||||||
UINT32 OsCopyPidContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent, UINT32 *processID);
|
|
||||||
|
|
||||||
UINT32 OsUnsharePidContainer(UINTPTR flags, LosProcessCB *curr, struct Container *newContainer);
|
|
||||||
|
|
||||||
UINT32 OsSetNsPidContainer(UINT32 flags, struct Container *container, struct Container *newContainer);
|
|
||||||
|
|
||||||
UINT32 OsInitRootPidContainer(PidContainer **pidContainer);
|
|
||||||
|
|
||||||
LosProcessCB *OsGetPCBFromVpid(UINT32 vpid);
|
|
||||||
|
|
||||||
LosTaskCB *OsGetTCBFromVtid(UINT32 vtid);
|
|
||||||
|
|
||||||
UINT32 OsGetVpidFromCurrContainer(const LosProcessCB *processCB);
|
|
||||||
|
|
||||||
UINT32 OsGetVpidFromRootContainer(const LosProcessCB *processCB);
|
|
||||||
|
|
||||||
UINT32 OsGetVtidFromCurrContainer(const LosTaskCB *taskCB);
|
|
||||||
|
|
||||||
VOID OsFreeVtid(LosTaskCB *taskCB);
|
|
||||||
|
|
||||||
UINT32 OsAllocVtid(LosTaskCB *taskCB, const LosProcessCB *processCB);
|
|
||||||
|
|
||||||
UINT32 OsGetPidContainerID(PidContainer *pidContainer);
|
|
||||||
|
|
||||||
BOOL OsPidContainerProcessParentIsRealParent(const LosProcessCB *processCB, const LosProcessCB *curr);
|
|
||||||
|
|
||||||
UINT32 OsGetPidContainerCount(VOID);
|
|
||||||
#endif /* _LOS_PID_CONTAINER_PRI_H */
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -33,7 +33,6 @@
|
||||||
#define _LOS_PROCESS_PRI_H
|
#define _LOS_PROCESS_PRI_H
|
||||||
|
|
||||||
#include "los_task_pri.h"
|
#include "los_task_pri.h"
|
||||||
#include "sched.h"
|
|
||||||
#include "los_sem_pri.h"
|
#include "los_sem_pri.h"
|
||||||
#include "los_process.h"
|
#include "los_process.h"
|
||||||
#include "los_vm_map.h"
|
#include "los_vm_map.h"
|
||||||
|
@ -47,12 +46,6 @@
|
||||||
#include "vid_type.h"
|
#include "vid_type.h"
|
||||||
#endif
|
#endif
|
||||||
#include "sys/resource.h"
|
#include "sys/resource.h"
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
#include "los_container_pri.h"
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
#include "los_plimits.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
@ -75,11 +68,11 @@ typedef struct {
|
||||||
} User;
|
} User;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct ProcessGroup {
|
typedef struct {
|
||||||
UINTPTR pgroupLeader; /**< Process group leader is the the process that created the group */
|
UINT32 groupID; /**< Process group ID is the PID of the process that created the group */
|
||||||
LOS_DL_LIST processList; /**< List of processes under this process group */
|
LOS_DL_LIST processList; /**< List of processes under this process group */
|
||||||
LOS_DL_LIST exitProcessList; /**< List of closed processes (zombie processes) under this group */
|
LOS_DL_LIST exitProcessList; /**< List of closed processes (zombie processes) under this group */
|
||||||
LOS_DL_LIST groupList; /**< Process group list */
|
LOS_DL_LIST groupList; /**< Process group list */
|
||||||
} ProcessGroup;
|
} ProcessGroup;
|
||||||
|
|
||||||
typedef struct ProcessCB {
|
typedef struct ProcessCB {
|
||||||
|
@ -89,15 +82,15 @@ typedef struct ProcessCB {
|
||||||
running in the process */
|
running in the process */
|
||||||
UINT16 consoleID; /**< The console id of task belongs */
|
UINT16 consoleID; /**< The console id of task belongs */
|
||||||
UINT16 processMode; /**< Kernel Mode:0; User Mode:1; */
|
UINT16 processMode; /**< Kernel Mode:0; User Mode:1; */
|
||||||
struct ProcessCB *parentProcess; /**< Parent process */
|
UINT32 parentProcessID; /**< Parent process ID */
|
||||||
UINT32 exitCode; /**< Process exit status */
|
UINT32 exitCode; /**< Process exit status */
|
||||||
LOS_DL_LIST pendList; /**< Block list to which the process belongs */
|
LOS_DL_LIST pendList; /**< Block list to which the process belongs */
|
||||||
LOS_DL_LIST childrenList; /**< Children process list */
|
LOS_DL_LIST childrenList; /**< Children process list */
|
||||||
LOS_DL_LIST exitChildList; /**< Exit children process list */
|
LOS_DL_LIST exitChildList; /**< Exit children process list */
|
||||||
LOS_DL_LIST siblingList; /**< Linkage in parent's children list */
|
LOS_DL_LIST siblingList; /**< Linkage in parent's children list */
|
||||||
ProcessGroup *pgroup; /**< Process group to which a process belongs */
|
ProcessGroup *group; /**< Process group to which a process belongs */
|
||||||
LOS_DL_LIST subordinateGroupList; /**< Linkage in group list */
|
LOS_DL_LIST subordinateGroupList; /**< Linkage in group list */
|
||||||
LosTaskCB *threadGroup;
|
UINT32 threadGroupID; /**< Which thread group , is the main thread ID of the process */
|
||||||
LOS_DL_LIST threadSiblingList; /**< List of threads under this process */
|
LOS_DL_LIST threadSiblingList; /**< List of threads under this process */
|
||||||
volatile UINT32 threadNumber; /**< Number of threads alive under this process */
|
volatile UINT32 threadNumber; /**< Number of threads alive under this process */
|
||||||
UINT32 threadCount; /**< Total number of threads created under this process */
|
UINT32 threadCount; /**< Total number of threads created under this process */
|
||||||
|
@ -133,36 +126,20 @@ typedef struct ProcessCB {
|
||||||
OsCpupBase *processCpup; /**< Process cpu usage */
|
OsCpupBase *processCpup; /**< Process cpu usage */
|
||||||
#endif
|
#endif
|
||||||
struct rlimit *resourceLimit;
|
struct rlimit *resourceLimit;
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
Container *container;
|
|
||||||
#ifdef LOSCFG_USER_CONTAINER
|
|
||||||
struct Credentials *credentials;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
|
||||||
struct ProcDirEntry *procDir;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
|
||||||
ProcLimiterSet *plimits;
|
|
||||||
LOS_DL_LIST plimitsList; /* plimit process list */
|
|
||||||
PLimitsData limitStat;
|
|
||||||
#endif
|
|
||||||
} LosProcessCB;
|
} LosProcessCB;
|
||||||
|
|
||||||
extern LosProcessCB *g_processCBArray;
|
#define CLONE_VM 0x00000100
|
||||||
extern UINT32 g_processMaxNum;
|
#define CLONE_FS 0x00000200
|
||||||
|
#define CLONE_FILES 0x00000400
|
||||||
|
#define CLONE_SIGHAND 0x00000800
|
||||||
|
#define CLONE_PTRACE 0x00002000
|
||||||
|
#define CLONE_VFORK 0x00004000
|
||||||
|
#define CLONE_PARENT 0x00008000
|
||||||
|
#define CLONE_THREAD 0x00010000
|
||||||
|
|
||||||
#define OS_PCB_FROM_RPID(processID) (((LosProcessCB *)g_processCBArray) + (processID))
|
#define OS_PCB_FROM_PID(processID) (((LosProcessCB *)g_processCBArray) + (processID))
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
#define OS_PCB_FROM_SIBLIST(ptr) LOS_DL_LIST_ENTRY((ptr), LosProcessCB, siblingList)
|
||||||
#define OS_PCB_FROM_PID(processID) OsGetPCBFromVpid(processID)
|
#define OS_PCB_FROM_PENDLIST(ptr) LOS_DL_LIST_ENTRY((ptr), LosProcessCB, pendList)
|
||||||
#else
|
|
||||||
#define OS_PCB_FROM_PID(processID) OS_PCB_FROM_RPID(processID)
|
|
||||||
#endif
|
|
||||||
#define OS_PCB_FROM_TCB(taskCB) ((LosProcessCB *)((taskCB)->processCB))
|
|
||||||
#define OS_PCB_FROM_TID(taskID) ((LosProcessCB *)(OS_TCB_FROM_TID(taskID)->processCB))
|
|
||||||
#define OS_GET_PGROUP_LEADER(pgroup) ((LosProcessCB *)((pgroup)->pgroupLeader))
|
|
||||||
#define OS_PCB_FROM_SIBLIST(ptr) LOS_DL_LIST_ENTRY((ptr), LosProcessCB, siblingList)
|
|
||||||
#define OS_PCB_FROM_PENDLIST(ptr) LOS_DL_LIST_ENTRY((ptr), LosProcessCB, pendList)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_process
|
* @ingroup los_process
|
||||||
|
@ -269,17 +246,12 @@ STATIC INLINE BOOL OsProcessIsInactive(const LosProcessCB *processCB)
|
||||||
*/
|
*/
|
||||||
STATIC INLINE BOOL OsProcessIsDead(const LosProcessCB *processCB)
|
STATIC INLINE BOOL OsProcessIsDead(const LosProcessCB *processCB)
|
||||||
{
|
{
|
||||||
return ((processCB->processStatus & OS_PROCESS_STATUS_ZOMBIES) != 0);
|
return ((processCB->processStatus & (OS_PROCESS_FLAG_UNUSED | OS_PROCESS_STATUS_ZOMBIES)) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE BOOL OsProcessIsInit(const LosProcessCB *processCB)
|
STATIC INLINE BOOL OsProcessIsInit(const LosProcessCB *processCB)
|
||||||
{
|
{
|
||||||
return ((processCB->processStatus & OS_PROCESS_STATUS_INIT) != 0);
|
return (processCB->processStatus & OS_PROCESS_STATUS_INIT);
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE BOOL OsProcessIsPGroupLeader(const LosProcessCB *processCB)
|
|
||||||
{
|
|
||||||
return ((processCB->processStatus & OS_PROCESS_FLAG_GROUP_LEADER) != 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,24 +284,6 @@ STATIC INLINE BOOL OsProcessIsPGroupLeader(const LosProcessCB *processCB)
|
||||||
*/
|
*/
|
||||||
#define OS_PROCESS_USERINIT_PRIORITY 28
|
#define OS_PROCESS_USERINIT_PRIORITY 28
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup los_process
|
|
||||||
* ID of the kernel idle process
|
|
||||||
*/
|
|
||||||
#define OS_KERNEL_IDLE_PROCESS_ID 0U
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup los_process
|
|
||||||
* ID of the user root process
|
|
||||||
*/
|
|
||||||
#define OS_USER_ROOT_PROCESS_ID 1U
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup los_process
|
|
||||||
* ID of the kernel root process
|
|
||||||
*/
|
|
||||||
#define OS_KERNEL_ROOT_PROCESS_ID 2U
|
|
||||||
|
|
||||||
#define OS_TASK_DEFAULT_STACK_SIZE 0x2000
|
#define OS_TASK_DEFAULT_STACK_SIZE 0x2000
|
||||||
#define OS_USER_TASK_SYSCALL_STACK_SIZE 0x3000
|
#define OS_USER_TASK_SYSCALL_STACK_SIZE 0x3000
|
||||||
#define OS_USER_TASK_STACK_SIZE 0x100000
|
#define OS_USER_TASK_STACK_SIZE 0x100000
|
||||||
|
@ -345,8 +299,8 @@ STATIC INLINE BOOL OsProcessIsUserMode(const LosProcessCB *processCB)
|
||||||
#define LOS_PRIO_PGRP 1U
|
#define LOS_PRIO_PGRP 1U
|
||||||
#define LOS_PRIO_USER 2U
|
#define LOS_PRIO_USER 2U
|
||||||
|
|
||||||
#define OS_USER_PRIVILEGE_PROCESS_GROUP ((UINTPTR)OsGetUserInitProcess())
|
#define OS_USER_PRIVILEGE_PROCESS_GROUP 1U
|
||||||
#define OS_KERNEL_PROCESS_GROUP ((UINTPTR)OsGetKernelInitProcess())
|
#define OS_KERNEL_PROCESS_GROUP 2U
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process exit code
|
* Process exit code
|
||||||
|
@ -380,6 +334,9 @@ STATIC INLINE VOID OsProcessExitCodeSet(LosProcessCB *processCB, UINT32 code)
|
||||||
processCB->exitCode |= ((code & 0x000000FFU) << 8U) & 0x0000FF00U; /* 8: Move 8 bits to the left, exitCode */
|
processCB->exitCode |= ((code & 0x000000FFU) << 8U) & 0x0000FF00U; /* 8: Move 8 bits to the left, exitCode */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern LosProcessCB *g_processCBArray;
|
||||||
|
extern UINT32 g_processMaxNum;
|
||||||
|
|
||||||
#define OS_PID_CHECK_INVALID(pid) (((UINT32)(pid)) >= g_processMaxNum)
|
#define OS_PID_CHECK_INVALID(pid) (((UINT32)(pid)) >= g_processMaxNum)
|
||||||
|
|
||||||
STATIC INLINE BOOL OsProcessIDUserCheckInvalid(UINT32 pid)
|
STATIC INLINE BOOL OsProcessIDUserCheckInvalid(UINT32 pid)
|
||||||
|
@ -392,7 +349,7 @@ STATIC INLINE LosProcessCB *OsCurrProcessGet(VOID)
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
LosProcessCB *runProcess = OS_PCB_FROM_TCB(OsCurrTaskGet());
|
LosProcessCB *runProcess = OS_PCB_FROM_PID(OsCurrTaskGet()->processID);
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
return runProcess;
|
return runProcess;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +371,7 @@ STATIC INLINE UINT32 OsProcessUserIDGet(const LosTaskCB *taskCB)
|
||||||
UINT32 intSave = LOS_IntLock();
|
UINT32 intSave = LOS_IntLock();
|
||||||
UINT32 uid = OS_INVALID;
|
UINT32 uid = OS_INVALID;
|
||||||
|
|
||||||
LosProcessCB *process = OS_PCB_FROM_TCB(taskCB);
|
LosProcessCB *process = OS_PCB_FROM_PID(taskCB->processID);
|
||||||
if (process->user != NULL) {
|
if (process->user != NULL) {
|
||||||
uid = process->user->userID;
|
uid = process->user->userID;
|
||||||
}
|
}
|
||||||
|
@ -423,14 +380,14 @@ STATIC INLINE UINT32 OsProcessUserIDGet(const LosTaskCB *taskCB)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC INLINE BOOL OsIsProcessThreadGroup(const LosTaskCB *taskCB)
|
STATIC INLINE UINT32 OsProcessThreadGroupIDGet(const LosTaskCB *taskCB)
|
||||||
{
|
{
|
||||||
return (OS_PCB_FROM_TCB(taskCB)->threadGroup == taskCB);
|
return OS_PCB_FROM_PID(taskCB->processID)->threadGroupID;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE UINT32 OsProcessThreadNumberGet(const LosTaskCB *taskCB)
|
STATIC INLINE UINT32 OsProcessThreadNumberGet(const LosTaskCB *taskCB)
|
||||||
{
|
{
|
||||||
return OS_PCB_FROM_TCB(taskCB)->threadNumber;
|
return OS_PCB_FROM_PID(taskCB->processID)->threadNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
#ifdef LOSCFG_KERNEL_VM
|
||||||
|
@ -446,26 +403,6 @@ STATIC INLINE struct Vnode *OsProcessExecVnodeGet(const LosProcessCB *processCB)
|
||||||
return processCB->execVnode;
|
return processCB->execVnode;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC INLINE UINT32 OsGetPid(const LosProcessCB *processCB)
|
|
||||||
{
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
if (OS_PROCESS_CONTAINER_CHECK(processCB, OsCurrProcessGet())) {
|
|
||||||
return OsGetVpidFromCurrContainer(processCB);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return processCB->processID;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE UINT32 OsGetRootPid(const LosProcessCB *processCB)
|
|
||||||
{
|
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
return OsGetVpidFromRootContainer(processCB);
|
|
||||||
#else
|
|
||||||
return processCB->processID;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return immediately if no child has exited.
|
* return immediately if no child has exited.
|
||||||
*/
|
*/
|
||||||
|
@ -523,7 +460,6 @@ extern UINTPTR __user_init_entry;
|
||||||
extern UINTPTR __user_init_bss;
|
extern UINTPTR __user_init_bss;
|
||||||
extern UINTPTR __user_init_end;
|
extern UINTPTR __user_init_end;
|
||||||
extern UINTPTR __user_init_load_addr;
|
extern UINTPTR __user_init_load_addr;
|
||||||
extern UINT32 OsProcessInit(VOID);
|
|
||||||
extern UINT32 OsSystemProcessCreate(VOID);
|
extern UINT32 OsSystemProcessCreate(VOID);
|
||||||
extern VOID OsProcessNaturalExit(LosProcessCB *processCB, UINT32 status);
|
extern VOID OsProcessNaturalExit(LosProcessCB *processCB, UINT32 status);
|
||||||
extern VOID OsProcessCBRecycleToFree(VOID);
|
extern VOID OsProcessCBRecycleToFree(VOID);
|
||||||
|
@ -535,25 +471,22 @@ extern LosVmSpace *OsExecProcessVmSpaceReplace(LosVmSpace *newSpace, UINTPTR sta
|
||||||
extern UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR *name, LosVmSpace *oldAspace, UINTPTR oldFiles);
|
extern UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR *name, LosVmSpace *oldAspace, UINTPTR oldFiles);
|
||||||
extern UINT32 OsExecStart(const TSK_ENTRY_FUNC entry, UINTPTR sp, UINTPTR mapBase, UINT32 mapSize);
|
extern UINT32 OsExecStart(const TSK_ENTRY_FUNC entry, UINTPTR sp, UINTPTR mapBase, UINT32 mapSize);
|
||||||
extern UINT32 OsSetProcessName(LosProcessCB *processCB, const CHAR *name);
|
extern UINT32 OsSetProcessName(LosProcessCB *processCB, const CHAR *name);
|
||||||
extern INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 policy, const LosSchedParam *param);
|
extern INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio, UINT16 policy);
|
||||||
extern INT32 OsGetProcessPriority(INT32 which, INT32 pid);
|
extern INT32 OsGetProcessPriority(INT32 which, INT32 pid);
|
||||||
extern LosProcessCB *OsGetUserInitProcess(VOID);
|
extern UINT32 OsGetUserInitProcessID(VOID);
|
||||||
extern LosProcessCB *OsGetIdleProcess(VOID);
|
extern UINT32 OsGetIdleProcessID(VOID);
|
||||||
extern INT32 OsSetProcessGroupID(UINT32 pid, UINT32 gid);
|
extern INT32 OsSetProcessGroupID(UINT32 pid, UINT32 gid);
|
||||||
extern INT32 OsSetCurrProcessGroupID(UINT32 gid);
|
extern INT32 OsSetCurrProcessGroupID(UINT32 gid);
|
||||||
extern LosProcessCB *OsGetKernelInitProcess(VOID);
|
extern UINT32 OsGetKernelInitProcessID(VOID);
|
||||||
extern VOID OsSetSigHandler(UINTPTR addr);
|
extern VOID OsSetSigHandler(UINTPTR addr);
|
||||||
extern UINTPTR OsGetSigHandler(VOID);
|
extern UINTPTR OsGetSigHandler(VOID);
|
||||||
extern VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID);
|
extern VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID);
|
||||||
extern INT32 OsSendSignalToProcessGroup(INT32 pid, siginfo_t *info, INT32 permission);
|
extern INT32 OsSendSignalToProcessGroup(INT32 pid, siginfo_t *info, INT32 permission);
|
||||||
extern INT32 OsSendSignalToAllProcess(siginfo_t *info, INT32 permission);
|
extern INT32 OsSendSignalToAllProcess(siginfo_t *info, INT32 permission);
|
||||||
extern UINT32 OsProcessAddNewTask(UINTPTR processID, LosTaskCB *taskCB, SchedParam *param, UINT32 *numCount);
|
extern UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB, SchedParam *param);
|
||||||
extern VOID OsDeleteTaskFromProcess(LosTaskCB *taskCB);
|
extern VOID OsDeleteTaskFromProcess(LosTaskCB *taskCB);
|
||||||
extern VOID OsProcessThreadGroupDestroy(VOID);
|
extern VOID OsProcessThreadGroupDestroy(VOID);
|
||||||
extern UINT32 OsGetProcessGroupCB(UINT32 pid, UINTPTR *ppgroupLeader);
|
|
||||||
extern LosProcessCB *OsGetDefaultProcessCB(VOID);
|
|
||||||
extern ProcessGroup *OsCreateProcessGroup(LosProcessCB *processCB);
|
|
||||||
INT32 OsSchedulerParamCheck(UINT16 policy, BOOL isThread, const LosSchedParam *param);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ typedef enum {
|
||||||
* @ingroup los_queue
|
* @ingroup los_queue
|
||||||
* Queue information block structure
|
* Queue information block structure
|
||||||
*/
|
*/
|
||||||
typedef struct TagQueueCB {
|
typedef struct {
|
||||||
UINT8 *queueHandle; /**< Pointer to a queue handle */
|
UINT8 *queueHandle; /**< Pointer to a queue handle */
|
||||||
UINT16 queueState; /**< Queue state */
|
UINT16 queueState; /**< Queue state */
|
||||||
UINT16 queueLen; /**< Queue length */
|
UINT16 queueLen; /**< Queue length */
|
||||||
|
@ -108,9 +108,6 @@ typedef struct TagQueueCB {
|
||||||
* Queue information control block
|
* Queue information control block
|
||||||
*/
|
*/
|
||||||
extern LosQueueCB *g_allQueue;
|
extern LosQueueCB *g_allQueue;
|
||||||
#ifndef LOSCFG_IPC_CONTAINER
|
|
||||||
#define IPC_ALL_QUEUE g_allQueue
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_queue
|
* @ingroup los_queue
|
||||||
|
@ -140,7 +137,7 @@ extern LosQueueCB *g_allQueue;
|
||||||
* Obtain a handle of the queue that has a specified ID.
|
* Obtain a handle of the queue that has a specified ID.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define GET_QUEUE_HANDLE(queueID) (((LosQueueCB *)IPC_ALL_QUEUE) + GET_QUEUE_INDEX(queueID))
|
#define GET_QUEUE_HANDLE(queueID) (((LosQueueCB *)g_allQueue) + GET_QUEUE_INDEX(queueID))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_queue
|
* @ingroup los_queue
|
||||||
|
@ -199,8 +196,6 @@ extern VOID *OsQueueMailAlloc(UINT32 queueID, VOID *mailPool, UINT32 timeout);
|
||||||
*/
|
*/
|
||||||
extern UINT32 OsQueueMailFree(UINT32 queueID, VOID *mailPool, VOID *mailMem);
|
extern UINT32 OsQueueMailFree(UINT32 queueID, VOID *mailPool, VOID *mailMem);
|
||||||
|
|
||||||
extern LosQueueCB *OsAllQueueCBInit(LOS_DL_LIST *freeQueueList);
|
|
||||||
|
|
||||||
extern UINT32 OsQueueInit(VOID);
|
extern UINT32 OsQueueInit(VOID);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -52,9 +52,6 @@
|
||||||
#include "hm_liteipc.h"
|
#include "hm_liteipc.h"
|
||||||
#endif
|
#endif
|
||||||
#include "los_mp.h"
|
#include "los_mp.h"
|
||||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
|
||||||
#include "los_container_pri.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
@ -68,10 +65,6 @@ extern "C" {
|
||||||
#define OS_SCHED_TICK_TO_CYCLE(ticks) ((UINT64)ticks * OS_CYCLE_PER_TICK)
|
#define OS_SCHED_TICK_TO_CYCLE(ticks) ((UINT64)ticks * OS_CYCLE_PER_TICK)
|
||||||
#define AFFI_MASK_TO_CPUID(mask) ((UINT16)((mask) - 1))
|
#define AFFI_MASK_TO_CPUID(mask) ((UINT16)((mask) - 1))
|
||||||
|
|
||||||
#define OS_SCHED_EDF_MIN_RUNTIME 100 /* 100 us */
|
|
||||||
#define OS_SCHED_EDF_MIN_DEADLINE 400 /* 400 us */
|
|
||||||
#define OS_SCHED_EDF_MAX_DEADLINE 5000000 /* 5 s */
|
|
||||||
|
|
||||||
extern UINT32 g_taskScheduled;
|
extern UINT32 g_taskScheduled;
|
||||||
#define OS_SCHEDULER_ACTIVE (g_taskScheduled & (1U << ArchCurrCpuid()))
|
#define OS_SCHEDULER_ACTIVE (g_taskScheduled & (1U << ArchCurrCpuid()))
|
||||||
#define OS_SCHEDULER_ALL_ACTIVE (g_taskScheduled == LOSCFG_KERNEL_CPU_MASK)
|
#define OS_SCHEDULER_ALL_ACTIVE (g_taskScheduled == LOSCFG_KERNEL_CPU_MASK)
|
||||||
|
@ -102,19 +95,12 @@ typedef struct {
|
||||||
UINT32 queueBitmap;
|
UINT32 queueBitmap;
|
||||||
} HPFRunqueue;
|
} HPFRunqueue;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
LOS_DL_LIST root;
|
|
||||||
LOS_DL_LIST waitList;
|
|
||||||
UINT64 period;
|
|
||||||
} EDFRunqueue;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SortLinkAttribute timeoutQueue; /* task timeout queue */
|
SortLinkAttribute timeoutQueue; /* task timeout queue */
|
||||||
HPFRunqueue *hpfRunqueue;
|
HPFRunqueue *hpfRunqueue;
|
||||||
EDFRunqueue *edfRunqueue;
|
|
||||||
UINT64 responseTime; /* Response time for current CPU tick interrupts */
|
UINT64 responseTime; /* Response time for current CPU tick interrupts */
|
||||||
UINT32 responseID; /* The response ID of the current CPU tick interrupt */
|
UINT32 responseID; /* The response ID of the current CPU tick interrupt */
|
||||||
LosTaskCB *idleTask; /* idle task id */
|
UINT32 idleTaskID; /* idle task id */
|
||||||
UINT32 taskLockCnt; /* task lock flag */
|
UINT32 taskLockCnt; /* task lock flag */
|
||||||
UINT32 schedFlag; /* pending scheduler flag */
|
UINT32 schedFlag; /* pending scheduler flag */
|
||||||
} SchedRunqueue;
|
} SchedRunqueue;
|
||||||
|
@ -213,9 +199,9 @@ STATIC INLINE BOOL OsPreemptableInSched(VOID)
|
||||||
return preemptible;
|
return preemptible;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE LosTaskCB *OsSchedRunqueueIdleGet(VOID)
|
STATIC INLINE UINT32 OsSchedRunqueueIdleGet(VOID)
|
||||||
{
|
{
|
||||||
return OsSchedRunqueue()->idleTask;
|
return OsSchedRunqueue()->idleTaskID;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE VOID OsSchedRunqueuePendingSet(VOID)
|
STATIC INLINE VOID OsSchedRunqueuePendingSet(VOID)
|
||||||
|
@ -223,52 +209,30 @@ STATIC INLINE VOID OsSchedRunqueuePendingSet(VOID)
|
||||||
OsSchedRunqueue()->schedFlag |= INT_PEND_RESCH;
|
OsSchedRunqueue()->schedFlag |= INT_PEND_RESCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOS_SCHED_NORMAL 0U
|
#define LOS_SCHED_NORMAL 0U
|
||||||
#define LOS_SCHED_FIFO 1U
|
#define LOS_SCHED_FIFO 1U
|
||||||
#define LOS_SCHED_RR 2U
|
#define LOS_SCHED_RR 2U
|
||||||
#define LOS_SCHED_IDLE 3U
|
#define LOS_SCHED_IDLE 3U
|
||||||
#define LOS_SCHED_DEADLINE 6U
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT16 policy;
|
UINT16 policy;
|
||||||
/* HPF scheduling parameters */
|
|
||||||
UINT16 basePrio;
|
UINT16 basePrio;
|
||||||
UINT16 priority;
|
UINT16 priority;
|
||||||
UINT32 timeSlice;
|
UINT32 timeSlice;
|
||||||
|
|
||||||
/* EDF scheduling parameters */
|
|
||||||
INT32 runTimeUs;
|
|
||||||
UINT32 deadlineUs;
|
|
||||||
UINT32 periodUs;
|
|
||||||
} SchedParam;
|
} SchedParam;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT16 policy; /* This field must be present for all scheduling policies and must be the first in the structure */
|
UINT16 policy; /* This field must be present for all scheduling policies and must be the first in the structure */
|
||||||
UINT16 basePrio;
|
UINT16 basePrio;
|
||||||
UINT16 priority;
|
UINT16 priority;
|
||||||
UINT32 initTimeSlice; /* cycle */
|
UINT32 initTimeSlice;
|
||||||
UINT32 priBitmap; /* Bitmap for recording the change of task priority, the priority can not be greater than 31 */
|
UINT32 priBitmap; /**< Bitmap for recording the change of task priority, the priority can not be greater than 31 */
|
||||||
} SchedHPF;
|
} SchedHPF;
|
||||||
|
|
||||||
#define EDF_UNUSED 0
|
|
||||||
#define EDF_NEXT_PERIOD 1
|
|
||||||
#define EDF_WAIT_FOREVER 2
|
|
||||||
#define EDF_INIT 3
|
|
||||||
typedef struct {
|
|
||||||
UINT16 policy;
|
|
||||||
UINT16 cpuid;
|
|
||||||
UINT32 flags;
|
|
||||||
INT32 runTime; /* cycle */
|
|
||||||
UINT64 deadline; /* deadline >> runTime */
|
|
||||||
UINT64 period; /* period >= deadline */
|
|
||||||
UINT64 finishTime; /* startTime + deadline */
|
|
||||||
} SchedEDF;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
SchedEDF edf;
|
|
||||||
SchedHPF hpf;
|
SchedHPF hpf;
|
||||||
};
|
} Policy;
|
||||||
} SchedPolicy;
|
} SchedPolicy;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -276,7 +240,6 @@ typedef struct {
|
||||||
VOID (*enqueue)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
VOID (*enqueue)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||||
VOID (*start)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
VOID (*start)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||||
VOID (*exit)(LosTaskCB *taskCB);
|
VOID (*exit)(LosTaskCB *taskCB);
|
||||||
UINT64 (*waitTimeGet)(LosTaskCB *taskCB);
|
|
||||||
UINT32 (*wait)(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 timeout);
|
UINT32 (*wait)(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 timeout);
|
||||||
VOID (*wake)(LosTaskCB *taskCB);
|
VOID (*wake)(LosTaskCB *taskCB);
|
||||||
BOOL (*schedParamModify)(LosTaskCB *taskCB, const SchedParam *param);
|
BOOL (*schedParamModify)(LosTaskCB *taskCB, const SchedParam *param);
|
||||||
|
@ -446,7 +409,7 @@ typedef struct TagTaskCB {
|
||||||
UINT32 userMapSize; /**< user thread stack size ,real size : userMapSize + USER_STACK_MIN_SIZE */
|
UINT32 userMapSize; /**< user thread stack size ,real size : userMapSize + USER_STACK_MIN_SIZE */
|
||||||
FutexNode futex;
|
FutexNode futex;
|
||||||
#endif
|
#endif
|
||||||
UINTPTR processCB; /**< Which belong process */
|
UINT32 processID; /**< Which belong process */
|
||||||
LOS_DL_LIST joinList; /**< join list */
|
LOS_DL_LIST joinList; /**< join list */
|
||||||
LOS_DL_LIST lockList; /**< Hold the lock list */
|
LOS_DL_LIST lockList; /**< Hold the lock list */
|
||||||
UINTPTR waitID; /**< Wait for the PID or GID of the child process */
|
UINTPTR waitID; /**< Wait for the PID or GID of the child process */
|
||||||
|
@ -459,12 +422,6 @@ typedef struct TagTaskCB {
|
||||||
UINTPTR pc;
|
UINTPTR pc;
|
||||||
UINTPTR fp;
|
UINTPTR fp;
|
||||||
#endif
|
#endif
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
PidContainer *pidContainer;
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_IPC_CONTAINER
|
|
||||||
BOOL cloneIpc;
|
|
||||||
#endif
|
|
||||||
} LosTaskCB;
|
} LosTaskCB;
|
||||||
|
|
||||||
STATIC INLINE BOOL OsTaskIsRunning(const LosTaskCB *taskCB)
|
STATIC INLINE BOOL OsTaskIsRunning(const LosTaskCB *taskCB)
|
||||||
|
@ -497,12 +454,6 @@ STATIC INLINE BOOL OsTaskIsBlocked(const LosTaskCB *taskCB)
|
||||||
return ((taskCB->taskStatus & (OS_TASK_STATUS_SUSPENDED | OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY)) != 0);
|
return ((taskCB->taskStatus & (OS_TASK_STATUS_SUSPENDED | OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY)) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE BOOL OsSchedPolicyIsEDF(const LosTaskCB *taskCB)
|
|
||||||
{
|
|
||||||
const SchedEDF *sched = (const SchedEDF *)&taskCB->sp;
|
|
||||||
return (sched->policy == LOS_SCHED_DEADLINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
|
STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
|
||||||
{
|
{
|
||||||
return (LosTaskCB *)ArchCurrTaskGet();
|
return (LosTaskCB *)ArchCurrTaskGet();
|
||||||
|
@ -659,20 +610,6 @@ STATIC INLINE VOID SchedTaskUnfreeze(LosTaskCB *taskCB)
|
||||||
g_taskScheduled &= ~(1U << (cpuid)); \
|
g_taskScheduled &= ~(1U << (cpuid)); \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
|
||||||
BOOL OsSchedLimitCheckTime(LosTaskCB *task);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
STATIC INLINE LosTaskCB *EDFRunqueueTopTaskGet(EDFRunqueue *rq)
|
|
||||||
{
|
|
||||||
LOS_DL_LIST *root = &rq->root;
|
|
||||||
if (LOS_ListEmpty(root)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return LOS_DL_LIST_ENTRY(LOS_DL_LIST_FIRST(root), LosTaskCB, pendList);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
|
STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
|
||||||
{
|
{
|
||||||
LosTaskCB *newTask = NULL;
|
LosTaskCB *newTask = NULL;
|
||||||
|
@ -688,12 +625,6 @@ STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
|
||||||
while (bitmap) {
|
while (bitmap) {
|
||||||
UINT32 priority = CLZ(bitmap);
|
UINT32 priority = CLZ(bitmap);
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY(newTask, &queueList->priQueList[priority], LosTaskCB, pendList) {
|
LOS_DL_LIST_FOR_EACH_ENTRY(newTask, &queueList->priQueList[priority], LosTaskCB, pendList) {
|
||||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
|
||||||
if (!OsSchedLimitCheckTime(newTask)) {
|
|
||||||
bitmap &= ~(1U << (OS_PRIORITY_QUEUE_NUM - priority - 1));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef LOSCFG_KERNEL_SMP
|
#ifdef LOSCFG_KERNEL_SMP
|
||||||
if (newTask->cpuAffiMask & (1U << cpuid)) {
|
if (newTask->cpuAffiMask & (1U << cpuid)) {
|
||||||
#endif
|
#endif
|
||||||
|
@ -710,16 +641,9 @@ STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID EDFProcessDefaultSchedParamGet(SchedParam *param);
|
|
||||||
VOID EDFSchedPolicyInit(SchedRunqueue *rq);
|
|
||||||
UINT32 EDFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
|
||||||
const SchedParam *parentParam,
|
|
||||||
const LosSchedParam *param);
|
|
||||||
|
|
||||||
VOID HPFSchedPolicyInit(SchedRunqueue *rq);
|
VOID HPFSchedPolicyInit(SchedRunqueue *rq);
|
||||||
VOID HPFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
VOID HPFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||||
const SchedParam *parentParam,
|
const SchedParam *parentParam, const TSK_INIT_PARAM_S *param);
|
||||||
const LosSchedParam *param);
|
|
||||||
VOID HPFProcessDefaultSchedParamGet(SchedParam *param);
|
VOID HPFProcessDefaultSchedParamGet(SchedParam *param);
|
||||||
|
|
||||||
VOID IdleTaskSchedParamInit(LosTaskCB *taskCB);
|
VOID IdleTaskSchedParamInit(LosTaskCB *taskCB);
|
||||||
|
@ -727,8 +651,7 @@ VOID IdleTaskSchedParamInit(LosTaskCB *taskCB);
|
||||||
INT32 OsSchedParamCompare(const LosTaskCB *task1, const LosTaskCB *task2);
|
INT32 OsSchedParamCompare(const LosTaskCB *task1, const LosTaskCB *task2);
|
||||||
VOID OsSchedPriorityInheritance(LosTaskCB *owner, const SchedParam *param);
|
VOID OsSchedPriorityInheritance(LosTaskCB *owner, const SchedParam *param);
|
||||||
UINT32 OsSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
UINT32 OsSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||||
const SchedParam *parentParam,
|
const SchedParam *parentParam, const TSK_INIT_PARAM_S *param);
|
||||||
const LosSchedParam *param);
|
|
||||||
VOID OsSchedProcessDefaultSchedParamGet(UINT16 policy, SchedParam *param);
|
VOID OsSchedProcessDefaultSchedParamGet(UINT16 policy, SchedParam *param);
|
||||||
|
|
||||||
VOID OsSchedResponseTimeReset(UINT64 responseTime);
|
VOID OsSchedResponseTimeReset(UINT64 responseTime);
|
||||||
|
@ -737,7 +660,7 @@ VOID OsSchedTick(VOID);
|
||||||
UINT32 OsSchedInit(VOID);
|
UINT32 OsSchedInit(VOID);
|
||||||
VOID OsSchedStart(VOID);
|
VOID OsSchedStart(VOID);
|
||||||
|
|
||||||
VOID OsSchedRunqueueIdleInit(LosTaskCB *idleTask);
|
VOID OsSchedRunqueueIdleInit(UINT32 idleTaskID);
|
||||||
VOID OsSchedRunqueueInit(VOID);
|
VOID OsSchedRunqueueInit(VOID);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -151,8 +151,6 @@ typedef struct {
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
} sig_cb;
|
} sig_cb;
|
||||||
|
|
||||||
typedef struct ProcessCB LosProcessCB;
|
|
||||||
|
|
||||||
#define SIGEV_THREAD_ID 4
|
#define SIGEV_THREAD_ID 4
|
||||||
|
|
||||||
int sys_sigqueue(pid_t, int, const union sigval);
|
int sys_sigqueue(pid_t, int, const union sigval);
|
||||||
|
@ -167,7 +165,6 @@ int OsSigEmptySet(sigset_t *);
|
||||||
int OsSigAddSet(sigset_t *, int);
|
int OsSigAddSet(sigset_t *, int);
|
||||||
int OsSigIsMember(const sigset_t *, int);
|
int OsSigIsMember(const sigset_t *, int);
|
||||||
int OsKill(pid_t pid, int sig, int permission);
|
int OsKill(pid_t pid, int sig, int permission);
|
||||||
int OsSendSigToProcess(LosProcessCB *spcb, int sig, int permission);
|
|
||||||
int OsDispatch(pid_t pid, siginfo_t *info, int permission);
|
int OsDispatch(pid_t pid, siginfo_t *info, int permission);
|
||||||
int OsSigTimedWait(sigset_t *set, siginfo_t *info, unsigned int timeout);
|
int OsSigTimedWait(sigset_t *set, siginfo_t *info, unsigned int timeout);
|
||||||
int OsPause(void);
|
int OsPause(void);
|
||||||
|
|
|
@ -57,11 +57,9 @@ typedef struct {
|
||||||
#ifdef LOSCFG_SCHED_TICK_DEBUG
|
#ifdef LOSCFG_SCHED_TICK_DEBUG
|
||||||
VOID OsSchedDebugRecordData(VOID);
|
VOID OsSchedDebugRecordData(VOID);
|
||||||
UINT32 OsShellShowTickResponse(VOID);
|
UINT32 OsShellShowTickResponse(VOID);
|
||||||
|
UINT32 OsShellShowSchedStatistics(VOID);
|
||||||
UINT32 OsSchedDebugInit(VOID);
|
UINT32 OsSchedDebugInit(VOID);
|
||||||
#endif
|
#endif
|
||||||
UINT32 OsShellShowSchedStatistics(VOID);
|
|
||||||
UINT32 OsShellShowEdfSchedStatistics(VOID);
|
|
||||||
VOID EDFDebugRecord(UINTPTR *taskCB, UINT64 oldFinish);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -108,7 +108,7 @@ extern UINT32 OsSwtmrGetNextTimeout(VOID);
|
||||||
extern BOOL OsIsSwtmrTask(const LosTaskCB *taskCB);
|
extern BOOL OsIsSwtmrTask(const LosTaskCB *taskCB);
|
||||||
extern VOID OsSwtmrResponseTimeReset(UINT64 startTime);
|
extern VOID OsSwtmrResponseTimeReset(UINT64 startTime);
|
||||||
extern UINT32 OsSwtmrInit(VOID);
|
extern UINT32 OsSwtmrInit(VOID);
|
||||||
extern VOID OsSwtmrRecycle(UINTPTR ownerID);
|
extern VOID OsSwtmrRecycle(UINT32 processID);
|
||||||
extern BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
|
extern BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
|
||||||
extern SPIN_LOCK_S g_swtmrSpin;
|
extern SPIN_LOCK_S g_swtmrSpin;
|
||||||
extern UINT32 OsSwtmrTaskIDGetByCpuid(UINT16 cpuid);
|
extern UINT32 OsSwtmrTaskIDGetByCpuid(UINT16 cpuid);
|
||||||
|
|
|
@ -101,16 +101,6 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define OS_NS_PER_TICK (OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
|
#define OS_NS_PER_TICK (OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
|
||||||
|
|
||||||
#define OS_US_TO_CYCLE(time, freq) ((((time) / OS_SYS_US_PER_SECOND) * (freq)) + \
|
|
||||||
(((time) % OS_SYS_US_PER_SECOND) * (freq) / OS_SYS_US_PER_SECOND))
|
|
||||||
|
|
||||||
#define OS_SYS_US_TO_CYCLE(time) OS_US_TO_CYCLE((time), OS_SYS_CLOCK)
|
|
||||||
|
|
||||||
#define OS_CYCLE_TO_US(cycle, freq) ((((cycle) / (freq)) * OS_SYS_US_PER_SECOND) + \
|
|
||||||
((cycle) % (freq) * OS_SYS_US_PER_SECOND / (freq)))
|
|
||||||
|
|
||||||
#define OS_SYS_CYCLE_TO_US(cycle) OS_CYCLE_TO_US((cycle), OS_SYS_CLOCK)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_sys
|
* @ingroup los_sys
|
||||||
* The maximum length of name.
|
* The maximum length of name.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
|
@ -54,7 +54,6 @@ extern "C" {
|
||||||
|
|
||||||
/* scheduler lock */
|
/* scheduler lock */
|
||||||
extern SPIN_LOCK_S g_taskSpin;
|
extern SPIN_LOCK_S g_taskSpin;
|
||||||
#define SCHEDULER_HELD() LOS_SpinHeld(&g_taskSpin)
|
|
||||||
#define SCHEDULER_LOCK(state) LOS_SpinLockSave(&g_taskSpin, &(state))
|
#define SCHEDULER_LOCK(state) LOS_SpinLockSave(&g_taskSpin, &(state))
|
||||||
#define SCHEDULER_UNLOCK(state) LOS_SpinUnlockRestore(&g_taskSpin, state)
|
#define SCHEDULER_UNLOCK(state) LOS_SpinUnlockRestore(&g_taskSpin, state)
|
||||||
|
|
||||||
|
@ -193,12 +192,7 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||||
* <ul><li>los_task_pri.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_task_pri.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see
|
* @see
|
||||||
*/
|
*/
|
||||||
#define OS_TCB_FROM_RTID(taskID) (((LosTaskCB *)g_taskCBArray) + (taskID))
|
#define OS_TCB_FROM_TID(taskID) (((LosTaskCB *)g_taskCBArray) + (taskID))
|
||||||
#ifdef LOSCFG_PID_CONTAINER
|
|
||||||
#define OS_TCB_FROM_TID(taskID) OsGetTCBFromVtid(taskID)
|
|
||||||
#else
|
|
||||||
#define OS_TCB_FROM_TID(taskID) OS_TCB_FROM_RTID(taskID)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef LOSCFG_STACK_POINT_ALIGN_SIZE
|
#ifndef LOSCFG_STACK_POINT_ALIGN_SIZE
|
||||||
#define LOSCFG_STACK_POINT_ALIGN_SIZE (sizeof(UINTPTR) * 2)
|
#define LOSCFG_STACK_POINT_ALIGN_SIZE (sizeof(UINTPTR) * 2)
|
||||||
|
@ -261,12 +255,7 @@ STATIC INLINE BOOL OsTaskIsUnused(const LosTaskCB *taskCB)
|
||||||
|
|
||||||
STATIC INLINE BOOL OsTaskIsKilled(const LosTaskCB *taskCB)
|
STATIC INLINE BOOL OsTaskIsKilled(const LosTaskCB *taskCB)
|
||||||
{
|
{
|
||||||
return((taskCB->taskStatus & OS_TASK_FLAG_EXIT_KILL) != 0);
|
return ((taskCB->taskStatus & OS_TASK_FLAG_EXIT_KILL) != 0);
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE BOOL OsTaskIsNotDelete(const LosTaskCB *taskCB)
|
|
||||||
{
|
|
||||||
return ((taskCB->taskStatus & (OS_TASK_STATUS_UNUSED | OS_TASK_FLAG_SYSTEM_TASK | OS_TASK_FLAG_NO_DELETE)) != 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE BOOL OsTaskIsUserMode(const LosTaskCB *taskCB)
|
STATIC INLINE BOOL OsTaskIsUserMode(const LosTaskCB *taskCB)
|
||||||
|
@ -313,8 +302,8 @@ extern BOOL OsTaskCpuAffiSetUnsafe(UINT32 taskID, UINT16 newCpuAffiMask, UINT16
|
||||||
extern VOID OsTaskSchedule(LosTaskCB *, LosTaskCB *);
|
extern VOID OsTaskSchedule(LosTaskCB *, LosTaskCB *);
|
||||||
extern VOID OsTaskContextLoad(LosTaskCB *newTask);
|
extern VOID OsTaskContextLoad(LosTaskCB *newTask);
|
||||||
extern VOID OsIdleTask(VOID);
|
extern VOID OsIdleTask(VOID);
|
||||||
extern UINT32 OsIdleTaskCreate(UINTPTR processID);
|
extern UINT32 OsIdleTaskCreate(VOID);
|
||||||
extern UINT32 OsTaskInit(UINTPTR processCB);
|
extern UINT32 OsTaskInit(VOID);
|
||||||
extern UINT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv);
|
extern UINT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv);
|
||||||
extern UINT32 OsShellCmdTskInfoGet(UINT32 taskID, VOID *seqfile, UINT16 flag);
|
extern UINT32 OsShellCmdTskInfoGet(UINT32 taskID, VOID *seqfile, UINT16 flag);
|
||||||
extern LosTaskCB *OsGetMainTask(VOID);
|
extern LosTaskCB *OsGetMainTask(VOID);
|
||||||
|
@ -322,20 +311,18 @@ extern VOID OsSetMainTask(VOID);
|
||||||
extern UINT32 OsGetIdleTaskId(VOID);
|
extern UINT32 OsGetIdleTaskId(VOID);
|
||||||
extern VOID OsTaskEntry(UINT32 taskID);
|
extern VOID OsTaskEntry(UINT32 taskID);
|
||||||
extern VOID OsTaskProcSignal(VOID);
|
extern VOID OsTaskProcSignal(VOID);
|
||||||
extern UINT32 OsCreateUserTask(UINTPTR processID, TSK_INIT_PARAM_S *initParam);
|
extern UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S *initParam);
|
||||||
extern INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL setPName);
|
extern INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL setPName);
|
||||||
extern VOID OsTaskCBRecycleToFree(VOID);
|
extern VOID OsTaskCBRecycleToFree(VOID);
|
||||||
extern VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status);
|
extern VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status);
|
||||||
extern INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB);
|
extern INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB);
|
||||||
extern INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINTPTR processCB);
|
extern INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINT32 processID);
|
||||||
extern INT32 OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info);
|
extern INT32 OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info);
|
||||||
extern VOID OsWriteResourceEvent(UINT32 events);
|
extern VOID OsWriteResourceEvent(UINT32 events);
|
||||||
extern VOID OsWriteResourceEventUnsafe(UINT32 events);
|
extern VOID OsWriteResourceEventUnsafe(UINT32 events);
|
||||||
extern UINT32 OsResourceFreeTaskCreate(VOID);
|
extern UINT32 OsResourceFreeTaskCreate(VOID);
|
||||||
extern VOID OsTaskInsertToRecycleList(LosTaskCB *taskCB);
|
extern VOID OsTaskInsertToRecycleList(LosTaskCB *taskCB);
|
||||||
extern VOID OsInactiveTaskDelete(LosTaskCB *taskCB);
|
extern VOID OsInactiveTaskDelete(LosTaskCB *taskCB);
|
||||||
extern VOID OsSetMainTaskProcess(UINTPTR processCB);
|
|
||||||
extern LosTaskCB *OsGetDefaultTaskCB(VOID);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue