Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Aug 1999 19:04:25 -0600
From:      Wes Peters <wes@softweyr.com>
To:        Don Lewis <Don.Lewis@tsc.tdk.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: mmap mapped segment length
Message-ID:  <37BF4C99.67814B7@softweyr.com>
References:  <199908210906.CAA17706@salsa.gv.tsc.tdk.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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/                                           wes@softweyr.com


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37BF4C99.67814B7>