Subject: Re: Second patch for lseek() sparse file extension
To: None <>
From: Pawel Jakub Dawidek <>
List: tech-kern
Date: 12/02/2006 01:08:46
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Sep 21, 2006 at 08:47:49PM +0200, Reinoud Zandijk wrote:
> Dear folks,
> 2nd try that ought to be complete. I had to change the VOP_SEEK() a bit=
> since i was worried about FS layering and got wierd results at times; thu=
> i pass the vattr down so it reflects the top vnode and not the bottom=20
> vnode. This might be important for some file systems and it saves=20
> duplicating and thus error-prone ness.
> I've also added and updated src/regress/os/fs/lseek to test for normal=20
> lseek() behaviour and to test the SEEK_DATA and SEEK_HOLE extension if it=
> is defined.
> If all is ok, i'd like to commit this.

Hi. I'm implementing the same functionality for FreeBSD and here are few
notes from me:

First of all, there is no VOP_SEEK(9) on FreeBSD, so I'm using just like
in OpenSolaris VOP_IOCTL(9) to pass SEEK_DATA/SEEK_HOLE requests to the
file system.

> --- include/stdio.h	10 May 2006 21:09:45 -0000	1.64
> +++ include/stdio.h	21 Sep 2006 18:37:52 -0000
> @@ -203,6 +203,12 @@
>  #ifndef SEEK_END
>  #define	SEEK_END	2	/* set file offset to EOF plus offset */
>  #endif
> +#ifndef SEEK_DATA
> +#define	SEEK_DATA	3	/* Set file pointer to next data past offset */
> +#endif
> +#ifndef SEEK_HOLE
> +#define	SEEK_HOLE	4	/* Set file pointer to next hole past offset */
> +#endif

You may want to use s/pointer/offset/ for consistency here. The same for
sys/unistd.h and sys/fcntl.h.

In OpenSolaris (as well as in my patch) _PC_MIN_HOLE_SIZE attribute for
pathconf(2) is used to determine if file system supports
SEEK_DATA/SEEK_HOLE functionality, which you may also want to add.

Pawel Jakub Dawidek                              
FreeBSD committer                         Am I Evil? Yes, I Am!

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.4.4 (FreeBSD)