| LLAPI_NAME_VALIDATE(3) | Lustre Library Functions | LLAPI_NAME_VALIDATE(3) |
NAME
llapi_name_validate() - check string contains only valid characters
SYNOPSIS
#include <lustre/lustreapi.h>
int llapi_name_validate(const char *name, const char *extra_chars,
unsigned int maxlen);
DESCRIPTION
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.
RETURN VALUE
llapi_name_validate() returns 0 on success, or a negative errno value on failure.
ERRORS
- 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.
EXAMPLES
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;
}
}
AVAILABILITY
llapi_name_validate is part of the lustre(7) filesystem package since release 2.18.0.
SEE ALSO
| 2026-08-23 | Lustre User API |