From 0d080223a8567a5ef673deb6ac49152fd67dd1b7 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 16 Dec 2023 18:03:13 +0000 Subject: [PATCH] file: Further rework documentation of dir= parameter Move the documentation to a new section, allowing us to expand on this topic. This also makes the HTML documentation linkable. Updates: commit 7cbd49ced6414e49fcf4ff1a967929a2b83ab44e (cherry picked from commit 74621ec608d0edd76c2d8de140e7d1d5626c8251) --- plugins/file/nbdkit-file-plugin.pod | 66 +++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/plugins/file/nbdkit-file-plugin.pod b/plugins/file/nbdkit-file-plugin.pod index 5feb8ea9..de8fbeba 100644 --- a/plugins/file/nbdkit-file-plugin.pod +++ b/plugins/file/nbdkit-file-plugin.pod @@ -63,23 +63,7 @@ directory named C, including those found by following symbolic links. Other special files in the directory (such as subdirectories, pipes, or Unix sockets) are ignored. -When this mode is used, the file to be served is chosen by the export -name passed by the client. For security, when using directory mode, -this plugin will not accept export names containing slash (C). - -To list exports, use L I<--list> option, for example: - - nbdinfo --list nbd://localhost - -An NBD client can request a list of available exports using -C. - -A client that requests the default export (C<"">) will be rejected. -However, you can use L to adjust what -export names the client sees, and which one the client uses as a -default. For example to make F be the default export: - - nbdkit file dir=/dir --filter=exportname default-export=file +See L below. =item BFILE_DESCRIPTOR @@ -89,6 +73,8 @@ This is like the C option, but instead of specifying the directory by name, the parent process should open the directory and pass this file descriptor by inheritance to nbdkit. +See L below. + =item B =item B @@ -140,6 +126,52 @@ L (or C) you can serve all regular +files and block devices located directly inside the directory named +C, including those found by following symbolic links. +Other special files in the directory (such as subdirectories, pipes, +or Unix sockets) are ignored. + +When this mode is used, the file to be served is chosen by the export +name passed by the client. For security, when using directory mode, +this plugin will not accept export names containing slash (C). + +For example: + + $ ls -l /var/tmp/exports + total 0 + -rw-r--r--. 1 rjones rjones 1048576 Dec 14 15:34 disk1 + -rw-r--r--. 1 rjones rjones 2097152 Dec 14 15:34 disk2 + lrwxrwxrwx. 1 rjones rjones 9 Dec 14 15:35 sda1 -> /dev/sda1 + $ nbdkit file dir=/var/tmp/exports + +will serve three exports called C<"disk1">, C<"disk2"> and C<"sda1">. +The first two are regular files and the last is a block device. You +can add or remove files or symbolic links from the directory while +nbdkit is running. + +To list exports, use L I<--list> option, for example: + + $ nbdinfo --list nbd://localhost + protocol: newstyle-fixed without TLS, using structured packets + export="disk1": + export-size: 1048576 (1M) + uri: nbd://localhost:10809/disk1 + [etc] + +An NBD client can request a list of available exports using +C. For libnbd clients see nbd_opt_list(3). + +A client that requests the default export (C<"">) will be rejected. +However, you can use L to adjust the +default export as well as other transformations of export names. For +example to make F be the default export: + + nbdkit file dir=/var/tmp/exports \ + --filter=exportname default-export=disk1 + =head2 Optimizing for random or sequential access If you know in advance that the NBD client will access the file -- 2.39.3