LLAPI_NAME_VALIDATE(3)

πŸ“¦ version 2.17.58, in ubuntu stonking

πŸ’– LLAPI_NAME_VALIDATE(3) β€” the llapi_name_validate() page, bestie edition πŸ’–

ok so real talk, this is a page from the Lustre Library Functions manual, section 3, and it's lowkey one of the most useful little sanity-checkers in the whole thing. let's get into it πŸ¦‹


✨ NAME ✨

llapi_name_validate() β€” check whether a string has only valid characters, no cap πŸ’…


🌸 SYNOPSIS 🌸

#include <lustre/lustreapi.h>

int llapi_name_validate(const char *name, const char *extra_chars, int maxlen);

πŸŽ€ DESCRIPTION πŸŽ€

so here's the vibe. llapi_name_validate() looks at everything in name and makes sure it's only made up of:

  • alphanumeric characters ✨
  • plus a limited set of other characters, the ones you pass in through extra_chars

and it also checks that the whole thing isn't longer than maxlen bytes (and yes, that's excluding the NUL terminator, bestie, we're not counting the terminator, we'd never πŸ‘‘).

the way that this matters is that it guarantees name is actually suitable to be used as a filesystem identifier β€” think things like the filesystem name, the OST pool name, the nodemap name, and similar. like, if you're about to name something in Lustre, run it through here first or you're gonna have a bad time 😭


πŸ”₯ RETURN VALUE πŸ”₯

llapi_name_validate() returns 0 on success. it returns a negative errno value on failure. that's it, that's the whole deal πŸ™ˆ


πŸ’€ ERRORS πŸ’€

  • EINVAL β€” the name you supplied had an illegal character in it. not allowed, sorry babe.
  • ENAMETOOLONG β€” the name you supplied went past maxlen characters without a NUL terminator. it's giving too long, bestie.
  • ENXIO β€” the name was NULL or empty. nothing there. absolutely nothing. πŸ’€

🌈 EXAMPLES 🌈

ok so say you wanna check whether fsname contains only alphanumeric characters, dash ('-'), and underscore ('_'), and that it doesn't exceed the maximum filesystem name length. here's exactly that:

#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;
        }
}

see how extra_chars is "-_"? that's the dash and the underscore getting their little permission slips signed 🫢 and LUSTRE_MAXFSNAME is doing the maxlen job. iconic.


⭐ AVAILABILITY ⭐

llapi_name_validate has been part of the lustre(7) filesystem package since release 2.18.0. so if you're on anything older, this one's not in your group chat yet ✨


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie!! written up by the Lustre User API girlies and dated 2026-08-23. go forth and validate your names, mwah πŸ’…πŸ’–

πŸ“¦ where this page comes from