Expand description
Wrappers for the Linux fs-verity ioctls and for a read-only memory map.
A caller seals a file with fs-verity and reads the digest and the
parameters that the kernel holds for the sealed file. The seal has the
parameters that ostree uses: SHA-256, 4096-byte blocks, and no salt. A
caller can also map a file read-only. The only dependency of the crate is
rustix.
§Entry points
enable_verityseals a file with fs-verity.measure_verityreturns the fs-verity digest of a sealed file.read_verity_descriptorreturns the parameters of a sealed file.Mmapis a read-only memory map of a file.
§Examples
The example seals a file and reads its parameters and its digest. The file system of the file must support fs-verity.
use std::fs::File;
use ostrya_sys::{enable_verity, measure_verity, read_verity_descriptor};
// A read-only descriptor, and no writable descriptor to the file.
let file = File::open("object.file")?;
enable_verity(&file)?;
let desc = read_verity_descriptor(&file)?;
// SHA-256, 4096-byte blocks (2 to the power 12), and no salt.
assert_eq!((desc.hash_algorithm, desc.log_blocksize, desc.salt_size), (1, 12, 0));
let digest: [u8; 32] = measure_verity(&file)?;This crate holds all unsafe code of the ostrya library crates. A
SAFETY comment on each unsafe block gives its reasoning.
Re-exports§
pub use imp::VerityDescriptor;pub use imp::enable_verity;pub use imp::measure_verity;pub use imp::read_verity_descriptor;
Structs§
- Mmap
- A read-only, private memory map of an open file.
- Verity
Descriptor - The fs-verity parameters of a sealed file, from its
fsverity_descriptor.
Functions§
- enable_
verity - Enables fs-verity on
fdwith SHA-256, 4096-byte blocks, and no salt. - measure_
verity - Returns the fs-verity SHA-256 digest that the kernel holds for
fd. - read_
verity_ descriptor - Returns the fs-verity parameters that the kernel holds for
fd.