Date: Fri, 24 Mar 95 14:12:40 +0100 From: Jurgen <jali@oce.nl> To: freebsd-bugs@FreeBSD.org Subject: Endless kernel error message loop Message-ID: <199503241312.AA18798@oce-rd1.oce.nl>
index | next in thread | raw e-mail
/*-----------------------------------------------------
* mmap() results in endless kernel error message loop.
*-----------------------------------------------------
*
* The program below, straight from Steven's "Advanced Programming In The
* Unix Environment", crashes FreeBSD 1.1.5.1 and FreeBSD 2.0-RELEASE.
*
* When compiled and run as 'a.out a.out z', it results in an endless loop
* in the kernel, printing the message: 'vnode pager write error: 5'.
* A forced reset and a reboot is needed.
*
* Funny thing is that if the file to copy is within a pagesize (4K) it
* works fine. If the file is bigger than 4K, things go wrong.
*
* I tried it on Solaris 2.x, SunOS 4.1.3. and HP-UX B.09.00, no problems.
*
* What is the situation in FreeBSD-CURRENT?
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
int
main (argc, argv)
int argc;
char **argv;
{
int fdin, fdout;
char *src, *dst;
struct stat statbuf;
if ((fdin = open (argv[1], O_RDONLY)) < 0)
{
perror ("open source file failed");
exit (1);
}
if ((fdout = open (argv[2], O_RDWR | O_CREAT | O_TRUNC, 0644)) < 0)
{
perror ("open destination file failed");
exit (1);
}
(void) fstat (fdin, &statbuf);
(void) lseek (fdout, statbuf.st_size-1, SEEK_SET);
(void) write (fdout, "", 1);
src = (char *) mmap (0, statbuf.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fdin, 0);
if (src == (caddr_t) -1)
{
perror ("mmap source file failed");
exit (1);
}
dst = (char *) mmap (0, statbuf.st_size, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, fdout, 0);
if (dst == (caddr_t) -1)
{
perror ("mmap destination file failed");
exit (1);
}
(void) memcpy (dst, src, statbuf.st_size);
return (0);
}
================================================================================
JALI.
###########################################################
# This note does not necessarily represent the position #
# of Oce-Nederland B.V. Therefore no liability or #
# responsibility for whatever will be accepted. #
###########################################################
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503241312.AA18798>
