diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2016-07-14 14:54:21 +0300 |
---|---|---|
committer | Sergey Bugaev <bugaevc@gmail.com> | 2016-07-14 14:54:21 +0300 |
commit | 8f6b162fb189d092afc7e6a6162e00d5d5332f4a (patch) | |
tree | e1479b9e8bbc6286f71cb21c77112b42800eab44 /src/sys | |
parent | f682458c829e6d715cabd9e8ef6730ff05567966 (diff) | |
download | nix-8f6b162fb189d092afc7e6a6162e00d5d5332f4a.zip |
Revert "Manually match on RebootMode::*"
This reverts commit 012c6623c9c50aca91b81e6d30800613f515f898.
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/reboot.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/sys/reboot.rs b/src/sys/reboot.rs index 81502d01..d593ee78 100644 --- a/src/sys/reboot.rs +++ b/src/sys/reboot.rs @@ -9,27 +9,20 @@ use std::mem::drop; /// /// See [`set_cad_enabled()`](fn.set_cad_enabled.html) for /// enabling/disabling Ctrl-Alt-Delete. +#[repr(i32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum RebootMode { - Halt, - kexec, - PowerOff, - Restart, + Halt = libc::RB_HALT_SYSTEM, + kexec = libc::RB_KEXEC, + PowerOff = libc::RB_POWER_OFF, + Restart = libc::RB_AUTOBOOT, // we do not support Restart2, - Suspend, + Suspend = libc::RB_SW_SUSPEND, } pub fn reboot(how: RebootMode) -> Result<Void> { - let cmd = match how { - RebootMode::Halt => libc::RB_HALT_SYSTEM, - RebootMode::kexec => libc::RB_KEXEC, - RebootMode::PowerOff => libc::RB_POWER_OFF, - RebootMode::Restart => libc::RB_AUTOBOOT, - // we do not support Restart2, - RebootMode::Suspend => libc::RB_SW_SUSPEND, - }; unsafe { - libc::reboot(cmd) + libc::reboot(how as libc::c_int) }; Err(Error::Sys(Errno::last())) } |