OS Manuals

llapi_file_create_foreign(3)

llapi_file_create_foreign - create a file with foreign layout on a Lustre filesystem

LLAPI_FILE_CREATE_FOREIGN(3) Lustre Library Functions LLAPI_FILE_CREATE_FOREIGN(3)

llapi_file_create_foreign - create a file with foreign layout on a Lustre filesystem

#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);

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.

specifies the permission bits. Refer to open(2) man page for a detailed description.
specifies a type of foreign layout.
specifies any flags for foreign layout.
free-format string to be set as file layout/LOV EA.

llapi_file_create_foreign() return:

>=0
on success, for llapi_file_open() the return value is a file descriptor.
<0
on failure, the absolute value is an error code.

EEXIST
name already exists.
ENOTTY
name may not point to a Lustre filesystem.

#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; }

llapi_file_create_foreign() is part of the lustre(7) user application interface library since release 2.13.0

open(2), llapi_file_open(3), lustre(7), lustreapi(7)

2024-08-23 Lustre User API

lustre 2.17.60-r0 · enterprise-packages · ingested 2026-10-22