OS Manuals

llapi_file_open(3)

llapi_file_open, llapi_file_create - open and possibly create a file or a device on a Lustre filesystem

LLAPI_FILE_OPEN(3) Lustre Library Functions LLAPI_FILE_OPEN(3)

llapi_file_open, llapi_file_create - open and possibly create a file or a device on a Lustre filesystem

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <lustre/lustreapi.h>
int llapi_file_open(const char *name, int flags, int mode,
                    unsigned long long stripe_size, int stripe_offset,
                    int stripe_count, int stripe_pattern);
int llapi_file_create(const char *name, unsigned long long stripe_size,
                      int stripe_offset, int stripe_count,
                      int stripe_pattern);

llapi_file_create() call is equivalent to llapi_file_open call with flags equal to O_CREAT|O_WRONLY and mode equal to 0644, followed by file close.

llapi_file_open() opens a file with a given name on a Lustre filesystem.

can be a combination of O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, O_NONBLOCK, O_SYNC, FASYNC, O_DIRECT, O_LARGEFILE, O_DIRECTORY, O_NOFOLLOW, O_NOATIME.
Refer to open(2) man page for a detailed description.
specifies the permission bits to be used for a new file when O_CREAT is used.
Refer to open(2) man page for a detailed description.
specifies stripe size in bytes and should be multiple of 64 KiB not exceeding 4 GiB.
specifies an OST index from which the file should start, -1 to use the default setting.
specifies number of OSTs to stripe the file across, -1 to use the default setting.
specifies striping pattern, only LOV_PATTERN_RAID0 is available in this Lustre version, 0 to use the default setting.

llapi_file_open() and llapi_file_create() 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.

EINVAL
stripe_size or stripe_offset or stripe_count or stripe_pattern is invalid.
EEXIST
Striping information has already been set and cannot be altered.
name already exists.
EALREADY
Striping information has already been set and cannot be altered.
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(argv[1], 1048576, 0, 2, LOV_PATTERN_RAID0);
if (rc < 0) {
fprintf(stderr, "file creation has failed, %s\n", strerror(-rc));
return -1;
}
printf("%s with stripe size 1048576, striped across 2 OSTs,"
" has been created!\n", argv[1]);
return 0; }

llapi_file_open() and llapi_file_create() are part of the lustre(7) user application interface library since release 2.4.0

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

2024-08-23 Lustre User API

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