Skip to content

Commit

Permalink
Merge pull request #335 from workingjubilee/remove-trivial-deps
Browse files Browse the repository at this point in the history
Remove trivial deps
  • Loading branch information
koverstreet committed Sep 4, 2024
2 parents 1e058db + a1122ac commit 68704c3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 36 deletions.
24 changes: 0 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "bcachefs-tools"
version = "1.12.0"
authors = ["Yuxuan Shui <[email protected]>", "Kayla Firestack <[email protected]>", "Kent Overstreet <[email protected]>" ]
edition = "2021"
rust-version = "1.70"
rust-version = "1.77"

[[bin]]
name = "bcachefs"
Expand All @@ -20,7 +20,6 @@ uuid = "1.2.2"
errno = "0.2"
either = "1.5"
bch_bindgen = { path = "bch_bindgen" }
byteorder = "1.3"
strum = { version = "0.26", features = ["derive"] }
strum_macros = "0.26"
zeroize = { version = "1", features = ["std", "zeroize_derive"] }
Expand Down
3 changes: 1 addition & 2 deletions bch_bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "bch_bindgen"
version = "0.1.0"
authors = [ "Kayla Firestack <[email protected]>", "Yuxuan Shui <[email protected]>", "Kent Overstreet <[email protected]>" ]
edition = "2021"
rust-version = "1.77"

[lib]
crate-type = ["lib"]
Expand All @@ -12,8 +13,6 @@ crate-type = ["lib"]
anyhow = "1.0"
uuid = "1.2.2"
bitfield = "0.14.0"
memoffset = "0.8.0"
byteorder = "1.3"
bitflags = "1.3.2"
paste = "1.0.11"

Expand Down
9 changes: 4 additions & 5 deletions bch_bindgen/src/bcachefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bitfield! {
pub struct bch_crypt_flags(u64);
pub TYPE, _: 4, 0;
}
use memoffset::offset_of;
use std::mem::offset_of;
impl bch_sb_field_crypt {
pub fn scrypt_flags(&self) -> Option<bch_scrypt_flags> {
use std::convert::TryInto;
Expand Down Expand Up @@ -67,10 +67,9 @@ impl bch_sb {

/// Get the nonce used to encrypt the superblock
pub fn nonce(&self) -> nonce {
use byteorder::{LittleEndian, ReadBytesExt};
let mut internal_uuid = &self.uuid.b[..];
let dword1 = internal_uuid.read_u32::<LittleEndian>().unwrap();
let dword2 = internal_uuid.read_u32::<LittleEndian>().unwrap();
let [a, b, c, d, e, f, g, h, _rest @ ..] = self.uuid.b;
let dword1 = u32::from_le_bytes([a, b, c, d]);
let dword2 = u32::from_le_bytes([e, f, g, h]);
nonce {
d: [0, 0, dword1, dword2],
}
Expand Down
5 changes: 2 additions & 3 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ use bch_bindgen::{
c::{bch2_chacha_encrypt_key, bch_encrypted_key, bch_sb_field_crypt},
keyutils::{self, keyctl_search},
};
use byteorder::{LittleEndian, ReadBytesExt};
use log::{debug, info};
use rustix::termios;
use uuid::Uuid;
use zeroize::{ZeroizeOnDrop, Zeroizing};

use crate::{c_str, ErrnoError};

const BCH_KEY_MAGIC: &str = "bch**key";
const BCH_KEY_MAGIC: &[u8; 8] = b"bch**key";

#[derive(Clone, Debug, clap::ValueEnum, strum::Display)]
pub enum UnlockPolicy {
Expand Down Expand Up @@ -225,7 +224,7 @@ impl Passphrase {
}

pub fn check(&self, sb: &bch_sb_handle) -> Result<(bch_key, bch_encrypted_key)> {
let bch_key_magic = BCH_KEY_MAGIC.as_bytes().read_u64::<LittleEndian>().unwrap();
let bch_key_magic = u64::from_le_bytes(*BCH_KEY_MAGIC);

let crypt = sb
.sb()
Expand Down

0 comments on commit 68704c3

Please sign in to comment.