Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Feb 2011 12:51:33 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        Alexander Best <arundel@freebsd.org>, Garrett Cooper <gcooper@freebsd.org>
Subject:   Re: seeking into /dev/{null,zero}
Message-ID:  <201102221251.33717.jhb@freebsd.org>
In-Reply-To: <AANLkTimwOVub6XxZqgCmHPnLbekJrEbYQBzxUr%2BUrcR5@mail.gmail.com>
References:  <20110222141112.GA98964@freebsd.org> <AC6674AB7BC78549BB231821ABF7A9AE970EA06474@EMBX01-WF.jnpr.net> <AANLkTimwOVub6XxZqgCmHPnLbekJrEbYQBzxUr%2BUrcR5@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, February 22, 2011 11:46:05 am Garrett Cooper wrote:
> (Please bottom post)
>=20
> On Tue, Feb 22, 2011 at 8:31 AM, Andrew Duane <aduane@juniper.net> wrote:
> > I thought seeking past EOF was valid; writing something creates a file=
=20
with a hole in it. I always assumed that was standard semantics.
>=20
>     That's with SET_HOLE/SET_DATA though, correct? If so, outside of
> that functionality I would assume relatively standard POSIX semantics.

Err, no, you can always seek past EOF and then call write(2) to extend a fi=
le=20
(it does an implicit ftruncate(2)).  SEEK_HOLE and SEEK_DATA are different,=
=20
they are just used to discover sparse regions within a file.

=46rom the manpage:

     The lseek() system call allows the file offset to be set beyond the end
     of the existing end-of-file of the file.  If data is later written at
     this point, subsequent reads of the data in the gap return bytes of ze=
ros
     (until data is actually written into the gap).

=2D-=20
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102221251.33717.jhb>