Merge pull request #291 from tmuehlbacher/fix-subvolume-commands

Fix subvolume commands
This commit is contained in:
koverstreet 2024-06-03 17:01:22 -04:00 committed by GitHub
commit d456f9e97a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -11,7 +11,7 @@ use std::{
use anyhow::{anyhow, ensure, Result}; use anyhow::{anyhow, ensure, Result};
use bch_bindgen::{ use bch_bindgen::{
bcachefs::{self, bch_key, bch_sb_handle}, bcachefs::{self, bch_key, bch_sb_handle},
c::bch2_chacha_encrypt_key, c::{bch2_chacha_encrypt_key, bch_sb_field_crypt},
keyutils::{self, keyctl_search}, keyutils::{self, keyctl_search},
}; };
use byteorder::{LittleEndian, ReadBytesExt}; use byteorder::{LittleEndian, ReadBytesExt};
@ -66,7 +66,7 @@ impl KeyHandle {
let bch_key_magic = BCH_KEY_MAGIC.as_bytes().read_u64::<LittleEndian>().unwrap(); let bch_key_magic = BCH_KEY_MAGIC.as_bytes().read_u64::<LittleEndian>().unwrap();
let crypt = sb.sb().crypt().unwrap(); let crypt = sb.sb().crypt().unwrap();
let crypt_ptr = ptr::addr_of!(*crypt).cast_mut(); let crypt_ptr = (crypt as *const bch_sb_field_crypt).cast_mut();
let mut output: bch_key = let mut output: bch_key =
unsafe { bcachefs::derive_passphrase(crypt_ptr, passphrase.get().as_ptr()) }; unsafe { bcachefs::derive_passphrase(crypt_ptr, passphrase.get().as_ptr()) };

View File

@ -1,4 +1,4 @@
use std::{path::Path, ptr}; use std::path::Path;
use bch_bindgen::c::{ use bch_bindgen::c::{
bcache_fs_close, bcache_fs_open, bch_ioctl_subvolume, bchfs_handle, BCH_IOCTL_SUBVOLUME_CREATE, bcache_fs_close, bcache_fs_open, bch_ioctl_subvolume, bchfs_handle, BCH_IOCTL_SUBVOLUME_CREATE,
@ -42,7 +42,7 @@ pub enum BcachefsIoctlPayload {
impl From<&BcachefsIoctlPayload> for *const libc::c_void { impl From<&BcachefsIoctlPayload> for *const libc::c_void {
fn from(value: &BcachefsIoctlPayload) -> Self { fn from(value: &BcachefsIoctlPayload) -> Self {
match value { match value {
BcachefsIoctlPayload::Subvolume(p) => ptr::addr_of!(p).cast(), BcachefsIoctlPayload::Subvolume(p) => (p as *const bch_ioctl_subvolume).cast(),
} }
} }
} }