nbd_set_private_data(3)
β¨ nbd_set_private_data β set the per-handle private data β¨
okay so this is nbd_set_private_data(3) from the libnbd manual, bestie, and it's genuinely one of the chillest little functions you'll ever meet π
πΈ SYNOPSIS πΈ
#include <libnbd.h>
uintptr_t nbd_set_private_data (
struct nbd_handle *h, uintptr_t private_data
);
π DESCRIPTION π
So every handle has this little stash spot in it β a private data field β and it's literally there for you, the application, to use for absolutely any purpose you want. No rules, no vibe check from libnbd, it's yours π
This function sets the value of that field, and β plot twist β it returns the old value (or 0 if it was never set before). Cute, right? It's giving "here's your stuff back."
When you're calling libnbd from C, the type of this field is uintptr_t, so you can use it to store an unsigned integer or a pointer. Both slay.
In non-C bindings, you can use it to store an unsigned integer. That's it, that's the range π¦
Now, the important part, no cap: libnbd does not use or interpret the value at all β the only thing it ever does with it is hand it back to you when you call nbd_get_private_data(3). And in particular: if that value is a pointer, it is not freed when the handle is closed π«Ά So if you were hoping libnbd would clean up after your pointer, it won't. If you want that behaviour, go look at nbd_add_close_callback(3) instead β that's the friend who'll actually do the cleanup for you.
β RETURN VALUE β
This call returns a uintptr_t. (The old value, remember? π)
π ERRORS π
This function does not fail. Not even a little. It literally cannot fail, iconic behaviour, we stan π
The following parameters must not be NULL: h. For more information see "Non-NULL parameters" in libnbd(3).
π VERSION π
This function first appeared in libnbd 1.8.
If you need to test if this function is available at compile time, check if the following macro is defined:
#define LIBNBD_HAVE_NBD_SET_PRIVATE_DATA 1
π¦ SEE ALSO π¦
nbd_add_close_callback(3), nbd_create(3), nbd_get_private_data(3), libnbd(3).
π AUTHORS π
Eric Blake
Richard W.M. Jones
π COPYRIGHT π
Copyright Red Hat
πΈ LICENSE πΈ
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
kk that's the whole page π this one's from libnbd-1.25.8, dated 2026-10-13, and it's nbd_set_private_data(3) β go store something unhinged in your handle's private data field, you've earned it πβ¨
π¦ where this page comes from
- centos-stream 10: libnbd-devel 1.25.8-1.el10 Β· LGPL-2.0-or-later AND BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms