.\" Automatically generated by Pandoc 2.0.6 .\" .TH "PMEM2_SOURCE_SIZE" "3" "2022-08-25" "PMDK - pmem2 API version 1.0" "PMDK Programmer's Manual" .hy .\" SPDX-License-Identifier: BSD-3-Clause .\" Copyright 2019-2021, Intel Corporation .SH NAME .PP \f[B]pmem2_source_size\f[]() \- returns the size of the data source .SH SYNOPSIS .IP .nf \f[C] #include\ struct\ pmem2_source; int\ pmem2_source_size(const\ struct\ pmem2_source\ *source,\ size_t\ *size); \f[] .fi .SH DESCRIPTION .PP The \f[B]pmem2_source_size\f[]() function retrieves the size of the file in bytes pointed by file descriptor or handle stored in the \f[I]source\f[] and puts it in \f[I]*size\f[]. .PP This function is a portable replacement for OS\-specific APIs. On Linux, it hides the quirkiness of Device DAX size detection. .SH RETURN VALUE .PP The \f[B]pmem2_source_size\f[]() function returns 0 on success. If the function fails, the \f[I]*size\f[] variable is left unmodified and a negative error code is returned. .SH ERRORS .PP The \f[B]pmem2_source_size\f[]() can fail with the following errors: .PP On all systems: .IP \[bu] 2 \f[B]PMEM2_E_INVALID_FILE_HANDLE\f[] \- source contains an invalid file handle. .PP On Windows: .IP \[bu] 2 \f[B]PMEM2_E_INVALID_FILE_TYPE\f[] \- handle points to a resource that is not a regular file. .PP On Linux: .IP \[bu] 2 \f[B]PMEM2_E_INVALID_FILE_TYPE\f[] \- file descriptor points to a directory, block device, pipe, or socket. .IP \[bu] 2 \f[B]PMEM2_E_INVALID_FILE_TYPE\f[] \- file descriptor points to a character device other than Device DAX. .IP \[bu] 2 \f[B]PMEM2_E_INVALID_SIZE_FORMAT\f[] \- kernel query for Device DAX size returned data in invalid format. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]fstat\f[](2), while trying to validate the file descriptor. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]realpath\f[](3), while trying to determine whether fd points to a Device DAX. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]open\f[](2), while trying to determine Device DAX's size. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]read\f[](2), while trying to determine Device DAX's size. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]strtoull\f[](3), while trying to determine Device DAX's size. .PP On FreeBSD: .IP \[bu] 2 \f[B]PMEM2_E_INVALID_FILE_TYPE\f[] \- file descriptor points to a directory, block device, pipe, socket, or character device. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]fstat\f[](2), while trying to validate the file descriptor. .SH SEE ALSO .PP \f[B]errno\f[](3), \f[B]fstat\f[](2), \f[B]realpath\f[](3), \f[B]open\f[](2), \f[B]read\f[](2), \f[B]strtoull\f[](3), \f[B]pmem2_config_new\f[](3), \f[B]libpmem2\f[](7) and \f[B]\f[]