Bug 22754

Summary: mmap man page states that non-page aligned offsets don't work. they do.
Product: Base System Reporter: nick <nick>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-RELEASE   
Hardware: Any   
OS: Any   

Description nick 2000-11-10 18:30:01 UTC
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.

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.
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.
Comment 1 iedowse freebsd_committer freebsd_triage 2001-11-18 00:48:00 UTC
State Changed
From-To: open->closed


Fixed, thanks!