From owner-freebsd-hackers Mon Apr 22 15:21:14 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mailhub.yumyumyum.org (dsl092-171-091.wdc1.dsl.speakeasy.net [66.92.171.91]) by hub.freebsd.org (Postfix) with SMTP id 1C74437C55A for ; Mon, 22 Apr 2002 15:12:48 -0700 (PDT) Received: (qmail 23745 invoked from network); 22 Apr 2002 22:12:14 -0000 Received: from dsl092-171-091.wdc1.dsl.speakeasy.net (66.92.171.91) by dsl092-171-091.wdc1.dsl.speakeasy.net with SMTP; 22 Apr 2002 22:12:14 -0000 Date: Mon, 22 Apr 2002 18:12:14 -0400 (EDT) From: Kenneth Culver To: Andrew Gallatin Cc: freebsd-hackers@freebsd.org, Subject: Re: implementing linux mmap2 syscall In-Reply-To: <15556.28962.259876.509643@grasshopper.cs.duke.edu> Message-ID: <20020422172703.C23429-100000@alpha.yumyumyum.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > AHH, ok I was wondering where PAGE_SHIFT was for FreeBSD. I guess ctob > > does what I need it to. I think that's probably why it still wasn't > > working yet... I think it also has to be page aligned before you pass it > > in though, I have to look at linux's do_mmap_pgoff() (I think that's the > > right function name) to see if it's expecting an already page-aligned arg, > > or if it's aligning it before it uses it. > > The name implies that do_mmap_pgoff() takes page-shift'ed args. > An offset specified as a page-shift is page-aligned by definition. > Eg, when you call ctob(pgoff) this turns out to be (pgoff << > PAGE_SHIFT) bytes. > > Drew > > That makes sense, regular linux mmap seems to expect the offset to be in bytes (from linux's mmap): ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT); Where linux's mmap2 does this: error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); so this looks to me like do_mmap_pgoff expects a page-aligned offset, meaning that the difference between a regular linux mmap, and linux's mmap2 is that mmap expects bytes, and mmap2 expects a page offset instead... even more is that linux's old_mmap (the one that we actually emulate in linux_mmap(), calls do_mmap2 with these args: err = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT); so, I'll just do the ctob() and see what happens. :-) Ken To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message