[lkml]   [2009]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: On the workings of mmap
On Thu, 17 Dec 2009, Rafael Almeida wrote:

> Hello. I have been studying the mmap function and it seems like when I
> map an sparse file, that the parts of the file that have nothing are
> defined as 0 when I access them through the address space returned by
> mmap. Is that luck or is it defined to be this way? My only source of
> information was debian's manpage on mmap that didn't seem to talk
> about sparse files at all.

That's not luck, it is required to be that way.

Though I've not located such a definition with respect to mmap(),
it would be perverse if mmap() showed you different data there from
what read() shows you, and the Single Unix Specification (Version 3)
says of read():

"If any portion of a regular file prior to the end-of-file has not
been written, read() shall return bytes with value 0."


 \ /
  Last update: 2009-12-17 19:53    [W:0.035 / U:0.304 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site