nbd_aio_opt_set_meta_context(3)
β¨ nbd_aio_opt_set_meta_context β¨
okay bestie, welcome to the libnbd manual, and this one is genuinely such a niche little icon π
β it's nbd_aio_opt_set_meta_context, and yes, the name is a mouthful, but we're gonna get through it together fr fr.
π NAME π
nbd_aio_opt_set_meta_context β pick specific meta contexts, with an implicit query list. that's the whole vibe β¨
π¦ SYNOPSIS π¦
#include <libnbd.h>
typedef struct {
int (*callback) (void *user_data, const char *name);
void *user_data;
void (*free) (void *user_data);
} nbd_context_callback;
typedef struct {
int (*callback) (void *user_data, int *error);
void *user_data;
void (*free) (void *user_data);
} nbd_completion_callback;
int nbd_aio_opt_set_meta_context (
struct nbd_handle *h,
nbd_context_callback context_callback,
nbd_completion_callback completion_callback
);
like, look at those callback structs. so structured. so demure. π«Ά
πΈ DESCRIPTION πΈ
so what this cutie actually does: it asks the server to supply all the recognized meta contexts you registered through earlier calls to nbd_add_meta_context(3), and it does that in conjunction with the export you already set with the most recent nbd_set_export_name(3) or nbd_connect_uri(3). iykyk π
the one big caveat: you can only use this if nbd_set_opt_mode(3) turned option mode on. no option mode, no function, periodt.
and ngl, normally this function is redundant β because nbd_opt_go(3) already does the exact same task automatically if structured replies or extended headers have already been negotiated. like it's literally already doing it for you bestie π
but! manual control over meta context requests is genuinely useful when you want fine-grained testing of how a server handles unusual negotiation sequences. that's the main character energy use case π and often you'll couple this function with nbd_set_request_meta_context(3) to bypass the automatic context request that nbd_opt_go(3) normally performs.
so how do you know when the request is done? two options, bestie:
- wait for
nbd_aio_is_connecting(3)to return false, or - supply the optional
completion_callback, which gets invoked as described in "Completion callbacks" inlibnbd(3)β except that it's automatically retired regardless of return value. yes, regardless. it just leaves. iconic π
β οΈ heads up: detecting whether the server returns an error (which is what the return value of the synchronous counterpart does for you) is only possible with a completion callback. so if you wanna know, you gotta supply one. no cap.
β RETURN VALUE β
this call returns an integer β₯ 0. slay π
π ERRORS π
on error, -1 is returned. rough, but that's life.
refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error. that's where the lore lives.
also, the following parameters must not be NULL: "h". for more info, see "Non-NULL parameters" in libnbd(3). don't be handing it a NULL handle, bestie, i'm begging π
π¦ HANDLE STATE π¦
nbd_aio_opt_set_meta_context can be called when the handle is in the following state:
- Handle created, before connecting β β error
- Connecting β β error
- Connecting & handshaking (opt_mode) β β allowed
- Connected to the server β β error
- Connection shut down β β error
- Handle dead β β error
so basically: it's giving "only during handshaking in opt_mode" and nowhere else. the vibes are extremely specific π
π§ VERSION π§
this function first appeared in libnbd 1.16. baby girl is a 1.16 era legend β
if you need to test whether this function is available at compile time, check if the following macro is defined:
#define LIBNBD_HAVE_NBD_AIO_OPT_SET_META_CONTEXT 1
π₯ SEE ALSO π₯
nbd_add_meta_context(3), nbd_aio_is_connecting(3), nbd_aio_opt_set_meta_context_queries(3), nbd_connect_uri(3), nbd_create(3), nbd_opt_go(3), nbd_opt_set_meta_context(3), nbd_set_export_name(3), nbd_set_opt_mode(3), nbd_set_request_meta_context(3), libnbd(3).
the whole friend group, assembled π«Ά
π AUTHORS π
Eric Blake
Richard W.M. Jones
π COPYRIGHT π
Copyright Red Hat
π LICENSE π
legal era, bestie, gotta keep it exact:
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
and that's the page, bestie π this was libnbd-1.25.8, dated 2026-10-13, and honestly? it ate. go forth and negotiate those meta contexts responsibly β¨π¦π
π¦ 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