LLAPI_FID_PARSE(3)

NAME
llapi_fid_parse - parse ASCII FID string into binary lu_fid

SYNOPSIS
#include <lustre/lustreapi.h>

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

DESCRIPTION
llapi_fid_parse() converts an ASCII FID string into a binary struct lu_fid for use in other interfaces such as llapi_layout_get_by_fid(). fidstr should contain three numbers in the form fid_seq:fid_oid:fid_ver and may optionally be enclosed in square braces []. It will skip any leading whitespace before the FID.

If endptr is not NULL, llapi_fid_parse() stores the address of the first invalid character in *endptr, or the character immediately following the end of the parsed FID.

RETURN VALUES
llapi_fid_parse() returns:

0   on success,

<0  a negative errno on failure and sets errno.

ERRORS

-EINVAL
    fidstr is NULL or does not contain a valid FID format.

-ERANGE
    fidstr contains numeric values that exceed valid values for a component.

EXAMPLES
#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 since release 2.14.0

SEE ALSO
llapi_path2parent(3), lustre(7), lustreapi(7)