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 <pbonz...@redhat.com>
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