os_version.c
2026/7/20小于 1 分钟附录源码附录
os_version.c
路径: kernel\source\os_version.c
功能: 提供 OneOS 版本和内核版本查询功能。在 Shell 模式下,通过 version 命令输出 ONEOS_VERSION 版本信息,方便开发者快速获取当前系统版本。
核心函数:
| 函数 | 说明 |
|---|---|
sh_query_oneos_version | Shell 命令处理函数,输出当前 OneOS 版本号 |
关键设计点:
- Shell 命令集成: 通过
SH_CMD_EXPORT(version, ...)将查询功能注册为 Shell 命令version - 条件编译: 仅在开启
OS_USING_SHELL时编译,避免额外代码开销
/**
* Copyright (c) 2020, China Mobile Communications Group Co.,Ltd.
* Licensed under the Apache License, Version 2.0...
* @file os_version.h
* @brief Query OneOS version and kernel version.
*/
#include <oneos_config.h>
#include <os_version.h>
#include <os_errno.h>
#include <os_types.h>
#include <os_util.h>
#ifdef OS_USING_SHELL
#include <shell.h>
static os_err_t sh_query_oneos_version(int32_t argc, char *const *argv)
{
OS_UNREFERENCE(argc);
OS_UNREFERENCE(argv);
os_kprintf("\r\n%s\r\n\r\n", ONEOS_VERSION);
return OS_SUCCESS;
}
SH_CMD_EXPORT(version, sh_query_oneos_version, "show oneos version");
#endif /* OS_USING_SHELL */