NetBSD Problem Report #169
From gnats Wed Mar 16 13:58:47 1994
Received: from darling.idt.unit.no (darling.idt.unit.no [129.241.111.171]) by sun-lamp.cs.berkeley.edu (8.6.7/8.6.6) with ESMTP id NAA07990 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Wed, 16 Mar 1994 13:58:41 -0800
Message-Id: <199403162157.WAA11317@darling.idt.unit.no>
Date: Wed, 16 Mar 1994 22:57:32 +0100
From: Jarle Greipsland <jarle@darling.idt.unit.no>
Reply-To: jarle@darling.idt.unit.no
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Subject: mmap'ing devices no longer work
X-Send-Pr-Version: 3.2
>Number: 169
>Category: kern
>Synopsis: mmap'ing /dev/* fails.
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: gnats-admin
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 16 14:05:02 +0000 1994
>Closed-Date: Thu Mar 20 05:53:01 +0000 1997
>Last-Modified: Tue Sep 09 01:08:48 +0000 2014
>Originator: Jarle Greipsland
>Release: NetBSD-current
>Organization:
Norwegian Institute of Technology
>Environment:
Intel Professional Workstation/GX, NetBSD-current, do. std.
System: NetBSD darling.idt.unit.no 0.9a AICTEST#184 i386
>Description:
mmap'ing device files seems to fail no matter what type of devices involved.
Encountered the bug while configuring XFree86-2.1 and trying to make it mmap
in the framebuffer from /dev/mem. Have since tried to mmap several other
files and devices, giving the consistent results that mmap'ing files work ok,
but mmap'ing devices fails. (Maybe this also explains why xload doesn't work
anymore).
>How-To-Repeat:
Run the following program (with appropriate filenames compiled in).
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
#define FILENAME "/dev/mem"
#define FOFFSET ((off_t)0x0000)
int main()
{
int fd;
caddr_t ptr;
fd = open(FILENAME, O_RDWR);
if (fd < 0) {
fprintf(stderr,"Couldn't open \"%s\"\n", FILENAME);
exit(-1);
}
ptr = mmap((caddr_t)0, 4096, PROT_READ|PROT_WRITE,
MAP_FILE, fd, FOFFSET);
if (ptr == (caddr_t)-1) {
fprintf(stderr, "mmap failed\n");
exit(-1);
}
fprintf(stderr, "Success!\n");
exit(0);
}
>Fix:
"how to correct or work around the problem, if known (multiple lines)"
Oh come on! I've filled out the two previous blanks. Now you fill out
this one. :-) Seriously, I'm not that experienced in kernel exploration,
but maybe the dev_pager is in error?
-jarle
----
"Don't get suckered in by the comments -- they can be terribly
misleading. Debug only code."
-- Dave Storer
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback
State-Changed-By: cgd
State-Changed-When: Wed Mar 16 15:07:09 PST 1994
State-Changed-Why:
this bug report is not correct, as stated. however, /dev/*mem should be
mappable, and i believe i've got the code to do it...
State-Changed-From-To: feedback->closed
State-Changed-By: perry
State-Changed-When: Wed Mar 19 21:53:01 PST 1997
State-Changed-Why:
mmap of devices has worked for some time
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.