Broke stat
out into workspace crate; Reduced clap features for smaller
size;
This commit is contained in:
parent
102678015b
commit
44914ced6f
174
Cargo.lock
generated
174
Cargo.lock
generated
@ -38,7 +38,7 @@ version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.19",
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
@ -120,12 +120,6 @@ dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.4.0"
|
||||
@ -143,9 +137,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.4.0"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3"
|
||||
checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
@ -161,7 +155,7 @@ dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim 0.8.0",
|
||||
"strsim",
|
||||
"textwrap 0.11.0",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
@ -175,9 +169,6 @@ checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
"is-terminal",
|
||||
"strsim 0.10.0",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -276,27 +267,6 @@ dependencies = [
|
||||
name = "errno"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
|
||||
dependencies = [
|
||||
"errno-dragonfly",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno-dragonfly"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.6"
|
||||
@ -331,40 +301,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.1",
|
||||
"io-lifetimes",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
@ -393,12 +335,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
@ -428,7 +364,7 @@ name = "mount"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"blkid",
|
||||
"errno 0.1.0",
|
||||
"errno",
|
||||
"sc",
|
||||
]
|
||||
|
||||
@ -514,20 +450,6 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.36.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno 0.2.8",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.11"
|
||||
@ -584,7 +506,7 @@ dependencies = [
|
||||
"clap_mangen",
|
||||
"data-encoding",
|
||||
"digest",
|
||||
"errno 0.1.0",
|
||||
"errno",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"md-5",
|
||||
@ -598,6 +520,7 @@ dependencies = [
|
||||
"textwrap 0.16.0",
|
||||
"unistd",
|
||||
"unix-mode",
|
||||
"unix-stat",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
@ -625,12 +548,6 @@ version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.23.0"
|
||||
@ -736,7 +653,7 @@ checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||
name = "unistd"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"errno 0.1.0",
|
||||
"errno",
|
||||
"libc",
|
||||
"sc",
|
||||
]
|
||||
@ -749,6 +666,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unix-stat"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"sc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
@ -811,69 +737,3 @@ name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
|
||||
|
12
Cargo.toml
12
Cargo.toml
@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
members = [ "bitflags-mini", "errno", "mount", "pw", "unistd", "unix-mode" ]
|
||||
members = [ "bitflags-mini", "errno", "mount", "pw", "unistd", "unix-mode", "unix-stat" ]
|
||||
|
||||
[[bin]]
|
||||
name = "corebox"
|
||||
@ -25,7 +25,6 @@ sc = "0.2"
|
||||
[dependencies]
|
||||
atty = "0.2"
|
||||
blake2b_simd = "1.0"
|
||||
clap = "4.1"
|
||||
clap_complete = "4.1"
|
||||
clap_complete_nushell = "0.1"
|
||||
clap_mangen = "0.2"
|
||||
@ -46,6 +45,11 @@ walkdir = "2.3"
|
||||
package = "bitflags-mini"
|
||||
path = "bitflags-mini"
|
||||
|
||||
[dependencies.clap]
|
||||
version = "4.1"
|
||||
default_features = false
|
||||
features = ["std", "help", "usage", "error-context"]
|
||||
|
||||
[dependencies.errno]
|
||||
package = "errno"
|
||||
path = "errno"
|
||||
@ -57,6 +61,10 @@ path = "unix-mode"
|
||||
[dependencies.mount]
|
||||
path = "mount"
|
||||
|
||||
[dependencies.stat]
|
||||
package = "unix-stat"
|
||||
path = "unix-stat"
|
||||
|
||||
[dependencies.unistd]
|
||||
package = "unistd"
|
||||
path = "unistd"
|
||||
|
@ -102,7 +102,7 @@ impl fmt::Display for Units {
|
||||
fn print_stats(fs: &str, mntpt: &str, units: Units) -> Result<(), Box<dyn Error>> {
|
||||
let p = PathBuf::from(mntpt);
|
||||
if p.exists() {
|
||||
let st = shitbox::stat::statfs(mntpt)?;
|
||||
let st = stat::statfs(mntpt)?;
|
||||
let bs = match units {
|
||||
Units::Posix => st.f_frsize / 512,
|
||||
Units::Kilo => st.f_frsize / 1024,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::{Arg, ArgMatches, Command};
|
||||
use mode::Parser;
|
||||
use shitbox::{args, stat};
|
||||
use shitbox::args;
|
||||
use std::error::Error;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::{value_parser, Arg, ArgMatches, Command};
|
||||
use mode::{get_umask, Parser};
|
||||
use shitbox::{args, stat};
|
||||
use shitbox::args;
|
||||
use std::{convert::Infallible, error::Error, io, str::FromStr};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -53,12 +53,14 @@ impl Cmd for B2sum {
|
||||
for line in reader.lines() {
|
||||
let line = line?;
|
||||
let mut split = line.split_whitespace();
|
||||
let sum = split.next().ok_or::<io::Error>(
|
||||
io::Error::new(io::ErrorKind::Other, "invalid checksum file"),
|
||||
)?;
|
||||
let file = split.next().ok_or::<io::Error>(
|
||||
io::Error::new(io::ErrorKind::Other, "invalid checksum file"),
|
||||
)?;
|
||||
let sum = split.next().ok_or::<io::Error>(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"invalid checksum file",
|
||||
))?;
|
||||
let file = split.next().ok_or::<io::Error>(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"invalid checksum file",
|
||||
))?;
|
||||
let mut buf = vec![];
|
||||
let mut fd = File::open(file)?;
|
||||
fd.read_to_end(&mut buf)?;
|
||||
|
@ -46,12 +46,14 @@ pub fn check_sums(file: &str, hashtype: HashType, erred: &mut usize) -> Result<(
|
||||
for line in reader.lines() {
|
||||
let line = line?;
|
||||
let mut split = line.split_whitespace();
|
||||
let sum = split.next().ok_or::<io::Error>(
|
||||
io::Error::new(io::ErrorKind::Other, "invalid checksum file"),
|
||||
)?;
|
||||
let file = split.next().ok_or::<io::Error>(
|
||||
io::Error::new(io::ErrorKind::Other, "invalid checksum file"),
|
||||
)?;
|
||||
let sum = split.next().ok_or::<io::Error>(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"invalid checksum file",
|
||||
))?;
|
||||
let file = split.next().ok_or::<io::Error>(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"invalid checksum file",
|
||||
))?;
|
||||
let s = match hashtype {
|
||||
HashType::Md5 => compute_hash(file, Md5::new())?,
|
||||
HashType::Sha1 => compute_hash(file, Sha1::new())?,
|
||||
|
@ -6,7 +6,6 @@ pub mod args;
|
||||
mod cmd;
|
||||
pub mod fs;
|
||||
pub mod math;
|
||||
pub mod stat;
|
||||
|
||||
pub use cmd::Cmd;
|
||||
|
||||
|
14
unix-stat/Cargo.toml
Normal file
14
unix-stat/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "unix-stat"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libc = { workspace = true }
|
||||
sc = { workspace = true }
|
||||
|
||||
[dependencies.errno]
|
||||
package = "errno"
|
||||
path = "../errno"
|
@ -1,12 +1,6 @@
|
||||
use errno::Errno;
|
||||
use sc::syscall;
|
||||
use std::{
|
||||
error::Error,
|
||||
ffi::CString,
|
||||
fs::File,
|
||||
mem,
|
||||
os::fd::AsRawFd,
|
||||
};
|
||||
use std::{error::Error, ffi::CString, fs::File, mem, os::fd::AsRawFd};
|
||||
|
||||
pub fn mknod(path: &str, mode: u32, dev: u64) -> Result<(), Box<dyn Error>> {
|
||||
let ret = unsafe {
|
Loading…
Reference in New Issue
Block a user