LLAPI_FID_PARSE(3)
π 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 negativeerrnoon failure, and she setserrnotoo. not the vibe, but at least she tells you why π
π ERRORS π
-EINVALβfidstrisNULL, or it doesn't contain a valid FID format. bestie the string was simply not FID-ing π-ERANGEβfidstrcontains 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
- ubuntu stonking: lustre-client-utils 2.17.58+dfsg-0ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms