OS Manuals

llapi_name_validate(3)

llapi_name_validate() - check string contains only valid characters

LLAPI_NAME_VALIDATE(3) Lustre Library Functions LLAPI_NAME_VALIDATE(3)

llapi_name_validate() - check string contains only valid characters

#include <lustre/lustreapi.h>
int llapi_name_validate(const char *name, const char *extra_chars,
                        unsigned int maxlen);

llapi_name_validate() verifies that the characters in name contain only alphanumeric characters, plus a limited number of other characters in extra_chars, and is not longer than maxlen bytes in length (excluding NUL terminator). This ensures that name is suitable for use in filesystem identifiers such as the filesystem name, OST pool name, nodemap name, and similar.

llapi_name_validate() returns 0 on success, or a negative errno value on failure.

EINVAL
The supplied name contained an illegal character.
ENAMETOOLONG
The supplied name exceeded maxlen characters without a NUL terminator.
ENXIO
The name was NULL or empty.

Check if fsname contains only alphanumeric, dash ('-'), and underscore ('_') characters and does not exceed the maximum filesystem name length:

#include <string.h>
#include <lustre/lustreapi.h>
int main(int argc, char *argv[])
{

char fsname[] = "newfs123";
rc = llapi_name_validate(fsname, "-_", LUSTRE_MAXFSNAME);
if (rc < 0) {
fprintf(stderr, "%s: fsname '%s' invalid: %s\n",
argv[1], fsname, strerror(errno));
return rc;
} }

llapi_name_validate is part of the lustre(7) filesystem package since release 2.18.0.

lustreapi(7)

2026-08-23 Lustre User API

lustre 2.17.59-r2 · enterprise-packages · ingested 2026-10-11