search for: ramdisk_pread

Displaying 3 results from an estimated 3 matches for "ramdisk_pread".

2019 Jun 11
3
[nbdkit PATCH 0/2] Few rust plugin fixups/nitpicks
There are few more things that could be cleaned up related to the coding style and other things, like explicitly specifying the abi style after "extern" (i.e. `extern "C" fn` instead of `extern fn`), but since those are configurable in rustfmt config, I'm not sure whether the config needs to be added or complying with the defaults should be the priority. But this was just
2019 Feb 08
0
[PATCH nbdkit] Add support for writing plugins in Rust.
...return Box::into_raw(h) as *mut c_void; +} + +extern fn ramdisk_close (h: *mut c_void) { + let h = unsafe { Box::from_raw(h as *mut Handle) }; + drop (h); +} + +extern fn ramdisk_get_size (_h: *mut c_void) -> int64_t { + return DISK.lock().unwrap().capacity() as int64_t; +} + +extern fn ramdisk_pread (_h: *mut c_void, buf: *mut c_char, count: uint32_t, + offset: uint64_t, _flags: uint32_t) -> c_int { + let offset = offset as usize; + let count = count as usize; + let disk = DISK.lock().unwrap(); + unsafe { + ptr::copy_nonoverlapping (&disk[offse...
2019 Feb 08
3
[PATCH nbdkit] Add support for writing plugins in Rust.
This adds very rough support for writing nbdkit plugins in Rust. This is not very idiomatic -- essentially we're handling the direct C calls from nbdkit in Rust. We have to use ‘unsafe’ in a few places because there's no way to tell the Rust code that nbdkit satisfies guarantees (eg. around thread safety, always returning leaked pointers back to the close function, always doing bounds