LLAPI\_FID\_PARSE(3) Lustre Library Functions LLAPI\_FID\_PARSE(3)

# [NAME](#NAME)

llapi\_fid\_parse - parse ASCII FID string into binary lu\_fid

# [SYNOPSIS](#SYNOPSIS)

```
#include <lustre/lustreapi.h>
```

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

```

```

# [DESCRIPTION](#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](#RETURN_VALUES)

**llapi\_fid\_parse()** returns:

0

on success,

&lt;0

a negative errno on failure and sets errno.

# [ERRORS](#ERRORS)

[**-EINVAL**](#EINVAL)

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

[**-ERANGE**](#ERANGE)

*fidstr* contains numeric values that exceed valid values for a component.

# [EXAMPLES](#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](#AVAILABILITY)

**llapi\_fid\_parse()** is part of the [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7) user application interface library since release 2.14.0

# [SEE ALSO](#SEE_ALSO)

[**llapi\_path2parent**(3)](/man/enterprise-packages/lustre/llapi_path2parent.3), [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7), [**lustreapi**(7)](/man/enterprise-packages/lustre/lustreapi.7)

2024-08-23 Lustre User API

---

Document: llapi_fid_parse(3) from lustre 2.17.59-r2 (Chainguard OS)
Source: https://github.com/lustre/lustre-release
