diff --git a/Cargo.toml b/Cargo.toml index 5de53b06c9..28d85d25a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,8 @@ default = ["std"] std = [] -# Enables functionality to actually read the filesystem, which is only done in -# the kernel. (Writing to the filesystem is done in utils, and that crate only -# needs the type definitions). -kernel = [] - [dev-dependencies] +# FIXME remove loggers log = "0.4" env_logger = "0.8" anyhow = "1" diff --git a/src/lib.rs b/src/lib.rs index 50c63e892b..ecc1cc9980 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,10 @@ -#![cfg_attr(not(any(test, feature = "std")), no_std)] +#![no_std] //! A super simple initfs, only meant to be loaded into RAM by the bootloader, and then directly be //! read. +#[cfg(any(test, feature = "std"))] +extern crate std; + use core::convert::{TryFrom, TryInto}; pub mod types; diff --git a/tools/Cargo.toml b/tools/Cargo.toml index 82330525c9..fb9acfae24 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -18,7 +18,7 @@ name = "redox-initfs-dump" [dependencies] anyhow = "1" -clap = "2.33" +clap = { version = "4", features = ["cargo"] } env_logger = "0.8" log = "0.4" plain = "0.2" diff --git a/tools/src/bin/archive.rs b/tools/src/bin/archive.rs index ac14f11bcd..6fc48c66b4 100644 --- a/tools/src/bin/archive.rs +++ b/tools/src/bin/archive.rs @@ -1,44 +1,41 @@ use std::path::Path; use anyhow::{Context, Result}; -use clap::{App, Arg}; +use clap::{Arg, Command}; #[path = "../archive_common.rs"] mod archive_common; use self::archive_common::{self as archive, Args, DEFAULT_MAX_SIZE}; fn main() -> Result<()> { - let matches = App::new("redox-initfs-ar") + let matches = Command::new("redox-initfs-ar") .about("create an initfs image from a directory") .version(clap::crate_version!()) .author(clap::crate_authors!()) .arg( - Arg::with_name("MAX_SIZE") - .long("--max-size") - .short("-m") - .takes_value(true) + Arg::new("MAX_SIZE") + .long("max-size") + .short('m') .required(false) .help("Set the upper limit for how large the image can become (default 64 MiB)."), ) .arg( - Arg::with_name("SOURCE") - .takes_value(true) + Arg::new("SOURCE") .required(true) .help("Specify the source directory to build the image from."), ) .arg( - Arg::with_name("OUTPUT") - .takes_value(true) + Arg::new("OUTPUT") .required(true) - .long("--output") - .short("-o") + .long("output") + .short('o') .help("Specify the path of the new image file."), ) .get_matches(); env_logger::init(); - let max_size = if let Some(max_size_str) = matches.value_of("MAX_SIZE") { + let max_size = if let Some(max_size_str) = matches.get_one::("MAX_SIZE") { max_size_str .parse::() .context("expected an integer for MAX_SIZE")? @@ -47,11 +44,11 @@ fn main() -> Result<()> { }; let source = matches - .value_of("SOURCE") + .get_one::("SOURCE") .expect("expected the required arg SOURCE to exist"); let destination = matches - .value_of("OUTPUT") + .get_one::("OUTPUT") .expect("expected the required arg OUTPUT to exist"); let args = Args { diff --git a/tools/src/bin/dump.rs b/tools/src/bin/dump.rs index 8f7c20af75..1c0a06e330 100644 --- a/tools/src/bin/dump.rs +++ b/tools/src/bin/dump.rs @@ -1,23 +1,24 @@ +use std::ffi::OsString; + use anyhow::{Context, Result}; -use clap::{App, Arg}; +use clap::{Arg, Command}; use redox_initfs::InitFs; fn main() -> Result<()> { - let matches = App::new("redox-initfs-dump") + let matches = Command::new("redox-initfs-dump") .about("dump initfs metadata") .version(clap::crate_version!()) .author(clap::crate_authors!()) .arg( - Arg::with_name("IMAGE") - .takes_value(true) + Arg::new("IMAGE") .required(true) - .help("specify the image to dump") + .help("specify the image to dump"), ) .get_matches(); let source = matches - .value_of_os("IMAGE") + .get_one::("IMAGE") .expect("expected the required arg IMAGE to exist"); let bytes = std::fs::read(source).context("failed to read image into memory")?; @@ -35,7 +36,12 @@ fn main() -> Result<()> { continue; } }; - print!("mode={:#0o}, uid={}, gid={}, kind=", inode_struct.mode(), inode_struct.uid(), inode_struct.gid()); + print!( + "mode={:#0o}, uid={}, gid={}, kind=", + inode_struct.mode(), + inode_struct.uid(), + inode_struct.gid() + ); use redox_initfs::InodeKind; @@ -67,7 +73,11 @@ fn main() -> Result<()> { continue; } }; - println!("\t`{}` => {:?},", String::from_utf8_lossy(name), entry.inode()); + println!( + "\t`{}` => {:?},", + String::from_utf8_lossy(name), + entry.inode() + ); } println!("]}}");