pmem2_source_size3
Returns the size of the data source
Usage
-
#include <libpmem2.h>struct pmem2_source;int pmem2_source_size(const struct pmem2_source *source, size_t *size);
Overview
The pmem2_source_size() function retrieves the size of the file in bytes pointed by file descriptor or handle stored in the source and puts it in *size.
This function is a portable replacement for OS-specific APIs. On Linux, it hides the quirkiness of Device DAX size detection.
Return value
The pmem2_source_size() function returns 0 on success. If the function fails, the *size variable is left unmodified and a negative error code is returned.
Errors
The pmem2_source_size() can fail with the following errors:
On all systems:
- •
-
PMEM2_E_INVALID_FILE_HANDLE- source contains an invalid file handle.
On Windows:
- •
-
PMEM2_E_INVALID_FILE_TYPE- handle points to a resource that is not a regular file.
On Linux:
- •
-
PMEM2_E_INVALID_FILE_TYPE- file descriptor points to a directory, block device, pipe, or socket.
- •
-
PMEM2_E_INVALID_FILE_TYPE- file descriptor points to a character device other than Device DAX.
- •
-
PMEM2_E_INVALID_SIZE_FORMAT- kernel query for Device DAX size returned data in invalid format.
- •
-
-
errnoset by failing fstat(2), while trying to validate the file descriptor.
- •
-
-
errnoset by failing realpath(3), while trying to determine whether fd points to a Device DAX.
- •
-
-
errnoset by failing open(2), while trying to determine Device DAX’s size.
- •
-
-
errnoset by failing read(2), while trying to determine Device DAX’s size.
- •
-
-
errnoset by failing strtoull(3), while trying to determine Device DAX’s size.
On FreeBSD:
- •
-
PMEM2_E_INVALID_FILE_TYPE- file descriptor points to a directory, block device, pipe, socket, or character device.
- •
-
-
errnoset by failing fstat(2), while trying to validate the file descriptor.
Releases
3 releases since Debian 11 (Bullseye); the text changed 2 times.