├── .cirrus.yml ├── .dir-locals.el ├── .gitignore ├── .gitlab-ci.yml ├── .vscode ├── settings.json └── tasks.json ├── BENCHMARKING ├── LICENSE ├── Makefile.am ├── OTHER_PLUGINS ├── README.md ├── SECURITY ├── TODO ├── bash-completion ├── Makefile.am ├── README └── nbdkit ├── ci ├── README.rst ├── build.sh ├── buildenv │ ├── almalinux-8.sh │ ├── alpine-315.sh │ ├── alpine-edge.sh │ ├── centos-stream-8.sh │ ├── debian-10.sh │ ├── debian-11.sh │ ├── debian-sid.sh │ ├── fedora-36-cross-mingw32.sh │ ├── fedora-36-cross-mingw64.sh │ ├── fedora-36.sh │ ├── fedora-rawhide.sh │ ├── opensuse-leap-153.sh │ ├── opensuse-leap-154.sh │ ├── opensuse-tumbleweed.sh │ └── ubuntu-2004.sh ├── cirrus │ ├── build.yml │ ├── freebsd-12.vars │ ├── freebsd-13.vars │ ├── freebsd-current.vars │ └── macos-12.vars ├── containers │ ├── almalinux-8.Dockerfile │ ├── alpine-315.Dockerfile │ ├── alpine-edge.Dockerfile │ ├── centos-stream-8.Dockerfile │ ├── debian-10.Dockerfile │ ├── debian-11.Dockerfile │ ├── debian-sid.Dockerfile │ ├── fedora-36-cross-mingw32.Dockerfile │ ├── fedora-36-cross-mingw64.Dockerfile │ ├── fedora-36.Dockerfile │ ├── fedora-rawhide.Dockerfile │ ├── opensuse-leap-153.Dockerfile │ ├── opensuse-leap-154.Dockerfile │ ├── opensuse-tumbleweed.Dockerfile │ └── ubuntu-2004.Dockerfile ├── gitlab.yml ├── gitlab │ ├── build-templates.yml │ ├── builds.yml │ ├── container-templates.yml │ └── containers.yml ├── manifest.yml ├── skipped_tests └── test-distro.sh ├── common-rules.mk ├── common ├── allocators │ ├── Makefile.am │ ├── allocator-internal.h │ ├── allocator.c │ ├── allocator.h │ ├── malloc.c │ ├── sparse.c │ └── zstd.c ├── bitmap │ ├── Makefile.am │ ├── bitmap.c │ ├── bitmap.h │ └── test-bitmap.c ├── gpt │ ├── Makefile.am │ ├── efi-crc32.c │ ├── efi-crc32.h │ └── gpt.h ├── include │ ├── Makefile.am │ ├── ansi-colours.h │ ├── array-size.h │ ├── ascii-ctype.h │ ├── ascii-string.h │ ├── byte-swapping.h │ ├── checked-overflow.h │ ├── compiler-macros.h │ ├── hexdigit.h │ ├── isaligned.h │ ├── ispowerof2.h │ ├── iszero.h │ ├── minmax.h │ ├── nextnonzero.h │ ├── random.h │ ├── rounding.h │ ├── static-assert.h │ ├── test-array-size.c │ ├── test-ascii-ctype.c │ ├── test-ascii-string.c │ ├── test-byte-swapping.c │ ├── test-checked-overflow.c │ ├── test-isaligned.c │ ├── test-ispowerof2.c │ ├── test-iszero.c │ ├── test-minmax.c │ ├── test-nextnonzero.c │ ├── test-random.c │ ├── test-tvdiff.c │ ├── tvdiff.h │ ├── unique-name.h │ └── unix-path-max.h ├── protocol │ ├── Makefile.am │ ├── generate-protostrings.sh.in │ ├── nbd-protocol.h │ └── protostrings.h ├── regions │ ├── Makefile.am │ ├── regions.c │ └── regions.h ├── replacements │ ├── Makefile.am │ ├── fdatasync.c │ ├── fdatasync.h │ ├── fsync.c │ ├── fsync.h │ ├── get_current_dir_name.c │ ├── get_current_dir_name.h │ ├── getdelim.c │ ├── getline.c │ ├── getline.h │ ├── open_memstream.c │ ├── open_memstream.h │ ├── openlog.c │ ├── poll.c │ ├── poll.h │ ├── posix_memalign.c │ ├── posix_memalign.h │ ├── pread.c │ ├── pread.h │ ├── pwrite.c │ ├── pwrite.h │ ├── realpath.c │ ├── realpath.h │ ├── strndup.c │ ├── strndup.h │ ├── sysconf.c │ ├── sysconf.h │ ├── syslog.c │ ├── syslog.h │ ├── test-current-dir-name.c │ ├── vsyslog.c │ └── win32 │ │ ├── Makefile.am │ │ └── nbdkit-cat.mc └── utils │ ├── Makefile.am │ ├── bench.h │ ├── cleanup-nbdkit.c │ ├── cleanup.c │ ├── cleanup.h │ ├── const-string-vector.h │ ├── environ.c │ ├── exit-with-parent.c │ ├── exit-with-parent.h │ ├── full-rw.c │ ├── nbdkit-string.h │ ├── quote.c │ ├── string-vector.h │ ├── test-quotes.c │ ├── test-vector.c │ ├── utils.c │ ├── utils.h │ ├── vector.c │ ├── vector.h │ ├── windows-compat.c │ ├── windows-compat.h │ └── windows-errors.txt ├── configure.ac ├── docs ├── Makefile.am ├── make-links.sh ├── nbdkit-captive.pod ├── nbdkit-client.pod ├── nbdkit-filter.pod ├── nbdkit-loop.pod ├── nbdkit-plugin.pod ├── nbdkit-probing.pod ├── nbdkit-protocol.pod ├── nbdkit-release-notes-1.10.pod ├── nbdkit-release-notes-1.12.pod ├── nbdkit-release-notes-1.14.pod ├── nbdkit-release-notes-1.16.pod ├── nbdkit-release-notes-1.18.pod ├── nbdkit-release-notes-1.20.pod ├── nbdkit-release-notes-1.22.pod ├── nbdkit-release-notes-1.24.pod ├── nbdkit-release-notes-1.26.pod ├── nbdkit-release-notes-1.28.pod ├── nbdkit-release-notes-1.30.pod ├── nbdkit-release-notes-1.32.pod ├── nbdkit-release-notes-1.4.pod ├── nbdkit-release-notes-1.6.pod ├── nbdkit-release-notes-1.8.pod ├── nbdkit-security.pod ├── nbdkit-service.pod ├── nbdkit-tls.pod ├── nbdkit.pod └── synopsis.txt ├── filters ├── Makefile.am ├── blocksize-policy │ ├── Makefile.am │ ├── nbdkit-blocksize-policy-filter.pod │ └── policy.c ├── blocksize │ ├── Makefile.am │ ├── blocksize.c │ └── nbdkit-blocksize-filter.pod ├── cache │ ├── Makefile.am │ ├── blk.c │ ├── blk.h │ ├── cache.c │ ├── cache.h │ ├── lru.c │ ├── lru.h │ ├── nbdkit-cache-filter.pod │ ├── reclaim.c │ └── reclaim.h ├── cacheextents │ ├── Makefile.am │ ├── cacheextents.c │ └── nbdkit-cacheextents-filter.pod ├── checkwrite │ ├── Makefile.am │ ├── checkwrite.c │ └── nbdkit-checkwrite-filter.pod ├── cow │ ├── Makefile.am │ ├── blk.c │ ├── blk.h │ ├── cow.c │ ├── cow.h │ └── nbdkit-cow-filter.pod ├── ddrescue │ ├── Makefile.am │ ├── ddrescue.c │ └── nbdkit-ddrescue-filter.pod ├── delay │ ├── Makefile.am │ ├── delay.c │ └── nbdkit-delay-filter.pod ├── error │ ├── Makefile.am │ ├── error.c │ └── nbdkit-error-filter.pod ├── exitlast │ ├── Makefile.am │ ├── exitlast.c │ └── nbdkit-exitlast-filter.pod ├── exitwhen │ ├── Makefile.am │ ├── exitwhen.c │ └── nbdkit-exitwhen-filter.pod ├── exportname │ ├── Makefile.am │ ├── exportname.c │ └── nbdkit-exportname-filter.pod ├── ext2 │ ├── Makefile.am │ ├── ext2.c │ ├── io.c │ ├── io.h │ └── nbdkit-ext2-filter.pod ├── extentlist │ ├── Makefile.am │ ├── extentlist.c │ └── nbdkit-extentlist-filter.pod ├── filters.syms ├── fua │ ├── Makefile.am │ ├── fua.c │ └── nbdkit-fua-filter.pod ├── gzip │ ├── Makefile.am │ ├── gzip.c │ └── nbdkit-gzip-filter.pod ├── ip │ ├── Makefile.am │ ├── ip.c │ └── nbdkit-ip-filter.pod ├── limit │ ├── Makefile.am │ ├── limit.c │ └── nbdkit-limit-filter.pod ├── log │ ├── Makefile.am │ ├── log.c │ ├── log.h │ ├── nbdkit-log-filter.pod │ └── output.c ├── luks │ ├── Makefile.am │ ├── luks-encryption.c │ ├── luks-encryption.h │ ├── luks.c │ └── nbdkit-luks-filter.pod ├── multi-conn │ ├── Makefile.am │ ├── multi-conn.c │ └── nbdkit-multi-conn-filter.pod ├── nocache │ ├── Makefile.am │ ├── nbdkit-nocache-filter.pod │ └── nocache.c ├── noextents │ ├── Makefile.am │ ├── nbdkit-noextents-filter.pod │ └── noextents.c ├── nofilter │ ├── Makefile.am │ ├── nbdkit-nofilter-filter.pod │ └── nofilter.c ├── noparallel │ ├── Makefile.am │ ├── nbdkit-noparallel-filter.pod │ └── noparallel.c ├── nozero │ ├── Makefile.am │ ├── nbdkit-nozero-filter.pod │ └── nozero.c ├── offset │ ├── Makefile.am │ ├── nbdkit-offset-filter.pod │ └── offset.c ├── partition │ ├── Makefile.am │ ├── nbdkit-partition-filter.pod │ ├── partition-gpt.c │ ├── partition-mbr.c │ ├── partition.c │ └── partition.h ├── pause │ ├── Makefile.am │ ├── nbdkit-pause-filter.pod │ └── pause.c ├── protect │ ├── Makefile.am │ ├── nbdkit-protect-filter.pod │ └── protect.c ├── rate │ ├── Makefile.am │ ├── bucket.c │ ├── bucket.h │ ├── nbdkit-rate-filter.pod │ └── rate.c ├── readahead │ ├── Makefile.am │ ├── bgthread.c │ ├── nbdkit-readahead-filter.pod │ ├── readahead.c │ └── readahead.h ├── retry-request │ ├── Makefile.am │ ├── nbdkit-retry-request-filter.pod │ └── retry-request.c ├── retry │ ├── Makefile.am │ ├── nbdkit-retry-filter.pod │ └── retry.c ├── scan │ ├── Makefile.am │ ├── bgthread.c │ ├── nbdkit-scan-filter.pod │ ├── scan.c │ └── scan.h ├── stats │ ├── Makefile.am │ ├── nbdkit-stats-filter.pod │ └── stats.cpp ├── swab │ ├── Makefile.am │ ├── nbdkit-swab-filter.pod │ └── swab.c ├── tar │ ├── Makefile.am │ ├── nbdkit-tar-filter.pod │ └── tar.c ├── tls-fallback │ ├── Makefile.am │ ├── nbdkit-tls-fallback-filter.pod │ └── tls-fallback.c ├── truncate │ ├── Makefile.am │ ├── nbdkit-truncate-filter.pod │ └── truncate.c └── xz │ ├── Makefile.am │ ├── blkcache.c │ ├── blkcache.h │ ├── nbdkit-xz-filter.pod │ ├── xz.c │ ├── xzfile.c │ └── xzfile.h ├── fuzzing ├── Makefile.am ├── README └── testcase_dir │ ├── newstyle-cflags │ ├── newstyle-cflags-exportname │ ├── newstyle-cflags-exportname-read4 │ ├── newstyle-cflags-go │ ├── newstyle-cflags-go-read │ ├── newstyle-cflags-go-read4 │ └── newstyle-cflags-go-write ├── html └── pod.css ├── include ├── Makefile.am ├── nbdkit-common.h ├── nbdkit-filter.h ├── nbdkit-plugin.h └── nbdkit-version.h.in ├── m4 ├── .gitignore ├── ax_pthread.m4 └── ocaml.m4 ├── plugins ├── Makefile.am ├── S3 │ ├── Makefile.am │ ├── S3.py │ ├── nbdkit-S3-plugin.pod │ └── nbdkit.py ├── blkio │ ├── Makefile.am │ ├── blkio.c │ └── nbdkit-blkio-plugin.pod ├── cc │ ├── Makefile.am │ ├── cc.c │ └── nbdkit-cc-plugin.pod ├── cdi │ ├── Makefile.am │ ├── cdi.c │ └── nbdkit-cdi-plugin.pod ├── curl │ ├── Makefile.am │ ├── curl.c │ ├── curldefs.h │ ├── nbdkit-curl-plugin.pod │ ├── pool.c │ └── scripts.c ├── data │ ├── Makefile.am │ ├── data.c │ ├── data.h │ ├── disk2data.pl │ ├── format.c │ ├── format.h │ └── nbdkit-data-plugin.pod ├── eval │ ├── Makefile.am │ ├── eval.c │ └── nbdkit-eval-plugin.pod ├── example1 │ ├── Makefile.am │ ├── example1.c │ └── nbdkit-example1-plugin.pod ├── example2 │ ├── Makefile.am │ ├── example2.c │ ├── nbdkit-example2-plugin.pod │ └── winexample2.c ├── example3 │ ├── Makefile.am │ ├── example3.c │ └── nbdkit-example3-plugin.pod ├── example4 │ ├── Makefile.am │ └── example4.pl ├── file │ ├── Makefile.am │ ├── file.c │ ├── nbdkit-file-plugin.pod │ └── winfile.c ├── floppy │ ├── Makefile.am │ ├── directory-lfn.c │ ├── floppy.c │ ├── nbdkit-floppy-plugin.pod │ ├── virtual-floppy.c │ └── virtual-floppy.h ├── full │ ├── Makefile.am │ ├── full.c │ └── nbdkit-full-plugin.pod ├── golang │ ├── Makefile.am │ ├── config-test.go │ ├── dump-plugin-examples.sh │ ├── examples │ │ ├── disk │ │ │ ├── disk.go │ │ │ └── go.mod │ │ ├── dump-plugin │ │ │ ├── dumpplugin.go │ │ │ └── go.mod │ │ ├── minimal │ │ │ ├── go.mod │ │ │ └── minimal.go │ │ └── ramdisk │ │ │ ├── go.mod │ │ │ └── ramdisk.go │ ├── nbdkit-golang-plugin.pod │ └── src │ │ └── libguestfs.org │ │ └── nbdkit │ │ ├── go.mod │ │ ├── nbdkit.go │ │ ├── utils.go │ │ ├── wrappers.go │ │ └── wrappers.h ├── guestfs │ ├── Makefile.am │ ├── guestfs-plugin.c │ └── nbdkit-guestfs-plugin.pod ├── info │ ├── Makefile.am │ ├── info.c │ └── nbdkit-info-plugin.pod ├── iso │ ├── Makefile.am │ ├── iso.c │ └── nbdkit-iso-plugin.pod ├── libvirt │ ├── Makefile.am │ ├── libvirt-plugin.c │ └── nbdkit-libvirt-plugin.pod ├── linuxdisk │ ├── Makefile.am │ ├── filesystem.c │ ├── linuxdisk.c │ ├── nbdkit-linuxdisk-plugin.pod │ ├── partition-gpt.c │ ├── subdir │ │ └── .gitignore │ ├── virtual-disk.c │ └── virtual-disk.h ├── lua │ ├── Makefile.am │ ├── example.lua │ ├── lua.c │ └── nbdkit-lua-plugin.pod ├── memory │ ├── Makefile.am │ ├── memory.c │ └── nbdkit-memory-plugin.pod ├── nbd │ ├── Makefile.am │ ├── nbd.c │ └── nbdkit-nbd-plugin.pod ├── null │ ├── Makefile.am │ ├── nbdkit-null-plugin.pod │ └── null.c ├── ocaml │ ├── Makefile.am │ ├── NBDKit.ml │ ├── NBDKit.mli │ ├── bindings.c │ ├── callbacks.h │ ├── example.ml │ ├── nbdkit-ocaml-plugin.pod │ ├── plugin.c │ └── plugin.h ├── ondemand │ ├── Makefile.am │ ├── default-command.sh.in │ ├── nbdkit-ondemand-plugin.pod │ └── ondemand.c ├── partitioning │ ├── Makefile.am │ ├── nbdkit-partitioning-plugin.pod │ ├── partition-gpt.c │ ├── partition-mbr.c │ ├── partitioning.c │ ├── virtual-disk.c │ └── virtual-disk.h ├── pattern │ ├── Makefile.am │ ├── nbdkit-pattern-plugin.pod │ └── pattern.c ├── perl │ ├── Makefile.am │ ├── example.pl │ ├── nbdkit-perl-plugin.pod │ └── perl.c ├── plugins.syms ├── python │ ├── Makefile.am │ ├── errors.c │ ├── examples │ │ ├── error.py │ │ ├── file.py │ │ ├── imageio.py │ │ ├── ramdisk.py │ │ └── url.py │ ├── helpers.c │ ├── modfunctions.c │ ├── nbdkit-python-plugin.pod │ ├── plugin.c │ └── plugin.h ├── random │ ├── Makefile.am │ ├── nbdkit-random-plugin.pod │ └── random.c ├── ruby │ ├── Makefile.am │ ├── example.rb │ ├── nbdkit-ruby-plugin.pod │ └── ruby.c ├── rust │ ├── CHANGELOG.md │ ├── Cargo.toml │ ├── LICENSE │ ├── Makefile.am │ ├── README.md │ ├── examples │ │ └── ramdisk.rs │ ├── nbdkit-rust-plugin.pod │ ├── src │ │ └── lib.rs │ ├── test.sh │ └── tests │ │ ├── bare_bones.rs │ │ ├── common │ │ └── mod.rs │ │ └── full_featured.rs ├── sh │ ├── Makefile.am │ ├── assemble.sh │ ├── call.c │ ├── call.h │ ├── example.sh │ ├── methods.c │ ├── methods.h │ ├── nbdkit-sh-plugin.pod │ └── sh.c ├── sparse-random │ ├── Makefile.am │ ├── nbdkit-sparse-random-plugin.pod │ └── sparse-random.c ├── split │ ├── Makefile.am │ ├── nbdkit-split-plugin.pod │ └── split.c ├── ssh │ ├── Makefile.am │ ├── nbdkit-ssh-plugin.pod │ └── ssh.c ├── tcl │ ├── Makefile.am │ ├── example.tcl │ ├── nbdkit-tcl-plugin.pod │ └── tcl.c ├── tmpdisk │ ├── Makefile.am │ ├── default-command.sh.in │ ├── nbdkit-tmpdisk-plugin.pod │ └── tmpdisk.c ├── torrent │ ├── Makefile.am │ ├── nbdkit-torrent-plugin.pod │ └── torrent.cpp ├── vddk │ ├── Makefile.am │ ├── README.VDDK │ ├── nbdkit-vddk-plugin.pod │ ├── reexec.c │ ├── stats.c │ ├── utils.c │ ├── vddk-structs.h │ ├── vddk-stubs.h │ ├── vddk.c │ ├── vddk.h │ └── worker.c └── zero │ ├── Makefile.am │ ├── nbdkit-zero-plugin.pod │ └── zero.c ├── podwrapper.pl.in ├── scripts └── git.orderfile ├── server ├── Makefile.am ├── backend.c ├── background.c ├── captive.c ├── connections.c ├── crypto.c ├── debug-flags.c ├── debug.c ├── exports.c ├── extents.c ├── filters.c ├── fuzzer.c ├── internal.h ├── local │ └── nbdkit.pc.in ├── locks.c ├── log-stderr.c ├── log-syslog.c ├── log.c ├── main.c ├── nbdkit.pc.in ├── nbdkit.syms ├── options.h ├── plugins.c ├── protocol-handshake-newstyle.c ├── protocol-handshake-oldstyle.c ├── protocol-handshake.c ├── protocol.c ├── public.c ├── quit.c ├── signals.c ├── socket-activation.c ├── sockets.c ├── test-public.c ├── threadlocal.c ├── usergroup.c └── vfprintf.c ├── tests ├── Makefile.am ├── README.tests ├── cc-shebang.c ├── cc_shebang.ml ├── dummy-vddk.c ├── functions.sh.in ├── generate-file-data.sh ├── make-pki.sh.in ├── make-psk.sh ├── old-plugins │ ├── README │ ├── i686 │ │ └── Linux │ │ │ ├── v1.0.0 │ │ │ └── nbdkit-file-plugin.so │ │ │ ├── v1.12.8-2-g1e2ccc27 │ │ │ └── nbdkit-file-plugin.so │ │ │ ├── v1.18.4 │ │ │ └── nbdkit-file-plugin.so │ │ │ ├── v1.2.8-3-g0560f8f │ │ │ └── nbdkit-file-plugin.so │ │ │ └── v1.8.4-3-g11f5a90d │ │ │ └── nbdkit-file-plugin.so │ └── x86_64 │ │ └── Linux │ │ ├── v1.0.0 │ │ └── nbdkit-file-plugin.so │ │ ├── v1.12.8 │ │ └── nbdkit-file-plugin.so │ │ ├── v1.18.2 │ │ └── nbdkit-file-plugin.so │ │ ├── v1.2.8 │ │ └── nbdkit-file-plugin.so │ │ └── v1.8.4 │ │ └── nbdkit-file-plugin.so ├── pycodestyle.sh ├── python-exception.py ├── python-export-list.py ├── python-export-name.py ├── python-thread-model.py ├── shebang.pl ├── shebang.py ├── shebang.rb ├── test-S3-unit.sh ├── test-S3.sh ├── test-S3 │ ├── boto3 │ │ └── __init__.py │ └── botocore │ │ └── exceptions.py ├── test-ansi-c-plugin.c ├── test-ansi-c.sh ├── test-binary.sh ├── test-blkio.sh ├── test-block-size-constraints.sh ├── test-blocksize-default.sh ├── test-blocksize-error-policy.sh ├── test-blocksize-extents.sh ├── test-blocksize-policy.sh ├── test-blocksize-sharding.sh ├── test-blocksize-write-disconnect.sh ├── test-blocksize.sh ├── test-cache-block-size.sh ├── test-cache-max-size.sh ├── test-cache-on-read-caches.sh ├── test-cache-on-read.sh ├── test-cache-unaligned.sh ├── test-cache.sh ├── test-cacheextents.sh ├── test-captive-tls.sh ├── test-captive.sh ├── test-cc-cpp.cpp ├── test-cc-cpp.sh ├── test-cc-ocaml.sh ├── test-cc.sh ├── test-cdi.sh ├── test-checkwrite-bounds.sh ├── test-checkwrite-fail.sh ├── test-checkwrite.sh ├── test-client-death-tls.sh ├── test-client-death.sh ├── test-connect.c ├── test-cow-block-size.sh ├── test-cow-extents-large.sh ├── test-cow-extents1.sh ├── test-cow-extents2.sh ├── test-cow-null.sh ├── test-cow-on-read-caches.sh ├── test-cow-on-read.sh ├── test-cow-unaligned.sh ├── test-cow.sh ├── test-curl-cookie-script.c ├── test-curl-file.sh ├── test-curl-header-script-fail.script ├── test-curl-header-script-fail.sh ├── test-curl-header-script.c ├── test-curl.c ├── test-cxx-filter.cpp ├── test-cxx-plugin.cpp ├── test-cxx.sh ├── test-data-64b.sh ├── test-data-7E.sh ├── test-data-bad.sh ├── test-data-base64.sh ├── test-data-extents.sh ├── test-data-file.sh ├── test-data-format.sh ├── test-data-optimum.sh ├── test-data-partition.sh ├── test-data-random-slice.sh ├── test-data-random-slice2.sh ├── test-data-raw-copy.sh ├── test-data-raw.sh ├── test-data-reloffset.sh ├── test-data-sectors.sh ├── test-data-size.sh ├── test-data.c ├── test-ddrescue-filter.sh ├── test-debug-flags.sh ├── test-delay-close.sh ├── test-delay-open.sh ├── test-delay-shutdown.sh ├── test-delay.c ├── test-disconnect-plugin.c ├── test-disconnect-tls.sh ├── test-disconnect.sh ├── test-disk2data.sh ├── test-dump-config-major-1.sh ├── test-dump-config-version-major-minor.sh ├── test-dump-config.sh ├── test-dump-plugin-and-single.sh ├── test-dump-plugin-example1.sh ├── test-dump-plugin-example2.sh ├── test-dump-plugin-example4.sh ├── test-dump-plugin-name.sh ├── test-dump-plugin-thread-model.sh ├── test-dump-plugin.sh ├── test-eflags.sh ├── test-error-triggered.sh ├── test-error0.sh ├── test-error10.sh ├── test-error100.sh ├── test-eval-cache.sh ├── test-eval-disconnect.sh ├── test-eval-dump-plugin.sh ├── test-eval-exports.sh ├── test-eval-file.sh ├── test-eval.sh ├── test-exit-with-parent.c ├── test-exitlast.sh ├── test-exitwhen-file-already-created.sh ├── test-exitwhen-file-created-reject-new.sh ├── test-exitwhen-file-created-when-idle.sh ├── test-exitwhen-file-created.sh ├── test-exitwhen-file-deleted.sh ├── test-exitwhen-pipe-closed.c ├── test-exitwhen-process-exits.sh ├── test-exitwhen-script.sh ├── test-export-info.sh ├── test-export-name.sh ├── test-exportname.sh ├── test-ext2-exportname.sh ├── test-ext2.c ├── test-extentlist.sh ├── test-file-block.c ├── test-file-dir.sh ├── test-file-dirfd.sh ├── test-file-extents.sh ├── test-file-fd.sh ├── test-file-readonly.sh ├── test-file.sh ├── test-floppy.sh ├── test-flush-plugin.c ├── test-flush.sh ├── test-foreground.sh ├── test-fua.sh ├── test-full.sh ├── test-golang.c ├── test-gzip-curl.c ├── test-gzip.c ├── test-help-example1.sh ├── test-help-plugin.sh ├── test-help.sh ├── test-info-address.sh ├── test-info-base64.sh ├── test-info-conntime.sh ├── test-info-raw.sh ├── test-info-time.sh ├── test-info-uptime.sh ├── test-ip-filter-anyunix.sh ├── test-ip-filter-anyvsock.sh ├── test-ip-filter-gid.sh ├── test-ip-filter-pid.sh ├── test-ip-filter-uid.sh ├── test-ip-filter.sh ├── test-ipv4-lo.sh ├── test-ipv6-lo.sh ├── test-iso.sh ├── test-just-filter-header.c ├── test-just-plugin-header.c ├── test-lang-plugins.c ├── test-layers-filter.c ├── test-layers-plugin.c ├── test-layers.c ├── test-layers.sh ├── test-limit.sh ├── test-linuxdisk-copy-out.sh ├── test-linuxdisk.sh ├── test-log-error.sh ├── test-log-extents.sh ├── test-log-script-info.sh ├── test-log-script.sh ├── test-log.sh ├── test-long-name.sh ├── test-long-options.sh ├── test-luks-copy-zero.sh ├── test-luks-copy.sh ├── test-luks-info.sh ├── test-manual.sh ├── test-memory-allocator-malloc-mlock.sh ├── test-memory-allocator-malloc.sh ├── test-memory-largest-for-qemu.sh ├── test-memory-largest.sh ├── test-memory.c ├── test-multi-conn-name.sh ├── test-multi-conn-plugin.sh ├── test-multi-conn.sh ├── test-nbd-block-size.sh ├── test-nbd-client-tls.sh ├── test-nbd-client.sh ├── test-nbd-dynamic-content.sh ├── test-nbd-dynamic-list.sh ├── test-nbd-extents.sh ├── test-nbd-qcow2.sh ├── test-nbd-tls-psk.sh ├── test-nbd-tls.sh ├── test-nbd-vsock.sh ├── test-nbd.c ├── test-nbdkit-backend-debug.sh ├── test-newstyle.c ├── test-nofilter.sh ├── test-not-linked-to-libssl.sh ├── test-nozero.sh ├── test-null-extents.sh ├── test-null.c ├── test-ocaml-errorcodes.c ├── test-ocaml.c ├── test-offset-extents.sh ├── test-offset-truncate.sh ├── test-offset.c ├── test-offset2.sh ├── test-old-plugins.sh ├── test-oldstyle.c ├── test-ondemand-list.sh ├── test-ondemand-locking.sh ├── test-ondemand.sh ├── test-parallel-file.sh ├── test-parallel-nbd.sh ├── test-parallel-sh.sh ├── test-partition1.sh ├── test-partition2.sh ├── test-partitioning1.sh ├── test-partitioning2.sh ├── test-partitioning3.sh ├── test-partitioning4.sh ├── test-partitioning5.sh ├── test-partitioning6.sh ├── test-pattern-largest-for-qemu.sh ├── test-pattern-largest.sh ├── test-pattern.sh ├── test-pause.c ├── test-plugin-docs.sh ├── test-probe-filter.sh ├── test-probe-plugin.sh ├── test-protect-ranges.sh ├── test-protect.c ├── test-python-exception.sh ├── test-python-export-list.sh ├── test-python-export-name.sh ├── test-python-plugin.py ├── test-python-thread-model.sh ├── test-python.sh ├── test-random-copy.sh ├── test-random-sock.sh ├── test-random.c ├── test-rate-dynamic.sh ├── test-rate.sh ├── test-read-password-interactive.sh ├── test-read-password-plugin.c ├── test-read-password.sh ├── test-readahead-copy.sh ├── test-readahead.sh ├── test-retry-extents.sh ├── test-retry-open.sh ├── test-retry-readonly.sh ├── test-retry-reopen-fail.sh ├── test-retry-request-mirror.c ├── test-retry-request-open.sh ├── test-retry-request.sh ├── test-retry-size.sh ├── test-retry-zero-flags.sh ├── test-retry.sh ├── test-scan-copy.sh ├── test-scan-info.sh ├── test-sh-errors.sh ├── test-sh-extents.sh ├── test-sh-tmpdir-leak.sh ├── test-shebang-cc-ocaml.sh ├── test-shebang-cc.sh ├── test-shebang-perl.sh ├── test-shebang-python.sh ├── test-shebang-ruby.sh ├── test-shell.sh ├── test-short-options.sh ├── test-shutdown-plugin.c ├── test-shutdown.sh ├── test-single-from-file.sh ├── test-single-sh.sh ├── test-single.sh ├── test-socket-activation.c ├── test-sparse-random-copy.sh ├── test-sparse-random-info.sh ├── test-split-extents.sh ├── test-split.c ├── test-ssh.sh ├── test-start.sh ├── test-stdio-plugin.c ├── test-stdio.sh ├── test-swab-16r.sh ├── test-swab-16w.sh ├── test-swab-32r.sh ├── test-swab-32w.sh ├── test-swab-64r.sh ├── test-swab-64w.sh ├── test-swab-8.sh ├── test-swab-extents.sh ├── test-swap.sh ├── test-synopsis.sh ├── test-tar-gzip-curl.c ├── test-tar-info-xz.sh ├── test-tar-info.sh ├── test-tar-xz-curl.c ├── test-tar.sh ├── test-tls-fallback.sh ├── test-tls-psk.sh ├── test-tls.sh ├── test-tmpdisk-command.sh ├── test-tmpdisk.c ├── test-truncate-extents.sh ├── test-truncate1.sh ├── test-truncate2.sh ├── test-truncate3.sh ├── test-truncate4.sh ├── test-vddk-dump-plugin.sh ├── test-vddk-password-fd.sh ├── test-vddk-password-interactive.sh ├── test-vddk-real-create.sh ├── test-vddk-real-dump-plugin.sh ├── test-vddk-real.sh ├── test-vddk-reexec.sh ├── test-vddk-run.sh ├── test-vddk.c ├── test-version-example1.sh ├── test-version-filter.sh ├── test-version-plugin.sh ├── test-version.sh ├── test-vsock.sh ├── test-xz-curl.c ├── test-xz.c ├── test-zero.sh ├── test.c ├── test.h ├── test.lua ├── test.pl ├── test.rb ├── test.tcl ├── test_ocaml_errorcodes_plugin.ml ├── test_ocaml_plugin.ml ├── test_python.py ├── web-server.c └── web-server.h ├── valgrind ├── Makefile.am ├── ext2fs.suppressions ├── glibc.suppressions ├── gnutls.suppressions ├── nbdkit.suppressions ├── ocaml.suppressions ├── perl.suppressions └── sh.suppressions └── wrapper.c /.cirrus.yml: -------------------------------------------------------------------------------- 1 | rust_test_task: 2 | matrix: 3 | - name: rust-1.46.0 4 | container: 5 | image: rust:1.46.0 6 | env: 7 | RUSTFLAGS: -Dwarnings 8 | RUSTDOCFLAGS: -Dwarnings 9 | - name: rust-stable 10 | container: 11 | image: rust:latest 12 | env: 13 | RUSTFLAGS: -Dwarnings 14 | RUSTDOCFLAGS: -Dwarnings 15 | - name: rust-nightly 16 | container: 17 | image: rustlang/rust:nightly 18 | env: 19 | CARGO_ARGS: --all-features 20 | RUSTFLAGS: -Dwarnings 21 | RUSTDOCFLAGS: -Dwarnings 22 | cargo_cache: 23 | folder: $CARGO_HOME/registry 24 | build_script: 25 | - cd plugins/rust; cargo build $CARGO_ARGS 26 | test_script: 27 | - cd plugins/rust; cargo test $CARGO_ARGS 28 | example_script: 29 | - cd plugins/rust; cargo build $CARGO_ARGS --examples 30 | doc_script: 31 | - cd plugins/rust; cargo doc $CARGO_ARGS --no-deps 32 | before_cache_script: rm -rf $CARGO_HOME/registry/index 33 | 34 | minver_task: 35 | name: minver 36 | depends_on: 37 | - rust-1.46.0 38 | - rust-stable 39 | - rust-nightly 40 | - rust-clippy 41 | container: 42 | image: rustlang/rust:nightly 43 | env: 44 | RUSTFLAGS: -Dwarnings 45 | RUSTDOCFLAGS: -Dwarnings 46 | cargo_cache: 47 | folder: $CARGO_HOME/registry 48 | test_script: 49 | - cd plugins/rust 50 | - cargo update -Zminimal-versions 51 | - cargo test --all-features 52 | before_cache_script: rm -rf $CARGO_HOME/registry/index 53 | 54 | rust_clippy_task: 55 | name: rust-clippy 56 | matrix: 57 | - container: 58 | image: rustlang/rust:nightly 59 | cargo_cache: 60 | folder: $CARGO_HOME/registry 61 | lint_script: 62 | - rustup component add clippy 63 | - cd plugins/rust 64 | - cargo clippy --all-features --all-targets -- -D warnings 65 | before_cache_script: rm -rf $CARGO_HOME/registry/index 66 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | ((autoconf-mode . ((indent-tabs-mode . nil))) 4 | (c-mode . ((indent-tabs-mode . nil) 5 | (c-basic-offset . 2)))) 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.vcFormat.newLine.beforeOpenBrace.function": "newLine", 3 | "C_Cpp.vcFormat.space.beforeFunctionOpenParenthesis": "insert", 4 | "C_Cpp.vcFormat.space.pointerReferenceAlignment": "right", 5 | "C_Cpp.formatting": "vcFormat", 6 | "C_Cpp.vcFormat.indent.withinParentheses": "alignToParenthesis", 7 | "python.linting.flake8Enabled": true, 8 | "rewrap.wrappingColumn": 79 9 | } 10 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "process", 6 | "label": "Build project", 7 | "command": "/usr/bin/make", 8 | "args": [], 9 | "options": { 10 | "cwd": "${workspaceFolder}" 11 | }, 12 | "problemMatcher": [ 13 | "$gcc" 14 | ], 15 | "group": { 16 | "kind": "build", 17 | "isDefault": true 18 | } 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | nbdkit 2 | Copyright Red Hat 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | * Neither the name of Red Hat nor the names of its contributors may be 16 | used to endorse or promote products derived from this software without 17 | specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /OTHER_PLUGINS: -------------------------------------------------------------------------------- 1 | Have you written an nbdkit plugin that you're willing to share? 2 | Email to get it added to this list. 3 | 4 | * XVA (XenServer Virtual Appliance) 5 | 6 | This simple plugin written in Perl lets you read these files and 7 | reexport them as NBD. It does not require that the XVA is unpacked: 8 | https://lists.gnu.org/archive/html/qemu-devel/2017-11/msg02971.html 9 | https://lists.gnu.org/archive/html/qemu-devel/2017-11/plHKJ062x5Uo.pl 10 | 11 | The whole thread is worth reading because several different approaches 12 | to dealing with XVA files are presented: 13 | https://lists.gnu.org/archive/html/qemu-devel/2017-11/threads.html#02839 14 | -------------------------------------------------------------------------------- /SECURITY: -------------------------------------------------------------------------------- 1 | If you think you've found a serious or potential security bug that you 2 | don't want to report on a public mailing list, then send email to both 3 | and . 4 | 5 | Make it clear in the email Subject line that it's a serious or 6 | security-related bug in nbdkit. 7 | 8 | You can also sign and/or encrypt messages using our GPG public keys 9 | available on the usual keyservers, or online here: 10 | https://download.libguestfs.org/libguestfs.keyring 11 | 12 | For information about past security issues, see 13 | docs/nbdkit-security.pod, or the nbdkit-security(1) man page if you 14 | have installed nbdkit, also available online here: 15 | http://libguestfs.org/nbdkit-security.1.html 16 | -------------------------------------------------------------------------------- /bash-completion/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | EXTRA_DIST = README 35 | 36 | if HAVE_BASH_COMPLETION 37 | 38 | dist_bashcomp_DATA = nbdkit 39 | 40 | endif 41 | -------------------------------------------------------------------------------- /bash-completion/README: -------------------------------------------------------------------------------- 1 | This directory contains the scripts for tab-completing commands in 2 | bash. Note these new-style demand-loaded scripts require 3 | bash-completion >= 1.99. 4 | 5 | Tip: To test the bash completions without having to install them, 6 | simply start a new shell and do: 7 | 8 | source ./bash-completion/nbdkit; PATH=$PWD:$PATH 9 | -------------------------------------------------------------------------------- /ci/buildenv/alpine-315.sh: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | function install_buildenv() { 8 | apk update 9 | apk upgrade 10 | apk add \ 11 | autoconf \ 12 | automake \ 13 | bash \ 14 | bash-completion \ 15 | busybox \ 16 | ca-certificates \ 17 | cargo \ 18 | ccache \ 19 | cdrkit \ 20 | clang \ 21 | curl-dev \ 22 | e2fsprogs \ 23 | expect \ 24 | g++ \ 25 | gcc \ 26 | git \ 27 | gnutls-dev \ 28 | go \ 29 | gzip \ 30 | hexdump \ 31 | iproute2 \ 32 | jq \ 33 | libselinux-dev \ 34 | libssh-dev \ 35 | libtool \ 36 | libtorrent \ 37 | libvirt-dev \ 38 | lua5.4 \ 39 | make \ 40 | ocaml \ 41 | perl \ 42 | perl-dev \ 43 | pkgconf \ 44 | py3-boto3 \ 45 | py3-flake8 \ 46 | python3 \ 47 | python3-dev \ 48 | qemu-img \ 49 | rust \ 50 | sfdisk \ 51 | socat \ 52 | tcl \ 53 | xz \ 54 | xz-dev \ 55 | zlib-dev \ 56 | zstd 57 | apk list | sort > /packages.txt 58 | mkdir -p /usr/libexec/ccache-wrappers 59 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/c++ 60 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/cc 61 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/clang 62 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ 63 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc 64 | } 65 | 66 | export CCACHE_WRAPPERSDIR="/usr/libexec/ccache-wrappers" 67 | export LANG="en_US.UTF-8" 68 | export MAKE="/usr/bin/make" 69 | export PYTHON="/usr/bin/python3" 70 | -------------------------------------------------------------------------------- /ci/buildenv/alpine-edge.sh: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | function install_buildenv() { 8 | apk update 9 | apk upgrade 10 | apk add \ 11 | autoconf \ 12 | automake \ 13 | bash \ 14 | bash-completion \ 15 | busybox \ 16 | ca-certificates \ 17 | cargo \ 18 | ccache \ 19 | cdrkit \ 20 | clang \ 21 | curl-dev \ 22 | e2fsprogs \ 23 | expect \ 24 | g++ \ 25 | gcc \ 26 | git \ 27 | gnutls-dev \ 28 | go \ 29 | gzip \ 30 | hexdump \ 31 | iproute2 \ 32 | jq \ 33 | libselinux-dev \ 34 | libssh-dev \ 35 | libtool \ 36 | libtorrent \ 37 | libvirt-dev \ 38 | lua5.4 \ 39 | make \ 40 | ocaml \ 41 | perl \ 42 | perl-dev \ 43 | pkgconf \ 44 | py3-boto3 \ 45 | py3-flake8 \ 46 | python3 \ 47 | python3-dev \ 48 | qemu-img \ 49 | rust \ 50 | rust-clippy \ 51 | sfdisk \ 52 | socat \ 53 | tcl \ 54 | xz \ 55 | xz-dev \ 56 | zlib-dev \ 57 | zstd 58 | apk list | sort > /packages.txt 59 | mkdir -p /usr/libexec/ccache-wrappers 60 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/c++ 61 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/cc 62 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/clang 63 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ 64 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc 65 | } 66 | 67 | export CCACHE_WRAPPERSDIR="/usr/libexec/ccache-wrappers" 68 | export LANG="en_US.UTF-8" 69 | export MAKE="/usr/bin/make" 70 | export PYTHON="/usr/bin/python3" 71 | -------------------------------------------------------------------------------- /ci/cirrus/build.yml: -------------------------------------------------------------------------------- 1 | @CIRRUS_VM_INSTANCE_TYPE@: 2 | @CIRRUS_VM_IMAGE_SELECTOR@: @CIRRUS_VM_IMAGE_NAME@ 3 | 4 | env: 5 | CI_REPOSITORY_URL: "@CI_REPOSITORY_URL@" 6 | CI_COMMIT_REF_NAME: "@CI_COMMIT_REF_NAME@" 7 | CI_COMMIT_SHA: "@CI_COMMIT_SHA@" 8 | PATH: "@PATH@" 9 | PKG_CONFIG_PATH: "@PKG_CONFIG_PATH@" 10 | PYTHON: "@PYTHON@" 11 | MAKE: "@MAKE@" 12 | PERL: "@PERL@" 13 | GOLANG: "@GOLANG@" 14 | RUST: "@RUST@" 15 | 16 | build_task: 17 | install_script: 18 | - @UPDATE_COMMAND@ 19 | - @UPGRADE_COMMAND@ 20 | - @INSTALL_COMMAND@ @PKGS@ 21 | - if test -n "@PYPI_PKGS@" ; then @PIP3@ install @PYPI_PKGS@ ; fi 22 | clone_script: 23 | - git clone --depth 100 "$CI_REPOSITORY_URL" . 24 | - git fetch origin "$CI_COMMIT_REF_NAME" 25 | - git reset --hard "$CI_COMMIT_SHA" 26 | build_script: 27 | - ci/build.sh 28 | -------------------------------------------------------------------------------- /ci/cirrus/freebsd-12.vars: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | CCACHE='/usr/local/bin/ccache' 8 | CPAN_PKGS='' 9 | CROSS_PKGS='' 10 | MAKE='/usr/local/bin/gmake' 11 | NINJA='/usr/local/bin/ninja' 12 | PACKAGING_COMMAND='pkg' 13 | PIP3='/usr/local/bin/pip-3.8' 14 | PKGS='autoconf automake bash bash-completion ca_root_nss ccache cdrkit-genisoimage curl e2fsprogs expect git gmake gnutls go gzip jq libssh libtool libtorrent libvirt lua54 ocaml p5-Pod-Simple perl5 perl5-devel pkgconf py39-boto3 py39-flake8 python3 qemu rust socat tcl87 xorriso zstd' 15 | PYPI_PKGS='' 16 | PYTHON='/usr/local/bin/python3' 17 | -------------------------------------------------------------------------------- /ci/cirrus/freebsd-13.vars: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | CCACHE='/usr/local/bin/ccache' 8 | CPAN_PKGS='' 9 | CROSS_PKGS='' 10 | MAKE='/usr/local/bin/gmake' 11 | NINJA='/usr/local/bin/ninja' 12 | PACKAGING_COMMAND='pkg' 13 | PIP3='/usr/local/bin/pip-3.8' 14 | PKGS='autoconf automake bash bash-completion ca_root_nss ccache cdrkit-genisoimage curl e2fsprogs expect git gmake gnutls go gzip jq libssh libtool libtorrent libvirt lua54 ocaml p5-Pod-Simple perl5 perl5-devel pkgconf py39-boto3 py39-flake8 python3 qemu rust socat tcl87 xorriso zstd' 15 | PYPI_PKGS='' 16 | PYTHON='/usr/local/bin/python3' 17 | -------------------------------------------------------------------------------- /ci/cirrus/freebsd-current.vars: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | CCACHE='/usr/local/bin/ccache' 8 | CPAN_PKGS='' 9 | CROSS_PKGS='' 10 | MAKE='/usr/local/bin/gmake' 11 | NINJA='/usr/local/bin/ninja' 12 | PACKAGING_COMMAND='pkg' 13 | PIP3='/usr/local/bin/pip-3.8' 14 | PKGS='autoconf automake bash bash-completion ca_root_nss ccache cdrkit-genisoimage curl e2fsprogs expect git gmake gnutls go gzip jq libssh libtool libtorrent libvirt lua54 ocaml p5-Pod-Simple perl5 perl5-devel pkgconf py39-boto3 py39-flake8 python3 qemu rust socat tcl87 xorriso zstd' 15 | PYPI_PKGS='' 16 | PYTHON='/usr/local/bin/python3' 17 | -------------------------------------------------------------------------------- /ci/cirrus/macos-12.vars: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | CCACHE='/opt/homebrew/bin/ccache' 8 | CPAN_PKGS='ExtUtils::Embed' 9 | CROSS_PKGS='' 10 | MAKE='/opt/homebrew/bin/gmake' 11 | NINJA='/opt/homebrew/bin/ninja' 12 | PACKAGING_COMMAND='brew' 13 | PIP3='/opt/homebrew/bin/pip3' 14 | PKGS='autoconf automake bash bash-completion ccache cpanminus curl e2fsprogs expect flake8 git gnutls golang gzip jq libssh libtool libvirt lua make ocaml perl pkg-config python3 qemu rust socat tcl-tk xorriso xz zlib zstd' 15 | PYPI_PKGS='boto3' 16 | PYTHON='/opt/homebrew/bin/python3' 17 | -------------------------------------------------------------------------------- /ci/containers/alpine-315.Dockerfile: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | FROM docker.io/library/alpine:3.15 8 | 9 | RUN apk update && \ 10 | apk upgrade && \ 11 | apk add \ 12 | autoconf \ 13 | automake \ 14 | bash \ 15 | bash-completion \ 16 | busybox \ 17 | ca-certificates \ 18 | cargo \ 19 | ccache \ 20 | cdrkit \ 21 | clang \ 22 | curl-dev \ 23 | e2fsprogs \ 24 | expect \ 25 | g++ \ 26 | gcc \ 27 | git \ 28 | gnutls-dev \ 29 | go \ 30 | gzip \ 31 | hexdump \ 32 | iproute2 \ 33 | jq \ 34 | libselinux-dev \ 35 | libssh-dev \ 36 | libtool \ 37 | libtorrent \ 38 | libvirt-dev \ 39 | lua5.4 \ 40 | make \ 41 | ocaml \ 42 | perl \ 43 | perl-dev \ 44 | pkgconf \ 45 | py3-boto3 \ 46 | py3-flake8 \ 47 | python3 \ 48 | python3-dev \ 49 | qemu-img \ 50 | rust \ 51 | sfdisk \ 52 | socat \ 53 | tcl \ 54 | xz \ 55 | xz-dev \ 56 | zlib-dev \ 57 | zstd && \ 58 | apk list | sort > /packages.txt && \ 59 | mkdir -p /usr/libexec/ccache-wrappers && \ 60 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/c++ && \ 61 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/cc && \ 62 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/clang && \ 63 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \ 64 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc 65 | 66 | ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" 67 | ENV LANG "en_US.UTF-8" 68 | ENV MAKE "/usr/bin/make" 69 | ENV PYTHON "/usr/bin/python3" 70 | -------------------------------------------------------------------------------- /ci/containers/alpine-edge.Dockerfile: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | FROM docker.io/library/alpine:edge 8 | 9 | RUN apk update && \ 10 | apk upgrade && \ 11 | apk add \ 12 | autoconf \ 13 | automake \ 14 | bash \ 15 | bash-completion \ 16 | busybox \ 17 | ca-certificates \ 18 | cargo \ 19 | ccache \ 20 | cdrkit \ 21 | clang \ 22 | curl-dev \ 23 | e2fsprogs \ 24 | expect \ 25 | g++ \ 26 | gcc \ 27 | git \ 28 | gnutls-dev \ 29 | go \ 30 | gzip \ 31 | hexdump \ 32 | iproute2 \ 33 | jq \ 34 | libselinux-dev \ 35 | libssh-dev \ 36 | libtool \ 37 | libtorrent \ 38 | libvirt-dev \ 39 | lua5.4 \ 40 | make \ 41 | ocaml \ 42 | perl \ 43 | perl-dev \ 44 | pkgconf \ 45 | py3-boto3 \ 46 | py3-flake8 \ 47 | python3 \ 48 | python3-dev \ 49 | qemu-img \ 50 | rust \ 51 | rust-clippy \ 52 | sfdisk \ 53 | socat \ 54 | tcl \ 55 | xz \ 56 | xz-dev \ 57 | zlib-dev \ 58 | zstd && \ 59 | apk list | sort > /packages.txt && \ 60 | mkdir -p /usr/libexec/ccache-wrappers && \ 61 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/c++ && \ 62 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/cc && \ 63 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/clang && \ 64 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \ 65 | ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc 66 | 67 | ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" 68 | ENV LANG "en_US.UTF-8" 69 | ENV MAKE "/usr/bin/make" 70 | ENV PYTHON "/usr/bin/python3" 71 | -------------------------------------------------------------------------------- /ci/gitlab/container-templates.yml: -------------------------------------------------------------------------------- 1 | # THIS FILE WAS AUTO-GENERATED 2 | # 3 | # $ lcitool manifest ci/manifest.yml 4 | # 5 | # https://gitlab.com/libvirt/libvirt-ci 6 | 7 | 8 | # We want to publish containers with tag 'latest': 9 | # 10 | # - In upstream, for push to default branch with CI changes. 11 | # - In upstream, on request, for scheduled/manual pipelines 12 | # against default branch 13 | # 14 | # Note: never publish from merge requests since they have non-committed code 15 | # 16 | .container_job: 17 | image: docker:stable 18 | stage: containers 19 | interruptible: false 20 | needs: [] 21 | services: 22 | - docker:dind 23 | before_script: 24 | - export TAG="$CI_REGISTRY_IMAGE/ci-$NAME:latest" 25 | - docker info 26 | - docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" 27 | script: 28 | - docker build --tag "$TAG" -f "ci/containers/$NAME.Dockerfile" ci/containers ; 29 | - docker push "$TAG" 30 | after_script: 31 | - docker logout 32 | rules: 33 | # upstream: publish containers if there were CI changes on the default branch 34 | - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' 35 | when: on_success 36 | changes: 37 | - ci/gitlab/container-templates.yml 38 | - ci/containers/$NAME.Dockerfile 39 | 40 | # upstream: allow force re-publishing containers on default branch for web/api/scheduled pipelines 41 | - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $RUN_CONTAINER_BUILDS == "1"' 42 | when: on_success 43 | 44 | # upstream+forks: that's all folks 45 | - when: never 46 | -------------------------------------------------------------------------------- /ci/skipped_tests: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/ci/skipped_tests -------------------------------------------------------------------------------- /common-rules.mk: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | # Convenient list terminator 33 | NULL = 34 | 35 | plugindir = $(libdir)/nbdkit/plugins 36 | filterdir = $(libdir)/nbdkit/filters 37 | 38 | CLEANFILES = *~ *.cmi *.cmx *.cmxa *.so *.dll 39 | -------------------------------------------------------------------------------- /common/allocators/allocator-internal.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_ALLOCATOR_INTERNAL_H 34 | #define NBDKIT_ALLOCATOR_INTERNAL_H 35 | 36 | #include "vector.h" 37 | 38 | struct key_value { char *key, *value; }; 39 | DEFINE_VECTOR_TYPE (allocator_parameters, struct key_value); 40 | 41 | extern void register_allocator (const struct allocator_functions *); 42 | 43 | #endif /* NBDKIT_ALLOCATOR_INTERNAL_H */ 44 | -------------------------------------------------------------------------------- /common/gpt/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | noinst_LTLIBRARIES = libgpt.la 35 | 36 | libgpt_la_SOURCES = \ 37 | efi-crc32.c \ 38 | efi-crc32.h \ 39 | gpt.h \ 40 | $(NULL) 41 | libgpt_la_CFLAGS = $(WARNINGS_CFLAGS) 42 | -------------------------------------------------------------------------------- /common/gpt/efi-crc32.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_EFI_CRC32_H 34 | #define NBDKIT_EFI_CRC32_H 35 | 36 | #include 37 | 38 | extern uint32_t efi_crc32 (const void *buf, size_t len) 39 | __attribute__ ((__nonnull__ (1))); 40 | 41 | #endif /* NBDKIT_EFI_CRC32_H */ 42 | -------------------------------------------------------------------------------- /common/include/array-size.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_ARRAY_SIZE_H 34 | #define NBDKIT_ARRAY_SIZE_H 35 | 36 | #include "compiler-macros.h" 37 | 38 | #define ARRAY_SIZE(a) \ 39 | ((sizeof (a) / sizeof ((a)[0])) + BUILD_BUG_UNLESS_TRUE (TYPE_IS_ARRAY (a))) 40 | 41 | #endif /* NBDKIT_ARRAY_SIZE_H */ 42 | -------------------------------------------------------------------------------- /common/include/unique-name.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_UNIQUE_NAME_H 34 | #define NBDKIT_UNIQUE_NAME_H 35 | 36 | /* https://stackoverflow.com/a/1597129 37 | * https://stackoverflow.com/a/12711226 38 | */ 39 | #define XXUNIQUE_NAME(name, counter) name ## counter 40 | #define XUNIQUE_NAME(name, counter) XXUNIQUE_NAME (name, counter) 41 | #define NBDKIT_UNIQUE_NAME(name) XUNIQUE_NAME (name, __COUNTER__) 42 | 43 | #endif /* NBDKIT_UNIQUE_NAME_H */ 44 | -------------------------------------------------------------------------------- /common/include/unix-path-max.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_UNIX_PATH_MAX_H 34 | #define NBDKIT_UNIX_PATH_MAX_H 35 | 36 | #ifdef __APPLE__ 37 | #define UNIX_PATH_MAX 104 38 | #else 39 | #define UNIX_PATH_MAX 108 40 | #endif 41 | 42 | #endif /* NBDKIT_UNIX_PATH_MAX_H */ 43 | -------------------------------------------------------------------------------- /common/regions/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | noinst_LTLIBRARIES = libregions.la 35 | 36 | libregions_la_SOURCES = \ 37 | regions.c \ 38 | regions.h \ 39 | $(NULL) 40 | libregions_la_CPPFLAGS = \ 41 | -I$(top_srcdir)/include \ 42 | -I$(top_builddir)/include \ 43 | -I$(top_srcdir)/common/include \ 44 | -I$(top_srcdir)/common/utils \ 45 | $(NULL) 46 | libregions_la_CFLAGS = $(WARNINGS_CFLAGS) 47 | -------------------------------------------------------------------------------- /common/replacements/fdatasync.c: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | /* Replacement for fdatasync for platforms which lack this function. */ 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | #ifndef HAVE_FDATASYNC 41 | 42 | #include "fsync.h" 43 | #include "fdatasync.h" 44 | 45 | int 46 | fdatasync (int fd) 47 | { 48 | return fsync (fd); 49 | } 50 | 51 | #endif /* !HAVE_FDATASYNC */ 52 | -------------------------------------------------------------------------------- /common/replacements/fdatasync.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_FDATASYNC_H 34 | #define NBDKIT_FDATASYNC_H 35 | 36 | #include 37 | 38 | #include 39 | 40 | #ifndef HAVE_FDATASYNC 41 | extern int fdatasync (int fd); 42 | #endif 43 | 44 | #endif /* NBDKIT_FDATASYNC_H */ 45 | -------------------------------------------------------------------------------- /common/replacements/fsync.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_FSYNC_H 34 | #define NBDKIT_FSYNC_H 35 | 36 | #include 37 | 38 | #include 39 | 40 | #ifndef HAVE_FSYNC 41 | extern int fsync (int fd); 42 | #endif 43 | 44 | #endif /* NBDKIT_FSYNC_H */ 45 | -------------------------------------------------------------------------------- /common/replacements/get_current_dir_name.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_GET_CURRENT_DIR_NAME_H 34 | #define NBDKIT_GET_CURRENT_DIR_NAME_H 35 | 36 | #include 37 | 38 | #ifdef HAVE_GET_CURRENT_DIR_NAME 39 | 40 | #include 41 | 42 | #else 43 | 44 | extern char *get_current_dir_name (void); 45 | 46 | #endif 47 | 48 | #endif /* NBDKIT_GET_CURRENT_DIR_NAME_H */ 49 | -------------------------------------------------------------------------------- /common/replacements/getline.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: getline.c,v 1.2 2015/12/25 20:12:46 joerg Exp $ */ 2 | /* NetBSD-src: getline.c,v 1.2 2014/09/16 17:23:50 christos Exp */ 3 | 4 | /*- 5 | * Copyright (c) 2011 The NetBSD Foundation, Inc. 6 | * All rights reserved. 7 | * 8 | * This code is derived from software contributed to The NetBSD Foundation 9 | * by Christos Zoulas. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | #ifndef HAVE_GETLINE 37 | 38 | #include "getline.h" 39 | 40 | ssize_t 41 | getline (char **buf, size_t *bufsiz, FILE *fp) 42 | { 43 | return getdelim (buf, bufsiz, '\n', fp); 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /common/replacements/getline.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_GETLINE_H 34 | #define NBDKIT_GETLINE_H 35 | 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | #ifndef HAVE_GETLINE 42 | 43 | ssize_t getline (char **lineptr, size_t *n, FILE *stream); 44 | ssize_t getdelim (char **lineptr, size_t *n, int delim, FILE *stream); 45 | 46 | #endif 47 | 48 | #endif /* NBDKIT_GETLINE_H */ 49 | -------------------------------------------------------------------------------- /common/replacements/pread.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_PREAD_H 34 | #define NBDKIT_PREAD_H 35 | 36 | #include 37 | 38 | #include 39 | 40 | #ifndef HAVE_PREAD 41 | extern ssize_t pread (int fd, void *buf, size_t count, off_t offset); 42 | #endif 43 | 44 | #endif /* NBDKIT_PREAD_H */ 45 | -------------------------------------------------------------------------------- /common/replacements/pwrite.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_PWRITE_H 34 | #define NBDKIT_PWRITE_H 35 | 36 | #include 37 | 38 | #include 39 | 40 | #ifndef HAVE_PWRITE 41 | extern ssize_t pwrite (int fd, const void *buf, size_t count, off_t offset); 42 | #endif 43 | 44 | #endif /* NBDKIT_PWRITE_H */ 45 | -------------------------------------------------------------------------------- /common/replacements/realpath.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_REALPATH_H 34 | #define NBDKIT_REALPATH_H 35 | 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | #ifndef HAVE_REALPATH 42 | 43 | char *realpath (const char *path, char *out); 44 | 45 | #endif 46 | 47 | #endif /* NBDKIT_REALPATH_H */ 48 | -------------------------------------------------------------------------------- /common/replacements/strndup.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_STRNDUP_H 34 | #define NBDKIT_STRNDUP_H 35 | 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | #ifndef HAVE_STRNDUP 42 | 43 | char *strndup (const char *s, size_t n); 44 | 45 | #endif 46 | 47 | #endif /* NBDKIT_STRNDUP_H */ 48 | -------------------------------------------------------------------------------- /common/replacements/win32/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | EXTRA_DIST = nbdkit-cat.mc 35 | 36 | if IS_WINDOWS 37 | 38 | # Build the message catalog. 39 | noinst_DATA = MSG00001.bin nbdkit-cat.h nbdkit-cat.rc 40 | 41 | $(noinst_DATA): nbdkit-cat.mc 42 | rm -f $@ 43 | $(MC) $< 44 | 45 | endif 46 | -------------------------------------------------------------------------------- /common/replacements/win32/nbdkit-cat.mc: -------------------------------------------------------------------------------- 1 | ;// nbdkit 2 | ;// Copyright Red Hat 3 | ;// 4 | ;// Redistribution and use in source and binary forms, with or without 5 | ;// modification, are permitted provided that the following conditions are 6 | ;// met: 7 | ;// 8 | ;// * Redistributions of source code must retain the above copyright 9 | ;// notice, this list of conditions and the following disclaimer. 10 | ;// 11 | ;// * Redistributions in binary form must reproduce the above copyright 12 | ;// notice, this list of conditions and the following disclaimer in the 13 | ;// documentation and/or other materials provided with the distribution. 14 | ;// 15 | ;// * Neither the name of Red Hat nor the names of its contributors may be 16 | ;// used to endorse or promote products derived from this software without 17 | ;// specific prior written permission. 18 | ;// 19 | ;// THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | ;// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | ;// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | ;// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | ;// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | ;// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | ;// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ;// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | ;// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | ;// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | ;// SUCH DAMAGE. 31 | 32 | MessageId=1 33 | Severity=Error 34 | SymbolicName=NBDKIT_SYSLOG_ERROR 35 | Language=English 36 | %1 37 | . 38 | -------------------------------------------------------------------------------- /common/utils/cleanup-nbdkit.c: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | #include "cleanup.h" 39 | #include "nbdkit-filter.h" 40 | 41 | void 42 | cleanup_extents_free (struct nbdkit_extents **ptr) 43 | { 44 | nbdkit_extents_free (*ptr); 45 | } 46 | 47 | void 48 | cleanup_exports_free (struct nbdkit_exports **ptr) 49 | { 50 | nbdkit_exports_free (*ptr); 51 | } 52 | -------------------------------------------------------------------------------- /common/utils/nbdkit-string.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | /* Extensible string. The implementation uses vector.h. */ 34 | 35 | #ifndef NBDKIT_STRING_H 36 | #define NBDKIT_STRING_H 37 | 38 | #include "vector.h" 39 | 40 | DEFINE_VECTOR_TYPE (string, char); 41 | #define CLEANUP_FREE_STRING __attribute__ ((cleanup (string_reset))) 42 | 43 | #endif /* NBDKIT_STRING_H */ 44 | -------------------------------------------------------------------------------- /docs/make-links.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Turn a list of plugins or filters into a comma-separated 34 | # list of POD links. 35 | # eg: 36 | # ./make-links.sh plugin 1 foo bar 37 | # --> L, L 38 | 39 | type="$1" 40 | section="$2" 41 | shift 2 42 | for (( i = 1; i <= $#; ++i )); do 43 | printf %s "L" 44 | if [ "$i" -lt "$#" ]; then printf %s , ; fi 45 | echo 46 | done 47 | -------------------------------------------------------------------------------- /docs/nbdkit-security.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-security - information about past security issues in nbdkit 4 | 5 | =head1 DESCRIPTION 6 | 7 | This page details past security issues found in nbdkit. 8 | 9 | For how to report new security issues, see the C file in the 10 | top level source directory, also available online here: 11 | L 12 | 13 | =head2 CVE-2019-14850 14 | denial of service due to premature opening of back-end connection 15 | 16 | See the full announcement and links to mitigation, tests and fixes 17 | here: 18 | https://www.redhat.com/archives/libguestfs/2019-September/msg00084.html 19 | 20 | =head2 CVE-2019-14851 21 | assertion failure by issuing commands in the wrong order 22 | 23 | This CVE was caused by the fix to the previous issue. 24 | 25 | See the full announcement and links to mitigation, tests and fixes 26 | here: 27 | https://www.redhat.com/archives/libguestfs/2019-September/msg00272.html 28 | 29 | =head2 CVE-2021-3716 30 | structured read denial of service attack against starttls 31 | 32 | See the full announcement and links to mitigation, tests and fixes 33 | here: 34 | https://www.redhat.com/archives/libguestfs/2021-August/msg00083.html 35 | 36 | =head1 SEE ALSO 37 | 38 | L. 39 | 40 | =head1 AUTHORS 41 | 42 | Eric Blake 43 | 44 | Richard W.M. Jones 45 | 46 | =head1 COPYRIGHT 47 | 48 | Copyright Red Hat 49 | -------------------------------------------------------------------------------- /docs/synopsis.txt: -------------------------------------------------------------------------------- 1 | nbdkit [-4|--ipv4-only] [-6|--ipv6-only] 2 | [-D|--debug PLUGIN|FILTER|nbdkit.FLAG=N] 3 | [--exit-with-parent] [-e|--exportname EXPORTNAME] 4 | [--filter=FILTER ...] [-f|--foreground] 5 | [-g|--group GROUP] [-i|--ipaddr IPADDR] 6 | [--log=stderr|syslog|null] [--mask-handshake=MASK] 7 | [-n|--newstyle] [--no-sr] [-o|--oldstyle] 8 | [-P|--pidfile PIDFILE] [-p|--port PORT] 9 | [-r|--readonly] [--run 'COMMAND ARGS ...'] 10 | [--selinux-label=LABEL] [-s|--single] [--swap] 11 | [-t|--threads THREADS] [--tls=off|on|require] 12 | [--tls-certificates=/path/to/certificates] 13 | [--tls-psk=/path/to/pskfile] [--tls-verify-peer] 14 | [-U|--unix SOCKET|-] [-u|--user USER] 15 | [-v|--verbose] [--vsock] 16 | PLUGIN [[KEY=]VALUE [KEY=VALUE [...]]] 17 | 18 | nbdkit --dump-config 19 | 20 | nbdkit PLUGIN --dump-plugin 21 | 22 | nbdkit --help 23 | 24 | nbdkit [-V|--version] 25 | -------------------------------------------------------------------------------- /filters/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | EXTRA_DIST = filters.syms 35 | 36 | SUBDIRS = $(filters) 37 | -------------------------------------------------------------------------------- /filters/cacheextents/nbdkit-cacheextents-filter.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-cacheextents-filter - cache extents 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit --filter=cacheextents plugin 8 | 9 | =head1 DESCRIPTION 10 | 11 | C is a filter that caches the result of last 12 | extents() call. 13 | 14 | A common use for this filter is to improve performance when using a 15 | client performing a linear pass over the entire image while asking for 16 | only one extent at a time (such as S>), but where 17 | the plugin can provide multiple extents for the same high latency as a 18 | single extent (such as L). For example: 19 | 20 | nbdkit -U - --filter=cacheextents --run 'qemu-img map $nbd' vddk ... 21 | 22 | For files with big extents (when it is unlikely for one extents() call 23 | to return multiple different extents) this does not slow down the 24 | access. 25 | 26 | This filter only caches image metadata; to also cache image contents, 27 | place this filter between L and the plugin. 28 | 29 | =head1 PARAMETERS 30 | 31 | There are no parameters specific to nbdkit-cacheextents-filter. Any 32 | parameters are passed through to and processed by the underlying 33 | plugin in the normal way. 34 | 35 | =head1 FILES 36 | 37 | =over 4 38 | 39 | =item F<$filterdir/nbdkit-cacheextents-filter.so> 40 | 41 | The filter. 42 | 43 | Use C to find the location of C<$filterdir>. 44 | 45 | =back 46 | 47 | =head1 VERSION 48 | 49 | C first appeared in nbdkit 1.14. 50 | 51 | =head1 SEE ALSO 52 | 53 | L, 54 | L, 55 | L, 56 | L, 57 | L, 58 | L, 59 | L, 60 | L. 61 | 62 | =head1 AUTHORS 63 | 64 | Martin Kletzander 65 | 66 | =head1 COPYRIGHT 67 | 68 | Copyright Red Hat 69 | -------------------------------------------------------------------------------- /filters/cow/cow.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_COW_H 34 | #define NBDKIT_COW_H 35 | 36 | /* Size of a block in the cache. */ 37 | extern unsigned blksize; 38 | 39 | #endif /* NBDKIT_COW_H */ 40 | -------------------------------------------------------------------------------- /filters/exitlast/nbdkit-exitlast-filter.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-exitlast-filter - exit on last client connection 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit --filter=exitlast PLUGIN 8 | 9 | =head1 DESCRIPTION 10 | 11 | C is an nbdkit filter that causes nbdkit to 12 | exit when there are no more client connections. Note that it doesn't 13 | exit before the first client connection. 14 | 15 | One use for this is in combination with a superserver, to save 16 | resources when nbdkit is not in use (see L). 17 | Another use is to ensure nbdkit exits after the client has finished 18 | (but see also nbdkit-captive(1) for other ways to do this). 19 | 20 | To exit when an event occurs, try L. 21 | 22 | =head1 PARAMETERS 23 | 24 | There are no parameters specific to nbdkit-exitlast-filter. Any 25 | parameters are passed through to and processed by the underlying 26 | plugin in the normal way. 27 | 28 | =head1 FILES 29 | 30 | =over 4 31 | 32 | =item F<$filterdir/nbdkit-exitlast-filter.so> 33 | 34 | The filter. 35 | 36 | Use C to find the location of C<$filterdir>. 37 | 38 | =back 39 | 40 | =head1 VERSION 41 | 42 | C first appeared in nbdkit 1.20. 43 | 44 | =head1 SEE ALSO 45 | 46 | L, 47 | L, 48 | L, 49 | L, 50 | L, 51 | L, 52 | L, 53 | L, 54 | L. 55 | 56 | =head1 AUTHORS 57 | 58 | Richard W.M. Jones 59 | 60 | =head1 COPYRIGHT 61 | 62 | Copyright Red Hat 63 | -------------------------------------------------------------------------------- /filters/filters.syms: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | # This linker script controls the visibility of symbols in filters. 33 | # Filters only need to export the "filter_init" function and debug 34 | # flags. 35 | # 36 | # Use of this linker script is entirely optional. It's just for 37 | # hygiene. 38 | 39 | { 40 | global: 41 | filter_init; 42 | *_debug_*; 43 | 44 | # Everything else is hidden. 45 | local: *; 46 | }; 47 | -------------------------------------------------------------------------------- /filters/limit/nbdkit-limit-filter.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-limit-filter - limit number of clients that can connect concurrently 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit --filter=limit PLUGIN [limit=N] 8 | 9 | =head1 DESCRIPTION 10 | 11 | C is an nbdkit filter that limits the number of 12 | clients which can connect concurrently. If more than C 13 | (default: 1) clients try to connect at the same time then later 14 | clients are rejected. 15 | 16 | =head1 PARAMETERS 17 | 18 | =over 4 19 | 20 | =item BN 21 | 22 | Limit the number of concurrent clients to C. This parameter is 23 | optional. If not specified then the limit defaults to 1. You can 24 | also set this to 0 to make the number of clients unlimited (ie. 25 | disable the filter). 26 | 27 | =back 28 | 29 | =head1 FILES 30 | 31 | =over 4 32 | 33 | =item F<$filterdir/nbdkit-limit-filter.so> 34 | 35 | The filter. 36 | 37 | Use C to find the location of C<$filterdir>. 38 | 39 | =back 40 | 41 | =head1 VERSION 42 | 43 | C first appeared in nbdkit 1.20. 44 | 45 | =head1 SEE ALSO 46 | 47 | L, 48 | L, 49 | L, 50 | L, 51 | L, 52 | L, 53 | L, 54 | L. 55 | 56 | =head1 AUTHORS 57 | 58 | Richard W.M. Jones 59 | 60 | =head1 COPYRIGHT 61 | 62 | Copyright Red Hat 63 | -------------------------------------------------------------------------------- /filters/noextents/nbdkit-noextents-filter.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-noextents-filter - disable extents in the underlying plugin 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit --filter=noextents plugin 8 | 9 | =head1 DESCRIPTION 10 | 11 | “Extents” are a feature of the NBD protocol / nbdkit which allow the 12 | client to detect sparse regions of the underlying disk. 13 | C disables this so that the plugin appears to 14 | be fully allocated, at least to a client that requests structured 15 | replies. It is also possible to use the I<--no-sr> option to nbdkit 16 | to prevent the client from using structured replies, which among its 17 | other side effects will prevent the client from querying extents at 18 | all. 19 | 20 | This filter can be useful when combined with L 21 | serving a file from a file system known to have poor C 22 | performance (C is known to be one such system). 23 | 24 | =head1 PARAMETERS 25 | 26 | There are no parameters specific to nbdkit-noextents-filter. Any 27 | parameters are passed through to and processed by the underlying 28 | plugin in the normal way. 29 | 30 | =head1 FILES 31 | 32 | =over 4 33 | 34 | =item F<$filterdir/nbdkit-noextents-filter.so> 35 | 36 | The filter. 37 | 38 | Use C to find the location of C<$filterdir>. 39 | 40 | =back 41 | 42 | =head1 VERSION 43 | 44 | C first appeared in nbdkit 1.14. 45 | 46 | =head1 SEE ALSO 47 | 48 | L, 49 | L, 50 | L, 51 | L, 52 | L, 53 | L, 54 | L, 55 | L, 56 | L. 57 | 58 | =head1 AUTHORS 59 | 60 | Richard W.M. Jones 61 | 62 | =head1 COPYRIGHT 63 | 64 | Copyright Red Hat 65 | -------------------------------------------------------------------------------- /filters/nofilter/nbdkit-nofilter-filter.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-nofilter-filter - nbdkit passthrough filter 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit --filter=nofilter plugin [plugin-args...] 8 | 9 | =head1 DESCRIPTION 10 | 11 | C passes through requests unchanged. 12 | It is mostly used for testing nbdkit. 13 | 14 | =head1 FILES 15 | 16 | =over 4 17 | 18 | =item F<$filterdir/nbdkit-nofilter-filter.so> 19 | 20 | The filter. 21 | 22 | Use C to find the location of C<$filterdir>. 23 | 24 | =back 25 | 26 | =head1 VERSION 27 | 28 | C first appeared in nbdkit 1.18. 29 | 30 | =head1 SEE ALSO 31 | 32 | L, 33 | L. 34 | 35 | =head1 AUTHORS 36 | 37 | Richard W.M. Jones 38 | 39 | =head1 COPYRIGHT 40 | 41 | Copyright Red Hat 42 | -------------------------------------------------------------------------------- /filters/nofilter/nofilter.c: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | 35 | #include 36 | 37 | static struct nbdkit_filter filter = { 38 | .name = "nofilter", 39 | .longname = "nbdkit nofilter filter", 40 | }; 41 | 42 | NBDKIT_REGISTER_FILTER (filter) 43 | -------------------------------------------------------------------------------- /filters/partition/nbdkit-partition-filter.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-partition-filter - nbdkit partition filter 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit --filter=partition plugin partition=PART [plugin-args...] 8 | 9 | =head1 DESCRIPTION 10 | 11 | C is a filter that limits requests to a 12 | single partition within a disk image that is served by another plugin. 13 | 14 | Partition numbers are specified by the required C 15 | parameter, and count from 1. 16 | 17 | This works like the C option. 18 | 19 | The opposite of this filter is L which 20 | adds a virtual partition table to a file or files. 21 | 22 | =head1 PARAMETERS 23 | 24 | =over 4 25 | 26 | =item BPART 27 | 28 | The partition number to serve, counting from 1. 29 | 30 | This parameter is required. 31 | 32 | =back 33 | 34 | =head1 EXAMPLE 35 | 36 | F is a partitioned disk image (eg. a virtual machine disk 37 | image). To serve the first partition only use: 38 | 39 | nbdkit --filter=partition file disk.img partition=1 40 | 41 | =head1 FILES 42 | 43 | =over 4 44 | 45 | =item F<$filterdir/nbdkit-partition-filter.so> 46 | 47 | The filter. 48 | 49 | Use C to find the location of C<$filterdir>. 50 | 51 | =back 52 | 53 | =head1 VERSION 54 | 55 | C first appeared in nbdkit 1.2. 56 | 57 | =head1 SEE ALSO 58 | 59 | L, 60 | L, 61 | L, 62 | L, 63 | L, 64 | L, 65 | L, 66 | L. 67 | 68 | =head1 AUTHORS 69 | 70 | Eric Blake 71 | 72 | Richard W.M. Jones 73 | 74 | =head1 COPYRIGHT 75 | 76 | Copyright Red Hat 77 | -------------------------------------------------------------------------------- /filters/retry-request/nbdkit-retry-request-filter.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-retry-request-filter - retry single requests on error 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit --filter=retry-request PLUGIN 8 | [retry-request-retries=N] [retry-request-delay=N] 9 | [retry-request-open=false] 10 | 11 | =head1 DESCRIPTION 12 | 13 | C is a filter for nbdkit that 14 | transparently retries single requests if they fail. This is useful 15 | for plugins that are not completely reliable or have random behaviour. 16 | For example L might behave this way if pointed 17 | at a load balancer which sometimes redirects to a web server that is 18 | not responsive. 19 | 20 | An alternative filter with different trade-offs is 21 | L. That filter is more heavyweight because it 22 | always reopens the whole plugin connection on failure. 23 | 24 | =head1 PARAMETERS 25 | 26 | =over 4 27 | 28 | =item BN 29 | 30 | The number of times any single request will be retried before we give 31 | up and fail the operation. The default is 2. 32 | 33 | =item BN 34 | 35 | The number of seconds to wait before retrying. The default is 2 36 | seconds. 37 | 38 | =item B 39 | 40 | If set to false, do not retry opening the plugin. The default is to 41 | treat plugin open in the same way as other requests. 42 | 43 | =back 44 | 45 | =head1 FILES 46 | 47 | =over 4 48 | 49 | =item F<$filterdir/nbdkit-retry-request-filter.so> 50 | 51 | The filter. 52 | 53 | Use C to find the location of C<$filterdir>. 54 | 55 | =back 56 | 57 | =head1 VERSION 58 | 59 | C first appeared in nbdkit 1.30. 60 | 61 | =head1 SEE ALSO 62 | 63 | L, 64 | L, 65 | L, 66 | L. 67 | 68 | =head1 AUTHORS 69 | 70 | Richard W.M. Jones 71 | 72 | =head1 COPYRIGHT 73 | 74 | Copyright Red Hat 75 | -------------------------------------------------------------------------------- /fuzzing/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | EXTRA_DIST = \ 35 | README \ 36 | testcase_dir/newstyle-cflags \ 37 | testcase_dir/newstyle-cflags-exportname \ 38 | testcase_dir/newstyle-cflags-exportname-read4 \ 39 | testcase_dir/newstyle-cflags-go \ 40 | testcase_dir/newstyle-cflags-go-read \ 41 | testcase_dir/newstyle-cflags-go-read4 \ 42 | testcase_dir/newstyle-cflags-go-write \ 43 | $(NULL) 44 | -------------------------------------------------------------------------------- /fuzzing/testcase_dir/newstyle-cflags: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzing/testcase_dir/newstyle-cflags-exportname: -------------------------------------------------------------------------------- 1 | IHAVEOPT/ -------------------------------------------------------------------------------- /fuzzing/testcase_dir/newstyle-cflags-exportname-read4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/fuzzing/testcase_dir/newstyle-cflags-exportname-read4 -------------------------------------------------------------------------------- /fuzzing/testcase_dir/newstyle-cflags-go: -------------------------------------------------------------------------------- 1 | IHAVEOPT -------------------------------------------------------------------------------- /fuzzing/testcase_dir/newstyle-cflags-go-read: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/fuzzing/testcase_dir/newstyle-cflags-go-read -------------------------------------------------------------------------------- /fuzzing/testcase_dir/newstyle-cflags-go-read4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/fuzzing/testcase_dir/newstyle-cflags-go-read4 -------------------------------------------------------------------------------- /fuzzing/testcase_dir/newstyle-cflags-go-write: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/fuzzing/testcase_dir/newstyle-cflags-go-write -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | include_HEADERS = \ 35 | nbdkit-common.h \ 36 | nbdkit-plugin.h \ 37 | nbdkit-filter.h \ 38 | nbdkit-version.h \ 39 | $(NULL) 40 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | libtool.m4 2 | lt~obsolete.m4 3 | ltoptions.m4 4 | ltsugar.m4 5 | ltversion.m4 6 | -------------------------------------------------------------------------------- /plugins/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | EXTRA_DIST = plugins.syms 35 | 36 | SUBDIRS = $(plugins) 37 | -------------------------------------------------------------------------------- /plugins/S3/nbdkit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | The real nbdkit module is only available when the Python interpreter 4 | runs inside the nbdkit binary. To get unit tests to pass, we provide this 5 | "stub" module that provides just the minimum attributes to do 6 | unit testing. 7 | """ 8 | 9 | import logging 10 | 11 | log = logging.getLogger(__name__) 12 | 13 | 14 | FLAG_MAY_TRIM = 1 15 | 16 | 17 | def parse_size(v): 18 | return int(v) 19 | 20 | 21 | def debug(msg): 22 | log.debug(msg) 23 | 24 | 25 | def set_error(err): 26 | pass 27 | -------------------------------------------------------------------------------- /plugins/data/data.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_DATA_DATA_H 34 | #define NBDKIT_DATA_DATA_H 35 | 36 | extern const char *get_extra_param (const char *name); 37 | 38 | #endif /* NBDKIT_DATA_DATA_H */ 39 | -------------------------------------------------------------------------------- /plugins/data/format.h: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef NBDKIT_DATA_FORMAT_H 34 | #define NBDKIT_DATA_FORMAT_H 35 | 36 | #include "allocator.h" 37 | 38 | /* Parses the data parameter as described in the man page 39 | * under "DATA FORMAT". 40 | */ 41 | extern int read_data_format (const char *value, 42 | struct allocator *a, uint64_t *size); 43 | 44 | #endif /* NBDKIT_DATA_FORMAT_H */ 45 | -------------------------------------------------------------------------------- /plugins/example1/nbdkit-example1-plugin.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-example1-plugin - minimal nbdkit plugin 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit example1 8 | 9 | =head1 DESCRIPTION 10 | 11 | C is a minimal L plugin. 12 | 13 | It serves, readonly, from memory, a static blob of data which looks a 14 | little bit like a 100 MB disk image that contains a single empty 15 | partition. 16 | 17 | Mainly this is useful for testing nbdkit and as an example for writing 18 | nbdkit plugins (L). 19 | 20 | =head1 FILES 21 | 22 | =over 4 23 | 24 | =item F<$plugindir/nbdkit-example1-plugin.so> 25 | 26 | The plugin. 27 | 28 | Use C to find the location of C<$plugindir>. 29 | 30 | =back 31 | 32 | =head1 VERSION 33 | 34 | C first appeared in nbdkit 1.0. 35 | 36 | =head1 SEE ALSO 37 | 38 | L, 39 | L, 40 | L 41 | 42 | =head1 AUTHORS 43 | 44 | Richard W.M. Jones 45 | 46 | =head1 COPYRIGHT 47 | 48 | Copyright Red Hat 49 | -------------------------------------------------------------------------------- /plugins/example2/nbdkit-example2-plugin.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-example2-plugin - example nbdkit plugin 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit example2 file=FILENAME 8 | 9 | =head1 DESCRIPTION 10 | 11 | C is an example L plugin. 12 | 13 | It serves the named C over NBD, readonly. 14 | 15 | Mainly this is useful for testing nbdkit and as an example for writing 16 | nbdkit plugins (L). 17 | 18 | There are two variations of this plugin which can be found in the 19 | source directory. F is the regular plugin for Linux and 20 | other Unix-like systems. F is the same plugin written 21 | for Windows using Win32 APIs to access the file. 22 | 23 | =head1 DEBUG FLAGS 24 | 25 | For extra debugging (only useful for developers) use 26 | S> 27 | 28 | =head1 FILES 29 | 30 | =over 4 31 | 32 | =item F<$plugindir/nbdkit-example2-plugin.so> 33 | 34 | The plugin. 35 | 36 | Use C to find the location of C<$plugindir>. 37 | 38 | =back 39 | 40 | =head1 VERSION 41 | 42 | C first appeared in nbdkit 1.0. 43 | 44 | =head1 SEE ALSO 45 | 46 | L, 47 | L, 48 | L, 49 | L 50 | 51 | =head1 AUTHORS 52 | 53 | Richard W.M. Jones 54 | 55 | =head1 COPYRIGHT 56 | 57 | Copyright Red Hat 58 | -------------------------------------------------------------------------------- /plugins/example3/nbdkit-example3-plugin.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-example3-plugin - example nbdkit plugin 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit example3 [size=SIZE] 8 | 9 | =head1 EXAMPLE 10 | 11 | nbdkit example3 size=1G 12 | guestfish --ro --format=raw -a nbd://localhost 13 | 14 | =head1 DESCRIPTION 15 | 16 | C is an example L plugin. 17 | 18 | On each connection, it generates a temporary writable block device of 19 | size C. The disk is thrown away when the client disconnects. 20 | 21 | The C parameter can use a number of common formats to 22 | specify the size, eg. C<100M>, C<2G>. If the parameter is omitted, it 23 | defaults to 100M. 24 | 25 | Mainly this is useful for testing nbdkit and as an example for writing 26 | nbdkit plugins (L). 27 | 28 | =head1 FILES 29 | 30 | =over 4 31 | 32 | =item F<$plugindir/nbdkit-example3-plugin.so> 33 | 34 | The plugin. 35 | 36 | Use C to find the location of C<$plugindir>. 37 | 38 | =back 39 | 40 | =head1 VERSION 41 | 42 | C first appeared in nbdkit 1.0. 43 | 44 | =head1 SEE ALSO 45 | 46 | L, 47 | L, 48 | L 49 | 50 | =head1 AUTHORS 51 | 52 | Richard W.M. Jones 53 | 54 | =head1 COPYRIGHT 55 | 56 | Copyright Red Hat 57 | -------------------------------------------------------------------------------- /plugins/golang/config-test.go: -------------------------------------------------------------------------------- 1 | /* Go configuration test 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | /* Used by ./configure to check golang is functional. */ 34 | 35 | package main 36 | 37 | func main() { 38 | } 39 | -------------------------------------------------------------------------------- /plugins/golang/dump-plugin-examples.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | set -e 34 | set -x 35 | 36 | # This test simply runs --dump-plugin on each example, which is enough 37 | # to check the plugin has been compiled properly and loads. 38 | 39 | for f in examples/*/nbdkit-*-plugin.so; do 40 | if test -f $f; then 41 | ../../nbdkit -f -v $f --dump-plugin 42 | fi 43 | done 44 | -------------------------------------------------------------------------------- /plugins/golang/examples/disk/go.mod: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit 4 | require libguestfs.org/nbdkit v1.0.0 5 | -------------------------------------------------------------------------------- /plugins/golang/examples/dump-plugin/go.mod: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit 4 | require libguestfs.org/nbdkit v1.0.0 5 | -------------------------------------------------------------------------------- /plugins/golang/examples/minimal/go.mod: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit 4 | require libguestfs.org/nbdkit v1.0.0 5 | -------------------------------------------------------------------------------- /plugins/golang/examples/ramdisk/go.mod: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit 4 | require libguestfs.org/nbdkit v1.0.0 5 | -------------------------------------------------------------------------------- /plugins/golang/src/libguestfs.org/nbdkit/go.mod: -------------------------------------------------------------------------------- 1 | module libguestfs.org/nbdkit 2 | 3 | // First version of golang with working module support. 4 | go 1.13 5 | -------------------------------------------------------------------------------- /plugins/libvirt/nbdkit-libvirt-plugin.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-libvirt-plugin - nbdkit libvirt plugin using virDomainBlockPeek 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit libvirt [connect=URI] domain=DOMAIN disk=DISK 8 | 9 | =head1 EXAMPLE 10 | 11 | nbdkit libvirt domain=MyGuest disk=sda 12 | guestfish --ro --format=raw -a nbd://localhost 13 | 14 | =head1 DESCRIPTION 15 | 16 | C is an L plugin that lets you 17 | access libvirt guest disks. Only read-only access is possible. It is 18 | implemented using the libvirt C API. It can also 19 | be used over remote libvirt connections. 20 | 21 | =head1 PARAMETERS 22 | 23 | =over 4 24 | 25 | =item BURI 26 | 27 | This optional parameter specifies the libvirt connection URI. 28 | 29 | =item BDOMAIN 30 | 31 | This required parameter specifies the libvirt domain name 32 | (guest name). 33 | 34 | =item BDISK 35 | 36 | This required parameter specifies the guest's disk that we want to 37 | read. 38 | 39 | You can either give the path to the backing device (F) 40 | or the target name (eg. C). 41 | 42 | In either case use C to list possible disks. 43 | Look for Ssource dev=...E>> or 44 | Ssource file=...E>> or 45 | Starget dev=...E>> in the XML. 46 | 47 | =back 48 | 49 | =head1 FILES 50 | 51 | =over 4 52 | 53 | =item F<$plugindir/nbdkit-libvirt-plugin.so> 54 | 55 | The plugin. 56 | 57 | Use C to find the location of C<$plugindir>. 58 | 59 | =back 60 | 61 | =head1 VERSION 62 | 63 | C first appeared in nbdkit 1.0. 64 | 65 | =head1 SEE ALSO 66 | 67 | L, 68 | L, 69 | L, 70 | L. 71 | 72 | =head1 AUTHORS 73 | 74 | Richard W.M. Jones 75 | 76 | =head1 COPYRIGHT 77 | 78 | Copyright Red Hat 79 | -------------------------------------------------------------------------------- /plugins/linuxdisk/subdir/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/plugins/linuxdisk/subdir/.gitignore -------------------------------------------------------------------------------- /plugins/null/nbdkit-null-plugin.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-null-plugin - nbdkit bitbucket plugin 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit null [[size=]SIZE] 8 | 9 | =head1 DESCRIPTION 10 | 11 | C is a null plugin for L. Everything 12 | written to the virtual device is discarded, and reads back as zeroes. 13 | 14 | Most NBD consumers will be very confused by this device. Trying to 15 | create filesystems etc on it will likely fail badly. If the client is 16 | caching writes locally then you will get inconsistent read behaviour. 17 | 18 | The null plugin is also used when probing for installed filters, see 19 | L. 20 | 21 | =head1 PARAMETERS 22 | 23 | =over 4 24 | 25 | =item [B]SIZE 26 | 27 | Specify the virtual size of the disk image. 28 | 29 | This parameter is optional. If omitted then a zero-sized device is 30 | created. 31 | 32 | C is a magic config key and may be omitted in most cases. 33 | See L. 34 | 35 | =back 36 | 37 | =head1 FILES 38 | 39 | =over 4 40 | 41 | =item F<$plugindir/nbdkit-null-plugin.so> 42 | 43 | The plugin. 44 | 45 | Use C to find the location of C<$plugindir>. 46 | 47 | =back 48 | 49 | =head1 VERSION 50 | 51 | C first appeared in nbdkit 1.2. 52 | 53 | =head1 SEE ALSO 54 | 55 | L, 56 | L, 57 | L, 58 | L, 59 | L. 60 | L, 61 | L. 62 | 63 | =head1 AUTHORS 64 | 65 | Richard W.M. Jones 66 | 67 | =head1 COPYRIGHT 68 | 69 | Copyright Red Hat 70 | -------------------------------------------------------------------------------- /plugins/plugins.syms: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | # This linker script controls the visibility of symbols in plugins. 33 | # Plugins only need to export the "plugin_init" function and debug 34 | # flags. 35 | # 36 | # Use of this linker script is entirely optional. It's just for 37 | # hygiene. 38 | 39 | { 40 | global: 41 | plugin_init; 42 | *_debug_*; 43 | 44 | # Everything else is hidden. 45 | local: *; 46 | }; 47 | -------------------------------------------------------------------------------- /plugins/ruby/example.rb: -------------------------------------------------------------------------------- 1 | # Example Ruby plugin. 2 | # 3 | # This example can be freely used for any purpose. 4 | 5 | # Run it from the build directory like this: 6 | # 7 | # ./nbdkit -f -v ruby ./plugins/ruby/example.rb test1=foo test2=bar 8 | # 9 | # Or run it after installing nbdkit like this: 10 | # 11 | # nbdkit -f -v ruby ./plugins/ruby/example.rb test1=foo test2=bar 12 | # 13 | # The -f -v arguments are optional. They cause the server to stay in 14 | # the foreground and print debugging, which is useful when testing. 15 | # 16 | # You can connect to the server using guestfish or qemu, eg: 17 | # 18 | # guestfish --format=raw -a nbd://localhost 19 | # > run 20 | # > part-disk /dev/sda mbr 21 | # > mkfs ext2 /dev/sda1 22 | # > list-filesystems 23 | # > mount /dev/sda1 / 24 | # > [etc] 25 | 26 | include Nbdkit 27 | 28 | $disk = "\0" * (1024 * 1024) 29 | 30 | def config(key, value) 31 | printf("%s = %s\n", key, value) 32 | end 33 | 34 | def open(readonly) 35 | # You can return any non-nil Ruby object as a handle. The 36 | # same object is passed as the first argument to the other 37 | # callbacks. 38 | h = {} 39 | return h 40 | end 41 | 42 | def get_size(h) 43 | return $disk.bytesize 44 | end 45 | 46 | def pread(h, count, offset) 47 | return $disk.byteslice(offset, count) 48 | end 49 | 50 | def pwrite(h, buf, offset) 51 | # Hmm, is this using bytes or chars? XXX 52 | $disk[offset, buf.length] = buf 53 | end 54 | 55 | def zero(h, count, offset, may_trim) 56 | if may_trim 57 | $disk[offset, count] = "\0" * count 58 | else 59 | set_error(Errno::EOPNOTSUPP) 60 | raise "falling back to pwrite" 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /plugins/rust/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](https://semver.org/). 5 | 6 | ## [Unreleased] - ReleaseDate 7 | ### Changed 8 | 9 | - The `peername` function is now generic, taking any argument that implements 10 | `nix::sys::socket::SockaddrLike`. 11 | (#[4](https://gitlab.com/nbdkit/nbdkit/-/merge_requests/4) 12 | 13 | - Raised the MSRV to 1.46.0 due to bitflags bug #255. 14 | (#[1](https://gitlab.com/nbdkit/nbdkit/-/merge_requests/1) 15 | 16 | -------------------------------------------------------------------------------- /plugins/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nbdkit" 3 | version = "0.2.0" 4 | authors = ["Alan Somers "] 5 | license = "BSD-2-Clause" 6 | edition = "2018" 7 | readme = "README.md" 8 | repository = "https://gitlab.com/nbdkit/nbdkit" 9 | categories = ["api-bindings", "filesystem"] 10 | keywords = ["network-block-device", "nbd"] 11 | homepage = "http://libguestfs.org/" 12 | exclude = ["nbdkit-rust-plugin.*", "Makefile*", "test.sh"] 13 | description = """ 14 | Rust bindings to the NBDKit framework for creating Network Block Device servers 15 | """ 16 | 17 | [package.metadata.docs.rs] 18 | features = ["nix"] 19 | rustdoc-args = ["--cfg", "docsrs"] 20 | 21 | [dependencies] 22 | bitflags = "1.3.0" 23 | libc = "0.2.71" 24 | nix = { version = "0.24.1", default-features = false, features = ["net", "socket"], optional=true } 25 | 26 | 27 | [dev-dependencies] 28 | errno = "0.2.5" 29 | lazy_static = "1.2.0" 30 | memoffset = "0.6.3" 31 | mockall = "0.11.0" 32 | 33 | [[example]] 34 | name = "ramdisk" 35 | crate-type = ["cdylib"] 36 | -------------------------------------------------------------------------------- /plugins/rust/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Axcient 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 21 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 24 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /plugins/rust/README.md: -------------------------------------------------------------------------------- 1 | # NBDKit 2 | 3 | Rust bindings to the Network Block Device Kit library. 4 | 5 | [![Crates.io](https://img.shields.io/crates/v/nbdkit.svg)](https://crates.io/crates/nbdkit) 6 | [![Documentation](https://docs.rs/nbdkit/badge.svg)](https://docs.rs/nbdkit) 7 | [![Build Status](https://api.cirrus-ci.com/github/libguestfs/nbdkit.svg)](https://cirrus-ci.com/github/libguestfs/nbdkit) 8 | 9 | ## Overview 10 | 11 | NBDKit is a framework for developing Network Block Device servers. Most of 12 | the logic lives in the C code, but there are plugins to implement a server 13 | in another language, such as Rust. 14 | 15 | ## Usage 16 | 17 | To create an NBD server in Rust, you must implement the `nbdkit::Server` 18 | trait, and register it with `nbdkit::plugin!`, like this: 19 | 20 | ```toml 21 | [dependencies] 22 | nbdkit = "0.1.0" 23 | ``` 24 | 25 | ```rust 26 | use nbdkit::*; 27 | 28 | #[derive(Default)] 29 | struct MyPlugin { 30 | // ... 31 | } 32 | 33 | impl Server for MyPlugin { 34 | // ... 35 | } 36 | 37 | plugin!(MyPlugin {write_at, trim, ...}); 38 | ``` 39 | 40 | # Minimum Supported Rust Version (MSRV) 41 | 42 | `nbdkit` is supported on Rust 1.46.0 and higher. The MSRV will not be 43 | changed in the future without raising the major or minor version. 44 | 45 | # License 46 | 47 | `nbdkit` is primarily distributed under the 2-clause BSD liense. See 48 | LICENSE for details. 49 | -------------------------------------------------------------------------------- /plugins/rust/test.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # cargo test wrapper suitable for invocation from automake-generated makefiles 3 | 4 | set -e 5 | 6 | export RUSTFLAGS=-Dwarnings 7 | export RUSTDOCFLAGS=-Dwarnings 8 | 9 | cargo test --all-features 10 | cargo test --all-features --release 11 | 12 | if type cargo-doc >/dev/null 2>/dev/null 13 | then 14 | cargo doc --no-deps 15 | fi 16 | 17 | if type cargo-clippy >/dev/null 2>/dev/null 18 | then 19 | cargo clippy --all-features --all-targets -- -D warnings 20 | fi 21 | -------------------------------------------------------------------------------- /plugins/sh/assemble.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Example plugin for nbdkit which assembles a boot sector (using NASM) 4 | # and can then be used to boot it in qemu. This comes from a 5 | # lightning talk I did at the KVM Forum in 2019. 6 | # 7 | # This example can be freely used for any purpose. 8 | # 9 | # Run it from the build directory like this: 10 | # 11 | # ./nbdkit sh ./plugins/sh/assemble.sh input.asm \ 12 | # --run 'qemu-system-i386 -hda $nbd' 13 | # 14 | # For some assembler files to use as input, see 15 | # http://git.annexia.org/?p=libguestfs-talks.git;a=tree;f=2019-lightning-talk 16 | 17 | # Check we're being run from nbdkit. 18 | if [ ! -d $tmpdir ] || [ "x$1" = "x" ]; then 19 | echo "$0: this script must be run from nbdkit" >&2 20 | echo "Use ‘nbdkit sh $0’" >&2 21 | exit 1 22 | fi 23 | 24 | i=$tmpdir/input.asm 25 | s=$tmpdir/source.asm 26 | b=$tmpdir/binary 27 | 28 | case "$1" in 29 | config) 30 | if [ "$2" = "file" ]; then 31 | ln -sf "$(realpath "$3")" $i 32 | else 33 | echo "unknown parameter $2=$3" >&2 34 | exit 1 35 | fi 36 | ;; 37 | config_complete) 38 | # Turn the input asm fragment into a boot sector and assemble it. 39 | echo 'org 07c00h' > $s 40 | cat $i >> $s 41 | echo 'times 510-($-$$) db 0' >> $s 42 | echo 'db 055h,0aah' >> $s 43 | nasm -f bin $s -o $b 44 | ;; 45 | get_size) 46 | echo 512 47 | ;; 48 | pread) 49 | dd if=$b skip=$4 count=$3 iflag=count_bytes,skip_bytes 50 | ;; 51 | can_write) 52 | # Default is yes to make it writable (but writes will fail). 53 | ;; 54 | pwrite) 55 | exit 1 56 | ;; 57 | magic_config_key) 58 | echo "file" 59 | ;; 60 | *) 61 | exit 2 62 | ;; 63 | esac 64 | -------------------------------------------------------------------------------- /plugins/vddk/README.VDDK: -------------------------------------------------------------------------------- 1 | VDDK (Virtual Disk Development Kit) is a proprietary VMware library 2 | for accessing VMDK files and VMware ESX servers. Note that the 3 | license of the VDDK library is highly restrictive, preventing any 4 | commercial usage without negotiating a separate license from VMware. 5 | 6 | In order to obtain the VDDK library you have to register for an 7 | account and download it from: 8 | 9 | https://www.vmware.com/support/developer/vddk/ 10 | 11 | This directory contains an nbdkit plugin which uses this library to 12 | export VMDK files and VMware disks over NBD. 13 | 14 | You do NOT require VDDK to compile the plugin, and the plugin does not 15 | contain any VMware code. You only need VDDK at runtime. The plugin 16 | uses dlopen to load the library from a directory determined by the 17 | configuration parameter libdir. It is NOT recommended to put VDDK in 18 | your regular library path (eg /usr/lib) because it contains components 19 | that conflict with system libraries. 20 | 21 | After building nbdkit-vddk-plugin.so, read the man page to find out 22 | how to use it (nbdkit-vddk-plugin(1)). You'll probably also want to 23 | read the VDDK developer documentation. 24 | -------------------------------------------------------------------------------- /plugins/vddk/utils.c: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #define NBDKIT_API_VERSION 2 40 | #include 41 | 42 | #include "vddk.h" 43 | 44 | void 45 | trim (char *str) 46 | { 47 | size_t len = strlen (str); 48 | 49 | if (len > 0 && str[len-1] == '\n') 50 | str[len-1] = '\0'; 51 | } 52 | -------------------------------------------------------------------------------- /plugins/zero/nbdkit-zero-plugin.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | nbdkit-zero-plugin - nbdkit zero length plugin 4 | 5 | =head1 SYNOPSIS 6 | 7 | nbdkit zero 8 | 9 | =head1 DESCRIPTION 10 | 11 | C is a zero length plugin for L. It 12 | presents a virtual device of length zero bytes. 13 | 14 | This plugin is mainly good for testing corner cases in nbdkit, the NBD 15 | protocol and NBD clients. 16 | 17 | =head1 FILES 18 | 19 | =over 4 20 | 21 | =item F<$plugindir/nbdkit-zero-plugin.so> 22 | 23 | The plugin. 24 | 25 | Use C to find the location of C<$plugindir>. 26 | 27 | =back 28 | 29 | =head1 VERSION 30 | 31 | C first appeared in nbdkit 1.4. 32 | 33 | =head1 SEE ALSO 34 | 35 | L, 36 | L, 37 | L, 38 | L, 39 | L, 40 | L, 41 | L, 42 | L. 43 | 44 | =head1 AUTHORS 45 | 46 | Richard W.M. Jones 47 | 48 | =head1 COPYRIGHT 49 | 50 | Copyright Red Hat 51 | -------------------------------------------------------------------------------- /server/local/nbdkit.pc.in: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | # This alternate pkg-config file may be used to compile plugins 33 | # against a locally compiled (but not installed) nbdkit. 34 | 35 | prefix=@abs_top_builddir@ 36 | exec_prefix=@abs_top_builddir@ 37 | 38 | Name: @PACKAGE_NAME@ 39 | Version: @PACKAGE_VERSION@ 40 | Description: A toolkit for creating NBD servers 41 | Requires: 42 | Cflags: -I@abs_top_srcdir@/include -I@abs_top_builddir@/include 43 | Libs: 44 | -------------------------------------------------------------------------------- /tests/cc-shebang.c: -------------------------------------------------------------------------------- 1 | #if 0 2 | exec nbdkit cc "$0" "$@" 3 | #endif 4 | #include 5 | #include 6 | 7 | #define NBDKIT_API_VERSION 2 8 | #include 9 | 10 | char data[100*1024*1024]; 11 | 12 | #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL 13 | 14 | static void * 15 | my_open (int readonly) 16 | { 17 | return NBDKIT_HANDLE_NOT_NEEDED; 18 | } 19 | 20 | static int64_t 21 | my_get_size (void *handle) 22 | { 23 | return (int64_t) sizeof (data); 24 | } 25 | 26 | static int 27 | my_pread (void *handle, void *buf, 28 | uint32_t count, uint64_t offset, 29 | uint32_t flags) 30 | { 31 | memcpy (buf, data+offset, count); 32 | return 0; 33 | } 34 | 35 | static int 36 | my_pwrite (void *handle, const void *buf, 37 | uint32_t count, uint64_t offset, 38 | uint32_t flags) 39 | { 40 | memcpy (data+offset, buf, count); 41 | return 0; 42 | } 43 | 44 | static struct nbdkit_plugin plugin = { 45 | .name = "myplugin", 46 | .open = my_open, 47 | .get_size = my_get_size, 48 | .pread = my_pread, 49 | .pwrite = my_pwrite, 50 | }; 51 | 52 | NBDKIT_REGISTER_PLUGIN (plugin) 53 | -------------------------------------------------------------------------------- /tests/cc_shebang.ml: -------------------------------------------------------------------------------- 1 | (*/.)>/dev/null 2>&1 2 | 3 | # The above line is parsed by OCaml as an opening comment and by the 4 | # shell as an impossible command which is ignored. The line below is 5 | # run by the shell and ignored by OCaml. 6 | 7 | exec nbdkit cc "$0" CC=ocamlopt CFLAGS="-output-obj -runtime-variant _pic unix.cmxa NBDKit.cmx -cclib -lnbdkitocaml" "$@" 8 | *) 9 | 10 | open Printf 11 | 12 | let disk = ref (Bytes.make (1024*1024) '\000') 13 | 14 | let config k v = 15 | match k with 16 | | "size" -> 17 | let size = NBDKit.parse_size v in 18 | let size = Int64.to_int size in 19 | disk := Bytes.make size '\000' 20 | | _ -> 21 | failwith (sprintf "unknown parameter: %s" k) 22 | 23 | let open_connection _ = () 24 | 25 | let get_size () = Bytes.length !disk |> Int64.of_int 26 | 27 | let pread () count offset _ = 28 | let buf = Bytes.create count in 29 | Bytes.blit !disk (Int64.to_int offset) buf 0 count; 30 | Bytes.unsafe_to_string buf 31 | 32 | let pwrite () buf offset _ = 33 | let len = String.length buf in 34 | let offset = Int64.to_int offset in 35 | String.blit buf 0 !disk offset len 36 | 37 | let () = 38 | NBDKit.register_plugin 39 | ~name: "cc-shebang.ml" 40 | ~version: (NBDKit.version ()) 41 | ~config 42 | ~open_connection 43 | ~get_size 44 | ~pread 45 | ~pwrite 46 | () 47 | -------------------------------------------------------------------------------- /tests/generate-file-data.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | set -e 33 | 34 | rm -f $1-t $1 35 | 36 | for f in {1..512}; do 37 | printf '\x01\x02\x03\x04\x05\x06\x07\x08' 38 | done > $1-t 39 | 40 | mv $1-t $1 41 | -------------------------------------------------------------------------------- /tests/old-plugins/README: -------------------------------------------------------------------------------- 1 | nbdkit has strict ABI guarantees: we don't break old plugins written 2 | in C and distributed as binaries. But to actually test that we need 3 | to run old plugins against the current nbdkit. This directory 4 | contains old binary plugins and is used to test that we don't break 5 | the ABI unintentionally. 6 | 7 | The binary plugins were prepared by compiling old versions of nbdkit 8 | and copying plugins/file/.libs/nbdkit-file-plugin.so. Therefore the 9 | source of these files is simply the older versions of nbdkit itself. 10 | 11 | If there is a problem with using/distributing binaries with your free 12 | software distribution then you can simply do: 13 | 14 | rm -rf tests/old-plugins/ 15 | 16 | and the ABI tests will be skipped. 17 | 18 | The old plugins are of course architecture specific. They will only 19 | be tested if there is a matching 20 | 21 | `uname -m`/`uname -s` 22 | 23 | directory here. 24 | 25 | - RWMJ December 2019 26 | -------------------------------------------------------------------------------- /tests/old-plugins/i686/Linux/v1.0.0/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/i686/Linux/v1.0.0/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/i686/Linux/v1.12.8-2-g1e2ccc27/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/i686/Linux/v1.12.8-2-g1e2ccc27/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/i686/Linux/v1.18.4/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/i686/Linux/v1.18.4/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/i686/Linux/v1.2.8-3-g0560f8f/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/i686/Linux/v1.2.8-3-g0560f8f/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/i686/Linux/v1.8.4-3-g11f5a90d/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/i686/Linux/v1.8.4-3-g11f5a90d/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/x86_64/Linux/v1.0.0/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/x86_64/Linux/v1.0.0/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/x86_64/Linux/v1.12.8/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/x86_64/Linux/v1.12.8/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/x86_64/Linux/v1.18.2/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/x86_64/Linux/v1.18.2/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/x86_64/Linux/v1.2.8/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/x86_64/Linux/v1.2.8/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/old-plugins/x86_64/Linux/v1.8.4/nbdkit-file-plugin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libguestfs/nbdkit/45b72f5bd8fc1b475fa130d06c86cd877bf595d5/tests/old-plugins/x86_64/Linux/v1.8.4/nbdkit-file-plugin.so -------------------------------------------------------------------------------- /tests/pycodestyle.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Checking python style 4 | # Copyright Red Hat 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # * Neither the name of Red Hat nor the names of its contributors may be 18 | # used to endorse or promote products derived from this software without 19 | # specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 22 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 25 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 28 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | # SUCH DAMAGE. 33 | 34 | . ./functions.sh 35 | 36 | set -e 37 | set -x 38 | 39 | requires flake8 --version 40 | requires git --version 41 | 42 | test -d "$abs_top_srcdir" 43 | flake8 $(git ls-files "$abs_top_srcdir/**/*.py") 44 | -------------------------------------------------------------------------------- /tests/shebang.pl: -------------------------------------------------------------------------------- 1 | #!../nbdkit perl 2 | 3 | use strict; 4 | 5 | my $disk = "\0" x (1024*1024); 6 | 7 | sub open 8 | { 9 | my $readonly = shift; 10 | my $h = { readonly => $readonly }; 11 | return $h; 12 | } 13 | 14 | sub close 15 | { 16 | my $h = shift; 17 | } 18 | 19 | sub get_size 20 | { 21 | my $h = shift; 22 | return length ($disk); 23 | } 24 | 25 | sub pread 26 | { 27 | my $h = shift; 28 | my $count = shift; 29 | my $offset = shift; 30 | return substr ($disk, $offset, $count); 31 | } 32 | -------------------------------------------------------------------------------- /tests/shebang.py: -------------------------------------------------------------------------------- 1 | #!../nbdkit python 2 | 3 | disk = bytearray(1024 * 1024) 4 | 5 | 6 | def open(readonly): 7 | print("open: readonly=%d" % readonly) 8 | return 1 9 | 10 | 11 | def get_size(h): 12 | global disk 13 | return len(disk) 14 | 15 | 16 | def pread(h, buf, offset): 17 | global disk 18 | end = offset + len(buf) 19 | buf[:] = disk[offset:end] 20 | -------------------------------------------------------------------------------- /tests/shebang.rb: -------------------------------------------------------------------------------- 1 | #!../nbdkit ruby 2 | 3 | include Nbdkit 4 | 5 | $disk = "\0" * (1024 * 1024) 6 | 7 | def open(readonly) 8 | h = {} 9 | return h 10 | end 11 | 12 | def get_size(h) 13 | return $disk.bytesize 14 | end 15 | 16 | def pread(h, count, offset) 17 | return $disk.byteslice(offset, count) 18 | end 19 | -------------------------------------------------------------------------------- /tests/test-S3-unit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | 35 | set -e 36 | set -x 37 | 38 | requires $PYTHON --version 39 | requires $PYTHON -c 'import unittest' 40 | skip_if_valgrind "because Python code leaks memory" 41 | 42 | export PYTHONPATH=$srcdir/../plugins/S3:$srcdir/test-S3:$PYTHONPATH 43 | 44 | $PYTHON -m unittest S3 45 | -------------------------------------------------------------------------------- /tests/test-ansi-c.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | 36 | # We only really care that the plugin compiled, so we don't 37 | # need to run it properly. 38 | nbdkit .libs/test-ansi-c-plugin.$SOEXT --version 39 | -------------------------------------------------------------------------------- /tests/test-cow-null.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Regression test for placing a cow filter over a < 4K sized device, 34 | # which was broken in nbdkit 1.14.0. 35 | 36 | source ./functions.sh 37 | set -e 38 | set -x 39 | 40 | requires_run 41 | requires_nbdinfo 42 | 43 | nbdkit -fv -U - --filter=cow null --run 'nbdinfo $nbd' 44 | -------------------------------------------------------------------------------- /tests/test-curl-header-script-fail.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # See test-curl-header-script-fail.sh 34 | 35 | echo TEST MESSAGE TEST MESSAGE >&2 36 | exit 1 37 | -------------------------------------------------------------------------------- /tests/test-cxx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | 36 | # We only really care that the plugin compiled, so we don't 37 | # need to run it properly. 38 | libs=./.libs 39 | nbdkit --filter=$libs/test-cxx-filter.$SOEXT \ 40 | $libs/test-cxx-plugin.$SOEXT --version 41 | -------------------------------------------------------------------------------- /tests/test-delay-open.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | requires_run 38 | requires_plugin null 39 | requires_filter delay 40 | requires_nbdinfo 41 | 42 | start_t=$SECONDS 43 | nbdkit -U - null --filter=delay delay-open=3 --run 'nbdinfo "$uri"' 44 | end_t=$SECONDS 45 | 46 | if [ $((end_t - start_t)) -lt 3 ]; then 47 | echo "$0: delay filter failed: delay-open=3 caused delay < 3 seconds" 48 | exit 1 49 | fi 50 | -------------------------------------------------------------------------------- /tests/test-dump-config-major-1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -x 35 | set -e 36 | 37 | output="$(nbdkit --dump-config)" 38 | if [[ ! ( "$output" =~ version_major=1 ) ]]; then 39 | echo "$0: version_major != 1 in nbdkit --dump-config" 40 | echo "$output" 41 | exit 1 42 | fi 43 | -------------------------------------------------------------------------------- /tests/test-dump-config.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -x 35 | set -e 36 | 37 | nbdkit --dump-config 38 | 39 | # Check for expected field in the output. 40 | output="$(nbdkit --dump-config)" 41 | if [[ ! ( "$output" =~ bindir= ) ]]; then 42 | echo "$0: unexpected output from nbdkit --dump-config" 43 | echo "$output" 44 | exit 1 45 | fi 46 | -------------------------------------------------------------------------------- /tests/test-dump-plugin-example2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # example2 overrides --dump-plugin with extra data. 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | requires_plugin example2 40 | 41 | output="$(nbdkit example2 --dump-plugin)" 42 | if [[ ! ( "$output" =~ example2_extra\=hello ) ]]; then 43 | echo "$0: unexpected output from nbdkit example2 --dump-plugin" 44 | echo "$output" 45 | exit 1 46 | fi 47 | -------------------------------------------------------------------------------- /tests/test-dump-plugin-example4.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | set -e 34 | source ./functions.sh 35 | 36 | output="$(nbdkit example4 --dump-plugin)" 37 | if [[ ! ( "$output" =~ example4_extra\=hello ) ]]; then 38 | echo "$0: unexpected output from nbdkit example4 --dump-plugin" 39 | echo "$output" 40 | exit 1 41 | fi 42 | -------------------------------------------------------------------------------- /tests/test-dump-plugin-name.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Basic check that the name field is present in --dump-plugin output. 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | output="$(nbdkit example1 --dump-plugin)" 40 | if [[ ! ( "$output" =~ name\=example1 ) ]]; then 41 | echo "$0: unexpected output from nbdkit example1 --dump-plugin" 42 | echo "$output" 43 | exit 1 44 | fi 45 | -------------------------------------------------------------------------------- /tests/test-eval-dump-plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Check --dump-plugin operation using eval 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | requires_plugin eval 40 | 41 | nbdkit --dump-plugin eval | grep '^max_known_status=' 42 | 43 | nbdkit --dump-plugin eval dump_plugin='echo extra=stuff' | grep '^extra=stuff$' 44 | -------------------------------------------------------------------------------- /tests/test-exitwhen-file-already-created.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -x 35 | 36 | requires_filter exitwhen 37 | 38 | eventfile=exitwhen-file-already-created.event 39 | rm -f $eventfile 40 | cleanup_fn rm -f $eventfile 41 | 42 | # nbdkit should exit immediately if the event file already exists. 43 | 44 | touch $eventfile 45 | nbdkit -fv -U - --filter=exitwhen null exit-when-file-created=$eventfile 46 | -------------------------------------------------------------------------------- /tests/test-help.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | output="$(nbdkit --help)" 38 | if [[ ! ( "$output" =~ dump-config ) ]]; then 39 | echo "$0: unexpected output from nbdkit --help" 40 | echo "$output" 41 | exit 1 42 | fi 43 | -------------------------------------------------------------------------------- /tests/test-just-filter-header.c: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | 35 | int 36 | main (int argc, char *argv[]) 37 | { 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /tests/test-just-plugin-header.c: -------------------------------------------------------------------------------- 1 | /* nbdkit 2 | * Copyright Red Hat 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * * Neither the name of Red Hat nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without 17 | * specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | 35 | int 36 | main (int argc, char *argv[]) 37 | { 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /tests/test-long-options.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | nbdkit --long-options 38 | nbdkit --long-options | grep '^--help' 39 | nbdkit --long-options | grep '^--version' 40 | -------------------------------------------------------------------------------- /tests/test-manual.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Test each option appears in the main nbdkit(1) manual page. 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | # If these fail it's probably because you ran the script by hand. 40 | test -n "$srcdir" 41 | podfile=$srcdir/../docs/nbdkit.pod 42 | test -f "$podfile" 43 | 44 | for i in $(nbdkit --short-options) $(nbdkit --long-options); do 45 | grep '^=item B<'$i'[=>]' $podfile 46 | done 47 | -------------------------------------------------------------------------------- /tests/test-nofilter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | requires_run 38 | requires_nbdcopy 39 | 40 | files="nofilter.img" 41 | rm -f $files 42 | cleanup_fn rm -f $files 43 | 44 | nbdkit -U - -v --filter=nofilter memory 10M \ 45 | --run 'nbdcopy "$uri" nofilter.img' 46 | -------------------------------------------------------------------------------- /tests/test-probe-filter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | # Test that the probe command suggested in nbdkit-probing(1) works. 38 | 39 | # This filter should exist. 40 | nbdkit --filter=readahead null --version 41 | 42 | # This filter should not exist. 43 | if nbdkit --filter=notsuchfilter null --version ; then 44 | echo "$0: expected this test to fail but it succeeded" 45 | exit 1 46 | fi 47 | -------------------------------------------------------------------------------- /tests/test-probe-plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | # Test that the probe command suggested in nbdkit-probing(1) works. 38 | 39 | # This plugin should exist. 40 | nbdkit null --version 41 | 42 | # This plugin should not exist. 43 | if nbdkit nosuchplugin --version ; then 44 | echo "$0: expected this test to fail but it succeeded" 45 | exit 1 46 | fi 47 | -------------------------------------------------------------------------------- /tests/test-python.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | requires $PYTHON --version 38 | requires $PYTHON -c 'import unittest' 39 | requires $PYTHON -c 'import nbd' 40 | requires test -f test_python.py 41 | requires test -f test-python-plugin.py 42 | skip_if_valgrind "because Python code leaks memory" 43 | 44 | $PYTHON -m unittest test_python 45 | -------------------------------------------------------------------------------- /tests/test-random-copy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Test the sparse-random plugin. 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | requires_run 40 | 41 | # nbdcopy >= 1.5.9 required for this test. 42 | requires_nbdcopy 43 | requires_libnbd_version 1.5.9 44 | 45 | # Copy from self to self which is what this plugin is intended for. 46 | nbdkit -U - random size=100M --run 'nbdcopy "$uri" "$uri"' 47 | -------------------------------------------------------------------------------- /tests/test-random-sock.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Test nbdkit -U - + captive nbdkit. 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | requires_run 40 | 41 | nbdkit -U - example1 --run 'sleep 5' 42 | -------------------------------------------------------------------------------- /tests/test-scan-copy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | requires_nbdcopy 38 | requires_plugin sparse-random 39 | requires_filter scan 40 | 41 | nbdkit -fv -U - sparse-random 1M --filter=scan --run 'nbdcopy "$uri" "$uri"' 42 | nbdkit -fv -U - sparse-random 1G --filter=scan --run 'nbdcopy "$uri" "$uri"' 43 | -------------------------------------------------------------------------------- /tests/test-short-options.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | nbdkit --short-options 38 | nbdkit --short-options | grep '^-v' 39 | nbdkit --short-options | grep '^-V' 40 | -------------------------------------------------------------------------------- /tests/test-single-from-file.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Check that the -s option can be used from a plain file. This is 34 | # used when we fuzz nbdkit (see fuzzing/README) so we should try not 35 | # to break it. 36 | 37 | source ./functions.sh 38 | set -e 39 | set -x 40 | 41 | requires_single_mode 42 | 43 | testcase=$srcdir/../fuzzing/testcase_dir/newstyle-cflags-go 44 | 45 | nbdkit -f -v -s memory 1M <$testcase >/dev/null 46 | -------------------------------------------------------------------------------- /tests/test-sparse-random-copy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Test the sparse-random plugin. 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | requires_run 40 | 41 | # nbdcopy >= 1.5.9 required for this test. 42 | requires_nbdcopy 43 | requires_libnbd_version 1.5.9 44 | 45 | # Copy from self to self which is what this plugin is intended for. 46 | nbdkit -U - sparse-random size=10G --run 'nbdcopy "$uri" "$uri"' 47 | -------------------------------------------------------------------------------- /tests/test-sparse-random-info.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Test the sparse-random plugin. 34 | 35 | source ./functions.sh 36 | set -e 37 | 38 | requires_run 39 | 40 | requires_nbdinfo 41 | if ! nbdinfo --help | grep -- --map ; then 42 | echo "$0: nbdinfo --map option required to run this test" 43 | exit 77 44 | fi 45 | 46 | nbdkit -U - sparse-random size=10G --run 'nbdinfo --map "$uri"' 47 | -------------------------------------------------------------------------------- /tests/test-swap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Root-only test of the --swap option. 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | requires_root 40 | requires_caps cap_sys_resource 41 | requires nbdsh --version 42 | 43 | nbdsh -c -<<'EOF' 44 | h.connect_command( 45 | ["nbdkit", "-fv", "-s", "--exit-with-parent", "--swap", "null"] 46 | ) 47 | assert h.get_size() == 0 48 | EOF 49 | -------------------------------------------------------------------------------- /tests/test-vddk-dump-plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | skip_if_valgrind "because setting LD_LIBRARY_PATH breaks valgrind" 38 | 39 | out=test-vddk-dump-plugin.out 40 | rm -f $out 41 | cleanup_fn rm -f $out 42 | 43 | nbdkit vddk libdir=.libs --dump-plugin > $out 44 | cat $out 45 | 46 | grep ^vddk_default_libdir= $out 47 | -------------------------------------------------------------------------------- /tests/test-vddk-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # Test VDDK + --run parameter. 34 | 35 | source ./functions.sh 36 | set -e 37 | set -x 38 | 39 | skip_if_valgrind "because setting LD_LIBRARY_PATH breaks valgrind" 40 | requires_nbdinfo 41 | 42 | out=test-vddk-run.out 43 | rm -f $out 44 | cleanup_fn rm -f $out 45 | 46 | nbdkit -U - vddk libdir=.libs /dev/null --run 'nbdinfo $nbd' > $out 47 | cat $out 48 | 49 | grep -E 'export-size: 524288\b' $out 50 | -------------------------------------------------------------------------------- /tests/test-version-filter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | 36 | cmd="nbdkit --filter offset --filter=cow file --version" 37 | output="$($cmd)" 38 | if [[ ! ( "$output" =~ file\ 1\. ) || 39 | ! ( "$output" =~ offset\ 1\. ) || 40 | ! ( "$output" =~ cow\ 1\. ) ]]; then 41 | echo "$0: unexpected output from $cmd" 42 | echo "$output" 43 | exit 1 44 | fi 45 | -------------------------------------------------------------------------------- /tests/test-version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -e 35 | set -x 36 | 37 | output="$(nbdkit --version)" 38 | if [[ ! ( "$output" =~ ^nbdkit\ 1\. ) ]]; then 39 | echo "$0: unexpected output from nbdkit --version" 40 | echo "$output" 41 | exit 1 42 | fi 43 | -------------------------------------------------------------------------------- /tests/test-zero.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # nbdkit 3 | # Copyright Red Hat 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Red Hat nor the names of its contributors may be 17 | # used to endorse or promote products derived from this software without 18 | # specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | source ./functions.sh 34 | set -x 35 | set -e 36 | 37 | requires_run 38 | requires_nbdcopy 39 | 40 | files="test-zero.out" 41 | rm -f $files 42 | cleanup_fn rm -f $files 43 | 44 | nbdkit -U - zero --run 'nbdcopy "$uri" test-zero.out' 45 | 46 | # Resulting file should be zero-sized. 47 | test -f test-zero.out 48 | ! test -s test-zero.out 49 | -------------------------------------------------------------------------------- /tests/test.lua: -------------------------------------------------------------------------------- 1 | disk = string.rep ('\0', 1024*1024) 2 | 3 | -- Lua strings are indexed from 1, which is crazy. This is a 4 | -- sane substring function. 5 | function disk_sub (n, len) 6 | return disk:sub (n+1, n+len) 7 | end 8 | 9 | function open (readonly) 10 | return 1 11 | end 12 | 13 | function get_size (h) 14 | return disk:len() 15 | end 16 | 17 | function pread (h, count, offset) 18 | return disk_sub(offset, count) 19 | end 20 | 21 | function pwrite (h, buf, offset) 22 | -- There's no built-in mutable string type, so this is going 23 | -- to be very inefficient. 24 | local count = buf:len() 25 | local end_len = disk:len() - (offset+count) 26 | disk = disk_sub(0, offset) .. buf .. disk_sub(offset+count, end_len) 27 | end 28 | -------------------------------------------------------------------------------- /tests/test.pl: -------------------------------------------------------------------------------- 1 | use strict; 2 | 3 | my $disk = "\0" x (1024*1024); 4 | 5 | BEGIN { 6 | # Call the debug function to check it works. 7 | Nbdkit::debug ("hello world!"); 8 | 9 | # Check some expected constants are defined. Since these constants 10 | # are defined by the nbdkit ABI, they should never change so checking 11 | # their absolute values here ought to be fine. 12 | die unless $Nbdkit::FLAG_MAY_TRIM == 1; 13 | die unless $Nbdkit::FLAG_FUA == 2; 14 | die unless $Nbdkit::FLAG_REQ_ONE == 4; 15 | die unless $Nbdkit::FUA_NATIVE == 2; 16 | die unless $Nbdkit::CACHE_EMULATE == 1; 17 | die unless $Nbdkit::EXTENT_ZERO == 2; 18 | } 19 | 20 | sub config_complete 21 | { 22 | } 23 | 24 | sub open 25 | { 26 | my $readonly = shift; 27 | Nbdkit::debug ("perl plugin opened, readonly=" . $readonly); 28 | my $h = { readonly => $readonly }; 29 | return $h; 30 | } 31 | 32 | sub close 33 | { 34 | my $h = shift; 35 | } 36 | 37 | sub get_size 38 | { 39 | my $h = shift; 40 | return length ($disk); 41 | } 42 | 43 | sub can_write 44 | { 45 | my $h = shift; 46 | return 1; 47 | } 48 | 49 | sub can_flush 50 | { 51 | my $h = shift; 52 | return 1; 53 | } 54 | 55 | sub is_rotational 56 | { 57 | my $h = shift; 58 | return 0; 59 | } 60 | 61 | sub can_trim 62 | { 63 | my $h = shift; 64 | return 1; 65 | } 66 | 67 | sub pread 68 | { 69 | my $h = shift; 70 | my $count = shift; 71 | my $offset = shift; 72 | return substr ($disk, $offset, $count); 73 | } 74 | 75 | sub pwrite 76 | { 77 | my $h = shift; 78 | my $buf = shift; 79 | my $count = length ($buf); 80 | my $offset = shift; 81 | substr ($disk, $offset, $count) = $buf; 82 | } 83 | 84 | sub flush 85 | { 86 | my $h = shift; 87 | } 88 | 89 | sub trim 90 | { 91 | my $h = shift; 92 | my $count = shift; 93 | my $offset = shift; 94 | } 95 | -------------------------------------------------------------------------------- /tests/test.rb: -------------------------------------------------------------------------------- 1 | $disk = "\0" * (1024*1024); 2 | 3 | def config_complete() 4 | end 5 | 6 | def open(readonly) 7 | return {} 8 | end 9 | 10 | def get_size(h) 11 | return $disk.bytesize 12 | end 13 | 14 | def can_write(h) 15 | return true 16 | end 17 | 18 | def can_flush(h) 19 | return true 20 | end 21 | 22 | def is_rotational(h) 23 | return false 24 | end 25 | 26 | def can_trim(h) 27 | return true 28 | end 29 | 30 | def pread(h, count, offset) 31 | return $disk.byteslice(offset, count) 32 | end 33 | 34 | def pwrite(h, buf, offset) 35 | # Is this using bytes or chars? XXX 36 | $disk[offset, buf.length] = buf 37 | end 38 | 39 | def flush(h) 40 | end 41 | 42 | def trim(h, count, offset) 43 | end 44 | -------------------------------------------------------------------------------- /tests/test.tcl: -------------------------------------------------------------------------------- 1 | # XXX This actually creates a Unicode (UCS-2) array. It's also rather 2 | # slow to run. It's possible we should be using a list instead. 3 | set disk [string repeat "\u0000" [expr 1024*1024]] 4 | 5 | proc plugin_open {readonly} { 6 | return 1 7 | } 8 | 9 | proc get_size {h} { 10 | global disk 11 | 12 | return [string length $disk] 13 | } 14 | 15 | proc pread {h count offset} { 16 | global disk 17 | 18 | set last [expr $offset+$count-1] 19 | return [string range $disk $offset $last] 20 | } 21 | 22 | proc pwrite {h buf offset} { 23 | global disk 24 | 25 | set count [string length $buf] 26 | set last [expr $offset+$count-1] 27 | set disk [string replace $disk $offset $last $buf] 28 | } 29 | -------------------------------------------------------------------------------- /valgrind/Makefile.am: -------------------------------------------------------------------------------- 1 | # nbdkit 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | include $(top_srcdir)/common-rules.mk 33 | 34 | suppressions_files = $(wildcard $(srcdir)/*.suppressions) 35 | 36 | EXTRA_DIST = $(suppressions_files) 37 | 38 | noinst_DATA = suppressions 39 | 40 | suppressions: $(suppressions_files) 41 | rm -f $@ $@-t 42 | cat $^ > $@-t 43 | mv $@-t $@ 44 | chmod 0444 $@ 45 | 46 | DISTCLEANFILES = suppressions 47 | -------------------------------------------------------------------------------- /valgrind/ext2fs.suppressions: -------------------------------------------------------------------------------- 1 | # ext2fs valgrind suppressions 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | # The error table is always leaked. 33 | { 34 | ext2fs_1 35 | Memcheck:Leak 36 | fun:malloc 37 | fun:initialize_ext2_error_table_r 38 | } 39 | -------------------------------------------------------------------------------- /valgrind/gnutls.suppressions: -------------------------------------------------------------------------------- 1 | # gnutls valgrind suppressions 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | # Although we call gnutls_global_init/gnutls_global_deinit, gnutls 33 | # still leaks stuff. 34 | { 35 | gnutls_1 36 | Memcheck:Leak 37 | ... 38 | fun:_gnutls_global_init 39 | } 40 | -------------------------------------------------------------------------------- /valgrind/sh.suppressions: -------------------------------------------------------------------------------- 1 | # nbdkit-sh-plugin valgrind suppressions 2 | # Copyright Red Hat 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # * Neither the name of Red Hat nor the names of its contributors may be 16 | # used to endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR 23 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | # SUCH DAMAGE. 31 | 32 | # nbdkit-sh-plugin calls setenv at load time and this unavoidably 33 | # leaks memory. 34 | { 35 | sh_1 36 | Memcheck:Leak 37 | ... 38 | fun:setenv 39 | fun:sh_load 40 | } 41 | --------------------------------------------------------------------------------