Update Red Hat Copyright Notices
[nbdkit.git] / filters / truncate / nbdkit-truncate-filter.pod
blob6706ad0570b28f3575961bdf56ca21076a2e83ae
1 =head1 NAME
3 nbdkit-truncate-filter - change the size of plugins
5 =head1 SYNOPSIS
7  nbdkit --filter=truncate plugin [truncate=SIZE]
8                                  [round-up=N] [round-down=N]
10 =head1 DESCRIPTION
12 C<nbdkit-truncate-filter> is a filter that changes the size of
13 the underlying plugin.  It can:
15 =over 4
17 =item *
19 Make the plugin smaller (truncate it).  Use the C<truncate=SIZE>
20 parameter to set the smaller size.
22 =item *
24 Make the plugin larger (the additional bytes read back as zeroes).
25 Use C<truncate=SIZE> to set the larger size.
27 =item *
29 Round the size of the plugin up or down to the next multiple of C<N>.
30 Use either C<round-up=N> or C<round-down=N>.
32 =back
34 A common use for this filter is to handle NBD clients which have a
35 problem dealing with device sizes which are not a multiple of 512
36 bytes.  Use C<round-up=512> to round the size up to the next multiple
37 of 512 bytes.  If the size is already a multiple of 512 bytes then
38 this has no effect.
40 =head1 PARAMETERS
42 =over 4
44 =item B<truncate=>SIZE
46 Set the absolute size in bytes of the apparent device.  This may be
47 smaller or larger or the same as the underlying plugin.
49 If the size is larger than the underlying plugin, reading the extra
50 space returns zeroes.  Writes are also permitted to the extra space,
51 but you must only write zeroes (any attempts to write non-zero bytes
52 will return an error back to the client).
54 This parameter is optional.
56 =item B<round-up=>N
58 Round the size up to the next multiple of C<N> bytes.  If the size of
59 the underlying plugin is already a multiple of C<N> bytes, this has no
60 effect.
62 This option is useful when combined with other filters (such as
63 L<nbdkit-blocksize-filter(1)>) that normally round down due to a
64 larger granularity, in order to access the last few bytes of a file
65 that would otherwise be rendered inaccessible.
67 This parameter is optional.
69 =item B<round-down=>N
71 Round the size down to a multiple of C<N> bytes.  If the size of the
72 underlying plugin is already a multiple of C<N> bytes, this has no
73 effect.
75 This parameter is optional.
77 =back
79 =head1 EXAMPLES
81 Serve a file as if it were a block device that insists on 4k
82 alignment, while still allowing access to any unaligned bytes at the
83 end of the file:
85  nbdkit --filter=blocksize --filter=truncate file /path/to/file \
86  minblock=4k round-up=4k
88 =head1 FILES
90 =over 4
92 =item F<$filterdir/nbdkit-truncate-filter.so>
94 The filter.
96 Use C<nbdkit --dump-config> to find the location of C<$filterdir>.
98 =back
100 =head1 VERSION
102 C<nbdkit-truncate-filter> first appeared in nbdkit 1.6.
104 =head1 SEE ALSO
106 L<nbdkit(1)>,
107 L<nbdkit-file-plugin(1)>,
108 L<nbdkit-filter(3)>,
109 L<nbdkit-blocksize-filter(1)>,
110 L<nbdkit-cache-filter(1)>,
111 L<nbdkit-cow-filter(1)>,
112 L<nbdkit-offset-filter(1)>,
113 L<nbdkit-partition-filter(1)>.
115 =head1 AUTHORS
117 Richard W.M. Jones
119 =head1 COPYRIGHT
121 Copyright Red Hat