From owner-freebsd-hackers Sat Aug 21 18: 6:22 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.xmission.com (mail.xmission.com [198.60.22.22]) by hub.freebsd.org (Postfix) with ESMTP id DD3661549B for ; Sat, 21 Aug 1999 18:06:01 -0700 (PDT) (envelope-from wes@softweyr.com) Received: from [204.68.178.39] (helo=softweyr.com) by mail.xmission.com with esmtp (Exim 2.12 #1) id 11IM3y-000265-00; Sat, 21 Aug 1999 19:04:47 -0600 Message-ID: <37BF4C99.67814B7@softweyr.com> Date: Sat, 21 Aug 1999 19:04:25 -0600 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.5 [en] (X11; U; FreeBSD 3.1-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Don Lewis Cc: hackers@FreeBSD.ORG Subject: Re: mmap mapped segment length References: <199908210906.CAA17706@salsa.gv.tsc.tdk.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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