lustreapi(3)

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

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

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
    specifies the permission bits. Refer to open(2) man page for a detailed description.

type
    specifies a type of foreign layout.

flags
    specifies any flags for foreign layout.

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

RETURN VALUES

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.

ERRORS

EEXIST
    name already exists.

ENOTTY
    name may not point to a Lustre filesystem.

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

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