Re: [PATCH v3] xfs_io: [v3] add the lseek() SEEK_DATA/SEEK_HOLE support

Dave Chinner
2012-10-29T00:09:15Z

On Fri, Oct 26, 2012 at 08:31:11AM -0500, Mark Tinguely wrote:
> On 10/25/12 17:29, Dave Chinner wrote:
> >On Thu, Oct 25, 2012 at 09:14:44AM -0500, Mark Tinguely wrote:
> >>Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io.
> >>The result from the lseek() call will be printed to the output.
> >>For example:
> >>
> >>xfs_io> lseek -h 609k
> >>Type Offset
> >>hole 630784
> >>
> >>v1 -> v2 Add "-a" and "-r" options.
> >> Simplify the output.
> >>v2 -> v3 Refactor for configure.in -> configure.ac change.
> >> SEEK_DATA with -1 offset behaves badly on older Linux.
> >> Display error message as "ERR<errno>".
> >....
> >>+
> >>+#include<linux/fs.h>
> >
> >I missed this first time around - why is this include necessary?
>
> Take it out and you will find that it contains the
> defines for SEEK_DATA/SEEK_HOLE.

It was added in glibc 2.14, IIRC. All this means is that your
userspace libraries are not current, while your kernel headers are.

So, you shouldn't be including linux/fs.h directly, I think,
especially as SEEK_DATA/SEEK_HOLE is functionality that is not linux
specific. I suspect that you should do something more like:

#ifndef SEEK_DATA
#define SEEK_DATA 3
#define SEEK_HOLE 4
#endif

Because the autoconf test passed, but the parameters are not defined
correctly by userspace. That way it will still work on other
platforms if they support this functionality....

Cheers,

Dave.
--
Dave Chinner
david@fromorbit.com