LLAPI\_LAYOUT\_FILE\_CREATE(3) Lustre Library Functions LLAPI\_LAYOUT\_FILE\_CREATE(3)

# [NAME](#NAME)

llapi\_layout\_file\_open, llapi\_layout\_file\_create, llapi\_layout\_set\_by\_fd, llapi\_layout\_set\_by\_xattr - open and apply a layout to a Lustre file

# [SYNOPSIS](#SYNOPSIS)

```
#include <lustre/lustreapi.h>
```

```
int llapi_layout_file_open(char *path, int open_flags, int mode,
                           const struct llapi_layout *layout);
```

```
int llapi_layout_file_create(char *path, int open_flags,
                             int mode,
                             const struct llapi_layout *layout);
```

```
int llapi_layout_set_by_fd(int fd,
                           struct llapi_layout *layout);
```

```
int llapi_layout_set_by_xattr(int fd, struct lov_user_md *lum);
```

# [DESCRIPTION](#DESCRIPTION)

The functions **llapi\_layout\_file\_open()** and **llapi\_layout\_file\_create()** open and possibly create a file at *path* with the permissions specified in *mode* using the Lustre layout attributes in *layout*. The returned file descriptor may be used in subsequent system calls ([**read**(2)](/man/enterprise-packages/lustre/read.2), [**write**(2)](/man/enterprise-packages/lustre/write.2), [**lseek**(2)](/man/enterprise-packages/lustre/lseek.2), etc.), and closed with [**close**(2)](/man/enterprise-packages/lustre/close.2). One access mode and zero or more file creation flags and file status flags may be bitwise-or'd in *open\_flags*. See [**open**(2)](/man/enterprise-packages/lustre/open.2). If *layout* is non-NULL and *path* is not on a Lustre filesystem this function will fail and set **errno** to **ENOTTY**.

The function **llapi\_layout\_set\_by\_fd** set the *layout* on an open file or directory specified by *fd*.

The function call

**llapi\_layout\_file\_create(path, open\_flags, mode, layout)**

shall be equivalent to:

**llapi\_layout\_file\_open(path, open\_flags|O\_CREAT|O\_EXCL, mode, layout)**

The *layout* and *mode* will not be applied to a file which already exists. Callers requiring a guarantee that the opened file is created with the specified *layout* and *mode* should use **llapi\_layout\_file\_create()**.

A **NULL** *layout* may be specified, in which case the standard Lustre behavior for assigning layouts to newly-created files will apply.

If the pool name attribute of *layout* has been set, it must refer to an OST pool that exists and contains one or more OSTs, otherwise these functions will fail and set **errno** to **EINVAL**. See [**llapi\_layout\_pool\_name\_set**(3)](/man/enterprise-packages/lustre/llapi_layout_pool_name_set.3).

For **llapi\_layout\_set\_by\_fd(),** *fd* is a valid file descriptor for a file or directory in a Lustre filesystem and *layout* is a valid Lustre layout to set on the file.

For **llapi\_layout\_set\_by\_xattr(),** *fd* is a valid file descriptor for a file or a directory in a Lustre filesystem and *lum* is a valid raw xattr to set on the file.

# [RETURN VALUES](#RETURN_VALUES)

**llapi\_layout\_file\_open()** and **llapi\_layout\_file\_create()** return a new file descriptor, or -1 if an error occurred (in which case, errno is set appropriately).

# [ERRORS](#ERRORS)

[**ENOTTY**](#ENOTTY)

*path* does not reside on a Lustre filesystem.

[**EINVAL**](#EINVAL)

An invalid argument was specified.

# [AVAILABILITY](#AVAILABILITY)

**llapi\_layout\_file\_open()** and **llapi\_layout\_file\_create()** are part of the [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7) user application interface library since release 2.7.0

# [SEE ALSO](#SEE_ALSO)

[**close**(2)](/man/enterprise-packages/lustre/close.2), [**open**(2)](/man/enterprise-packages/lustre/open.2), [**llapi\_layout\_alloc**(3)](/man/enterprise-packages/lustre/llapi_layout_alloc.3), [**llapi\_layout\_pool\_name\_set**(3)](/man/enterprise-packages/lustre/llapi_layout_pool_name_set.3), [**llapi\_layout**(7)](/man/enterprise-packages/lustre/llapi_layout.7), [**lustreapi**(7)](/man/enterprise-packages/lustre/lustreapi.7)

2025-04-14 Lustre User API

---

Document: llapi_layout_file_open(3) from lustre 2.17.59-r2 (Chainguard OS)
Source: https://github.com/lustre/lustre-release
