---
name: "pmem2_source_get_fd"
section: "3"
platform: "linux"
package: "libpmem2-dev"
version: "1.13.1-1.1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pmem2_source_get_fd"
---

# pmem2\_source\_get\_fd(3)

reads file descriptor of the data source

## NAME

**pmem2\_source\_get\_fd**() - reads file descriptor of the data source

## SYNOPSIS

-

  ```
  #include <libpmem2.h>
  int pmem2_source_get_fd(const struct pmem2_source *src, int *fd);
  ```

## DESCRIPTION

The **pmem2\_source\_get\_fd**() function reads the file descriptor of \*struct pmem2\_source\*\* object describing the data source and returns it by *fd* parameter.

This function is Linux only, on Windows use [**pmem2\_source\_get\_handle**(3)](/pmem2_source_get_handle/3.md).

## RETURN VALUE

The **pmem2\_source\_get\_fd**() function returns 0 on success or a negative error code on failure.

## ERRORS

The **pmem2\_source\_get\_fd**() can fail with the following errors:

- •

  **PMEM2\_E\_FILE\_DESCRIPTOR\_NOT\_SET** - in case of an instance of *struct pmem2\_source* that does not come from source type that support file descriptors, eg. anonymous data source.

## SEE ALSO

[**pmem2\_source\_get\_handle**(3)](/pmem2_source_get_handle/3.md), [**libpmem2**(7)](/libpmem2/7.md) and **\<https://pmem.io\>**
