qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1.1 19/22] block: implement is_allocated for raw


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH 1.1 19/22] block: implement is_allocated for raw
Date: Wed, 09 May 2012 15:40:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1

Am 08.05.2012 16:51, schrieb Paolo Bonzini:
> Either FIEMAP, or SEEK_DATA+SEEK_HOLE can be used to implement the
> is_allocated callback for raw files.  Ext4, btrfs and XFS all support
> it.
> 
> Signed-off-by: Paolo Bonzini <address@hidden>

This is for 1.2, I'll queue it in block-next.

> ---
>  block/raw-posix.c |  102 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  block/raw.c       |    8 +++++
>  2 files changed, 110 insertions(+)
> 
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 03fcfcc..6753c73 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -52,6 +52,10 @@
>  #include <sys/param.h>
>  #include <linux/cdrom.h>
>  #include <linux/fd.h>
> +#include <linux/fs.h>
> +#endif
> +#ifdef CONFIG_FIEMAP
> +#include <linux/fiemap.h>
>  #endif
>  #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
>  #include <sys/disk.h>
> @@ -104,6 +108,13 @@
>  #define O_DIRECT O_DSYNC
>  #endif
>  
> +#ifndef SEEK_DATA
> +#define SEEK_DATA 3
> +#endif
> +#ifndef SEEK_HOLE
> +#define SEEK_HOLE 4
> +#endif

How is that going to be portable? You assume that on non-Linux you'll
get -EINVAL, but what does guarantee that 3 or 4 aren't already used for
the standard SEEK_* constants or for a different non-standard extension?

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]