nbdkit-eval-plugin(1)
π nbdkit-eval-plugin β write a shell script plugin on the command line π
okay so hi bestie π you've landed on nbdkit-eval-plugin(1), one of the nbdkit manual pages, and honestly? this one is kind of iconic. it's the plugin that lets you write a whole custom nbdkit plugin as little shell script snippets right there on the command line. no cap. let's get into it β¨
SYNOPSIS π
nbdkit eval get_size='SCRIPT' pread='SCRIPT' pwrite='SCRIPT' [...]
DESCRIPTION πΈ
nbdkit-eval-plugin is an nbdkit(1) plugin, and the whole vibe is: you write custom plugins as shell script snippets that get βevalβd on the command line. that's it, that's the plugin π«Ά
A super common alternative to this plugin is nbdkit-sh-plugin(3). lowkey they're siblings β both plugins share the same source code and work in almost the same way. so the move is: go read nbdkit-sh-plugin(3) first, bestie. it's genuinely easier to just describe the differences between the two plugins and then peek at the examples below. so here are the differences π
- nbdkit-sh-plugin(3) plugins are written as a single script in a separate file. Eval plugins are shell script fragments written on the nbdkit command line β there is no separate script file. it's giving "no file, just vibes" β¨
- nbdkit-sh-plugin(3) has no way to know if a method is missing or not, so each
can_*method (eg.can_write) has to be written explicitly. In eval plugins you have the option of omittingcan_*methods if the associated callback (eg.pwrite) is defined. so eval plugins work more like regular nbdkit plugins. slay π - Eval plugins can only use
/bin/shto run the script snippets, but nbdkit-sh-plugin(3) (in spite of the name π) can run any executable. - There is no
loadmethod (although there is anunloadmethod, and all other methods are identical).
EXAMPLES π
okay bestie, example time. create a 64M read-only disk of zeroes:
nbdkit eval get_size=' echo 64M ' \
pread=' dd if=/dev/zero count=$3 iflag=count_bytes '
and the following command is the eval plugin equivalent of nbdkit-file-plugin(1) (except not as fast and missing many features, ngl):
nbdkit eval \
config='ln -sf "$(realpath "$3")" $tmpdir/file' \
get_size='stat -Lc %s $tmpdir/file' \
pread='dd if=$tmpdir/file skip=$4 count=$3 iflag=count_bytes,skip_bytes' \
pwrite='dd of=$tmpdir/file seek=$4 conv=notrunc oflag=seek_bytes' \
file=disk.img
PARAMETERS π
bestie here's the full menu, no skips, no skimming π every single one of these takes a script:
after_fork=SCRIPTβ the script for theafter_forkmethod β¨block_size=SCRIPTβ the script for theblock_sizemethodcache=SCRIPTβ the script for thecachemethodcan_cache=SCRIPTβ the script for thecan_cachemethodcan_extents=SCRIPTβ the script for thecan_extentsmethodcan_fast_zero=SCRIPTβ the script for thecan_fast_zeromethodcan_flush=SCRIPTβ the script for thecan_flushmethodcan_fua=SCRIPTβ the script for thecan_fuamethodcan_multi_conn=SCRIPTβ the script for thecan_multi_connmethodcan_trim=SCRIPTβ the script for thecan_trimmethodcan_write=SCRIPTβ the script for thecan_writemethodcan_zero=SCRIPTβ the script for thecan_zeromethodclose=SCRIPTβ the script for theclosemethodconfig=SCRIPTβ the script for theconfigmethodconfig_complete=SCRIPTβ the script for theconfig_completemethoddefault_export=SCRIPTβ the script for thedefault_exportmethoddump_plugin=SCRIPTβ the script for thedump_pluginmethodexport_description=SCRIPTβ the script for theexport_descriptionmethodextents=SCRIPTβ the script for theextentsmethodflush=SCRIPTβ the script for theflushmethodget_ready=SCRIPTβ the script for theget_readymethodget_size=SCRIPTβ the script for theget_sizemethodis_rotational=SCRIPTβ the script for theis_rotationalmethodlist_exports=SCRIPTβ the script for thelist_exportsmethoddefault_export=SCRIPTβ yep, thedefault_exportmethod again, it really is listed twice in the original and we are not erasing her πopen=SCRIPTβ the script for theopenmethodpread=SCRIPTβ the script for thepreadmethodpreconnect=SCRIPTβ the script for thepreconnectmethodpwrite=SCRIPTβ the script for thepwritemethodthread_model=SCRIPTβ the script for thethread_modelmethodtrim=SCRIPTβ the script for thetrimmethodunload=SCRIPTβ the script for theunloadmethodzero=SCRIPTβ the script for thezeromethod
so what do all of these actually mean? Define the script associated with each method. SCRIPT is a fragment of shell script which is executed when nbdkit wants to invoke the associated method. periodt π
If you are typing these commands at the shell, be careful about quoting, bestie, fr fr. Normally you will need to enclose SCRIPT in '...' (single quotes) to prevent it from being modified by your shell. your shell is NOT your friend here π
The script fragment behaves the same way as the corresponding method in nbdkit-sh-plugin(3). In particular, parameters are identical, $tmpdir is present and used in the same way, the exit code must be one of the valid exit codes described in that manual page, and error handling works the same way too. Likewise, nbdkit --dump-plugin eval includes a line for max_known_status= in nbdkit β₯ 1.34.
Note that aconfigcallback will only handle keys not recognized as callback names; when pickingkey=valuepairs that you want your script fragment to understand, be aware that if a future nbdkit release creates a callback by that name, yourconfigscript fragment will no longer see that key. π
All of these parameters are optional. yes, all of them. go wild β¨
missing=SCRIPT π§
The parameter missing defines a script that will be called in place of any other callback not explicitly provided. If omitted, this defaults to the script exit 2.
ENVIRONMENT VARIABLES π
tmpdirβ this is defined to the name of a temporary directory which can be used by the script snippets. It is deleted when nbdkit exits. so like, don't go storing your diary in there π
FILES π
/bin/shβ shell script fragments are executed using/bin/sh.$plugindir/nbdkit-eval-plugin.soβ the plugin. usenbdkit --dump-configto find the location of$plugindirπ¦
VERSION β
nbdkit-eval-plugin first appeared in nbdkit 1.18. a classic, honestly.
SEE ALSO π
nbdkit(1), nbdkit-plugin(3), nbdkit-sh-plugin(3), nbdkit-cc-plugin(1).
AUTHORS π
Richard W.M. Jones
COPYRIGHT
Copyright Red Hat
LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
and that's the whole page bestie π this one's from nbdkit-1.48.1, dated 2026-08-29 β go forth and eval some shell snippets, you've got this πβ¨
π¦ where this page comes from
- fedora 44: nbdkit-basic-plugins 1.48.1-1.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms