nbd_aio_opt_list(3)

✨ nbd_aio_opt_list(3) ✨

okay bestie so this is a page from the libnbd manual, section 3, and it's literally all about nbd_aio_opt_list β€” one of the async girlies. no cap, it's giving "let me see the menu" energy. πŸ“


🌸 NAME 🌸

nbd_aio_opt_list β€” ask the server to list all its exports while you're still in negotiation. that's it, that's the vibe. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <libnbd.h>

typedef struct {
  int (*callback) (void *user_data, const char *name,
                   const char *description);
  void *user_data;
  void (*free) (void *user_data);
} nbd_list_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_list (
      struct nbd_handle *h,
      nbd_list_callback list_callback,
      nbd_completion_callback completion_callback
    );

two whole structs, bestie. one for the listing, one for the completion notification. iconic. 🫢


πŸ’– DESCRIPTION πŸ’–

so you're asking the server to list all the exports it supports. cute, right? but listen β€” this only works if you already turned on option mode with nbd_set_opt_mode(3). no option mode, no listing. periodt. πŸ”₯

now, how do you know when the request is done? two options:

  • wait for nbd_aio_is_connecting(3) to return false β€” that's your signal ✨
  • or hand over the optional completion_callback, which gets invoked exactly how it's described in "Completion callbacks" in libnbd(3) … except with one twist: it's automatically retired regardless of return value. so don't come for it later, it's gone, she's retired, respect her choice πŸ’…
⚠️ heads up: knowing whether the server actually returned an error β€” the thing the synchronous counterpart tells you via its return value β€” is only possible with a completion callback. the async version can't tell you on its own. plan accordingly, bestie. 😭

🌈 RETURN VALUE 🌈

if the call slays, the function returns 0. simple. clean. ✨


πŸ’€ ERRORS πŸ’€

on error, -1 is returned. rip. πŸ™ˆ

want the deets on what went wrong? go read "ERROR HANDLING" in libnbd(3) β€” it's got the whole scoop.

also, a couple of non-negotiables: these parameters must not be NULL β€” h. that's the one. for more, check "Non-NULL parameters" in libnbd(3).


πŸ‘‘ HANDLE STATE πŸ‘‘

nbd_aio_opt_list can only be called when your handle is in the right state. vibe check your handle first, bestie:

  • 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: only during connecting & handshaking with opt_mode on. every other state? nah. πŸ’€


⭐ VERSION ⭐

this function first appeared in libnbd 1.4. she's been around a minute. πŸ’œ

if you need to test at compile time whether it's available, check whether this macro is defined:

#define LIBNBD_HAVE_NBD_AIO_OPT_LIST 1

πŸ¦‹ SEE ALSO πŸ¦‹

the whole friend group, fr fr:


πŸ’… AUTHORS πŸ’…

  • Eric Blake
  • Richard W.M. Jones

the literal main characters who wrote this. 🌟


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


okay that's the whole page, you're a nbd_aio_opt_list expert now, i don't make the rules πŸ’– mwah! this edition was libnbd-1.25.8, dated 2026-10-13 β€” go forth and list those exports, bestie πŸŽ€βœ¨

πŸ“¦ where this page comes from