lkml.org 
[lkml]   [1997]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectmmap trouble
Hello All!

When I create file and write to it something (file size != 0), then all is
OK. But when open creates new file, or opens file with size == 0, then
SIGBUS occurs. Why??? (I use 2.0.30 kernel). As gdb says SIGBUS occurs on
first write to buf asm instruction (in strcpy). Any cure????

=== Cut ===
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

main()
{
int fd;

fd = open("test.file", O_CREAT | O_RDWR, 0644);
buf = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
strcpy(buf, "Hello, World!");
msync(buf, 4096); munmap(buf, 4096);
close(fd);
}
=== Cut ===

Valery Shchedrin
o728@gu.kiev.ua


\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.165 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site