-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some functions and modularize
thread
(#129)
* Add some functions * Modularize rwlock * Modularize mutex * Reorder and format * Modularize once * Use atomic for spinlock * Write `eaccess` in terms of `euidaccess`
- Loading branch information
1 parent
593322f
commit 7cac7ff
Showing
14 changed files
with
727 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use errno::{set_errno, Errno}; | ||
use libc::c_int; | ||
|
||
use crate::convert_res; | ||
|
||
#[no_mangle] | ||
unsafe extern "C" fn reboot(cmd: c_int) -> c_int { | ||
libc!(libc::reboot(cmd)); | ||
|
||
let arg = match cmd { | ||
libc::LINUX_REBOOT_CMD_CAD_OFF => rustix::system::RebootCommand::CadOff, | ||
libc::LINUX_REBOOT_CMD_CAD_ON => rustix::system::RebootCommand::CadOn, | ||
libc::LINUX_REBOOT_CMD_HALT => rustix::system::RebootCommand::Halt, | ||
libc::LINUX_REBOOT_CMD_KEXEC => rustix::system::RebootCommand::Kexec, | ||
libc::LINUX_REBOOT_CMD_POWER_OFF => rustix::system::RebootCommand::PowerOff, | ||
libc::LINUX_REBOOT_CMD_RESTART => rustix::system::RebootCommand::Restart, | ||
libc::LINUX_REBOOT_CMD_SW_SUSPEND => rustix::system::RebootCommand::SwSuspend, | ||
_ => { | ||
set_errno(Errno(libc::EINVAL)); | ||
return -1; | ||
} | ||
}; | ||
|
||
match convert_res(rustix::system::reboot(arg)) { | ||
Some(()) => 0, | ||
None => -1, | ||
} | ||
} |
Oops, something went wrong.