nbd_aio_opt_info(3)

πŸ’… nbd_aio_opt_info β€” like, the libnbd girlie's guide

okay bestie, so this is a page from the libnbd manual (that's nbd_aio_opt_info(3), mwah), and we're about to make it make sense. buckle up πŸŽ€


✨ NAME ✨

nbd_aio_opt_info β€” ask the server for the tea about an export β˜•πŸ’–


✨ SYNOPSIS ✨

#include <libnbd.h>

typedef struct {
  int (*callback) (void *user_data, int *error);
  void *user_data;
  void (*free) (void *user_data);
} nbd_completion_callback;

int nbd_aio_opt_info (
      struct nbd_handle *h,
      nbd_completion_callback completion_callback
    );

like, that's the whole vibe. no cap. 🫢


🌸 DESCRIPTION 🌸

So basically you're requesting that the server, like, supply information about the export name β€” and which export name? the one you specified most recently with nbd_set_export_name(3) or nbd_connect_uri(3). the most recent one. don't @ me. πŸ’…

🚨 important vibe check: this can only be used if nbd_set_opt_mode(3) enabled option mode. no option mode, no service. periodt.

So how do you know when the request is done? two ways, bestie:

  • just wait for nbd_aio_is_connecting(3) to return false. iconic, simple.
  • OR supply the optional "completion_callback" β€” which gets invoked exactly as described in "Completion callbacks" in libnbd(3), except that it's automatically retired regardless of return value. (yes, automatically, regardless, we love a self-cleaning girlie ✨)
😭 ngl, this one's important: detecting whether the server returns an error β€” you know, the thing the return value of the synchronous counterpart does for you β€” is only possible with a completion callback. so if you skip the callback, you're lowkey flying blind on errors. iykyk.

πŸ¦‹ RETURN VALUE πŸ¦‹

If the call is successful, the function returns 0. slay. πŸŽ€


🌈 ERRORS 🌈

On error, -1 is returned. πŸ’€

If you wanna know more deets about what went wrong, refer to "ERROR HANDLING" in libnbd(3).

Also, "h" must not be NULL β€” that's a hard requirement, fr fr. like, it's just not optional. For more info, see "Non-NULL parameters" in libnbd(3).


πŸ‘‘ HANDLE STATE πŸ‘‘

nbd_aio_opt_info can be called when the handle is in the following state β€” here's the whole vibe check, one row at a time:

  • 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 yeah. only the opt_mode handshaking window. everything else? error. not me being picky, that's just the state machine 🧚


⭐ VERSION ⭐

This function first appeared in libnbd 1.4. a classic. a 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_INFO 1

πŸ’œ SEE ALSO πŸ’œ

go read these too, bestie, they're all linked up:

nbd_aio_is_connecting(3), nbd_connect_uri(3), nbd_create(3), nbd_is_read_only(3), nbd_opt_info(3), nbd_set_export_name(3), nbd_set_opt_mode(3), libnbd(3).


πŸ’– AUTHORS πŸ’–

  • Eric Blake
  • Richard W.M. Jones

the icons who made this happen πŸ«ΆπŸ‘‘


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. (yes, that's all caps for a reason, don't skip it πŸ™ˆ)

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


okay that's the whole page, bestie!! this was libnbd-1.25.8, dated 2026-10-13 β€” go forth and opt-info responsibly πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from