[io_engine] Add Block::zeroed() constructor
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -671,6 +671,12 @@ version = "1.0.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "safemem"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shared_child"
|
name = "shared_child"
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
@@ -798,6 +804,7 @@ dependencies = [
|
|||||||
"quickcheck",
|
"quickcheck",
|
||||||
"quickcheck_macros",
|
"quickcheck_macros",
|
||||||
"rand",
|
"rand",
|
||||||
|
"safemem",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"termion",
|
"termion",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@@ -27,6 +27,7 @@ num-derive = "0.3"
|
|||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
quick-xml = "0.18"
|
quick-xml = "0.18"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
|
safemem = "0.3.3"
|
||||||
tempfile = "3.1"
|
tempfile = "3.1"
|
||||||
threadpool = "1.8"
|
threadpool = "1.8"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
use io_uring::opcode::{self, types};
|
use io_uring::opcode::{self, types};
|
||||||
use io_uring::IoUring;
|
use io_uring::IoUring;
|
||||||
|
use safemem::write_bytes;
|
||||||
use std::alloc::{alloc, dealloc, Layout};
|
use std::alloc::{alloc, dealloc, Layout};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
@@ -32,6 +33,12 @@ impl Block {
|
|||||||
Block { loc, data: ptr }
|
Block { loc, data: ptr }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn zeroed(loc: u64) -> Block {
|
||||||
|
let r = Self::new(loc);
|
||||||
|
write_bytes(r.get_data(), 0);
|
||||||
|
r
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_data<'a>(&self) -> &'a mut [u8] {
|
pub fn get_data<'a>(&self) -> &'a mut [u8] {
|
||||||
unsafe { std::slice::from_raw_parts_mut::<'a>(self.data, BLOCK_SIZE) }
|
unsafe { std::slice::from_raw_parts_mut::<'a>(self.data, BLOCK_SIZE) }
|
||||||
}
|
}
|
||||||
|
@@ -95,6 +95,7 @@ impl Report {
|
|||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
struct PBInner {
|
struct PBInner {
|
||||||
title: String,
|
title: String,
|
||||||
bar: ProgressBar,
|
bar: ProgressBar,
|
||||||
|
Reference in New Issue
Block a user