Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Feb 2011 16:14:02 -0800
From:      Garrett Cooper <yanegomi@gmail.com>
To:        Alexander Best <arundel@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: seeking into /dev/{null,zero}
Message-ID:  <AANLkTi=U648S=Hdkz95g-uoopygFMv834GmKzcGcTeJV@mail.gmail.com>
In-Reply-To: <20110223235355.GA48790@freebsd.org>
References:  <20110222141112.GA98964@freebsd.org> <AC6674AB7BC78549BB231821ABF7A9AE970EA06474@EMBX01-WF.jnpr.net> <AANLkTimwOVub6XxZqgCmHPnLbekJrEbYQBzxUr%2BUrcR5@mail.gmail.com> <201102221251.33717.jhb@freebsd.org> <3A287E45-A369-4C7A-BA8E-A205679AC0BC@gmail.com> <20110223235355.GA48790@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 23, 2011 at 3:53 PM, Alexander Best <arundel@freebsd.org> wrote=
:
> On Wed Feb 23 11, Garrett Cooper wrote:
>> On Feb 22, 2011, at 9:51 AM, John Baldwin wrote:
>>
>> > On Tuesday, February 22, 2011 11:46:05 am Garrett Cooper wrote:
>> >> (Please bottom post)
>> >>
>> >> On Tue, Feb 22, 2011 at 8:31 AM, Andrew Duane <aduane@juniper.net> wr=
ote:
>> >>> I thought seeking past EOF was valid; writing something creates a fi=
le
>> > with a hole in it. I always assumed that was standard semantics.
>> >>
>> >> =A0 =A0That'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 file
>> > (it does an implicit ftruncate(2)). =A0SEEK_HOLE and SEEK_DATA are dif=
ferent,
>> > they are just used to discover sparse regions within a file.
>
> on the other hand POSIX says:
>
> "The behavior of lseek() on devices which are incapable of seeking is imp=
lementation-defined.
> The value of the file offset associated with such a device is undefined."
>
> ...if we define /dev/{zero,null} as incapable of seeking the current
> implementation should be ok.
>
>> >
>> > From the manpage:
>> >
>> > =A0 =A0 The lseek() system call allows the file offset to be set beyon=
d the end
>> > =A0 =A0 of the existing end-of-file of the file. =A0If data is later w=
ritten at
>> > =A0 =A0 this point, subsequent reads of the data in the gap return byt=
es of zeros
>> > =A0 =A0 (until data is actually written into the gap).
>>
>> =A0 =A0 =A0 You're correct. Linux (Fedora 13) isn't POSIX compliant (thi=
s is from the official POSIX text):
>>
>> The lseek ( ) function shall allow the file offset to be set beyond the =
end of the existing data in the file. If data is later written at this poin=
t, subsequent reads of data in the gap shall return bytes with the value 0 =
until data is actually written into the gap.

    Yes, but look at how it's defined by POSIX before you do that
(yes, there's a section for null/zero IIRC).
Thanks,
-Garrett



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTi=U648S=Hdkz95g-uoopygFMv834GmKzcGcTeJV>