nbd_opt_info(3)

πŸ’… nbd_opt_info β€” request the server for information about an export

okay bestie so this page is from the libnbd manual (that's the manual name, we're in nbd_opt_info(3) territory) and let me tell you, this little function is giving ✨reconnaissance era✨. It's literally you walking up to the server like "hey queen, tell me about this export before I commit" πŸŽ€


🌸 SYNOPSIS 🌸

#include <libnbd.h>

int nbd_opt_info (
      struct nbd_handle *h
    );

one function, one handle, zero drama. she's simple. she's iconic. πŸ’…


✨ DESCRIPTION ✨

So what you're doing here is requesting that the server supply info about the export name β€” and which export name, you ask? The one you already specified with the most recent nbd_set_export_name(3) or nbd_connect_uri(3). Like, you already dropped the name earlier, this is just you asking for the tea about it πŸ«–

🚨 important vibe check: this can only be used if nbd_set_opt_mode(3) enabled option mode. Option mode ON or this function says "not today bestie."

If it works out, functions like nbd_is_read_only(3) and nbd_get_size(3) will report the deets about that export. Very "now I know everything about you" energy, ngl 🌈

And listen β€” if nbd_set_request_meta_context(3) is set (which it is by default, just FYI) and structured replies or extended headers were negotiated, then it's also valid to use nbd_can_meta_context(3) after this call. cute!

That said πŸ‘€ it may be more efficient to clear that setting and manually utilize nbd_opt_list_meta_context(3) with its callback approach, if what you're actually trying to learn is which contexts an export supports. different tool, different job, y'know?

In general, if nbd_opt_go(3) is called next, that call will likely succeed with the details remaining the same β€” although this is not guaranteed by all servers. so like... probably fine? but not promised. servers are individuals, we respect that πŸ™ˆ

Also not all servers even understand this request 😭 and even when it is understood, the server might fail the request even when a corresponding nbd_opt_go(3) would succeed. awkward but real. fr fr.


πŸ¦‹ RETURN VALUE πŸ¦‹

If the call is successful the function returns 0. slay. ✨


πŸ’€ ERRORS πŸ’€

On error -1 is returned. (rude, but okay.)

Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error β€” that's where the actual explanation lives, go read it.

The following parameters must not be NULL: "h". For more information see "Non-NULL parameters" in libnbd(3).


πŸ‘‘ HANDLE STATE πŸ‘‘

nbd_opt_info 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 there's exactly one green light and it's the handshake window. that's the moment. main character moment only. ⭐


πŸŽ€ VERSION πŸŽ€

This function first appeared in libnbd 1.4.

If you need to test if this function is available at compile time, check if the following macro is defined:

#define LIBNBD_HAVE_NBD_OPT_INFO 1

iykyk, preprocessor girlies know πŸ’…


🌈 SEE ALSO 🌈

nbd_aio_opt_info(3), nbd_can_meta_context(3), nbd_connect_uri(3), nbd_create(3), nbd_get_size(3), nbd_is_read_only(3), nbd_opt_go(3), nbd_opt_list_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 honestly 🫢


🌸 AUTHORS 🌸

Eric Blake

Richard W.M. Jones


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 bestie, we ate and left no crumbs πŸ“ this was libnbd-1.25.8, dated 2026-10-13 β€” mwah, go forth and interrogate some servers πŸ’œπŸ§š

πŸ“¦ where this page comes from