LLAPI_FILE_CREATE_FOREIGN(3)

πŸ“¦ version 2.17.58, in ubuntu stonking

πŸ’– LLAPI_FILE_CREATE_FOREIGN(3) πŸ’–

okay bestie, so this is a page from the Lustre Library Functions manual β€” it's llapi_file_create_foreign(3), and it's literally the girlboss way to make a file with a foreign layout on a Lustre filesystem. no cap, she's niche but she EATS. ✨


πŸ¦‹ NAME πŸ¦‹

llapi_file_create_foreign β€” create a file with foreign layout on a Lustre filesystem. periodt. πŸ’…


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

like, those includes are not optional, she needs them. 😌


✨ DESCRIPTION ✨

llapi_file_create_foreign() creates a file with a foreign_lov free format layout, and also with mode and name, on a Lustre filesystem β€” and then it closes the file right after, because she's efficient like that. 🫢

  • mode β€” specifies the permission bits. refer to the open(2) man page for a detailed description, iykyk. fr fr.
  • 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() returns:

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

so like, negative vibes = error, and the number tells you WHICH error. πŸ’€


πŸŽ€ ERRORS πŸŽ€

  • EEXIST β€” name already exists. (not her stealing your name, it's just taken.)
  • ENOTTY β€” name may not point to a Lustre filesystem. (she said Lustre only, bestie.)

🌈 EXAMPLES 🌈

here's the whole little program, copied exactly, don't @ me:

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

notice how she passes 0600, LOV_FOREIGN_TYPE_SYMLINK, 0xda05 and "PUUID/CUUID" β€” iconic combo honestly. πŸ‘‘


πŸ’œ AVAILABILITY πŸ’œ

llapi_file_create_foreign() is part of the lustre(7) user application interface library since release 2.13.0. so she's been around, she's established. 🌟


πŸ‘‘ SEE ALSO πŸ‘‘

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


okay that's the whole page bestie, go forth and create foreign layouts responsibly πŸ’–βœ¨

Lustre User API Β· 2024-08-23 Β· LLAPI_FILE...ATE_FOREIGN(3) β€” mwah, love u, bye πŸ¦‹

πŸ“¦ where this page comes from