未验证 提交 e59c93e1 编写于 作者: O openharmony_ci 提交者: Gitee

!270 ramdisk增加基础的boybox和mksh,系统异常时可进入shell调试。

Merge pull request !270 from handy/0126
......@@ -14,4 +14,9 @@
declare_args() {
param_feature_watcher = true
param_test = false
if (defined(product_name) && product_name == "rk3568") {
boot_kernel_extended_cmdline =
"hardware=rk3568 default_boot_device=fe310000.sdhci"
}
}
......@@ -276,9 +276,11 @@ static int Mount(const char *source, const char *target, const char *fsType,
if (errno == EAGAIN) {
BEGET_LOGE("Mount %s to %s failed. try again", source, target);
continue;
} else {
break;
}
if (errno == EBUSY) {
rc = 0;
}
break;
}
return rc;
}
......
......@@ -87,6 +87,7 @@ void ReadConfig(void)
if (InUpdaterMode() == 0) {
ParseInitCfg(INIT_CONFIGURATION_FILE, NULL);
ReadFileInDir(OTHER_CFG_PATH, ".cfg", ParseInitCfg, NULL);
ReadFileInDir("/vendor/etc/init", ".cfg", ParseInitCfg, NULL);
} else {
ReadFileInDir("/etc", ".cfg", ParseInitCfg, NULL);
}
......
......@@ -33,10 +33,11 @@ int main(int argc, char * const argv[])
INIT_LOGE("Process id error %d!", getpid());
return 0;
}
LogInit();
if (isSecondStage == 0) {
SystemPrepare();
}
LogInit();
(void)AtlibInit();
SystemInit();
SystemExecuteRcs();
......
......@@ -121,8 +121,6 @@ void LogInit(void)
}
}
#ifndef DISABLE_INIT_TWO_STAGES
static char **GetRequiredDevices(Fstab fstab, int *requiredNum)
{
int num = 0;
......@@ -167,6 +165,9 @@ static void StartInitSecondStage(void)
{
const char *fstabFile = "/etc/fstab.required";
Fstab *fstab = NULL;
if (access(fstabFile, F_OK) != 0) {
fstabFile = "/system/etc/fstab.required";
}
INIT_ERROR_CHECK(access(fstabFile, F_OK) == 0, abort(), "Failed get fstab.required");
fstab = ReadFstabFromFile(fstabFile, false);
INIT_ERROR_CHECK(fstab != NULL, abort(), "Read fstab file \" %s \" failed\n", fstabFile);
......@@ -186,10 +187,13 @@ static void StartInitSecondStage(void)
// If mount required partitions failure.
// There is no necessary to continue.
// Just abort
INIT_LOGE("Mount requried partitions failed");
INIT_LOGE("Mount requried partitions failed; please check fstab file");
// Execute sh for debugging
execv("/bin/sh", NULL);
abort();
}
}
#ifndef DISABLE_INIT_TWO_STAGES
SwitchRoot("/usr");
// Execute init second stage
char * const args[] = {
......@@ -201,8 +205,8 @@ static void StartInitSecondStage(void)
INIT_LOGE("Failed to exec \"/bin/init\", err = %d", errno);
exit(-1);
}
}
#endif
}
void SystemPrepare(void)
{
......@@ -210,7 +214,6 @@ void SystemPrepare(void)
// Make sure init log always output to /dev/kmsg.
EnableDevKmsg();
CreateDeviceNode();
#ifndef DISABLE_INIT_TWO_STAGES
// Only ohos normal system support
// two stages of init.
// If we are in updater mode, only one stage of init,
......@@ -218,9 +221,6 @@ void SystemPrepare(void)
if (InUpdaterMode() == 0) {
StartInitSecondStage();
}
#else
INIT_LOGI("DISABLE_INIT_TWO_STAGES defined");
#endif
}
void SystemLoadSelinux(void)
......
......@@ -10,6 +10,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/startup/init_lite/begetd.gni")
import("//build/ohos.gni")
declare_args() {
......@@ -46,6 +47,10 @@ ohos_static_library("param_service") {
defines = [ "PARAM_SUPPORT_SAVE_PERSIST" ]
if (defined(boot_kernel_extended_cmdline)) {
defines += [ "BOOT_EXTENDED_CMDLINE=\"${boot_kernel_extended_cmdline}\"" ]
}
if (param_security == "selinux") {
sources += [ "adapter/param_selinux.c" ]
defines += [ "PARAM_SUPPORT_SELINUX" ]
......
......@@ -589,6 +589,7 @@ static int GetParamValueFromBuffer(const char *name, const char *buffer, char *v
static int LoadParamFromCmdLine(void)
{
int ret;
static const char *cmdLines[] = {
OHOS_BOOT"hardware",
OHOS_BOOT"bootgroup",
......@@ -611,7 +612,14 @@ static int LoadParamFromCmdLine(void)
return -1, "Failed to read file %s", PARAM_CMD_LINE);
for (size_t i = 0; i < ARRAY_LENGTH(cmdLines); i++) {
int ret = GetParamValueFromBuffer(cmdLines[i], data, value, PARAM_CONST_VALUE_LEN_MAX);
#ifdef BOOT_EXTENDED_CMDLINE
ret = GetParamValueFromBuffer(cmdLines[i], BOOT_EXTENDED_CMDLINE, value, PARAM_CONST_VALUE_LEN_MAX);
if (ret != 0) {
ret = GetParamValueFromBuffer(cmdLines[i], data, value, PARAM_CONST_VALUE_LEN_MAX);
}
#else
ret = GetParamValueFromBuffer(cmdLines[i], data, value, PARAM_CONST_VALUE_LEN_MAX);
#endif
if (ret == 0) {
PARAM_LOGV("Add param from cmdline %s %s", cmdLines[i], value);
ret = CheckParamName(cmdLines[i], 0);
......@@ -744,4 +752,4 @@ void DumpParametersAndTriggers(void)
if (GetTriggerWorkSpace() != NULL) {
DumpTrigger(GetTriggerWorkSpace());
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册