From d3b0a26aec1e70ae2c3cf3b33c441f1f75a6d02e Mon Sep 17 00:00:00 2001 From: longjin Date: Thu, 2 Jan 2025 22:28:40 +0800 Subject: [PATCH] fix: sys reboot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于dragonos修正了sys_reboot系统调用(对齐Linux),因此把novashell的reboot调整为跟DragonOS一致. --- src/shell/command/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/shell/command/mod.rs b/src/shell/command/mod.rs index 77b3fe9..02c266d 100644 --- a/src/shell/command/mod.rs +++ b/src/shell/command/mod.rs @@ -1,4 +1,5 @@ use help::Helper; +use libc::{reboot, LINUX_REBOOT_CMD_RESTART}; use std::collections::HashMap; use std::os::fd::{AsFd, AsRawFd}; use std::os::unix::process::CommandExt; @@ -169,7 +170,14 @@ impl BuildInCmd { fn shell_cmd_reboot(args: &Vec) -> Result<(), ExecuteErrorType> { if args.len() == 0 { - unsafe { libc::syscall(libc::SYS_reboot, 0, 0, 0, 0, 0, 0) }; + // 调用 reboot 系统调用 + unsafe { + let result = reboot(LINUX_REBOOT_CMD_RESTART); + if result == -1 { + eprintln!("Failed to reboot: {}", std::io::Error::last_os_error()); + return Err(ExecuteErrorType::ExecuteFailed); + } + } return Ok(()); } else { return Err(ExecuteErrorType::TooManyArguments);