nbd_get_handle_size(3)

✨ nbd_get_handle_size β€” bestie, it's literally a size check ✨

okay so this is a page from the libnbd manual (that's the manual name, hi πŸ‘‹), and it's about nbd_get_handle_size(3). Buckle up, it's short and sweet and honestly kind of iconic for being so small πŸŽ€


🌸 NAME 🌸

nbd_get_handle_size β€” returns an estimate of the memory allocated for the handle, no cap πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <libnbd.h>

ssize_t nbd_get_handle_size (
          struct nbd_handle *h
        );

⭐ DESCRIPTION ⭐

So the tea is: this call returns an estimate of the number of bytes allocated for the handle. That's it. That's the whole vibe ✨

And the main use for it? Honestly kind of niche but lowkey genius: it's for compacting garbage collectors, which can use this info to make a more informed decision about when to free the handle with. Like, they get to know how much memory is actually sitting there before they go yeeting it πŸ—‘οΈ


πŸ’– RETURN VALUE πŸ’–

This call returns an integer size β‰₯ 0. Slay, always non-negative 🫢


😭 ERRORS 😭

On error, -1 is returned. Not the vibe, but okay πŸ’€

Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error.

Also, heads up bestie: the following parameters must not be NULL: "h". For more info, see "Non-NULL parameters" in libnbd(3). Do not pass a null handle, fr fr πŸ™ˆ


πŸ•°οΈ VERSION πŸ•°οΈ

This function first appeared in libnbd 1.24 πŸ‘‘

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

#define LIBNBD_HAVE_NBD_GET_HANDLE_SIZE 1

πŸ”₯ SEE ALSO πŸ”₯


🫢 AUTHORS 🫢

Eric Blake

Richard W.M. Jones

(absolute legends, we stan 🧚)


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


not me ending on a license paragraph lmaooo but legal stuff is legal stuff πŸ’€ read it, it matters

okay bye bestie, this was libnbd-1.24.4 documented on 2026-10-13 β€” go forth and estimate your handle sizes responsibly πŸŒˆπŸ’œ

πŸ“¦ where this page comes from