---
name: "pmem2_source_alignment"
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_alignment"
---

# pmem2\_source\_alignment(3)

returns data source alignment

## NAME

**pmem2\_source\_alignment**() - returns data source alignment

## SYNOPSIS

-

  ```
  #include <libpmem2.h>
  struct pmem2_source;
  int pmem2_source_alignment(const struct pmem2_source *source, size_t *alignment);
  ```

## DESCRIPTION

The **pmem2\_source\_alignment**() function retrieves the alignment of offset and length needed for [**pmem2\_map\_new**(3)](/pmem2_map_new/3.md) to succeed. The alignment is stored in *\*alignment*.

## RETURN VALUE

The **pmem2\_source\_alignment**() function returns 0 on success. If the function fails, the *\*alignment* variable is left unmodified and a negative error code is returned.

## ERRORS

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

On all systems:

- •

  **PMEM2\_E\_INVALID\_ALIGNMENT\_VALUE** - operating system returned unexpected alignment value (eg. it is not a power of two).

on Linux:

- •

  **PMEM2\_E\_INVALID\_FILE\_TYPE** - file descriptor points to a character device other than Device DAX.

- •

  **PMEM2\_E\_INVALID\_ALIGNMENT\_FORMAT** - kernel query for Device DAX alignment returned data in invalid format.

- •

  \-**errno** set by failing [**fstat**(2)](/fstat/2.md), while trying to validate the file descriptor.

- •

  \-**errno** set by failing [**realpath**(3)](/realpath/3.md), while trying to determine whether fd points to a Device DAX.

- •

  \-**errno** set by failing [**read**(2)](/read/2.md), while trying to determine Device DAX’s alignment.

- •

  \-**errno** set by failing [**strtoull**(3)](/strtoull/3.md), while trying to determine Device DAX’s alignment.

On FreeBSD:

- •

  **PMEM2\_E\_INVALID\_FILE\_TYPE** - file descriptor points to a directory, block device, pipe, socket, or character device.

- •

  \-**errno** set by failing [**fstat**(2)](/fstat/2.md), while trying to validate the file descriptor.

## SEE ALSO

[**errno**(3)](/errno/3.md), [**fstat**(2)](/fstat/2.md), [**realpath**(3)](/realpath/3.md), [**read**(2)](/read/2.md), [**strtoull**(3)](/strtoull/3.md), [**pmem2\_config\_new**(3)](/pmem2_config_new/3.md), [**pmem2\_source\_from\_handle**(3)](/pmem2_source_from_handle/3.md), [**pmem2\_source\_from\_fd**(3)](/pmem2_source_from_fd/3.md), [**libpmem2**(7)](/libpmem2/7.md) and **\<https://pmem.io\>**
