pmemblk_sys/
lib.rs

1//! # FFI bindings to **libpmemblk**
2//!
3//! The **libpmemblk** library supports arrays of pmem-resident blocks, all the same size, that are atomically updated.
4//! For example, a program keeping a cache of fixed-size objects in pmem might find this library useful.
5//!
6//! > This is **not** an official port of the NVM Library.
7//! >
8//! > The official **libpmemblk** documentation can be found at: [http://pmem.io/nvml/libpmemblk/](http://pmem.io/nvml/libpmemblk/)
9
10extern crate libc;
11
12use ::libc::{size_t, mode_t};
13use ::libc::{c_void, c_char, c_int, c_longlong, c_uint};
14
15pub enum PMEMblkpool {}
16
17#[allow(dead_code)]
18#[link(name = "pmemblk")]
19extern "C" {
20    // Most commonly used functions:
21
22    pub fn pmemblk_open(path: *const c_char, bsize: size_t) -> *mut PMEMblkpool;
23    pub fn pmemblk_create(path: *const c_char, bsize: size_t, poolsize: size_t, mode: mode_t) -> *mut PMEMblkpool;
24    pub fn pmemblk_close(pbp: *mut PMEMblkpool);
25    pub fn pmemblk_bsize(pbp: *mut PMEMblkpool) -> size_t;
26    pub fn pmemblk_nblock(pbp: *mut PMEMblkpool) -> size_t;
27    pub fn pmemblk_read(pbp: *mut PMEMblkpool, buf: *mut c_void, blockno: c_longlong) -> c_int;
28    pub fn pmemblk_write(pbp: *mut PMEMblkpool, buf: *const c_void, blockno: c_longlong) -> c_int;
29    pub fn pmemblk_set_zero(pbp: *mut PMEMblkpool, blockno: c_longlong) -> c_int;
30    pub fn pmemblk_set_error(pbp: *mut PMEMblkpool, blockno: c_longlong) -> c_int;
31
32    // Library API versioning:
33
34    pub fn pmemblk_check_version(major_required: c_uint, minor_required: c_uint) -> *const c_char;
35
36    // Managing library behavior:
37
38    pub fn pmemblk_check(path: *const c_char, bsize: size_t) -> c_int;
39
40    // Error handling:
41
42    pub fn pmemblk_errormsg() -> *const c_char;
43
44    // Globals
45
46    pub static PMEMBLK_MIN_POOL: size_t;
47}