[Libguestfs] [PATCH nbdkit filters-v2 5/5] INCOMPLETE filters: Add nbdkit-partition-filter.

Eric Blake eblake at redhat.com
Fri Jan 19 16:53:44 UTC 2018


On 01/19/2018 09:23 AM, Richard W.M. Jones wrote:
> This can be used to filter a single partition from a disk image.
> ---
>  TODO                                          |   2 -
>  configure.ac                                  |   1 +
>  filters/Makefile.am                           |   3 +-
>  filters/delay/delay.c                         |  12 +--
>  filters/offset/nbdkit-offset-filter.pod       |  17 ++-
>  filters/offset/offset.c                       |  20 ++--
>  filters/partition/Makefile.am                 |  62 +++++++++++
>  filters/partition/nbdkit-partition-filter.pod |  94 +++++++++++++++++
>  filters/partition/partition.c                 | 145 ++++++++++++++++++++++++++
>  9 files changed, 336 insertions(+), 20 deletions(-)
> 
> diff --git a/TODO b/TODO
> index 3ec45fd..b1f922e 100644
> --- a/TODO

> +++ b/filters/delay/delay.c
> @@ -121,30 +121,30 @@ delay_config (nbdkit_next_config *next, void *nxdata,
>  
>  /* Read data. */
>  static int
> -delay_pread (struct nbdkit_next *next, void *nxdata,
> +delay_pread (struct nbdkit_next_ops *next_ops, void *nxdata,
>               void *handle, void *buf, uint32_t count, uint64_t offset)

Squashed into the wrong patch?

> +++ b/filters/offset/offset.c
> @@ -81,10 +81,10 @@ offset_config_complete (nbdkit_next_config_complete *next, void *nxdata)
>  
>  /* Get the file size. */
>  static int64_t
> -offset_get_size (struct nbdkit_next *next, void *nxdata,
> +offset_get_size (struct nbdkit_next_ops *next_ops, void *nxdata,

Again, rebase churn not squashed correctly?

> +++ b/filters/partition/partition.c
> @@ -0,0 +1,145 @@

> +/* Called for each key=value passed on the command line. */
> +static int
> +partition_config (nbdkit_next_config *next, void *nxdata,
> +                  const char *key, const char *value)
> +{
> +  if (strcmp (key, "partition") == 0) {
> +    if (sscanf (value, "%d", &partnum) != 1 || partnum <= 0) {

I'm not a fan of scanf("%d") - it has undefined behavior on integer
overflow.


> +#define partition_config_help \
> +  "partition=<PART>    (required) The partition number (counting from 1)."
> +
> +#if 0

Hence the RFC :)


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20180119/82934aed/attachment.sig>


More information about the Libguestfs mailing list