From nick@thinking-cap.babyhippo.co.uk  Fri Nov 10 10:20:04 2000
Return-Path: <nick@thinking-cap.babyhippo.co.uk>
Received: from thinking-cap.babyhippo.co.uk (m100-mp1-cvx1c.edi.ntl.com [62.253.12.100])
	by hub.freebsd.org (Postfix) with ESMTP id A16E437B4C5
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 10 Nov 2000 10:20:02 -0800 (PST)
Received: (from nick@localhost)
	by thinking-cap.babyhippo.co.uk (8.9.3/8.9.3) id SAA46830;
	Fri, 10 Nov 2000 18:19:50 GMT
	(envelope-from nick)
Message-Id: <200011101819.SAA46830@thinking-cap.babyhippo.co.uk>
Date: Fri, 10 Nov 2000 18:19:50 GMT
From: nick@flirble.org
Sender: nick@thinking-cap.babyhippo.co.uk
Reply-To: nick@flirble.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: mmap man page states non-page offsets do not work 
X-Send-Pr-Version: 3.2

>Number:         22754
>Category:       kern
>Synopsis:       mmap man page states that non-page aligned offsets don't work. they do.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 10 10:30:01 PST 2000
>Closed-Date:    Sat Nov 17 16:48:00 PST 2001
>Last-Modified:  Sat Nov 17 16:48:14 PST 2001
>Originator:     Nicholas Clark
>Release:        FreeBSD 4.0-RELEASE i386
>Organization:
>Environment:

FreeBSD thinking-cap.babyhippo.co.uk 4.0-RELEASE FreeBSD 4.0-RELEASE #0: Mon Mar 20 22:50:22 GMT 2000     root@monster.cdrom.com:/usr/src/sys/compile/GENERIC  i386

Anything else needed here?

>Description:

the mmap man page states in the BUGS section:

     We currently can only deal with page aligned file offsets.

This doesn't appear to be true as mmap() will map /etc/motd without error
at offset 11. I assume that the documentation is out of date.

>How-To-Repeat:

#include <unistd.h>
#include <sys/mman.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>

int main () {
  int motd = open ("/etc/motd", O_RDONLY);
  void *mapped;

  if (motd < 0) {
    perror ("Failed to open /etc/motd");
    return 1;
  }
  mapped = mmap(NULL, 1024, PROT_EXEC | PROT_READ | PROT_WRITE , MAP_PRIVATE, motd, 11);
  printf ("mapped = %p errno = %d\n", mapped, errno);
  return 0;
}

gives

mapped = 0x280f000b errno = 0

on FreeBSD 3.4-STABLE, 4.0-RELEASE and 4.1-STABLE, all x86 (all I have access
to)

which isn't what the man page says should happen.

>Fix:

Ammend man page to remove this from the bugs. (It doesn't appear to be
just regular files, as /dev/zero also works)
Or if not all devices support it, state this in the BUGS section.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: iedowse 
State-Changed-When: Sat Nov 17 16:48:00 PST 2001 
State-Changed-Why:  

Fixed, thanks! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=22754 
>Unformatted:
