Don Lewis wrote:
> 
> On Aug 21,  2:10am, Wes Peters wrote:
> } Subject: mmap mapped segment length
> } I discovered to my dismay today that the length field in the mmap call is
> } a size_t, not an off_t.  I was attempting to process a large (~50 MByte) 
> file
> } and found I was only processing the first 4 MBytes of it.
> 
> 50 MB should comfortably fit in a size_t.

Oh, duh.  Notice the time on my message?  Yeah, that's what I get for jumping
into a mailing list when I've been up for way too long.

> } Is this intentional, or just an artifact of the implementation?  Is there 
> any
> } reason NOT to change this to an off_t?
> 
> The type of size_t is supposed to be large enough to express the length of
> any object that will fit in the virtual address space of a process.  Since
> a size_t is 32 bits on an i386 and pointers are also 32 bits, there wouldn't
> be any advantage to changing mmap() to use a 64 bit wide length parameter,
> since you wouldn't be able to access all of such a large object.

Obviously.  I'm not sure which memory space my HEAD was in last night, the 
moment I read your message I realized size_t spans 4 GB.  Duh.  Sorry to
embarass myself in such a public manner.

Now I've got to go figure out what *I've* screwed up.  I fstat the file before
mapping it and pass S.st_size as the map length.  Is there any reason why
mmap would return non-NULL but map less than the requested size?

Scratching my head,

-- 
            "Where am I, and what am I doing in this handbasket?"

Wes Peters                                                         Softweyr LLC
http://softweyr.com/                                           w...@softweyr.com


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to