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

# [NAME](#NAME)

llapi\_file\_create\_foreign - create a file with foreign layout on a Lustre filesystem

# [SYNOPSIS](#SYNOPSIS)

```
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <lustre/lustreapi.h>
```

```
int llapi_file_create_foreign(const char *name, mode_t mode,
                              __u32 type, __u32 flags,
                              char *foreign_lov);
```

# [DESCRIPTION](#DESCRIPTION)

**llapi\_file\_create\_foreign()** creates a file with *foreign\_lov* free format layout and *mode* and *name* on a Lustre filesystem, followed by file close.

[*mode*](#mode)

specifies the permission bits. Refer to [**open(2)**](/man/enterprise-packages/lustre/open.2) man page for a detailed description.

[*type*](#type)

specifies a type of foreign layout.

[*flags*](#flags)

specifies any flags for foreign layout.

[*foreign\_lov*](#foreign_lov)

free-format string to be set as file layout/LOV EA.

# [RETURN VALUES](#RETURN_VALUES)

**llapi\_file\_create\_foreign()** return:

&gt;=0

on success, for **llapi\_file\_open()** the return value is a file descriptor.

&lt;0

on failure, the absolute value is an error code.

# [ERRORS](#ERRORS)

EEXIST

*name* already exists.

ENOTTY

*name* may not point to a Lustre filesystem.

# [EXAMPLES](#EXAMPLES)

```
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <lustre/lustreapi.h>
int main(int argc, char *argv[])
{


        int rc;


        if (argc != 2)


                return -1;


        rc = llapi_file_create_foreign(argv[1], 0600, LOV_FOREIGN_TYPE_SYMLINK,
				       0xda05, "PUUID/CUUID");


        if (rc < 0) {


                fprintf(stderr, "file creation has failed, %s\n", strerror(-rc));


                return -1;


        }


        printf("foreign file %s has been created with 'PUUID/CUUID' layout!\n",


               argv[1]);


        return 0;
}
```

# [AVAILABILITY](#AVAILABILITY)

**llapi\_file\_create\_foreign()** is part of the [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7) user application interface library since release 2.13.0

# [SEE ALSO](#SEE_ALSO)

[**open**(2)](/man/enterprise-packages/lustre/open.2), [**llapi\_file\_open**(3)](/man/enterprise-packages/lustre/llapi_file_open.3), [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7), [**lustreapi**(7)](/man/enterprise-packages/lustre/lustreapi.7)

2024-08-23 Lustre User API

---

Document: llapi_file_create_foreign(3) from lustre 2.17.60-r0 (Chainguard OS)
Source: https://github.com/lustre/lustre-release
