Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
nbdkit-eval-plugin(1)		    NBDKIT		 nbdkit-eval-plugin(1)

NAME
       nbdkit-eval-plugin - write a shell script plugin	on the command line

SYNOPSIS
	nbdkit eval get_size='SCRIPT' pread='SCRIPT' pwrite='SCRIPT' [...]

DESCRIPTION
       "nbdkit-eval-plugin" is an nbdkit(1) plugin which allows	you to write
       custom plugins as shell scripts snippets	evald on the command line.

       A common	alternative to this plugin is nbdkit-sh-plugin(1).  Both
       plugins share the same source code and work in almost the same way.
       You should read nbdkit-sh-plugin(1) first.  It is easier	to describe
       the differences between the two plugins and look	at the examples	below.

          nbdkit-sh-plugin(1)	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.

          nbdkit-sh-plugin(1)	has  no	 way to	know if	a method is missing or
	   not and so each "can_*" method (eg. "can_write")  must  be  written
	   explicitly.	 In  eval  plugins  you	 have  the  option of omitting
	   "can_*" methods  if	the  associated	 callback  (eg.	 "pwrite")  is
	   defined.   In  this	way eval plugins work more like	regular	nbdkit
	   plugins.

          Eval	plugins	can only use /bin/sh to	run the	script	snippets,  but
	   nbdkit-sh-plugin(1) (in spite of the	name) can run any executable.

          There is no "load" method (although there is	an "unload" method and
	   all other methods are identical).

EXAMPLES
       Create a	64M read-only disk of zeroes:

	nbdkit eval get_size=' echo 64M	' \
		       pread=' dd if=/dev/zero count=$3	iflag=count_bytes '

       The    following	  command   is	 the   eval   plugin   equivalent   of
       nbdkit-file-plugin(1) (except not as fast and missing many features):

	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
       cache=SCRIPT
       can_cache=SCRIPT
       can_extents=SCRIPT
       can_fast_zero=SCRIPT
       can_flush=SCRIPT
       can_fua=SCRIPT
       can_multi_conn=SCRIPT
       can_trim=SCRIPT
       can_write=SCRIPT
       can_zero=SCRIPT
       close=SCRIPT
       config=SCRIPT
       config_complete=SCRIPT
       dump_plugin=SCRIPT
       extents=SCRIPT
       flush=SCRIPT
       get_ready=SCRIPT
       get_size=SCRIPT
       is_rotational=SCRIPT
       open=SCRIPT
       pread=SCRIPT
       preconnect=SCRIPT
       pwrite=SCRIPT
       thread_model=SCRIPT
       trim=SCRIPT
       unload=SCRIPT
       zero=SCRIPT
	   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.

	   If you are typing these commands at the  shell,  be	careful	 about
	   quoting.   Normally	you  will  need	 to  enclose "SCRIPT" in '...'
	   (single quotes) to prevent it from being modified by	your shell.

	   The script fragment behaves	the  same  way	as  the	 corresponding
	   method  in  nbdkit-sh-plugin(1).   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.

	   Note	that a "config"	callback will only handle keys not  recognized
	   as  callback	names; when picking key=value pairs that you want your
	   script fragment to understand, be aware that	 if  a	future	nbdkit
	   release  creates  a	callback  by  that  name, your "config"	script
	   fragment will no longer see that key.

	   All of these	parameters are optional.

       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.

FILES
       /bin/sh
	   Shell script	fragments are executed using /bin/sh.

       $plugindir/nbdkit-eval-plugin.so
	   The plugin.

	   Use "nbdkit --dump-config" to find the location of $plugindir.

VERSION
       "nbdkit-eval-plugin" first appeared in nbdkit 1.18.

SEE ALSO
       nbdkit(1), nbdkit-plugin(3), nbdkit-sh-plugin(1).

AUTHORS
       Richard W.M. Jones

COPYRIGHT
       Copyright (C) 2019 Red Hat Inc.

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.

nbdkit-1.20.4			  2025-04-13		 nbdkit-eval-plugin(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=nbdkit-eval-plugin&sektion=1&manpath=FreeBSD+Ports+14.3.quarterly>

home | help