Skip to content

Commit d7d2136

Browse files
authored
fix: sys reboot (#54)
由于dragonos修正了sys_reboot系统调用(对齐Linux),因此把novashell的reboot调整为跟DragonOS一致.
1 parent feaebef commit d7d2136

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/shell/command/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use help::Helper;
2+
use libc::{reboot, LINUX_REBOOT_CMD_RESTART};
23
use std::collections::HashMap;
34
use std::os::fd::{AsFd, AsRawFd};
45
use std::os::unix::process::CommandExt;
@@ -169,7 +170,14 @@ impl BuildInCmd {
169170

170171
fn shell_cmd_reboot(args: &Vec<String>) -> Result<(), ExecuteErrorType> {
171172
if args.len() == 0 {
172-
unsafe { libc::syscall(libc::SYS_reboot, 0, 0, 0, 0, 0, 0) };
173+
// 调用 reboot 系统调用
174+
unsafe {
175+
let result = reboot(LINUX_REBOOT_CMD_RESTART);
176+
if result == -1 {
177+
eprintln!("Failed to reboot: {}", std::io::Error::last_os_error());
178+
return Err(ExecuteErrorType::ExecuteFailed);
179+
}
180+
}
173181
return Ok(());
174182
} else {
175183
return Err(ExecuteErrorType::TooManyArguments);

0 commit comments

Comments
 (0)