docs: For .open callback, clarify TLS and purpose of readonly flag.
[nbdkit/ericb.git] / docs / nbdkit-probing.pod
blob46a7c470404aac96d620bcaf41a73ca5385b4abc
1 =head1 NAME
3 nbdkit-probing - how to probe for nbdkit configuration and plugins
5 =head1 SYNOPSIS
7  nbdkit --dump-config
9  nbdkit PLUGIN --dump-plugin
11 =head1 DESCRIPTION
13 You can query information about nbdkit and available plugins from the
14 nbdkit binary.
16 =head2 Query basic configuration
18  nbdkit --dump-config
20 lists information about how nbdkit was configured.  The most important
21 fields in the output are the name of the directory where nbdkit looks
22 for plugins and the version of nbdkit, eg:
24  plugindir=/usr/lib64/nbdkit/plugins
25  version=1.2.3
27 =head2 Query information about a particular plugin
29  nbdkit pluginname --dump-plugin
31 (where I<pluginname> is the name or full path of a plugin) will dump
32 information about that plugin, eg:
34  $ nbdkit file --dump-plugin
35  path=/usr/lib64/nbdkit/plugins/nbdkit-file-plugin.so
36  name=file
37  version=1.2.3
38  api_version=1
39  struct_size=176
40  thread_model=serialize_requests
41  [etc]
43 Plugins which ship with nbdkit usually have the same version as the
44 corresponding nbdkit binary.  The nbdkit binary will always be able to
45 utilize plugins compiled against an older version of the header;
46 however, newer plugins may not be fully supported by an older nbdkit
47 binary (for example, a plugin compiled with C<NBDKIT_API_VERSION> of 2
48 fails to load with an older nbdkit that only knows
49 C<NBDKIT_API_VERSION> 1).
51 =head2 Detect if a plugin is installed
53 To find out if a plugin is installed (and working) in the plugin
54 directory, use I<--dump-plugin> as above:
56  $ nbdkit foo --dump-plugin
57  nbdkit: error: cannot open plugin 'foo': /usr/lib64/nbdkit/plugins/nbdkit-foo-plugin.so: cannot open shared object file: No such file or directory
58  Use 'nbdkit --help' or read the nbdkit(1) manual page for documentation.
60 Note it is better to test for the existence of plugins this way rather
61 than just seeing if the F<.so> file exists, because nbdkit will load
62 the plugin and check that all its dependencies can be satisfied, and
63 also that plugin registration works.
65 =head2 List all plugins in the plugin directory
67 You could simply get the plugin directory (from I<--dump-config>) and
68 list all files in this directory called F<nbdkit-*-plugin.so>.
70 However a better test is to run I<--dump-plugin> (see above) on each
71 one to check that it is working and all of its dependencies are
72 installed.  A complete shell script which does this is:
74  #!/bin/sh -
75  plugindir=`nbdkit --dump-config | grep ^plugindir= | sed 's/[^=]*=//'`
76  for f in $plugindir/nbdkit-*-plugin.so; do
77      if nbdkit "$f" --dump-plugin >/dev/null 2>&1; then
78          b=`echo "$f" | sed 's,.*/nbdkit-\(.*\)-plugin.so$,\1,'`
79          echo "$b ($f)"
80      fi
81  done
83 =head2 Detect if a filter is installed
85 To find out if a filter is installed (and working) use
86 I<--dump-plugin> with the C<null> plugin and the name of the filter to
87 test:
89  nbdkit --dump-plugin --filter=foo null
91 This will fail with an error and non-zero exit code if the C<foo>
92 filter cannot be loaded.
94 =head1 SEE ALSO
96 L<nbdkit(1)>.
98 =head1 AUTHORS
100 Eric Blake
102 Richard W.M. Jones
104 Pino Toscano
106 =head1 COPYRIGHT
108 Copyright (C) 2013-2018 Red Hat Inc.