2018-12-14 10:10:15 -05:00
|
|
|
#[macro_use] extern crate failure;
|
|
|
|
#[macro_use] extern crate nix;
|
|
|
|
#[macro_use] extern crate serde_derive;
|
|
|
|
#[macro_use] extern crate lazy_static;
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! info {
|
|
|
|
($e:expr) => { if $crate::verbose() { println!("[+] {}", $e);} };
|
|
|
|
($fmt:expr, $($arg:tt)+) => { if $crate::verbose() { println!("[+] {}", format!($fmt, $($arg)+));} };
|
|
|
|
}
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! warn {
|
|
|
|
($e:expr) => { println!("WARNING: {}", $e); };
|
|
|
|
($fmt:expr, $($arg:tt)+) => { println!("WARNING: {}", format!($fmt, $($arg)+)); };
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! notify {
|
|
|
|
($e:expr) => { println!("[+] {}", $e); };
|
|
|
|
($fmt:expr, $($arg:tt)+) => { println!("[+] {}", format!($fmt, $($arg)+)); };
|
|
|
|
}
|
|
|
|
|
|
|
|
extern crate libc;
|
|
|
|
extern crate serde;
|
|
|
|
extern crate toml;
|
2018-12-31 18:27:17 -05:00
|
|
|
extern crate ring;
|
|
|
|
extern crate untrusted;
|
2018-12-14 10:10:15 -05:00
|
|
|
extern crate rustc_serialize;
|
|
|
|
|
|
|
|
use std::cell::RefCell;
|
|
|
|
use std::result;
|
|
|
|
|
|
|
|
use failure::Error;
|
|
|
|
|
|
|
|
thread_local! {
|
|
|
|
pub static VERBOSE: RefCell<bool> = RefCell::new(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn verbose() -> bool {
|
|
|
|
VERBOSE.with(|f| { *f.borrow() })
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_verbose(val: bool) {
|
|
|
|
VERBOSE.with(|f| { *f.borrow_mut() = val });
|
|
|
|
}
|
|
|
|
|
2018-12-31 18:27:17 -05:00
|
|
|
pub fn format_error(err: &Error) -> String {
|
|
|
|
let mut output = err.to_string();
|
|
|
|
let mut prev = err.as_fail();
|
|
|
|
while let Some(next) = prev.cause() {
|
|
|
|
output.push_str(": ");
|
|
|
|
output.push_str(&next.to_string());
|
|
|
|
prev = next;
|
|
|
|
}
|
|
|
|
output
|
|
|
|
}
|
|
|
|
|
2018-12-14 10:10:15 -05:00
|
|
|
mod blockdev;
|
|
|
|
mod config;
|
|
|
|
mod keys;
|
|
|
|
mod cmdline;
|
|
|
|
mod header;
|
|
|
|
mod partition;
|
|
|
|
mod resource;
|
2018-12-31 18:27:17 -05:00
|
|
|
pub mod util;
|
|
|
|
pub mod verity;
|
|
|
|
mod mount;
|
2018-12-14 10:10:15 -05:00
|
|
|
|
|
|
|
pub use config::Config;
|
|
|
|
pub use config::Channel;
|
|
|
|
pub use blockdev::BlockDev;
|
|
|
|
pub use cmdline::CommandLine;
|
|
|
|
pub use header::{ImageHeader,MetaInfo};
|
|
|
|
pub use partition::Partition;
|
|
|
|
pub use resource::ResourceImage;
|
2018-12-31 18:27:17 -05:00
|
|
|
pub use keys::KeyPair;
|
|
|
|
pub use mount::Mount;
|
|
|
|
|
2018-12-14 10:10:15 -05:00
|
|
|
|
|
|
|
pub type Result<T> = result::Result<T,Error>;
|
|
|
|
|
|
|
|
pub const BLOCK_SIZE: usize = 4096;
|