DNV(9)
β¨ DNV(9) β¨
okay so bestie, welcome to the dnv(9) era β this is the Kernel Developer's Manual page for the FreeBSD dnv API, and honestly? it's giving "default value but make it fashion" π
πΈ LIBRARY πΈ
library "libnv" β yeah she's from libnv, iconic behavior only π
π¦ SYNOPSIS π¦
not me about to dump all these function signatures on you but fr fr they're all important so pay attention bestie:
#include <sys/dnv.h>
bool
dnvlist_get_bool(const nvlist_t *nvl, const char *name, bool defval);
uint64_t
dnvlist_get_number(const nvlist_t *nvl, const char *name,
uint64_t defval);
char *
dnvlist_get_string(const nvlist_t *nvl, const char *name,
const char *defval);
nvlist_t *
dnvlist_get_nvlist(const nvlist_t *nvl, const char *name,
nvlist_t *defval);
int
dnvlist_get_descriptor(const nvlist_t *nvl, const char *name,
int defval);
void *
dnvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep,
void *defval, size_t defsize);
bool
dnvlist_take_bool(const nvlist_t *nvl, const char *name, bool defval);
uint64_t
dnvlist_take_number(const nvlist_t *nvl, const char *name,
uint64_t defval);
char *
dnvlist_take_string(const nvlist_t *nvl, const char *name,
const char *defval);
nvlist_t *
dnvlist_take_nvlist(const nvlist_t *nvl, const char *name,
nvlist_t *defval);
int
dnvlist_take_descriptor(const nvlist_t *nvl, const char *name,
int defval);
void *
dnvlist_take_binary(const nvlist_t *nvl, const char *name,
size_t *sizep, void *defval, size_t defsize);
like yes there's a lot but they're all basically the same vibe with different data types, iykyk π
π DESCRIPTION π
so the libnv library? it's the moment. it lets you manage name/value pairs SO easily and can send and receive them over sockets. for more deets, go check out nv(9) β she's the big sister page π«Ά
β¨ the dnvlist_get girlies β¨
the dnvlist_get functions return the value associated with name. slay. but if an element named name doesn't exist? no stress β the function returns the value you passed in as defval. it's giving "backup plan" energy π
β οΈ BESTIE LISTEN TO ME β returned strings, nvlists, descriptors, binaries, or arrays must not be modified by the user, because they still belong to the nvlist. she's not yours, don't touch her. and if the nvlist is in an error state, attempts to use any of these functions will cause the program to abort. like literally dead. π
π₯ the dnvlist_take girlies π₯
the dnvlist_take functions return the value associated with name AND remove the associated element from nvl. she's taking it and she's not giving it back, periodt. if an element named name doesn't exist, the value provided in defval is returned β same deal as the get functions.
but here's where it gets real, bestie β the memory management is ON YOU:
- when the value is a
string,binary, orarrayvalue β the caller is responsible for freeing returned memory withfree(3)ποΈ - when the value is an
nvlistβ the caller is responsible for destroying the returned nvlist withnvlist_destroy()π - when the value is a
descriptorβ the caller is responsible for closing the returned descriptor withclose(2)πͺ
like she'll hand you the goods but you gotta clean up after yourself, no cap π
π SEE ALSO π
all the linked besties, go say hi π
π HISTORY π
the dnv API appeared in FreeBSD 11.0. she's been iconic since day one, we been knew π
β AUTHORS β
the dnv API was implemented by Pawel Jakub Dawidek <pawel@dawidek.net> under sponsorship from the FreeBSD Foundation β king behavior honestly π
this manual page was written by Adam Starak <starak.adam@gmail.com> β thank you for your service, legend π«‘
okay that's the whole page bestie, you're now officially dnv-literate, go forth and slay those name/value pairs πβ¨
Debian Β· January 3, 2025 Β· dnv(9) β mwah, love u, bye π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2016 Adam Starak <starak.adam@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms