Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libcryptsetup-rs"
version = "0.16.1"
authors = ["John Baublitz <jbaublitz@redhat.com>"]
edition = "2021"
edition = "2024"
rust-version = "1.87.0" # LOWEST SUPPORTED RUST TOOLCHAIN
description = "High level Rust bindings for libcryptsetup"
license = "MPL-2.0"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ release:
cargo build --release

test:
RUST_BACKTRACE=1 cargo test -- --skip test_mutex_poisoning_panic
RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test -- --skip test_mutex_poisoning_panic

test-mutex:
RUST_BACKTRACE=1 cargo test --features=mutex -- --skip test_mutex_poisoning_panic
Expand Down
8 changes: 4 additions & 4 deletions examples/cryptsetup-luks2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use std::{
};

use libcryptsetup_rs::{
CryptInit, LibcryptErr,
consts::{
flags::{CryptActivate, CryptDeactivate, CryptVolumeKey},
vals::EncryptionFormat,
},
CryptInit, LibcryptErr,
};

enum CryptCommand {
Expand All @@ -33,7 +33,7 @@ fn parse_args() -> Result<CryptCommand, LibcryptErr> {
None => {
return Err(LibcryptErr::Other(
"Device path for device to be encrypted is required".to_string(),
))
));
}
});
if dev.exists() {
Expand All @@ -50,7 +50,7 @@ fn parse_args() -> Result<CryptCommand, LibcryptErr> {
None => {
return Err(LibcryptErr::Other(
"Device path for device to be opened is required".to_string(),
))
));
}
});
if !dev.exists() {
Expand All @@ -69,7 +69,7 @@ fn parse_args() -> Result<CryptCommand, LibcryptErr> {
None => {
return Err(LibcryptErr::Other(
"Device path for device to be closed is required".to_string(),
))
));
}
});
if !dev.exists() {
Expand Down
3 changes: 1 addition & 2 deletions examples/format-luks2-with-token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use std::{
};

use libcryptsetup_rs::{
c_uint,
CryptInit, LibcryptErr, TokenInput, c_uint,
consts::{flags::CryptVolumeKey, vals::EncryptionFormat},
CryptInit, LibcryptErr, TokenInput,
};

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion examples/label_and_uuid.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env::args, error::Error, path::Path};

use libcryptsetup_rs::{consts::vals::EncryptionFormat, CryptInit, LibcryptErr};
use libcryptsetup_rs::{CryptInit, LibcryptErr, consts::vals::EncryptionFormat};
use uuid::Uuid;

