LLAPI_FID_PARSE(3)

πŸ“¦ version 2.17.58, in ubuntu stonking

πŸ’– LLAPI_FID_PARSE πŸ’–

okay bestie, welcome to the llapi_fid_parse page from the Lustre Library Functions manual (section 3, iykyk) πŸ’… this one's a lil function with a big job and honestly? she serves. let's get into it πŸ¦‹


✨ NAME ✨

llapi_fid_parse β€” parse an ASCII FID string into a binary lu_fid πŸ”₯


🌸 SYNOPSIS 🌸

#include <lustre/lustreapi.h>

int llapi_fid_parse(const char *fidstr, struct lu_fid *fid,
                    char **endptr);

πŸ’œ DESCRIPTION πŸ’œ

so basically, llapi_fid_parse() takes your cute lil ASCII FID string and converts it into a binary struct lu_fid so you can actually use it in other interfaces, like llapi_layout_get_by_fid() β€” it's giving glow-up, it's giving translation era ✨

your fidstr should contain three numbers in the form fid_seq:fid_oid:fid_ver, and she may optionally be wrapped in square braces [] like she's being presented on a platter πŸŽ€ bestie she will also skip any leading whitespace before the FID, no cap β€” she doesn't care about your stray spaces, she's unbothered, moisturized, in her lane 😌

now, the endptr tea: if endptr is not NULL, then llapi_fid_parse() stores the address of the first invalid character into *endptr, or the character immediately following the end of the parsed FID πŸ‘‘ so you always know where she stopped reading. iconic behavior fr fr.


🌈 RETURN VALUES 🌈

llapi_fid_parse() returns:

  • 0 β€” on success, slay πŸ’–
  • <0 β€” a negative errno on failure, and she sets errno too. not the vibe, but at least she tells you why 😭

πŸ’€ ERRORS πŸ’€

  • -EINVAL β€” fidstr is NULL, or it doesn't contain a valid FID format. bestie the string was simply not FID-ing πŸ™ˆ
  • -ERANGE β€” fidstr contains numeric values that exceed valid values for a component. she ate too hard and overflowed πŸ’…

⭐ EXAMPLES ⭐

here's the whole little program, copy it exactly bestie, code is code:

#include <lustre/lustreapi.h>

int main(int argc, char *argv[])
{
        char fidstr = "[0x200000004:0x2:0x0] [0x200000400:0x345:0x0]";
        struct lu_fid fid1, fid2;
        char *end;
        int rc;

        fidstr = argv[1];
        rc = llapi_fid_parse(fidstr, &fid1, &end);
        if (rc < 0) {
                fprintf(stderr, "invalid first FID '%s': %s\n",
                        fidstr, strerror(-rc));
                return -1;
        }

        fidstr = end;
        rc = llapi_fid_parse(fidstr, &fid2, &end);
        if (rc < 0) {
                fprintf(stderr, "invalid second FID '%s': %s\n",
                        fidstr, strerror(-rc));
                return -1;
        }

        printf("fid1=" DFID " fid2="DFID"\n", PFID(&fid1), PFID(&fid2));
        return 0;
}

πŸ¦‹ AVAILABILITY πŸ¦‹

llapi_fid_parse() is part of the lustre(7) user application interface library, and she's been around since release 2.14.0 β€” a real seasoned queen πŸ‘‘βœ¨


πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page bestie, no notes 🫢 this was the Lustre User API documentation, dated 2024-08-23, and like every good FID she's parsed and done πŸ’– go forth and llapi_fid_parse responsibly, mwah πŸ§šπŸ’œ

πŸ“¦ where this page comes from