1PMEM2_SOURCE_SIZE(3)       PMDK Programmer's Manual       PMEM2_SOURCE_SIZE(3)
2
3
4

NAME

6       pmem2_source_size() - returns the size of the data source
7

SYNOPSIS

9              #include <libpmem2.h>
10
11              struct pmem2_source;
12              int pmem2_source_size(const struct pmem2_source *source, size_t *size);
13

DESCRIPTION

15       The  pmem2_source_size()  function  retrieves  the  size of the file in
16       bytes pointed by file descriptor or handle stored  in  the  source  and
17       puts it in *size.
18
19       This  function is a portable replacement for OS-specific APIs.  On Lin‐
20       ux, it hides the quirkiness of Device DAX size detection.
21

RETURN VALUE

23       The pmem2_source_size() function returns 0 on success.  If the function
24       fails,  the *size variable is left unmodified and a negative error code
25       is returned.
26

ERRORS

28       The pmem2_source_size() can fail with the following errors:
29
30       On all systems:
31
32PMEM2_E_INVALID_FILE_HANDLE - source contains an invalid file handle.
33
34       On Windows:
35
36PMEM2_E_INVALID_FILE_TYPE - handle points to a resource that is not a
37         regular file.
38
39       On Linux:
40
41PMEM2_E_INVALID_FILE_TYPE  -  file  descriptor points to a directory,
42         block device, pipe, or socket.
43
44PMEM2_E_INVALID_FILE_TYPE - file descriptor points to a character de‐
45         vice other than Device DAX.
46
47PMEM2_E_INVALID_SIZE_FORMAT  -  kernel  query for Device DAX size re‐
48         turned data in invalid format.
49
50       • -errno set by failing fstat(2), while trying to validate the file de‐
51         scriptor.
52
53       • -errno  set by failing realpath(3), while trying to determine whether
54         fd points to a Device DAX.
55
56       • -errno set by failing open(2), while trying to determine Device DAX's
57         size.
58
59       • -errno set by failing read(2), while trying to determine Device DAX's
60         size.
61
62       • -errno set by failing strtoull(3), while trying to  determine  Device
63         DAX's size.
64
65       On FreeBSD:
66
67PMEM2_E_INVALID_FILE_TYPE  -  file  descriptor points to a directory,
68         block device, pipe, socket, or character device.
69
70       • -errno set by failing fstat(2), while trying to validate the file de‐
71         scriptor.
72

SEE ALSO

74       errno(3),   fstat(2),   realpath(3),   open(2),  read(2),  strtoull(3),
75       pmem2_config_new(3), libpmem2(7) and <https://pmem.io>
76
77
78
79PMDK - pmem2 API version 1.0      2022-05-24              PMEM2_SOURCE_SIZE(3)
Impressum