nbd_set_debug_callback(3)
π nbd_set_debug_callback β like, the libnbd page for setting your debug callback β¨
okay bestie, so this is a page from libnbd(3) β the Network Block Device library β and it's all about one li'l function: nbd_set_debug_callback. It's giving "let me spy on my own library" energy and honestly? Iconic.
πΈ SYNOPSIS πΈ
fr fr, here's the whole shape of it β don't touch, just vibe:
#include <libnbd.h>
typedef struct {
int (*callback) (void *user_data, const char *context,
const char *msg);
void *user_data;
void (*free) (void *user_data);
} nbd_debug_callback;
int nbd_set_debug_callback (
struct nbd_handle *h,
nbd_debug_callback debug_callback
);
Like, you pass in a handle h and a whole nbd_debug_callback struct, and it returns an int. Simple, clean, slay. π
π¦ DESCRIPTION π¦
So what does it do? It sets the debug callback. Groundbreaking, I know. π
This callback gets called when the library emits debug messages β specifically when debugging is enabled on a handle. The callback's parameters are:
"user_data"β the thing you passed to this function, your little personal stash of whatever"context"β the name of the libnbd function that's emitting the debug message"msg"β the message itself, the actual tea β
And listen: if no debug callback is set on a handle, then messages are just printed on "stderr". No callback, no problem β it still tells you stuff, just the default way.
β οΈ okay this part is IMPORTANT bestie, do not skip: the callback should not call nbd_* APIs on the same handle. Why? Because it can be called while holding the handle lock, and that will cause a deadlock. π Like, you'll just sit there forever waiting on yourself. Not the main character energy we want. Do not do it.
π RETURN VALUE π
If the call is successful, the function returns 0. That's it. Zero. The good zero. π«Ά
π₯ ERRORS π₯
On error, -1 is returned. π The bad one.
Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error β that's where the actual explanation lives, iykyk.
Also, heads up: the following parameters must not be NULL: "h". For more info, see "Non-NULL parameters" in libnbd(3). Don't be passing NULL handles around like it's cute, because it is not.
β VERSION β
This function first appeared in libnbd 1.0. OG behavior, honestly. π
If you need to test whether this function is available at compile time, check if the following macro is defined:
#define LIBNBD_HAVE_NBD_SET_DEBUG_CALLBACK 1
π SEE ALSO π
nbd_create(3)libnbd(3)
Go read those too, bestie, they're part of the lore. π
π AUTHORS π
- Eric Blake
- Richard W.M. Jones
Legends. Respect. π
π 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
aaand that's the whole page!! π this was libnbd-1.25.8, dated 2026-10-13, and the manual page is nbd_set_debug_callback(3) β go forth and debug, bestie, you've got this π
β¨π¦
π¦ 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