fn main() -> Result<(), Box<dyn Error>> {
Expand Down
2 changes: 1 addition & 1 deletion examples/unlock-luks2-with-token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::{

use libc::syscall;
use libcryptsetup_rs::{
consts::{flags::CryptActivate, vals::EncryptionFormat},
CryptInit, LibcryptErr,
consts::{flags::CryptActivate, vals::EncryptionFormat},
};

fn usage() -> &'static str {
Expand Down
2 changes: 1 addition & 1 deletion libcryptsetup-rs-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libcryptsetup-rs-sys"
version = "0.7.0"
authors = ["John Baublitz <jbaublitz@redhat.com>"]
edition = "2021"
edition = "2024"
rust-version = "1.87.0" # LOWEST SUPPORTED RUST TOOLCHAIN
description = "Low level bindings for libcryptsetup"
license = "MPL-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use std::{
ffi::{c_void, CString},
ffi::{CString, c_void},
os::raw::c_uint,
path::PathBuf,
ptr, slice,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ pub use crate::{
luks2::{
flags::CryptLuks2FlagsHandle,
reencrypt::{CryptLuks2ReencryptHandle, CryptParamsReencrypt, CryptParamsReencryptRef},
token::{register, CryptLuks2TokenHandle, CryptTokenInfo, TokenInput},
token::{CryptLuks2TokenHandle, CryptTokenInfo, TokenInput, register},
},
mem::SafeMemHandle,
runtime::{ActiveDevice, CryptRuntimeHandle},
settings::{CryptPbkdfType, CryptPbkdfTypeRef, CryptSettingsHandle},
status::{get_sector_size, status, CryptDeviceStatusHandle},
status::{CryptDeviceStatusHandle, get_sector_size, status},
wipe::CryptWipeHandle,
};

Expand Down
2 changes: 1 addition & 1 deletion src/luks2/reencrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
ptr,
};

use libcryptsetup_rs_sys::{crypt_params_reencrypt, CRYPT_ANY_SLOT};
use libcryptsetup_rs_sys::{CRYPT_ANY_SLOT, crypt_params_reencrypt};

use crate::{
consts::{
Expand Down
10 changes: 2 additions & 8 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ macro_rules! try_int_to_return {
macro_rules! ptr_to_option {
( $ptr:expr ) => {{
let p = $ptr;
if p.is_null() {
None
} else {
Some(p)
}
if p.is_null() { None } else { Some(p) }
}};
}

Expand All @@ -85,9 +81,7 @@ macro_rules! ptr_to_option_with_reference {

/// Convert a pointer to an `Result` containing a pointer
macro_rules! ptr_to_result {
( $ptr:expr ) => {{
ptr_to_option!($ptr).ok_or($crate::err::LibcryptErr::NullPtr)
}};
( $ptr:expr ) => {{ ptr_to_option!($ptr).ok_or($crate::err::LibcryptErr::NullPtr) }};
}

/// Convert a pointer to a `Result` containing a reference
Expand Down
2 changes: 1 addition & 1 deletion src/tests/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use std::{
};

use crate::{
Either,
consts::{
flags::{CryptActivate, CryptDeactivate, CryptKeyfile, CryptVolumeKey},
vals::EncryptionFormat,
},
device::CryptInit,
err::LibcryptErr,
tests::loopback,
Either,
};

use libc::c_uint;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/keyfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{env, fs::File, io::Write, path::PathBuf};

use super::loopback;

use crate::{consts::flags::CryptKeyfile, CryptInit};
use crate::{CryptInit, consts::flags::CryptKeyfile};

pub fn test_keyfile_cleanup() {
loopback::use_loopback(
Expand Down
2 changes: 1 addition & 1 deletion src/tests/loopback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use std::{
env,
fs::{remove_file, File},
fs::{File, remove_file},
io::{self, Write},
panic::{self, RefUnwindSafe},
path::{Path, PathBuf},
Expand Down
12 changes: 6 additions & 6 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ mod test {

#[test]
fn test_format_with_zeros() {
std::env::remove_var("FORMAT_WITH_ZEROS");
unsafe { std::env::remove_var("FORMAT_WITH_ZEROS") };
assert!(format_with_zeros());
std::env::set_var("FORMAT_WITH_ZEROS", "false");
unsafe { std::env::set_var("FORMAT_WITH_ZEROS", "false") };
assert!(!format_with_zeros());
std::env::remove_var("FORMAT_WITH_ZEROS");
unsafe { std::env::remove_var("FORMAT_WITH_ZEROS") };
}

#[test]
fn test_do_cleanup() {
std::env::remove_var("DO_CLEANUP");
unsafe { std::env::remove_var("DO_CLEANUP") };
assert!(do_cleanup());
std::env::set_var("DO_CLEANUP", "false");
unsafe { std::env::set_var("DO_CLEANUP", "false") };
assert!(!do_cleanup());
std::env::remove_var("DO_CLEANUP");
unsafe { std::env::remove_var("DO_CLEANUP") };
}
}
2 changes: 1 addition & 1 deletion src/tests/reencrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use crate::{
CryptParamsLuks2, CryptParamsReencrypt, Either,
consts::{
flags::{CryptActivate, CryptDeactivate, CryptReencrypt, CryptVolumeKey},
vals::{CryptReencryptDirectionInfo, CryptReencryptModeInfo, EncryptionFormat},
},
device::CryptInit,
get_sector_size,
tests::loopback,
CryptParamsLuks2, CryptParamsReencrypt, Either,
};

pub fn test_reencrypt_by_password() {
Expand Down
Loading