Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Nov 2000 18:19:50 GMT
From:      nick@flirble.org
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/22754: mmap man page states non-page offsets do not work 
Message-ID:  <200011101819.SAA46830@thinking-cap.babyhippo.co.uk>

next in thread | raw e-mail | index | archive | help

>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:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 10 10:30:01 PST 2000
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011101819.SAA46830>