pmem2_source_pread_mcsafe - Man Page
read source contents or write to the source in a safe manner
Synopsis
#include <libpmem2.h> struct pmem2_source; int pmem2_source_pread_mcsafe(struct pmem2_source *src, void *buf, size_t size, size_t offset); int pmem2_source_pwrite_mcsafe(struct pmem2_source *src, void *buf, size_t size, size_t offset);
Description
The pmem2_source_pread_mcsafe() function reads size bytes from the source src starting at offset offset into the buffer buf. The pmem2_source_pwrite_mcsafe() function writes size bytes from the buffer buf to the source src starting at the offset offset.
Above functions are capable of detecting bad blocks and handling the SIGBUS signal thrown when accessing a bad block. When a bad block is encountered, pmem2_source_pread_mcsafe() and pmem2_source_pwrite_mcsafe() functions return corresponding error. A signal handler for SIGBUS signal is registered using sigaction(2) for the running time of those operations. This capability is limited to POSIX systems.
For bad block detection and clearing, see pmem2_badblock_context_new(3), pmem2_badblock_next(3) and pmem2_badblock_clear(3).
Return Value
The pmem2_source_pread_mcsafe() and pmem2_source_pwrite_mcsafe() functions return 0 on success or a negative error code on failure.
Errors
The pmem2_source_pread_mcsafe() and pmem2_source_pwrite_mcsafe() can fail with the following errors:
- PMEM2_E_IO_FAIL - a physical I/O error occurred during the read/write operation, a possible bad block encountered.
- PMEM2_E_LENGTH_OUT_OF_RANGE - read/write operation size size from offset offset goes beyond the file length.
- PMEM2_E_SOURCE_TYPE_NOT_SUPPORTED - read/write operation doesn’t support provided source, only sources created with pmem2_source_from_fd(3) is supported.
Those operations can also return all errors from the underlying pread(2), pwrite(2), sigaction(2) functions.
See Also
pread(2), pwrite(2), ReadFile(), WriteFile(), pmem2_badblock_clear(3), pmem2_badblock_context_new(3), pmem2_badblock_next(3), pmem2_source_from_fd(3), libpmem2(7) and https://pmem.io\c
Referenced By
The man page pmem2_source_pwrite_mcsafe(3) is an alias of pmem2_source_pread_mcsafe(3).