summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2016-07-13 10:38:59 +0300
committerSergey Bugaev <bugaevc@gmail.com>2016-07-13 10:38:59 +0300
commitb19afe56ab55cc2aa3d7e7937d33e4525d860e29 (patch)
treeff56ad6c9226401e666f89cc203e1e2babec9f42 /src
parentbf796cce6e73f6e5518c76e013ded7518ff14a61 (diff)
downloadnix-b19afe56ab55cc2aa3d7e7937d33e4525d860e29.zip
Use libc's declarations
Diffstat (limited to 'src')
-rw-r--r--src/sys/reboot.rs32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/sys/reboot.rs b/src/sys/reboot.rs
index 10abef91..82a31380 100644
--- a/src/sys/reboot.rs
+++ b/src/sys/reboot.rs
@@ -1,41 +1,37 @@
use {Errno, Error, Result};
-use libc::c_int;
+use libc;
use void::Void;
use std::mem::drop;
-#[allow(overflowing_literals)]
+#[repr(i32)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum RebootMode {
- Halt = 0xcdef0123,
- kexec = 0x45584543,
- PowerOff = 0x4321fedc,
- Restart = 0x1234567,
+ Halt = libc::RB_HALT_SYSTEM,
+ kexec = libc::RB_KEXEC,
+ PowerOff = libc::RB_POWER_OFF,
+ Restart = libc::RB_AUTOBOOT,
// we do not support Restart2,
- Suspend = 0xd000fce1,
+ Suspend = libc::RB_SW_SUSPEND,
}
pub fn reboot(how: RebootMode) -> Result<Void> {
unsafe {
- ext::reboot(how as c_int)
+ libc::reboot(how as libc::c_int)
};
Err(Error::Sys(Errno::last()))
}
-
/// Enable or disable the reboot keystroke (Ctrl-Alt-Delete).
///
/// Corresponds to calling `reboot(RB_ENABLE_CAD)` or `reboot(RB_DISABLE_CAD)` in C.
-#[allow(overflowing_literals)]
pub fn set_cad_enabled(enable: bool) -> Result<()> {
+ let cmd = if enable {
+ libc::RB_ENABLE_CAD
+ } else {
+ libc::RB_DISABLE_CAD
+ };
let res = unsafe {
- ext::reboot(if enable { 0x89abcdef } else { 0 })
+ libc::reboot(cmd)
};
Errno::result(res).map(drop)
}
-
-mod ext {
- use libc::c_int;
- extern {
- pub fn reboot(cmd: c_int) -> c_int;
- }
-}