$filterdir/nbdkit-readonly-filter.so
The filter.
Use "nbdkit --dump-config" to find the location of $filterdir.
Switch a plugin between read-only and writable
nbdkit --filter=readonly
PLUGIN
nbdkit --filter=readonly
PLUGIN
readonly-file=/tmp/ro
"nbdkit-readonly-filter" is an nbdkit filter that has two modes:
When the "readonly-file" parameter is not used, make the underlying plugin completely read-only. This is similar to using the nbdkit -r option on the command line.
When the "readonly-file" parameter is used, make the underlying plugin read-only when that file is present on disk, but leave it writable when the file is not present (or if the file is deleted). This way you can switch a plugin between being writable and write-protected at run time.
Trying to write to the filter when the filter is enforcing read-only mode will cause "EPERM" ("Operation not permitted") to be returned to the client.
nbdkit-protect-filter(1) is a related filter which can write-protect parts of a plugin (eg only the boot sector). nbdkit-error-filter(1) is another filter which can be used for the same purpose as this filter but is more complicated to use. See also the -r option described in the nbdkit(1) manual.
Make a disk read-only 60 seconds after nbdkit is started:
rm -f /tmp/ronbdkit --filter=readonly file disk.img readonly-file=/tmp/rosleep 60; touch /tmp/ro
readonly-file=PATHNAMEIf this parameter is used, the filter makes the underlying plugin read-only when PATHNAME exists, otherwise the plugin is writable as usual.
If this parameter is not used, the filter always makes the underlying plugin read-only.
$filterdir/nbdkit-readonly-filter.so
The filter.
Use "nbdkit --dump-config" to find the location of $filterdir.
"nbdkit-readonly-filter" first appeared in nbdkit 1.38.