From 11f5d5939699b910cf4286a55c994a1574123edf Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sat, 27 Mar 2021 15:36:35 +0100 Subject: [PATCH] tape: page-align BlockHeader so that we can use it with SG_IO --- src/tape/file_formats/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tape/file_formats/mod.rs b/src/tape/file_formats/mod.rs index e94818b2..bf41b8a4 100644 --- a/src/tape/file_formats/mod.rs +++ b/src/tape/file_formats/mod.rs @@ -288,9 +288,12 @@ impl BlockHeader { pub fn new() -> Box { use std::alloc::{alloc_zeroed, Layout}; + // align to PAGESIZE, so that we can use it with SG_IO + let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) } as usize; + let mut buffer = unsafe { let ptr = alloc_zeroed( - Layout::from_size_align(Self::SIZE, std::mem::align_of::()) + Layout::from_size_align(Self::SIZE, page_size) .unwrap(), ); Box::from_raw(