diff options
author | Chirantan Ekbote <chirantan@chromium.org> | 2020-11-26 14:12:07 +0900 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2021-05-06 00:15:15 +0000 |
commit | e7155dda0a489d4aeb0d9527df7bcdb51f1589fb (patch) | |
tree | 9d9fa017f9ca3a7c410ddc68ba37a5ede04d4d3b | |
parent | 32b8bab08c5575cb6bd59a62ebfa7688cdd03d76 (diff) | |
download | flashrom-e7155dda0a489d4aeb0d9527df7bcdb51f1589fb.tar.gz flashrom-e7155dda0a489d4aeb0d9527df7bcdb51f1589fb.tar.bz2 flashrom-e7155dda0a489d4aeb0d9527df7bcdb51f1589fb.zip |
CHROMIUM: flashrom_tester: Drop nix dependency
We can just use the libc functions directly. This is exactly what nix
does anyway.
BUG=none
TEST=unit tests
BRANCH=none
Original-Change-Id: I45c02f0c71d164bd8f504fe2b8d3acd54e0d5704
Original-Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/2560393
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-by: Allen Webb <allenwebb@google.com>
Original-Commit-Queue: Allen Webb <allenwebb@google.com>
(cherry picked from commit 1ba7dbe83e01d270b6d8d597a079ea3bfeb2117e)
Change-Id: Iea61c65efb04da9cd0bc0bd85a34fc10912ea87b
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52889
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r-- | util/flashrom_tester/Cargo.toml | 2 | ||||
-rw-r--r-- | util/flashrom_tester/src/main.rs | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/util/flashrom_tester/Cargo.toml b/util/flashrom_tester/Cargo.toml index 0898d3c4..e7a58202 100644 --- a/util/flashrom_tester/Cargo.toml +++ b/util/flashrom_tester/Cargo.toml @@ -18,8 +18,8 @@ built = { version = "0.3", default-features = false, features = ["serialized_tim chrono = { version = "0.4", optional = true } clap = { version = "2.33", default-features = false, optional = true } flashrom = { path = "flashrom/" } +libc = "0.2" log = { version = "0.4", features = ["std"] } -nix = "0.14.1" rand = "0.6.4" serde_json = "1" sys-info = "0.5.7" diff --git a/util/flashrom_tester/src/main.rs b/util/flashrom_tester/src/main.rs index e589ee1e..80484d20 100644 --- a/util/flashrom_tester/src/main.rs +++ b/util/flashrom_tester/src/main.rs @@ -152,12 +152,11 @@ fn main() { /// Once a signal is trapped, the default behavior is restored (terminating /// the process) for future signals. fn handle_sigint() -> &'static AtomicBool { - use nix::libc::c_int; - use nix::sys::signal::{self, SigHandler, Signal}; + use libc::c_int; use std::sync::atomic::Ordering; unsafe { - let _ = signal::signal(Signal::SIGINT, SigHandler::Handler(sigint_handler)); + let _ = libc::signal(libc::SIGINT, sigint_handler as libc::sighandler_t); } static TERMINATE_FLAG: AtomicBool = AtomicBool::new(false); @@ -169,10 +168,17 @@ rendering your machine unbootable. Testing will end on completion of the current test, or press ^C again to exit immediately (possibly bricking your machine). "; - // Use raw write() because signal-safety is a very hard problem - let _ = nix::unistd::write(STDERR_FILENO, MESSAGE); + // Use raw write() because signal-safety is a very hard problem. Safe because this doesn't + // modify any memory. + let _ = unsafe { + libc::write( + STDERR_FILENO, + MESSAGE.as_ptr() as *const libc::c_void, + MESSAGE.len() as libc::size_t, + ) + }; unsafe { - let _ = signal::signal(Signal::SIGINT, SigHandler::SigDfl); + let _ = libc::signal(libc::SIGINT, libc::SIG_DFL); } TERMINATE_FLAG.store(true, Ordering::Release); } |