lkml.org 
[lkml]   [1998]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: What's wrong with MAP_SHARED|MAP_ANONYMOUS?
On 27 Sep 1998, Andi Kleen wrote:
> > Would it work if you create a scratch file, open it, unlink it, fill it
> > to the right size with zeros and then map it with a shared mapping?
>
> Yes, but you don't even need to fill it with zeros. Just use
> ftruncate(fd, length). This has the advantage that unused blocks won't
> be allocated.

It's probably better to lseek to the length you want and write a zero.
ftruncate is not required by POSIX to allow length to be greater than
the current length of the file, so using it that way is not portable.

--Tim Smith


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.044 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site